In some of my previous work, I had make a mistake forgetting that the PADDI
instruction did not allow adding a PC-relative reference to a register (you can
either load up a PC-relative address without adding a register, or you can add
a register to a constant).  The assembler allowed the instruction, but it
didn't do what I expected.

This patch adds an explicit (0),1 to PC-relative references.  This way if you
try to add the PC-relative offset to a register, it will get a syntax error.

I have built compilers with this patch installed on a little endian power8
Linux system, and there were no regressions.  Can I check this into the trunk?

2019-11-14  Michael Meissner  <meiss...@linux.ibm.com>

        * config/rs6000/rs6000.c (print_operand_address): Add (0),1 to
        @pcrel to catch errant usage.

Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c  (revision 278175)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -13241,7 +13241,10 @@ print_operand_address (FILE *file, rtx x
       if (SYMBOL_REF_P (x) && !SYMBOL_REF_LOCAL_P (x))
        fprintf (file, "@got");
 
-      fprintf (file, "@pcrel");
+      /* Specifically add (0),1 to catch uses where a @pcrel was added to a an
+        address with a base register, since the hardware does not support
+        adding a base register to a PC-relative address.  */
+      fprintf (file, "@pcrel(0),1");
     }
   else if (SYMBOL_REF_P (x) || GET_CODE (x) == CONST
           || GET_CODE (x) == LABEL_REF)

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.ibm.com, phone: +1 (978) 899-4797

Reply via email to