From: Andrew Sadek Date: Sun, 6 May 2018 11:42:06 +0000 (+0000) Subject: picdtr.c: Add test for -fPIE -mpic-data-is-text-relative. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b0e69bd6980044e30c99d3f1a82aac24b1bc0f59;p=gcc.git picdtr.c: Add test for -fPIE -mpic-data-is-text-relative. 2018-05-06 Andrew Sadek * gcc.target/microblaze/others/picdtr.c: Add test for -fPIE -mpic-data-is-text-relative. From-SVN: r259975 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3390087e327..5903cdc20e6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-05-06 Andrew Sadek + + * gcc.target/microblaze/others/picdtr.c: Add test for + -fPIE -mpic-data-is-text-relative. + 2018-05-06 Andre Vehreschild PR fortran/85507 diff --git a/gcc/testsuite/gcc.target/microblaze/others/picdtr.c b/gcc/testsuite/gcc.target/microblaze/others/picdtr.c new file mode 100644 index 00000000000..e7b8b0d2d79 --- /dev/null +++ b/gcc/testsuite/gcc.target/microblaze/others/picdtr.c @@ -0,0 +1,160 @@ +/* { dg-options "-fPIE -mpic-data-text-rel -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); + +} + +/* { dg-options "-fPIE -mpic-data-text-rel -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); + +} +