[v2,3/5] PRU: Fix R3.w0 register class

Message ID 20200503161204.18245-4-dimitar@dinux.eu
State New
Headers show
Series
  • Updates for PRU backend
Related show

Commit Message

Dimitar Dimitrov May 3, 2020, 4:12 p.m.
TI has clarified [1] that R3.w0 is caller saved, so allow compiler to
use it. This is safe change because older GCC versions treat R3.w0 as
fixed register and never use it.

[1] https://e2e.ti.com/support/tools/ccs/f/81/t/849993

gcc/ChangeLog:

2020-05-03  Dimitar Dimitrov  <dimitar@dinux.eu>

	* config/pru/pru.h: Mark R3.w0 as caller saved.

gcc/testsuite/ChangeLog:

2020-05-03  Dimitar Dimitrov  <dimitar@dinux.eu>

	* gcc.target/pru/lra-framepointer-fragmentation-1.c: Update test to
	  take into account additional available registers.
	* gcc.target/pru/lra-framepointer-fragmentation-2.c: Ditto.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>

---
 gcc/config/pru/pru.h                                  | 11 ++++++++---
 .../gcc.target/pru/lra-framepointer-fragmentation-1.c |  5 +++--
 .../gcc.target/pru/lra-framepointer-fragmentation-2.c | 10 ++++++----
 3 files changed, 17 insertions(+), 9 deletions(-)

-- 
2.20.1

Patch

diff --git a/gcc/config/pru/pru.h b/gcc/config/pru/pru.h
index ea6ee109184..314e877a5f9 100644
--- a/gcc/config/pru/pru.h
+++ b/gcc/config/pru/pru.h
@@ -125,7 +125,8 @@ 
    1      r1		  Caller Saved.  Also used as a temporary by function.
 			  profiler and function prologue/epilogue.
    2      r2       sp	  Stack Pointer.
-   3*     r3.w0    ra	  Return Address (16-bit).
+   3*     r3.w0		  Caller saved.
+   3*     r3.w2    ra	  Return Address (16-bit).
    4      r4       fp	  Frame Pointer, also called Argument Pointer in ABI.
    5-13   r5-r13	  Callee Saved Registers.
    14-29  r14-r29	  Register Arguments.  Caller Saved Registers.
@@ -152,7 +153,7 @@ 
 
 #define FIXED_REGISTERS				\
   {						\
-/*   0 */  0,0,0,0, 0,0,0,0, 1,1,1,1, 1,1,1,1,	\
+/*   0 */  0,0,0,0, 0,0,0,0, 1,1,1,1, 0,0,1,1,	\
 /*   4 */  0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,	\
 /*   8 */  0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,	\
 /*  12 */  0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,	\
@@ -178,10 +179,13 @@ 
   }
 
 #define PRU_SEQ_R(X)  (X) * 4 + 0, (X) * 4 + 1, (X) * 4 + 2, (X) * 4 + 3
