Re: [PATCH] [Microblaze]: PIC Data Text Relative

2018-05-05 Thread Andrew Sadek
Hello Michael,

I made a re-run for the GCC test suite.
I have just noticed that picdtr.c was not uploaded, also I forgot to
adapt the new pic option text in it.
thus we need to apply the attached patch.

Otherwise, it's all fine.
Results (Normal Run):

=== gcc Summary ===

# of expected passes91211
# of unexpected failures1325
# of unexpected successes3
# of expected failures212
# of unresolved testcases374
# of unsupported tests2863

Results (with -fPIE -mpic-data-is-text-relative):
=== gcc Summary ===

# of expected passes91243
# of unexpected failures1208
# of unexpected successes3
# of expected failures212
# of unresolved testcases374
# of unsupported tests2888

Comparison for PASS-> FAIL is only this one now:
PASS->FAIL: gcc.dg/uninit-19.c (test for excess errors) => already
fails with -fPIE/-fPIC as mentioned before.

On Thu, May 3, 2018 at 7:13 PM, Andrew Sadek <andrew.sadek...@gmail.com> wrote:
> --resend Michael's reply
>
> On Mon, Apr 30, 2018 at 1:19 PM, Michael Eager <ea...@eagerm.com> wrote:
>>
>>
>> Applied -- Committed revision 259758.
>>
>> Andrew -- Please re-run GCC regression test to verify that nothing
>> was lost in the editing.
>>
>>
>>
>> --
>> Michael Eagerea...@eagerm.com
>> 1960 Park Blvd., Palo Alto, CA 94306
>
>
>
>
> --
>
> Andrew



-- 

Andrew
Index: picdtr.c
===
--- picdtr.c(nonexistent)
+++ picdtr.c(working copy)
@@ -0,0 +1,79 @@
+/* { dg-options "-fPIE mpic-data-is-text-relative -save-temps" } */
+/* { dg-do run } */
+
+#define TEST_VAR(var,val) (var) = (val); if( (var) != (val)) return 0;
+
+int foo(unsigned int i);
+extern void abort(void);
+extern void exit(int);
+
+unsigned char data[8];
+long bigData[7];
+long var;
+typedef struct {int a; short b; long c[1000][1000]; long long d[3][3]; char e; 
} myDef;
+myDef def;
+const char* myString;
+
+/* { dg-final { scan-assembler "mfs\tr20,rpc" } } */
+/* { dg-final { scan-assembler "addik\tr20,r20,8@TXTPCREL" } } */
+/* { dg-final { scan-assembler ",r20,\[^\n]*var\[^\n]*@TXTREL" } } */
+/* { dg-final { scan-assembler-not ",r0,\[^\n]*var" } } */
+/* { dg-final { scan-assembler ",r20,\[^\n]*bigData\[^\n]*@TXTREL" } } */
+/* { dg-final { scan-assembler-not ",r0,\[^\n]*bigData" } } */
+/* { dg-final { scan-assembler ",r20,\[^\n]*def\[^\n]*@TXTREL" } } */
+/* { dg-final { scan-assembler-not ",r0,\[^\n]*def" } } */
+/* { dg-final { scan-assembler ",r20,\[^\n]*data\[^\n]*@TXTREL" } } */
+/* { dg-final { scan-assembler-not ",r0,\[^\n]*data" } } */
+/* { dg-final { scan-assembler ",r20,\[^\n]*L\[^\n]*@TXTREL" } } */
+/* { dg-final { scan-assembler-not ",r0,\[^\n]*L" } } */
+
+
+
+void foo2() {
+   var++;
+}
+
+int foo (unsigned int i) {
+
+   TEST_VAR(var,123)
+   TEST_VAR(data[i],77)
+   TEST_VAR(data[2],88)
+   TEST_VAR(def.a,897)
+   TEST_VAR(bigData[i],78)
+   TEST_VAR(bigData[2],777)
+   TEST_VAR(def.b,12333);
+   TEST_VAR(def.c[i][i],5);
+   TEST_VAR(def.c[0][1],7);
+   TEST_VAR(def.d[1][2],123);
+   TEST_VAR(def.e,7);
+   TEST_VAR(bigData[i+1],bigData[i*2]);
+
+   foo2();
+
+   myString = "Hello";
+
+   switch(i){
+
+   case 1: var += 2; break;
+   case 2: var += 3; break;
+   case 3: var += 5; break;
+   case 4: var += 7; break;
+   case 5: var += 8; break;
+   default: var = 0;
+
+   }
+
+   return 1;
+
+}
+
+int main() {
+
+   int result = foo(3);
+   if(result != 1 || var != 129) {
+   abort();
+   }
+
+   exit(0);
+
+}


Re: [PATCH] [Microblaze]: PIC Data Text Relative

2018-05-03 Thread Andrew Sadek
--resend Michael's reply

On Mon, Apr 30, 2018 at 1:19 PM, Michael Eager  wrote:

>
> Applied -- Committed revision 259758.
>
> Andrew -- Please re-run GCC regression test to verify that nothing
> was lost in the editing.
>
>
>
> --
> Michael Eagerea...@eagerm.com
> 1960 Park Blvd., Palo Alto, CA 94306
>



-- 

Andrew


Re: [PATCH] [Microblaze]: PIC Data Text Relative

2018-04-27 Thread Andrew Sadek
Thanks Michael.
Please find below updated Change Log.

2018-04-27 Andrew Sadek  <andrew.sadek...@gmail.com>

Microblaze Target: PIC data text relative
* gcc/config/microblaze/microblaze.opt: add new option
-mpic-is-data-text-relative.
* gcc/config/microblaze/microblaze-protos.h (microblaze_constant_address_p):
Add microblaze_constant_address_p function to encapsulate CONSTANT_ADDRESS_P
in microblaze.h.
* gcc/config/microblaze/microblaze.h (microblaze_constant_address_p):
change CONSTANT_ADDRESS_P definition to microblaze_constant_address_p.
* gcc/config/microblaze/microblaze.c (TARGET_PIC_DATA_TEXT_REL):
New addressing mode
for data-text relative position independent code.
(microblaze_classify_unspec): add 'UNSPEC_TEXT' case ->
'ADDRESS_SYMBOLIC_TXT_REL'.
(microblaze_classify_address): add handling for UNSPEC + CONST_INT
+ SYMBOL_REF.
(microblaze_legitimate_pic_operand): exclude function calls from
pic operands
in case of TARGET_PIC_DATA_TEXT_REL option.
(microblaze_legitimize_address): generate 'UNSPEC_TEXT' for all possible
addresses cases.
(microblaze_address_insns): add 'ADDRESS_SYMBOLIC_TXT_REL' case.
(print_operand): add 'ADDRESS_SYMBOLIC_TXT_REL' case.
(print_operand_address): add 'ADDRESS_SYMBOLIC_TXT_REL' case + handling for
'address + offset' + set strict with 2 in microblaze_classify_address call.
(microblaze_expand_prologue): add new function prologue call for
'r20' assignation.
(microblaze_asm_generate_pic_addr_dif_vec): override new target hook
'TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC' to disable address diff vector
table in case of TARGET_PIC_DATA_TEXT_REL.
(expand_pic_symbol_ref): add handling for TARGET_PIC_DATA_TEXT_REL cases.
* gcc/config/microblaze/microblaze.md (TARGET_PIC_DATA_TEXT_REL):
Add new macros 'UNSPEC_TEXT' and 'UNSPEC_SET_TEXT' +
add rule for setting r20 in function prologue + exclude function calls
from 'UNSPEC_PLT' in case of data text relative mode.
* gcc/doc/tm.texi.in (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC):
Add new target hook for generating address diff vector tables in
case of flag_pic.
* gcc/doc/tm.texi : Regenerate.
* gcc/stmt.c (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC): append new condition
'targetm.asm_out.generate_pic_addr_diff_vec' to flag_pic in case
of address diff vector generation.
* gcc/target.def (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC): add
target hook definition.
* gcc/targhooks.c (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC):
add default function for generate_pic_addr_diff_vec -> flag_pic.
* gcc/targhooks.h (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC):
add function declaration for generate_pic_addr_diff_vec.
* gcc/doc/invoke.texi (Add new pic option): Add new microblaze pic
option -mpic-is-data-text-relative.
* gcc/testsuite/gcc.target/microblaze/others/data_var1.c: include
PIC case of r20 base register.
* gcc/testsuite/gcc.target/microblaze/others/data_var2.c: include
PIC case of r20 base register.
* gcc/testsuite/gcc.target/microblaze/others/picdtr.c: add new
test case for -mpic-is-data-text-relative.
* gcc/testsuite/gcc.target/microblaze/others/sdata_var1.c: add
-fno-pic to exclude small data from PIC.
* gcc/testsuite/gcc.target/microblaze/others/sdata_var2.c: add
-fno-pic to exclude small data from PIC.
* gcc/testsuite/gcc.target/microblaze/others/sdata_var3.c: add
-fno-pic to exclude small data from PIC.
* gcc/testsuite/gcc.target/microblaze/others/sdata_var4.c: add
-fno-pic to exclude small data from PIC.
* gcc/testsuite/gcc.target/microblaze/others/sdata_var5.c: add
-fno-pic to exclude small data from PIC.
* gcc/testsuite/gcc.target/microblaze/others/sdata_var6.c: add
-fno-pic to exclude small data from PIC.
* gcc/testsuite/gcc.target/microblaze/others/string_cst1_gpopt.c:
add -fno-pic to exclude small data from PIC.
* gcc/testsuite/gcc.target/microblaze/others/string_cst2_gpopt.c:
add -fno-pic to exclude small data from PIC.

On Fri, Apr 27, 2018 at 3:36 AM, Michael Eager <ea...@eagerm.com> wrote:
> On 04/19/2018 03:43 AM, Andrew Sadek wrote:
>>
>> On Wed, Apr 18, 2018 at 6:57 PM, Michael Eager <ea...@eagercon.com> wrote:
>>>
>>>
>>> Hi Andrew --
>>>
>>> Check indents in the following files:
>>> (Make sure that your tabs are set at 8 chars.)
>>> --- gcc/config/microblaze/microblaze.c
>>> --- gcc/config/microblaze/microblaze.md
>>>
>> I have re-run check_GNU_Style.sh and no are issues are found now.
>
>
> I corrected a large number of indent problems in microblaze.c.
>
>>> Just a couple coding notes:
>>>
>>> microblaze.c:
>>>
>>> @@ -858,6 +879,16 @@ microblaze_classify_address (struct microblaze_add
>>> +   && strict == 2)
>>&

Re: [PATCH] [Microblaze]: PIC Data Text Relative

2018-04-19 Thread Andrew Sadek
On Wed, Apr 18, 2018 at 6:57 PM, Michael Eager  wrote:
>
> Hi Andrew --
>
> Check indents in the following files:
> (Make sure that your tabs are set at 8 chars.)
> --- gcc/config/microblaze/microblaze.c
> --- gcc/config/microblaze/microblaze.md
>
I have re-run check_GNU_Style.sh and no are issues are found now.

> Just a couple coding notes:
>
> microblaze.c:
>
> @@ -858,6 +879,16 @@ microblaze_classify_address (struct microblaze_add
> +   && strict == 2)
>
> Include comment in function header describing meaning of strict == 2.

Done