+#define PRU_SEQ_R_W0(X)  (X) * 4 + 0, (X) * 4 + 1
+#define PRU_SEQ_R_W2(X)  (X) * 4 + 2, (X) * 4 + 3
 #define REG_ALLOC_ORDER							    \
   {									    \
     /* Call-clobbered, yet not used for parameters.  */			    \
     PRU_SEQ_R (0),  PRU_SEQ_R ( 1),					    \
+    PRU_SEQ_R_W0 (3),							    \
 									    \
     PRU_SEQ_R (14), PRU_SEQ_R (15), PRU_SEQ_R (16), PRU_SEQ_R (17),	    \
     PRU_SEQ_R (18), PRU_SEQ_R (19), PRU_SEQ_R (20), PRU_SEQ_R (21),	    \
@@ -193,7 +197,8 @@ 
     PRU_SEQ_R (13),							    \
 									    \
     PRU_SEQ_R ( 4),							    \
-    PRU_SEQ_R ( 2), PRU_SEQ_R ( 3),					    \
+    PRU_SEQ_R ( 2),							    \
+    PRU_SEQ_R_W2 (3),							    \
 									    \
     /* I/O and virtual registers.  */					    \
     PRU_SEQ_R (30), PRU_SEQ_R (31), PRU_SEQ_R (32), PRU_SEQ_R (33),	    \
diff --git a/gcc/testsuite/gcc.target/pru/lra-framepointer-fragmentation-1.c b/gcc/testsuite/gcc.target/pru/lra-framepointer-fragmentation-1.c
index ee1288fc2ae..b2a49e3a9e1 100644
--- a/gcc/testsuite/gcc.target/pru/lra-framepointer-fragmentation-1.c
+++ b/gcc/testsuite/gcc.target/pru/lra-framepointer-fragmentation-1.c
@@ -12,6 +12,7 @@  uint64_t __attribute__((noinline)) test(uint64_t a, uint64_t b,
   uint64_t l1 = 0x12345678, l2 = 0x87654321, l3 = 1001, l4 = 1002;
   uint64_t l5 = 1004;
   uint32_t l6 = 2005;
+  uint16_t s1 = 4321;
   uint8_t c1 = 101, c2 = 102;
 
   /* The numerous dummy asm input operands create just
@@ -24,10 +25,10 @@  uint64_t __attribute__((noinline)) test(uint64_t a, uint64_t b,
        : "0" (l1), "r" (a), "r"(b),
        "r"(c), "r"(d), "r"(e), "r"(f),
        "r"(g), "r"(h), "r"(l2),
-       "r"(c1), "r"(c2),
+       "r"(c1), "r"(c2), "r"(s1),
        "r"(l3), "r"(l4), "r"(l5), "r"(l6));
 
-  global = a+b+c+d+e+f+g+h + c1+c2 + l2;
+  global = a+b+c+d+e+f+g+h + s1 + c1+c2 + l2;
 
   return l1;
 }
diff --git a/gcc/testsuite/gcc.target/pru/lra-framepointer-fragmentation-2.c b/gcc/testsuite/gcc.target/pru/lra-framepointer-fragmentation-2.c
index 6c98e9bf13b..2f910295f2a 100644
--- a/gcc/testsuite/gcc.target/pru/lra-framepointer-fragmentation-2.c
+++ b/gcc/testsuite/gcc.target/pru/lra-framepointer-fragmentation-2.c
@@ -14,6 +14,7 @@  uint64_t __attribute__((noinline)) test(uint64_t a, uint64_t b,
   uint64_t l1 = 0x12345678, l2 = 0x87654321, l3 = 1001, l4 = 1002;
   uint64_t l5 = 1004;
   uint32_t l6 = 2005;
+  uint16_t s1 = 4321;
   uint8_t c1 = 101, c2 = 102;
 
   /* The numerous dummy asm input operands create just
@@ -36,13 +37,14 @@  uint64_t __attribute__((noinline)) test(uint64_t a, uint64_t b,
        "add %0, %0, %14\n\t"
        "add %0, %0, %15\n\t"
        "add %0, %0, %16\n\t"
+       "add %0, %0, %17\n\t"
        : "=r" (l1)
        : "0" (l1), "r" (a), "r"(b),
        "r"(c), "r"(d), "r"(e), "r"(f),
-       "r"(g), "r"(h), "r"(c1), "r"(c2),
+       "r"(g), "r"(h), "r"(c1), "r"(c2), "r"(s1),
        "r"(l2), "r"(l3), "r"(l4), "r"(l5), "r"(l6));
 
-  global = a+b+c+d+e+f+g+h + c1+c2 + l2+l3+l4+l5+l6;
+  global = a+b+c+d+e+f+g+h + s1 + c1+c2 + l2+l3+l4+l5+l6;
 
   return l1;
 }
@@ -51,10 +53,10 @@  int main()
 {
   uint64_t a = test(1, 2, 3, 4, 5, 6, 7, 8);
 
-  if (a != 0x98878ae8) {
+  if (a != 0x98879bc9) {
     abort();
   }
-  if (global != 0x876557a4) {
+  if (global != 0x87656885) {
     abort();
   }
   return 0;