>
> @@ -1022,7 +1065,7 @@ microblaze_legitimize_address (rtx x, rtx oldx ATT
>   else if (flag_pic == 2 && !TARGET_PIC_DATA_TEXT_REL)
> {
>   ...
> }
>   else if (flag_pic == 2 && TARGET_PIC_DATA_TEXT_REL)
> {
>   ...
> }
>
> It's better to factor this into
>  else if (flag_pic == 2)
>{
>  if (TARGET_PIC_DATA_TEXT_REL)
>{
>  ...
>}
>  else
>{
>  ...
>}
>}
>

Done

> microblaze.md:
>
> @@ -1848,7 +1850,7 @@
>
> +if (!flag_pic || (flag_pic && TARGET_PIC_DATA_TEXT_REL))
>
> Test for flag_pic is redundant.  This can be
>
> +if (!flag_pic || TARGET_PIC_DATA_TEXT_REL)

Done

> doc/invoke.texi:
> -mpic-data-text-rel -- include description
> Is this different from -mpic-data-is-text-relative?
> (Yes, that's a bit of a wordy option.)

Changed the name and added description, now it's like ARM's option

> doc/tm.texi:
> +Return a flag for either generating ADDR_DIF_VEC table
> +or ADDR_VEC table for jumps in case of -fPIC.
>
> Explicitly state what true or false means.

Done

> target.def:
>
> +(generate_pic_addr_diff_vec,
>
> Explicitly state what true or false means.

Done

> targhooks.c:
>
> +bool
> +default_generate_pic_addr_diff_vec (void)
> +{
> +  return true;
> +}
>
> This doesn't appear to match the description in target.def.
>

Adapted

>
> --
> Michael Eagerea...@eagercon.com
>
> 1960 Park Blvd., Palo Alto, CA 94306

Please find patch attached
and also in 
(https://github.com/andrewsadek/microblaze-pic-data-text-rel/blob/pic_data_text_rel/PATCH_BUNDLE/gcc.patch)

-- 

Andrew
Index: gcc/config/microblaze/microblaze-protos.h
===
--- gcc/config/microblaze/microblaze-protos.h   (revision 258312)
+++ gcc/config/microblaze/microblaze-protos.h   (working copy)
@@ -24,6 +24,7 @@
 
 #ifdef RTX_CODE
 extern int pic_address_needs_scratch (rtx);
+extern bool microblaze_constant_address_p (rtx x);
 extern void expand_block_move(rtx *);
 extern void microblaze_expand_prologue (void);
 extern void microblaze_expand_epilogue (void);
Index: gcc/config/microblaze/microblaze.c
===
--- gcc/config/microblaze/microblaze.c  (revision 258312)
+++ gcc/config/microblaze/microblaze.c  (working copy)
@@ -91,7 +91,8 @@ enum microblaze_address_type
   ADDRESS_SYMBOLIC,
   ADDRESS_GOTOFF,
   ADDRESS_PLT,
-  ADDRESS_TLS
+  ADDRESS_TLS,
+  ADDRESS_SYMBOLIC_TXT_REL
 };
 
 /* Classifies symbols
@@ -650,6 +651,10 @@ microblaze_classify_unspec (struct microblaze_addr
   info->type = ADDRESS_TLS;
   info->tls_type = tls_reloc (INTVAL (XVECEXP (x, 0, 1)));
 }
+  else if (XINT (x, 1) == UNSPEC_TEXT)
+{
+ info->type = ADDRESS_SYMBOLIC_TXT_REL;
+}
   else
 {
   return false;
@@ -701,8 +706,10 @@ get_base_reg (rtx x)
 }
 
 /* Return true if X is a valid address for machine mode MODE.  If it is,
-   fill in INFO appropriately.  STRICT is true if we should only accept
-   hard base registers.  
+   fill in INFO appropriately.
+   STRICT > 0 if we should only accept hard base registers.
+   STRICT = 2 if the operand address is being printed thus
+   function has been called by print_operand_address.
 
   type regA  regBoffset  symbol
 
@@ -728,6 +735,7 @@ microblaze_classify_address (struct microblaze_add
 {
   rtx xplus0;
   rtx xplus1;
+  rtx offset;
 
   info->type = ADDRESS_INVALID;
   info->regA = NULL;
@@ -735,6 +743,7 @@ microblaze_classify_address (struct microblaze_add
   info->offset = NULL;
   info->symbol = NULL;
   info->symbol_type = SYMBOL_TYPE_INVALID;
+  offset = NULL;
 
   switch (GET_CODE (x))
 {
@@ -795,9 +804,14 @@ microblaze_classify_address (struct microblaze_add
/* for (plus x const_int) just look at x.  */
if (GET_CODE (xconst0) == PLUS
&& GET_CODE (XEXP (xconst0, 1)) == CONST_INT
-   && SMALL_INT (XEXP (xconst0, 1)))
+   && (SMALL_INT (XEXP (xconst0, 1))
+  || GET_CODE (XEXP (xconst0, 0)) == UNSPEC))
  {
-   /* This is ok as info->symbol is set to xplus1 the full
+/* Hold CONST_INT Value in offset in case of
+

Re: [PATCH] [Microblaze]: PIC Data Text Relative

2018-04-18 Thread Andrew Sadek
Hello Michael,

I have attached the patch as well,
(the same as in :
https://github.com/andrewsadek/microblaze-pic-data-text-rel/blob/pic_data_text_rel/PATCH_BUNDLE/gcc.patch)

On Thu, Mar 22, 2018 at 8:37 PM, Andrew Sadek <andrew.sadek...@gmail.com> wrote:
> Hello Michael,
>
> I have adapted the test cases.
>
> Please find the patch below with Change log, description and test results.
>
> Description:
> --
>
> This branch is regarding a new implemented feature in GCC Microblaze
> that allows Position Independent Code to run using Data Text Relative
> addressing instead of using Global Offset Table.
>
> Its aim was to make 'PIC' more efficient and flexible as elf size
> excess/ performance overhead were noticed when using GOT due to the
> indirect addressing.
> The change was tested with the dhrystone benchmark on a real Hardware
> (Xilinx FPGA Spartan 6) and the test report went successfully for all
> optimization levels.
>
> Indeed, Microblaze does not support PC-relative addressing in Hardware like 
> ARM.
> The idea was to store the start address of current text section in
> 'r20' instead of GOT, in the function prologue. Correspondingly, data
> references will be an offset from the original reference value to the
> start of text thus being added to the 'r20' base register will resolve
> the actual address.
>
> Henceforth, 2 new relocations have been created:
> - 'R_MICROBLAZE_TEXTPCREL_64': resolves offset of current PC to start
> of text in order to set r20
> - 'R_MICROBLAZE_TEXTREL_64': resolves offset of mentioned data
> reference to start of text
>
> Accordingly, both assembler and linker (binutils) have been adapted.
>
> For extra details:
> https://github.com/andrewsadek/microblaze-pic-data-text-rel/blob/pic_data_text_rel/README.md
>
> Change Log:
> -
>
> 2018-03-22 Andrew Sadek  <andrew.sadek...@gmail.com>
>
> Microblaze Target: PIC data text relative
> * gcc/config/microblaze/microblaze.opt: add new option
> -mpic-data-text-rel.
> * gcc/config/microblaze/microblaze-protos.h 
> (microblaze_constant_address_p):
> Add microblaze_constant_address_p function instead of the macro in
> microblaze.h
> * gcc/config/microblaze/microblaze.c (TARGET_PIC_DATA_TEXT_REL):
> New addressing mode
> for data-text relative position indepenedent code.
> (microblaze_classify_unspec): add 'UNSPEC_TEXT' case ->
> 'ADDRESS_SYMBOLIC_TXT_REL'.
> (microblaze_classify_address): add handling for UNSPEC + CONST_INT.
> (microblaze_legitimate_pic_operand): exclude function calls from
> pic operands
> in case of TARGET_PIC_DATA_TEXT_REL option.
> (microblaze_legitimize_address): generate 'UNSPEC_TEXT' for all possible
> addresses cases.
> (microblaze_address_insns): add 'ADDRESS_SYMBOLIC_TXT_REL' case.
> (print_operand): add 'ADDRESS_SYMBOLIC_TXT_REL' case.
> (print_operand_address): add 'ADDRESS_SYMBOLIC_TXT_REL' case + handling 
> for
> 'address + offset'.
> (microblaze_expand_prologue): add new function prologue call for
> 'r20' assignation.
> (microblaze_asm_generate_pic_addr_dif_vec): override new target hook
>'TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC' to disable address diff vector
> table in case of TARGET_PIC_DATA_TEXT_REL.
> (expand_pic_symbol_ref): add handling for 'UNSPEC_TEXT'.
> * gcc/config/microblaze/microblaze.md (TARGET_PIC_DATA_TEXT_REL):
> Add new macros 'UNSPEC_TEXT',
> 'UNSPEC_SET_TEXT' + add rule for setting r20 in function prologue
> + exclude function calls
> from 'UNSPEC_PLT' in case of data text relative mode.
> * gcc/doc/tm.texi.in (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC): Add
> new target hook for generating
> address diff vector tables in case of flag_pic.
> * gcc/doc/tm.texi : Regenerate.
> * gcc/stmt.c (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC): append new condition
> 'targetm.asm_out.generate_pic_addr_diff_vec' to flag_pic in case
> of addr diff vector generation.
> * gcc/target.def (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC): add
> target hook definition.
> * gcc/targhooks.h, gcc/targhooks.c 
> (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC):
> add default function for generate_pic_addr_diff_vec -> flag_pic.
> * gcc/doc/invoke.texi (Add new pic option): Add new microblaze pic
> option for data text relative.
>
>
> Test Results (using qemu microblaze little endian):
> 
>
> === gcc Summary ===
>
> # of expected passes90874
> # of unexpected failures1317
> # of unexpected successes3
> # of expected failures207
> # 

Re: [PATCH] [Microblaze]: PIC Data Text Relative

2018-03-22 Thread Andrew Sadek
Hello Michael,

I have adapted the test cases.

Please find the patch below with Change log, description and test results.

Description:
--

This branch is regarding a new implemented feature in GCC Microblaze
that allows Position Independent Code to run using Data Text Relative
addressing instead of using Global Offset Table.

Its aim was to make 'PIC' more efficient and flexible as elf size
excess/ performance overhead were noticed when using GOT due to the
indirect addressing.
The change was tested with the dhrystone benchmark on a real Hardware
(Xilinx FPGA Spartan 6) and the test report went successfully for all
optimization levels.

Indeed, Microblaze does not support PC-relative addressing in Hardware like ARM.
The idea was to store the start address of current text section in
'r20' instead of GOT, in the function prologue. Correspondingly, data
references will be an offset from the original reference value to the
start of text thus being added to the 'r20' base register will resolve
the actual address.

Henceforth, 2 new relocations have been created:
- 'R_MICROBLAZE_TEXTPCREL_64': resolves offset of current PC to start
of text in order to set r20
- 'R_MICROBLAZE_TEXTREL_64': resolves offset of mentioned data
reference to start of text

Accordingly, both assembler and linker (binutils) have been adapted.

For extra details:
https://github.com/andrewsadek/microblaze-pic-data-text-rel/blob/pic_data_text_rel/README.md

Change Log:
-

2018-03-22 Andrew Sadek  <andrew.sadek...@gmail.com>

Microblaze Target: PIC data text relative
* gcc/config/microblaze/microblaze.opt: add new option
-mpic-data-text-rel.
* gcc/config/microblaze/microblaze-protos.h (microblaze_constant_address_p):
Add microblaze_constant_address_p function instead of the macro in
microblaze.h
* gcc/config/microblaze/microblaze.c (TARGET_PIC_DATA_TEXT_REL):
New addressing mode
for data-text relative position indepenedent code.
(microblaze_classify_unspec): add 'UNSPEC_TEXT' case ->
'ADDRESS_SYMBOLIC_TXT_REL'.
(microblaze_classify_address): add handling for UNSPEC + CONST_INT.
(microblaze_legitimate_pic_operand): exclude function calls from
pic operands
in case of TARGET_PIC_DATA_TEXT_REL option.
(microblaze_legitimize_address): generate 'UNSPEC_TEXT' for all possible
addresses cases.
(microblaze_address_insns): add 'ADDRESS_SYMBOLIC_TXT_REL' case.
(print_operand): add 'ADDRESS_SYMBOLIC_TXT_REL' case.
(print_operand_address): add 'ADDRESS_SYMBOLIC_TXT_REL' case + handling for
'address + offset'.
(microblaze_expand_prologue): add new function prologue call for
'r20' assignation.
(microblaze_asm_generate_pic_addr_dif_vec): override new target hook
   'TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC' to disable address diff vector
table in case of TARGET_PIC_DATA_TEXT_REL.
(expand_pic_symbol_ref): add handling for 'UNSPEC_TEXT'.
* gcc/config/microblaze/microblaze.md (TARGET_PIC_DATA_TEXT_REL):
Add new macros 'UNSPEC_TEXT',
'UNSPEC_SET_TEXT' + add rule for setting r20 in function prologue
+ exclude function calls
from 'UNSPEC_PLT' in case of data text relative mode.
* gcc/doc/tm.texi.in (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC): Add
new target hook for generating
address diff vector tables in case of flag_pic.
* gcc/doc/tm.texi : Regenerate.
* gcc/stmt.c (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC): append new condition
'targetm.asm_out.generate_pic_addr_diff_vec' to flag_pic in case
of addr diff vector generation.
* gcc/target.def (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC): add
target hook definition.
* gcc/targhooks.h, gcc/targhooks.c (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC):
add default function for generate_pic_addr_diff_vec -> flag_pic.
* gcc/doc/invoke.texi (Add new pic option): Add new microblaze pic
option for data text relative.


Test Results (using qemu microblaze little endian):


=== gcc Summary ===

# of expected passes90874
# of unexpected failures1317
# of unexpected successes3
# of expected failures207
# of unresolved testcases115
# of unsupported tests2828

Full summary:
https://raw.githubusercontent.com/andrewsadek/microblaze-pic-data-text-rel/pic_data_text_rel/PATCH_BUNDLE/gcc.sum

Patch:
--

Actually, I found that gmail transforms tabs to spaces even plain text
mode, also I can not attach the patch as I receive error from
sourceware server,
so for now kindly find the patch in the link below,, if you have
solution for that please advise.


https://github.com/andrewsadek/microblaze-pic-data-text-rel/blob/pic_data_text_rel/PATCH_BUNDLE/gcc.patch

On Tue, Mar 20, 2018 at 5:30 PM, Michael Eager <ea...@eagerm.com> wrote:
> Hi Andrew --
>
> I just do a visual check.  The script can help.
>
> On 03/20/2018 07:13 AM, Andrew Sadek

Re: [PATCH] [Microblaze]: PIC Data Text Relative

2018-03-20 Thread Andrew Sadek
Many Thanks Michael for the updates .. I was actually looking for something
similar for my test case .. I m currently revising the Gnu code conventions
on the patches then will send them again.
I m actually running the 'check_GNU_Style' in contrib folder,, is this the
correct way ? Is it enough ?

Andrew

On Tue, Mar 20, 2018, 03:30 Michael Eager <ea...@eagerm.com> wrote:

> Also check the { dg-skip-if } directive.
> https://gcc.gnu.org/onlinedocs/gccint/Directives.html
>
> On 03/19/2018 06:14 PM, Michael Eager wrote:
> > Hi Andrew --
> >
> > Please take a look at the test case description:
> > https://gcc.gnu.org/wiki/HowToPrepareATestcase
> > and see if you can do one of the following:
> >- Modify the regex expression in the scan-assembler to accept
> >  either format of generated output
> > or
> >- Add { dg-option } directives to turn off your new options
> >  if specified.  (You should be able to specify -mno-pic)
> > or
> >- Duplicate the test cases and add { dg-option } directives
> >  to specify the correct options, with and without your
> >  new options.
> > or
> >- Add test cases with a { dg-option } directive with your
> >  new options.
> >
> > This is not required -- your patch appears to work OK.  Normally,
> > the new PIC Data options would not be used when running the test
> > suite, so the tests would not fail.  It's just nice to have the
> > test suite updated when new options are added.
> >
> > On 03/19/2018 01:07 PM, Michael Eager wrote:
> >> Hi Andrew --
> >>
> >> Good work.
> >>
> >> Please submit your updated patch.  Check that you follow
> >> GNU coding standards.  Also make sure that the new options
> >> are documented in gcc/doc/invoke.texi.
> >>
> >> On 03/18/18 03:27, Andrew Sadek wrote:
> >>> Hello Michael,
> >>>
> >>> I have run the test using the new PIC options.
> >>> Actually, I have discovered 2 unhandled cases in
> >>> 'microblaze_expand_move' + missing conditions in linker relax
> >>> leading some test cases execution to fail.
> >>> After fixing them, I made a re-run for the whole regression, and the
> >>> results analogy below:
> >>>
> >>> Original, without my patch:
> >>>  === gcc Summary ===
> >>>
> >>> # of expected passes90776
> >>> # of unexpected failures1317
> >>> # of unexpected successes3
> >>> # of expected failures207
> >>> # of unresolved testcases115
> >>> # of unsupported tests2828
> >>>
> >>> With my patch, calling '-fPIE - mpic-data-text-rel'
> >>>  === gcc Summary ===
> >>>
> >>> # of expected passes90843
> >>> # of unexpected failures1256
> >>> # of unexpected successes3
> >>> # of expected failures207
> >>> # of unresolved testcases115
> >>> # of unsupported tests2853
> >>>
> >>> After running the 'dg-cmp-results.sh' in contrib folder, the
> >>> PASS->FAIL are below:
> >>>
> >>> PASS->FAIL: gcc.dg/uninit-19.c (test for excess errors)
> >>> PASS->FAIL: gcc.target/microblaze/others/data_var1.c   -O0
> >>> scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r0
> >>> PASS->FAIL: gcc.target/microblaze/others/data_var1.c   -O1
> >>> scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r0
> >>> PASS->FAIL: gcc.target/microblaze/others/data_var1.c   -O2 -flto
> >>> -fno-use-linker-plugin -flto-partition=none   scan-assembler
> >>> lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r0
> >>> PASS->FAIL: gcc.target/microblaze/others/data_var1.c   -O2 -flto
> >>> -fuse-linker-plugin -fno-fat-lto-objects   scan-assembler
> >>> lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r0
> >>> PASS->FAIL: gcc.target/microblaze/others/data_var1.c   -O2
> >>> scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r0
> >>> PASS->FAIL: gcc.target/microblaze/others/data_var1.c   -O3 -g
> >>> scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r0
> >>> PASS->FAIL: gcc.target/microblaze/others/data_var1.c   -Os
> >>> scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r0
> >>> PASS->FAIL: gcc.target/microblaze/others/data_var2.c   -O0
> >>> scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r0
> >>> PASS->FAIL: gcc.target/microblaze/others

Re: [PATCH] [Microblaze]: PIC Data Text Relative

2018-03-18 Thread Andrew Sadek
t;FAIL: gcc.target/microblaze/others/sdata_var4.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-assembler
lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/sdata_var4.c   -O2
scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/sdata_var4.c   -O3 -g
scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/sdata_var4.c   -Os
scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/sdata_var5.c   -O0
scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/sdata_var5.c   -O1
scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/sdata_var5.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none   scan-assembler
lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/sdata_var5.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-assembler
lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/sdata_var5.c   -O2
scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/sdata_var5.c   -O3 -g
scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/sdata_var5.c   -Os
scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/string_cst1_gpopt.c   -O0
scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/string_cst1_gpopt.c   -O1
scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/string_cst1_gpopt.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none   scan-assembler
lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/string_cst1_gpopt.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-assembler
lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/string_cst1_gpopt.c   -O2
scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/string_cst1_gpopt.c   -O3 -g
scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/string_cst1_gpopt.c   -Os
scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/string_cst2_gpopt.c   -O0
scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/string_cst2_gpopt.c   -O1
scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/string_cst2_gpopt.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none   scan-assembler
lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/string_cst2_gpopt.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-assembler
lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/string_cst2_gpopt.c   -O2
scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/string_cst2_gpopt.c   -O3 -g
scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13
PASS->FAIL: gcc.target/microblaze/others/string_cst2_gpopt.c   -Os
scan-assembler lwi\tr([0-9]|[1-2][0-9]|3[0-1]),r13

the 'gcc.dg/uninit-19.c ' already fails with -fPIE, and for the others in
microblaze,
expectation is r0 or r13 as a base register which is not the case here
'r20', and these tests also fails with -fPIE.
Moreover, the test cases that failed due 'unresolved GLOBAL_OFFSET_TABLE'
now pass as we do not have GOT in data text relative.

Please tell me if any adjustments needed or If I need to re-run nything.

Thanks

On Sun, Mar 18, 2018 at 12:25 PM, Andrew Sadek <andrew.sadek...@gmail.com>
wrote:

> Hello Michael,
>
> I have run the test using the new PIC options.
> Actually, I have discovered 2 unhandled cases in 'microblaze_expand_move'
> + missing conditions in linker relax
> leading some test cases execution to fail.
> After fixing them, I made a re-run for the whole regression, and the
> results analogy below:
>
> Original, without my patch:
> === gcc Summary ===
>
> # of expected passes90776
> # of unexpected failures1317
> # of unexpected successes3
> # of expected failures207
> # of unresolved testcases115
> # of unsupported tests2828
>
> With my patch, calling '-fPIE - mpic-data-text-rel'
> === gcc Summary ===
>
> # of expected passes90843
> # of unexpected failures1256
> # of unexpected successes3
> # of expected failures207
> # of unresolved testcases115
> # of unsupported tests2853
>
> After running the 'dg-cmp-results.sh' in contrib folder, the PASS->FAIL
> are below:
>
> PASS->FAIL: gcc.dg/uninit-19.c (test for excess errors)
> PASS->FAIL: gcc.target/microbl

Re: [PATCH] [Microblaze]: PIC Data Text Relative

2018-03-13 Thread Andrew Sadek
Ok, so you mean with '-fPIC -mpic-data-text-relative' as I do in my test
case ?
If all is Ok, execution and compilation shall ideally pass for the test
cases.
But I have noticed that there are some output pattern checks done in some
test cases and this may fail since the output assembly is different,
anyway I shall give it a try and send you the results with the new options.

On Tue, Mar 13, 2018 at 8:42 AM, Michael Eager <ea...@eagerm.com> wrote:

> On 03/12/18 23:10, Andrew Sadek wrote:
>
>> _Command for running testsuite:_
>>
>> /make -k check-gcc RUNTESTFLAGS="-v --target_board=microblaze-qemu
>> CFLAGS_FOR_TARGET='-include /home/andrew/qemu/common.h
>> -L/home/andrew/qemu/lib -Wl,--start-group,-lxil,-lgcc,-lc,--end-group
>> -mlittle-endian' "/
>>
>> _Quick Details:_
>> 1) common.h: Here I define 'STACK_SIZE' with (0x4000) as it's used in
>> some test cases.
>> 2) -L . /lib: it contains libm, libc in little endian since we use
>> 'qemu-system-microblazeel', and libxil which is the libgloss + some
>> additional features (read, write, inbyte, outbyte) built with Xilinx SDK.
>>
>> _mb-gcc command example from gcc.log:_
>>
>> Testing execute/va-arg-15.c,   -O1
>> doing compile
>> Executing on host://home/andrew/gcc_workspace/gcc_orig/microblaze-xilinx-
>> elf/build/build-cc-gcc-final/gcc/xgcc -B/home/andrew/gcc_workspace/g
>> cc_orig/microblaze-xilinx-elf/build/build-cc-gcc-final/gcc/
>> /home/andrew/gcc_workspace/gcc_orig/microblaze-xilinx-elf/
>> src/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-15.c -include
>> /home/andrew/qemu/common.h -L/home/andrew/qemu/lib
>> -Wl,--start-group,-lxil,-lgcc,-lc,--end-group -mlittle-endian
>> -fno-diagnostics-show-caret -fdiagnostics-color=never-O1  -w
>> -T/home/andrew/qemu/qemu/microblazeel-softmmu/xilinx.ld  -lm  -o
>> ./va-arg-15.exe(timeout = 300)/
>>
>
> OK.  This shows that the patch does not cause regressions when the new
> options are not used.  That is good.
>
> Please run the same regression test with the new PIC options.  Ideally you
> should have the same results.
>
>
>
>>
>>
>> On Mon, Mar 12, 2018 at 4:30 PM, Michael Eager <ea...@eagerm.com > ea...@eagerm.com>> wrote:
>>
>> On 03/12/18 06:19, Andrew Sadek wrote:
>>
>>
>>
>> On Mon, Mar 5, 2018 at 9:21 PM, Michael Eager <ea...@eagerm.com
>> <mailto:ea...@eagerm.com> <mailto:ea...@eagerm.com
>>
>> <mailto:ea...@eagerm.com>>> wrote:
>>
>>  On 03/02/2018 08:12 AM, Andrew Sadek wrote:
>>
>>  Hello Michael,
>>
>>  I tried running the whole GCC test suite on the current
>> head
>>  (without my patch) along with 'microblaze-qemu' but I
>> have the
>>  following problems:
>>
>>  1) The test is hanging at
>> 'gcc.c-torture/string-large-1.c' , the
>>  gcc is making a 100% CPU usage and the machine stucks.
>>  I tried compiling the file alone, it generated a couple
>> of
>>  warnings than it hangs.
>> warning: '__builtin_memchr' specified size
>> 4294967295 exceeds
>>  maximum object size 2147483647 [-Wstringop-overflow=]
>>   vp1 = __builtin_memchr (a, b, SIZE1);
>>
>>  Is it a bug? Is there something wrong with my
>> configuration ?
>>  GCC configured with options :  --with-newlib
>> --enable-threads=no
>>  --disable-shared --with-pkgversion='crosstool-NG
>>  crosstool-ng-1.23.0-280-g01e3290' --enable-__cxa_atexit
>>  --disable-libgomp --disable-libmudflap --disable-libmpx
>>  --disable-libssp --disable-libquadmath
>>  --disable-libquadmath-support --enable-lto
>>  --with-host-libstdcxx='-static-libgcc
>>  -Wl,-Bstatic,-lstdc++,-Bdynamic -lm'
>> --enable-target-optspace
>>  --disable-nls --enable-multiarch --enable-languages=c,c++
>>
>>
>>  Your configuration is more complex than my hard-metal
>> target version,
>>  but it looks reasonable.
>>
>>  The problem with string-large-1.c does appear to be a bug.
>>You can
>>  add a line to the test case which will mark it as known
>> failure for MB

Re: [PATCH] [Microblaze]: PIC Data Text Relative

2018-03-13 Thread Andrew Sadek
*Command for running testsuite:*

*make -k check-gcc RUNTESTFLAGS="-v --target_board=microblaze-qemu
CFLAGS_FOR_TARGET='-include /home/andrew/qemu/common.h
-L/home/andrew/qemu/lib -Wl,--start-group,-lxil,-lgcc,-lc,--end-group
-mlittle-endian' "*

*Quick Details:*
1) common.h: Here I define 'STACK_SIZE' with (0x4000) as it's used in some
test cases.
2) -L . /lib: it contains libm, libc in little endian since we use
'qemu-system-microblazeel', and libxil which is the libgloss + some
additional features (read, write, inbyte, outbyte) built with Xilinx SDK.

*mb-gcc command example from gcc.log:*

Testing execute/va-arg-15.c,   -O1
doing compile
Executing on host:*
/home/andrew/gcc_workspace/gcc_orig/microblaze-xilinx-elf/build/build-cc-gcc-final/gcc/xgcc
-B/home/andrew/gcc_workspace/gcc_orig/microblaze-xilinx-elf/build/build-cc-gcc-final/gcc/
/home/andrew/gcc_workspace/gcc_orig/microblaze-xilinx-elf/src/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-15.c
  -include /home/andrew/qemu/common.h -L/home/andrew/qemu/lib
-Wl,--start-group,-lxil,-lgcc,-lc,--end-group -mlittle-endian
-fno-diagnostics-show-caret -fdiagnostics-color=never-O1  -w
-T/home/andrew/qemu/qemu/microblazeel-softmmu/xilinx.ld  -lm  -o
./va-arg-15.exe(timeout = 300)*



On Mon, Mar 12, 2018 at 4:30 PM, Michael Eager <ea...@eagerm.com> wrote:

> On 03/12/18 06:19, Andrew Sadek wrote:
>
>
>>
>> On Mon, Mar 5, 2018 at 9:21 PM, Michael Eager <ea...@eagerm.com > ea...@eagerm.com>> wrote:
>>
>> On 03/02/2018 08:12 AM, Andrew Sadek wrote:
>>
>> Hello Michael,
>>
>> I tried running the whole GCC test suite on the current head
>> (without my patch) along with 'microblaze-qemu' but I have the
>> following problems:
>>
>> 1) The test is hanging at 'gcc.c-torture/string-large-1.c' , the
>> gcc is making a 100% CPU usage and the machine stucks.
>> I tried compiling the file alone, it generated a couple of
>> warnings than it hangs.
>>warning: '__builtin_memchr' specified size 4294967295 exceeds
>> maximum object size 2147483647 [-Wstringop-overflow=]
>>  vp1 = __builtin_memchr (a, b, SIZE1);
>>
>> Is it a bug? Is there something wrong with my configuration ?
>> GCC configured with options :  --with-newlib --enable-threads=no
>> --disable-shared --with-pkgversion='crosstool-NG
>> crosstool-ng-1.23.0-280-g01e3290' --enable-__cxa_atexit
>> --disable-libgomp --disable-libmudflap --disable-libmpx
>> --disable-libssp --disable-libquadmath
>> --disable-libquadmath-support --enable-lto
>> --with-host-libstdcxx='-static-libgcc
>> -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-target-optspace
>> --disable-nls --enable-multiarch --enable-languages=c,c++
>>
>>
>> Your configuration is more complex than my hard-metal target version,
>> but it looks reasonable.
>>
>> The problem with string-large-1.c does appear to be a bug.  You can
>> add a line to the test case which will mark it as known failure for
>> MB:
>>
>>/* { dg-xfail-if "exceeds maximum" { microblaze-*-* } } */
>>
>> (I have not tested this, but it should work.  Compare with other
>> xfail's.)
>>
>>
>> Problem that the whole compile package is invoked with '-w' which
>> inhibits all warnings and overrides ' -Werror' as well as ' -Wfatal-errors'
>> .
>> As a result, the warning message does not appear when running
>> compile.exp. Any suggestions ? Do I remove the '-w' ?
>>
>>
>>
>> 2) For running QEMU, I have no problem with elf execution. But I
>> do not know how to auto terminate the QEMU itself  as it remains
>> up even after program execution.
>> Is there some command to be passed to QEMU in order make system
>> shut down after program termination with its exit code ?
>>
>>
>> Yes, this is a problem.  For other targets using QEMU I have added
>> dummy
>> HLT instructions to terminate QEMU, or used a wrapper around QEMU
>> which
>> sets breakpoints at exit (or _exit) and stops the simulator when hit.
>>
>> If you are running Linux on QEMU, instead of using QEMU's built-in gdb
>> interface you might use the Linux system as the target for the test
>> suite, running gdbserver on the target.
>>
>>
>> I have finally managed to fully run QEMU with test suite but had to make
>> a local modification in the QEMU code itself.
>> In the translate function, I ma

Re: [PATCH] [Microblaze]: PIC Data Text Relative

2018-03-12 Thread Andrew Sadek
On Mon, Mar 5, 2018 at 9:21 PM, Michael Eager <ea...@eagerm.com> wrote:

> On 03/02/2018 08:12 AM, Andrew Sadek wrote:
>
>> Hello Michael,
>>
>> I tried running the whole GCC test suite on the current head (without my
>> patch) along with 'microblaze-qemu' but I have the following problems:
>>
>> 1) The test is hanging at 'gcc.c-torture/string-large-1.c' , the gcc is
>> making a 100% CPU usage and the machine stucks.
>> I tried compiling the file alone, it generated a couple of warnings than
>> it hangs.
>>   warning: '__builtin_memchr' specified size 4294967295 exceeds maximum
>> object size 2147483647 [-Wstringop-overflow=]
>> vp1 = __builtin_memchr (a, b, SIZE1);
>>
>> Is it a bug? Is there something wrong with my configuration ?
>> GCC configured with options :  --with-newlib --enable-threads=no
>> --disable-shared --with-pkgversion='crosstool-NG
>> crosstool-ng-1.23.0-280-g01e3290' --enable-__cxa_atexit
>> --disable-libgomp --disable-libmudflap --disable-libmpx --disable-libssp
>> --disable-libquadmath --disable-libquadmath-support --enable-lto
>> --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic
>> -lm' --enable-target-optspace --disable-nls --enable-multiarch
>> --enable-languages=c,c++
>>
>
> Your configuration is more complex than my hard-metal target version,
> but it looks reasonable.
>
> The problem with string-large-1.c does appear to be a bug.  You can
> add a line to the test case which will mark it as known failure for MB:
>
>   /* { dg-xfail-if "exceeds maximum" { microblaze-*-* } } */
>
> (I have not tested this, but it should work.  Compare with other
> xfail's.)


Problem that the whole compile package is invoked with '-w' which inhibits
all warnings and overrides ' -Werror' as well as ' -Wfatal-errors' .
As a result, the warning message does not appear when running compile.exp.
Any suggestions ? Do I remove the '-w' ?


>
>
> 2) For running QEMU, I have no problem with elf execution. But I do not
>> know how to auto terminate the QEMU itself  as it remains up even after
>> program execution.
>> Is there some command to be passed to QEMU in order make system shut down
>> after program termination with its exit code ?
>>
>
> Yes, this is a problem.  For other targets using QEMU I have added dummy
> HLT instructions to terminate QEMU, or used a wrapper around QEMU which
> sets breakpoints at exit (or _exit) and stops the simulator when hit.
>
> If you are running Linux on QEMU, instead of using QEMU's built-in gdb
> interface you might use the Linux system as the target for the test
> suite, running gdbserver on the target.
>

I have finally managed to fully run QEMU with test suite but had to make a
local modification in the QEMU code itself.
In the translate function, I make a check if "bri 0" is reached which is
the '_exit'. Then, abort the QEMU app with the exit code stored in 'r5'.

Here are the results below:
*Without Patch:*
=== gcc Summary ===

# of expected passes 90776
# of unexpected failures 1317
# of unexpected successes 3
# of expected failures 207
# of unresolved testcases 115
# of unsupported tests 2828

*With Patch and after adding my test case:*
=== gcc Summary ===

# of expected passes 90790
# of unexpected failures 1317
# of unexpected successes 3
# of expected failures 207
# of unresolved testcases 115
# of unsupported tests 2828

Most of failures are in gcc.dg/pch folder => 'undefined reference main',
and in 'gcc.dg/torture/stackalign/' folder => 'undefined reference to
`_GLOBAL_OFFSET_TABLE_'

Please tell me if testing is on the right track and if any further
adaptations are needed.
Thanks.


>
>
>>
>> On Tue, Feb 27, 2018 at 10:13 AM, Andrew Sadek <andrew.sadek...@gmail.com
>> <mailto:andrew.sadek...@gmail.com>> wrote:
>>
>> Thanks Micheal for your response.
>> I shall re-submit patches separately after re-running the whole GCC
>> Test suite and re-checking code conventions.
>> For sending to gdb-patches, it was a conflict from my side as
>> actually I thought it is also for binutils.
>>
>> On Tue, Feb 27, 2018 at 2:07 AM, Michael Eager <ea...@eagerm.com
>> <mailto:ea...@eagerm.com>> wrote:
>>
>> On 02/25/2018 11:44 PM, Andrew Guirguis wrote:
>>
>> Dears,
>>
>> Kindly find attached the patch bundle for Microblaze
>> '-mpic-data-text-relative' feature.
>>
>> Description of the feature in the following link:
>> https://github.com/andrewsadek/microblaze-pic-data-text-rel/
>> blob/pic_data_

Re: [PATCH] [Microblaze]: PIC Data Text Relative

2018-03-02 Thread Andrew Sadek
Hello Michael,

I tried running the whole GCC test suite on the current head (without my
patch) along with 'microblaze-qemu' but I have the following problems:

1) The test is hanging at 'gcc.c-torture/string-large-1.c' , the gcc is
making a 100% CPU usage and the machine stucks.
I tried compiling the file alone, it generated a couple of warnings than it
hangs.
 warning: '__builtin_memchr' specified size 4294967295 exceeds maximum
object size 2147483647 [-Wstringop-overflow=]
   vp1 = __builtin_memchr (a, b, SIZE1);

Is it a bug? Is there something wrong with my configuration ?
GCC configured with options :  --with-newlib --enable-threads=no
--disable-shared --with-pkgversion='crosstool-NG
crosstool-ng-1.23.0-280-g01e3290' --enable-__cxa_atexit --disable-libgomp
--disable-libmudflap --disable-libmpx --disable-libssp
--disable-libquadmath --disable-libquadmath-support --enable-lto
--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm'
--enable-target-optspace --disable-nls --enable-multiarch
--enable-languages=c,c++

2) For running QEMU, I have no problem with elf execution. But I do not
know how to auto terminate the QEMU itself  as it remains up even after
program execution.
Is there some command to be passed to QEMU in order make system shut down
after program termination with its exit code ?


On Tue, Feb 27, 2018 at 10:13 AM, Andrew Sadek <andrew.sadek...@gmail.com>
wrote:

> Thanks Micheal for your response.
> I shall re-submit patches separately after re-running the whole GCC Test
> suite and re-checking code conventions.
> For sending to gdb-patches, it was a conflict from my side as actually I
> thought it is also for binutils.
>
> On Tue, Feb 27, 2018 at 2:07 AM, Michael Eager <ea...@eagerm.com> wrote:
>
>> On 02/25/2018 11:44 PM, Andrew Guirguis wrote:
>>
>>> Dears,
>>>
>>> Kindly find attached the patch bundle for Microblaze
>>> '-mpic-data-text-relative' feature.
>>>
>>> Description of the feature in the following link:
>>> https://github.com/andrewsadek/microblaze-pic-data-text-rel/
>>> blob/pic_data_text_rel/README.md <https://github.com/andrewsade
>>> k/microblaze-pic-data-text-rel/blob/pic_data_text_rel/README.md>
>>>
>>> Bundle includes:
>>> 1) Change logs for GCC, binutils
>>> 2) GCC Test results and comparison with the original.
>>> 3) New Test case (picdtr.c)
>>> 4) The Patches (against current heads)
>>>
>>
>> Hi Andrew --
>>
>> Thanks for the submission.  I have the following recommendations:
>>
>> Submit each patch to the appropriate project mailing list.  Only submit
>> the patch for the specific project, without patches for other projects.
>>
>> Include a description of the changes with each patch as well as the
>> changelog.  Include the patch in your email or as an attachment.
>>
>> It isn't clear why you sent your submission to the gdb-patches mailing
>> list, since there don't appear to be any GDB changes.  Conversely, it is
>> not clear why you did not include the binutils mailing list, since you
>> include a patch to that project.
>>
>> Be sure to follow GNU coding conventions,  Check brace placement,
>> indent, maximum line length, if statements, etc.  I noticed a number
>> of places where these conventions are not followed in your patches.
>>
>> GCC regression tests should include all tests (e.g., gcc.dg), not just
>> the limited number of MicroBlaze-specific tests.
>>
>> --
>> Michael Eagerea...@eagerm.com
>> 1960 Park Blvd., Palo Alto, CA 94306
>>
>
>
>
> --
>
> Andrew
>



-- 

Andrew


Re: [PATCH] [Microblaze]: PIC Data Text Relative

2018-02-27 Thread Andrew Sadek
Thanks Micheal for your response.
I shall re-submit patches separately after re-running the whole GCC Test
suite and re-checking code conventions.
For sending to gdb-patches, it was a conflict from my side as actually I
thought it is also for binutils.

On Tue, Feb 27, 2018 at 2:07 AM, Michael Eager  wrote:

> On 02/25/2018 11:44 PM, Andrew Guirguis wrote:
>
>> Dears,
>>
>> Kindly find attached the patch bundle for Microblaze
>> '-mpic-data-text-relative' feature.
>>
>> Description of the feature in the following link:
>> https://github.com/andrewsadek/microblaze-pic-data-text-rel/
>> blob/pic_data_text_rel/README.md > k/microblaze-pic-data-text-rel/blob/pic_data_text_rel/README.md>
>>
>> Bundle includes:
>> 1) Change logs for GCC, binutils
>> 2) GCC Test results and comparison with the original.
>> 3) New Test case (picdtr.c)
>> 4) The Patches (against current heads)
>>
>
> Hi Andrew --
>
> Thanks for the submission.  I have the following recommendations:
>
> Submit each patch to the appropriate project mailing list.  Only submit
> the patch for the specific project, without patches for other projects.
>
> Include a description of the changes with each patch as well as the
> changelog.  Include the patch in your email or as an attachment.
>
> It isn't clear why you sent your submission to the gdb-patches mailing
> list, since there don't appear to be any GDB changes.  Conversely, it is
> not clear why you did not include the binutils mailing list, since you
> include a patch to that project.
>
> Be sure to follow GNU coding conventions,  Check brace placement,
> indent, maximum line length, if statements, etc.  I noticed a number
> of places where these conventions are not followed in your patches.
>
> GCC regression tests should include all tests (e.g., gcc.dg), not just the
> limited number of MicroBlaze-specific tests.
>
> --
> Michael Eagerea...@eagerm.com
> 1960 Park Blvd., Palo Alto, CA 94306
>



-- 

Andrew


Re: [PATCH] [Microblaze]: PIC Data Text Relative

2018-02-26 Thread Andrew Sadek
Change logs below.
There is a problem in attaching the bundle. I get permanent error from
sourceware.org

GCC ChangeLog:
Microblaze Target: PIC data text relative
* gcc/config/microblaze/microblaze.opt: add new option -mpic-data-text-rel.

* gcc/config/microblaze/microblaze-protos.h (microblaze_constant_address_p
):
Add microblaze_constant_address_p function instead of the macro in
microblaze.h
* gcc/config/microblaze/microblaze.c (TARGET_PIC_DATA_TEXT_REL): New
addressing mode
for data-text relative position indepenedent code.
(microblaze_classify_unspec): add 'UNSPEC_TEXT' case ->
'ADDRESS_SYMBOLIC_TXT_REL'.
(microblaze_classify_address): add handling for UNSPEC + CONST_INT.
(microblaze_legitimate_pic_operand): exclude function calls from pic
operands
in case of TARGET_PIC_DATA_TEXT_REL option.
(microblaze_legitimize_address): generate 'UNSPEC_TEXT' for all possible
addresses cases.
(microblaze_address_insns): add 'ADDRESS_SYMBOLIC_TXT_REL' case.
(print_operand): add 'ADDRESS_SYMBOLIC_TXT_REL' case.
(print_operand_address): add 'ADDRESS_SYMBOLIC_TXT_REL' case + handling for
'address + offset'.
(microblaze_expand_prologue): add new function prologue call for 'r20'
assignation.
(microblaze_asm_generate_pic_addr_dif_vec): override new target hook
'TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC' to disable address diff vector
table in case of TARGET_PIC_DATA_TEXT_REL.
(expand_pic_symbol_ref): add handling for 'UNSPEC_TEXT'.
* gcc/config/microblaze/microblaze.md (TARGET_PIC_DATA_TEXT_REL): Add new
macros 'UNSPEC_TEXT',
'UNSPEC_SET_TEXT' + add rule for setting r20 in function prologue + exclude
function calls
from 'UNSPEC_PLT' in case of data text relative mode.
* gcc/doc/tm.texi.in (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC): Add new
target hook for generating
address diff vector tables in case of flag_pic.
* gcc/doc/tm.texi : Regenerate.
* gcc/stmt.c (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC): append new condition
'targetm.asm_out.generate_pic_addr_diff_vec' to flag_pic in case of addr
diff vector generation.
* gcc/target.def (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC): add target hook
definition.
* gcc/targhooks.h, gcc/targhooks.c (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC):
add default function for generate_pic_addr_diff_vec -> flag_pic.

Binutils ChangeLog:
Microblaze Target: PIC data text relative
* include/elf/microblaze.h (Add 3 new relocations):
'R_MICROBLAZE_TEXTPCREL_64', 'R_MICROBLAZE_TEXTREL_64'
and 'R_MICROBLAZE_TEXTREL_32_LO' for relax function.
* bfd/bfd-in2.h, bfd/libbfd.h (2 new BFD relocations):
'BFD_RELOC_MICROBLAZE_64_TEXTPCREL' + 'BFD_RELOC_MICROBLAZE_64_TEXTPCREL'
* bfd/elf32-microblaze.c (Handle new relocs): define 'HOWTO' of 3 new
relocs and handle them in both relocate
and relax functions.
(microblaze_elf_reloc_type_lookup): add mapping between for new bfd relocs.
(microblaze_bfd_write_branch_absolute_value_64): replace relative branch
with absolute in case 'adjust_insn_abs_refs' is true
(microblaze_bfd_revert_base_reg_value_64): revert base register from r20 to
r0 in case 'adjust_insn_abs_refs' is true
(microblaze_elf_relocate_section): Handle new relocs in case of elf
relocation.
(microblaze_elf_relax_section): Handle new relocs for elf relaxation.
* gas/config/tc-microblaze.c (Handle new relocs directives in assembler):
Handle new relocs from compiler output.
(imm_types): add new imm types for data text relative addressing
'TEXT_OFFSET', 'TEXT_PC_OFFSET'
(md_convert_frag): conversion for 'BFD_RELOC_MICROBLAZE_64_TEXTPCREL' ,
'BFD_RELOC_MICROBLAZE_64_TEXTPCREL'
(md_apply_fix): apply fix for 'BFD_RELOC_MICROBLAZE_64_TEXTPCREL' ,
'BFD_RELOC_MICROBLAZE_64_TEXTPCREL'
(md_estimate_size_before_relax): estimate size for
'BFD_RELOC_MICROBLAZE_64_TEXTPCREL' , 'BFD_RELOC_MICROBLAZE_64_TEXTPCREL'
(tc_gen_reloc): generate relocations for 'BFD_RELOC_MICROBLAZE_64_TEXTPCREL'
, 'BFD_RELOC_MICROBLAZE_64_TEXTPCREL'
Add new linker options for static linking: adjust-insn-abs-refs,
disable-multiple-abs-defs
* ld/lexsup.c (Add 2 ld options):
(ld_options): add adjust-insn-abs-refs, disable-multiple-abs-defs @
'ld_options' array
(parse_args): parse options and pass flags to 'link_info' struct.
* ld/ldlex.h (Add 2 enums): add new enums @ 'option_values' enum.
* include/bfdlink.h (Add 2 flags): Add new flags @ 'bfd_link_info' struct.
* ld/main.c: Initialize flags with false @ 'main'. Handle
disable-multiple-abs-defs
@ 'mutiple_definition'.


On Mon, Feb 26, 2018 at 9:56 AM, Andrew Guirguis 
wrote:

> Dears,
>
> Kindly find the patch bundle for Microblaze '-mpic-data-text-relative'
> feature at the following link:
> https://github.com/andrewsadek/microblaze-pic-data-text-rel/
> tree/pic_data_text_rel/PATCH%20BUNDLE
>
> Description of the feature:
> https://github.com/andrewsadek/microblaze-pic-data-text-rel/
> blob/pic_data_text_rel/README.md
>
> Bundle includes:
> 1) Change logs for GCC, binutils
> 2) GCC Test results and comparison with the original.
> 3) New Test case (picdtr.c)
> 4) The Patches