diff mbox series

, Rename and document PowerPC -mprefixed-addr to -mprefixed

Message ID 20200210184542.GA20688@ibm-toto.the-meissners.org
State New
Headers show
Series , Rename and document PowerPC -mprefixed-addr to -mprefixed | expand

Commit Message

Michael Meissner Feb. 10, 2020, 6:45 p.m. UTC
This patch renames the PowerPC internal switch -mprefixed-addr to be
-mprefixed.

Last week, Bill, Segher, and I were talking, and we came to the conclusion that
we needed to make the prefixed addressing option more public.  This is
particularly true, when you consider that only 64-bit little endian Linux will
have support for these mode.  Other OSes, ABI's, etc. out there that may/may
not support all of the new addressing modes in the 'future' computer.  And we
also decided, we preferred the simpler '-mprefixed' option over
'-mprefixed-addr'.

If you use -mno-prefixed, you get the current addressing modes on your system
for power9 and the compiler will not generate the prefixed loads or stores.

If you use -mprefixed -mno-pcrel, the compiler will generate prefixed loads and
stores utilizing 34-bit offset addressing with numeric offsets that don't need
relocation.  It will not generate PC-relative loads and stores.

If you use -mpcrel, you must be using the 64-bit ELF v2 ABI, and the code model
must be medium.  If you use -mpcrel, the compiler will generate PC-relative
loads and stores to access items, rather than the current TOC based loads and
stores.

If you use -mpcrel, it implies -mprefixed.  If you use -mno-prefixed, you
cannot use -mpcrel.

With the exception of making the switch a public switch, and documenting it,
this patch is just a simple mechanical conversion, converting
TARGET_PREFIXED_ADDR to TARGET_PREFIXED, etc.

Because the -mprefixed-addr was just an internal and undocumented switch, I
have not provided for an alias between -mprefixed to -mprefixed-addr (though I
can do that if desired).

I have tested these patches on both little endian and big endian Linux 64-bit
systems, and there were no regressions.  Can I check these patches into the
master GCC branch for GCC 10?

2020-02-10  Michael Meissner  <meissner@linux.ibm.com>

	* config/rs6000/predicates.md (cint34_operand): Rename the
	-mprefixed-addr option to be -mprefixed.
	* config/rs6000/rs6000-cpus.def (ISA_FUTURE_MASKS_SERVER): Rename
	the -mprefixed-addr option to be -mprefixed.
	(OTHER_FUTURE_MASKS): Likewise.
	(POWERPC_MASKS): Likewise.
	* config/rs6000/rs6000.c (rs6000_option_override_internal): Rename
	the -mprefixed-addr option to be -mprefixed.  Change error
	messages to refer to -mprefixed.
	(num_insns_constant_gpr): Rename the -mprefixed-addr option to be
	-mprefixed.
	(rs6000_legitimate_offset_address_p): Likewise.
	(rs6000_mode_dependent_address): Likewise.
	(rs6000_opt_masks): Change the spelling of "-mprefixed-addr" to be
	"-mprefixed" for target attributes and pragmas.
	(address_to_insn_form): Rename the -mprefixed-addr option to be
	-mprefixed.
	(rs6000_adjust_insn_length): Likewise.
	* config/rs6000/rs6000.h (FINAL_PRESCAN_INSN): Rename the
	-mprefixed-addr option to be -mprefixed.
	(ASM_OUTPUT_OPCODE): Likewise.
	* config/rs6000/rs6000.md (prefixed insn attribute): Rename the
	-mprefixed-addr option to be -mprefixed.
	* config/rs6000/rs6000.opt (-mprefixed): Rename the
	-mprefixed-addr option to be prefixed.  Change the option from
	being undocumented to being documented.
	* doc/invoke.texi (RS/6000 and PowerPC Options): Docment the
	-mprefixed option.  Update the -mpcrel documentation to mention
	-mprefixed.

Comments

Segher Boessenkool Feb. 11, 2020, 3:24 a.m. UTC | #1
Hi!

On Mon, Feb 10, 2020 at 01:45:42PM -0500, Michael Meissner wrote:
> This patch renames the PowerPC internal switch -mprefixed-addr to be
> -mprefixed.

> If you use -mpcrel, you must be using the 64-bit ELF v2 ABI, and the code model
> must be medium.

Currently, anyway.

> If you use -mpcrel, the compiler will generate PC-relative
> loads and stores to access items, rather than the current TOC based loads and
> stores.

Where that is the best thing to do.  Is that always now?  :-)

> If you use -mpcrel, it implies -mprefixed.  If you use -mno-prefixed, you
> cannot use -mpcrel.

-mno-prefixed should imply -mno-pcrel; does it?

> 	* doc/invoke.texi (RS/6000 and PowerPC Options): Docment the

(typo)

> --- /tmp/1ySv8k_invoke.texi	2020-02-07 17:56:52.700489015 -0500
> +++ gcc/doc/invoke.texi	2020-02-07 17:34:02.925611138 -0500
> @@ -22327,7 +22328,6 @@ faster on processors with 32-bit busses
>  aligns structures containing the above types differently than
>  most published application binary interface specifications for the m68k.
>  
> -@item -mpcrel
>  @opindex mpcrel
>  Use the pc-relative addressing mode of the 68000 directly, instead of
>  using a global offset table.  At present, this option implies @option{-fpic},

This isn't a correct change.

Okay for trunk modulo the m68k change.  Thanks!


Segher
Bill Schmidt Feb. 11, 2020, 4:22 a.m. UTC | #2
On 2/10/20 9:24 PM, Segher Boessenkool wrote:
> Hi!
>
> On Mon, Feb 10, 2020 at 01:45:42PM -0500, Michael Meissner wrote:
>> This patch renames the PowerPC internal switch -mprefixed-addr to be
>> -mprefixed.
>> If you use -mpcrel, you must be using the 64-bit ELF v2 ABI, and the code model
>> must be medium.
> Currently, anyway.
>
>> If you use -mpcrel, the compiler will generate PC-relative
>> loads and stores to access items, rather than the current TOC based loads and
>> stores.
> Where that is the best thing to do.  Is that always now?  :-)


Yes.  :-)

Bill

>
>> If you use -mpcrel, it implies -mprefixed.  If you use -mno-prefixed, you
>> cannot use -mpcrel.
> -mno-prefixed should imply -mno-pcrel; does it?
>
>> 	* doc/invoke.texi (RS/6000 and PowerPC Options): Docment the
> (typo)
>
>> --- /tmp/1ySv8k_invoke.texi	2020-02-07 17:56:52.700489015 -0500
>> +++ gcc/doc/invoke.texi	2020-02-07 17:34:02.925611138 -0500
>> @@ -22327,7 +22328,6 @@ faster on processors with 32-bit busses
>>   aligns structures containing the above types differently than
>>   most published application binary interface specifications for the m68k.
>>   
>> -@item -mpcrel
>>   @opindex mpcrel
>>   Use the pc-relative addressing mode of the 68000 directly, instead of
>>   using a global offset table.  At present, this option implies @option{-fpic},
> This isn't a correct change.
>
> Okay for trunk modulo the m68k change.  Thanks!
>
>
> Segher
Segher Boessenkool Feb. 11, 2020, 7:01 a.m. UTC | #3
On Mon, Feb 10, 2020 at 10:22:37PM -0600, Bill Schmidt wrote:
> On 2/10/20 9:24 PM, Segher Boessenkool wrote:
> >>If you use -mpcrel, the compiler will generate PC-relative
> >>loads and stores to access items, rather than the current TOC based loads 
> >>and
> >>stores.
> >Where that is the best thing to do.  Is that always now?  :-)
> 
> Yes.  :-)

Ah right, -mcmodel=medium is required, that makes many things much easier.


Segher
Michael Meissner Feb. 11, 2020, 6:32 p.m. UTC | #4
On Mon, Feb 10, 2020 at 09:24:07PM -0600, Segher Boessenkool wrote:
> Hi!
> 
> On Mon, Feb 10, 2020 at 01:45:42PM -0500, Michael Meissner wrote:
> > This patch renames the PowerPC internal switch -mprefixed-addr to be
> > -mprefixed.
> 
> > If you use -mpcrel, you must be using the 64-bit ELF v2 ABI, and the code model
> > must be medium.
> 
> Currently, anyway.
> 
> > If you use -mpcrel, the compiler will generate PC-relative
> > loads and stores to access items, rather than the current TOC based loads and
> > stores.
> 
> Where that is the best thing to do.  Is that always now?  :-)
> 
> > If you use -mpcrel, it implies -mprefixed.  If you use -mno-prefixed, you
> > cannot use -mpcrel.
> 
> -mno-prefixed should imply -mno-pcrel; does it?

Yes.  -mno-prefixed-addr also impied -mno-pcrel.

> > 	* doc/invoke.texi (RS/6000 and PowerPC Options): Docment the
> 
> (typo)

Thanks.

> > --- /tmp/1ySv8k_invoke.texi	2020-02-07 17:56:52.700489015 -0500
> > +++ gcc/doc/invoke.texi	2020-02-07 17:34:02.925611138 -0500
> > @@ -22327,7 +22328,6 @@ faster on processors with 32-bit busses
> >  aligns structures containing the above types differently than
> >  most published application binary interface specifications for the m68k.
> >  
> > -@item -mpcrel
> >  @opindex mpcrel
> >  Use the pc-relative addressing mode of the 68000 directly, instead of
> >  using a global offset table.  At present, this option implies @option{-fpic},
> 
> This isn't a correct change.

Yeah, evidently I put the PowerPC stuff in the m68 -mpcrel area.  I'll fix it.

> Okay for trunk modulo the m68k change.  Thanks!
> 
> 
> Segher
diff mbox series

Patch

--- /tmp/N41Ptv_predicates.md	2020-02-07 17:56:52.590487419 -0500
+++ gcc/config/rs6000/predicates.md	2020-02-07 17:34:02.891610645 -0500
@@ -306,7 +306,7 @@  (define_predicate "const_0_to_15_operand
 (define_predicate "cint34_operand"
   (match_code "const_int")
 {
-  if (!TARGET_PREFIXED_ADDR)
+  if (!TARGET_PREFIXED)
     return 0;
 
   return SIGNED_INTEGER_34BIT_P (INTVAL (op));
--- /tmp/aS8nV8_rs6000-cpus.def	2020-02-07 17:56:52.599487550 -0500
+++ gcc/config/rs6000/rs6000-cpus.def	2020-02-07 17:34:02.894610688 -0500
@@ -79,11 +79,11 @@ 
    is fully functional.  */
 #define ISA_FUTURE_MASKS_SERVER	(ISA_3_0_MASKS_SERVER			\
 				 | OPTION_MASK_FUTURE			\
-				 | OPTION_MASK_PREFIXED_ADDR)
+				 | OPTION_MASK_PREFIXED)
 
 /* Flags that need to be turned off if -mno-future.  */
 #define OTHER_FUTURE_MASKS	(OPTION_MASK_PCREL			\
-				 | OPTION_MASK_PREFIXED_ADDR)
+				 | OPTION_MASK_PREFIXED)
 
 /* Flags that need to be turned off if -mno-power9-vector.  */
 #define OTHER_P9_VECTOR_MASKS	(OPTION_MASK_FLOAT128_HW		\
@@ -143,7 +143,7 @@ 
 				 | OPTION_MASK_POWERPC64		\
 				 | OPTION_MASK_PPC_GFXOPT		\
 				 | OPTION_MASK_PPC_GPOPT		\
-				 | OPTION_MASK_PREFIXED_ADDR		\
+				 | OPTION_MASK_PREFIXED			\
 				 | OPTION_MASK_QUAD_MEMORY		\
 				 | OPTION_MASK_QUAD_MEMORY_ATOMIC	\
 				 | OPTION_MASK_RECIP_PRECISION		\
--- /tmp/BjEVpM_rs6000.c	2020-02-07 17:56:52.614487767 -0500
+++ gcc/config/rs6000/rs6000.c	2020-02-07 17:34:02.910610921 -0500
@@ -4013,22 +4013,22 @@  rs6000_option_override_internal (bool gl
       rs6000_isa_flags &= ~OPTION_MASK_FLOAT128_HW;
     }
 
-  /* -mprefixed-addr (and hence -mpcrel) requires -mcpu=future.  */
-  if (TARGET_PREFIXED_ADDR && !TARGET_FUTURE)
+  /* -mprefixed (and hence -mpcrel) requires -mcpu=future.  */
+  if (TARGET_PREFIXED && !TARGET_FUTURE)
     {
       if ((rs6000_isa_flags_explicit & OPTION_MASK_PCREL) != 0)
 	error ("%qs requires %qs", "-mpcrel", "-mcpu=future");
-      else if ((rs6000_isa_flags_explicit & OPTION_MASK_PREFIXED_ADDR) != 0)
-	error ("%qs requires %qs", "-mprefixed-addr", "-mcpu=future");
+      else if ((rs6000_isa_flags_explicit & OPTION_MASK_PREFIXED) != 0)
+	error ("%qs requires %qs", "-mprefixed", "-mcpu=future");
 
-      rs6000_isa_flags &= ~(OPTION_MASK_PCREL | OPTION_MASK_PREFIXED_ADDR);
+      rs6000_isa_flags &= ~(OPTION_MASK_PCREL | OPTION_MASK_PREFIXED);
     }
 
   /* -mpcrel requires prefixed load/store addressing.  */
-  if (TARGET_PCREL && !TARGET_PREFIXED_ADDR)
+  if (TARGET_PCREL && !TARGET_PREFIXED)
     {
       if ((rs6000_isa_flags_explicit & OPTION_MASK_PCREL) != 0)
-	error ("%qs requires %qs", "-mpcrel", "-mprefixed-addr");
+	error ("%qs requires %qs", "-mpcrel", "-mprefixed");
 
       rs6000_isa_flags &= ~OPTION_MASK_PCREL;
     }
@@ -5571,7 +5571,7 @@  num_insns_constant_gpr (HOST_WIDE_INT va
     return 1;
 
   /* PADDI can support up to 34 bit signed integers.  */
-  else if (TARGET_PREFIXED_ADDR && SIGNED_INTEGER_34BIT_P (value))
+  else if (TARGET_PREFIXED && SIGNED_INTEGER_34BIT_P (value))
     return 1;
 
   else if (TARGET_POWERPC64)
@@ -7960,7 +7960,7 @@  rs6000_legitimate_offset_address_p (mach
       break;
     }
 
-  if (TARGET_PREFIXED_ADDR)
+  if (TARGET_PREFIXED)
     return SIGNED_34BIT_OFFSET_EXTRA_P (offset, extra);
   else
     return SIGNED_16BIT_OFFSET_EXTRA_P (offset, extra);
@@ -8954,7 +8954,7 @@  rs6000_mode_dependent_address (const_rtx
 	{
 	  HOST_WIDE_INT val = INTVAL (XEXP (addr, 1));
 	  HOST_WIDE_INT extra = TARGET_POWERPC64 ? 8 : 12;
-	  if (TARGET_PREFIXED_ADDR)
+	  if (TARGET_PREFIXED)
 	    return !SIGNED_34BIT_OFFSET_EXTRA_P (val, extra);
 	  else
 	    return !SIGNED_16BIT_OFFSET_EXTRA_P (val, extra);
@@ -22884,7 +22884,7 @@  static struct rs6000_opt_mask const rs60
   { "power9-vector",		OPTION_MASK_P9_VECTOR,		false, true  },
   { "powerpc-gfxopt",		OPTION_MASK_PPC_GFXOPT,		false, true  },
   { "powerpc-gpopt",		OPTION_MASK_PPC_GPOPT,		false, true  },
-  { "prefixed-addr",		OPTION_MASK_PREFIXED_ADDR,	false, true  },
+  { "prefixed",			OPTION_MASK_PREFIXED,		false, true  },
   { "quad-memory",		OPTION_MASK_QUAD_MEMORY,	false, true  },
   { "quad-memory-atomic",	OPTION_MASK_QUAD_MEMORY_ATOMIC,	false, true  },
   { "recip-precision",		OPTION_MASK_RECIP_PRECISION,	false, true  },
@@ -24849,7 +24849,7 @@  address_to_insn_form (rtx addr,
   /* Large offsets must be prefixed.  */
   if (!SIGNED_INTEGER_16BIT_P (offset))
     {
-      if (TARGET_PREFIXED_ADDR)
+      if (TARGET_PREFIXED)
 	return INSN_FORM_PREFIXED_NUMERIC;
 
       return INSN_FORM_BAD;
@@ -24889,7 +24889,7 @@  address_to_insn_form (rtx addr,
       if ((offset & 3) == 0)
 	return INSN_FORM_DS;
 
-      else if (TARGET_PREFIXED_ADDR)
+      else if (TARGET_PREFIXED)
 	return INSN_FORM_PREFIXED_NUMERIC;
 
       else
@@ -24900,7 +24900,7 @@  address_to_insn_form (rtx addr,
       if ((offset & 15) == 0)
 	return INSN_FORM_DQ;
 
-      else if (TARGET_PREFIXED_ADDR)
+      else if (TARGET_PREFIXED)
 	return INSN_FORM_PREFIXED_NUMERIC;
 
       else
@@ -25150,7 +25150,7 @@  rs6000_asm_output_opcode (FILE *stream)
 int
 rs6000_adjust_insn_length (rtx_insn *insn, int length)
 {
-  if (TARGET_PREFIXED_ADDR && NONJUMP_INSN_P (insn))
+  if (TARGET_PREFIXED && NONJUMP_INSN_P (insn))
     {
       rtx pattern = PATTERN (insn);
       if (GET_CODE (pattern) != USE && GET_CODE (pattern) != CLOBBER
--- /tmp/KBrA1p_rs6000.h	2020-02-07 17:56:52.650488290 -0500
+++ gcc/config/rs6000/rs6000.h	2020-02-07 17:44:58.345122446 -0500
@@ -2558,7 +2558,7 @@  typedef struct GTY(()) machine_function
 #define FINAL_PRESCAN_INSN(INSN, OPERANDS, NOPERANDS)			\
 do									\
   {									\
-    if (TARGET_PREFIXED_ADDR)						\
+    if (TARGET_PREFIXED)						\
       rs6000_final_prescan_insn (INSN, OPERANDS, NOPERANDS);		\
   }									\
 while (0)
@@ -2568,7 +2568,7 @@  while (0)
 #define ASM_OUTPUT_OPCODE(STREAM, OPCODE)				\
   do									\
     {									\
-     if (TARGET_PREFIXED_ADDR)						\
+     if (TARGET_PREFIXED)						\
        rs6000_asm_output_opcode (STREAM);				\
     }									\
   while (0)
--- /tmp/Q6uiG3_rs6000.md	2020-02-07 17:56:52.666488522 -0500
+++ gcc/config/rs6000/rs6000.md	2020-02-07 17:50:25.094864166 -0500
@@ -265,7 +265,7 @@  (define_attr "cannot_copy" "no,yes" (con
 ;; insns.  The default "length" attribute will also be adjusted by default to
 ;; be 12 bytes.
 (define_attr "prefixed" "no,yes"
-  (cond [(ior (match_test "!TARGET_PREFIXED_ADDR")
+  (cond [(ior (match_test "!TARGET_PREFIXED")
 	      (match_test "!NONJUMP_INSN_P (insn)"))
 	 (const_string "no")
 
--- /tmp/lqX3mH_rs6000.opt	2020-02-07 17:56:52.676488667 -0500
+++ gcc/config/rs6000/rs6000.opt	2020-02-07 17:34:02.914610979 -0500
@@ -571,7 +571,7 @@  Target Report Mask(FUTURE) Var(rs6000_is
 Use instructions for a future architecture.
 
 mprefixed-addr
-Target Undocumented Mask(PREFIXED_ADDR) Var(rs6000_isa_flags)
+Target Report Mask(PREFIXED) Var(rs6000_isa_flags)
 Generate (do not generate) prefixed memory instructions.
 
 mpcrel
--- /tmp/1ySv8k_invoke.texi	2020-02-07 17:56:52.700489015 -0500
+++ gcc/doc/invoke.texi	2020-02-07 17:34:02.925611138 -0500
@@ -1208,7 +1208,8 @@  See RS/6000 and PowerPC Options.
 -mfloat128  -mno-float128  -mfloat128-hardware  -mno-float128-hardware @gol
 -mgnu-attribute  -mno-gnu-attribute @gol
 -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} @gol
--mstack-protector-guard-offset=@var{offset} -mpcrel -mno-pcrel}
+-mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed @gol
+-mpcrel -mno-pcrel}
 
 @emph{RX Options}
 @gccoptlist{-m64bit-doubles  -m32bit-doubles  -fpu  -nofpu@gol
@@ -22327,7 +22328,6 @@  faster on processors with 32-bit busses
 aligns structures containing the above types differently than
 most published application binary interface specifications for the m68k.
 
-@item -mpcrel
 @opindex mpcrel
 Use the pc-relative addressing mode of the 68000 directly, instead of
 using a global offset table.  At present, this option implies @option{-fpic},
@@ -26415,7 +26415,16 @@  the offset with a symbol reference to a
 @opindex mpcrel
 @opindex mno-pcrel
 Generate (do not generate) pc-relative addressing when the option
-@option{-mcpu=future} is used.
+@option{-mcpu=future} is used.  The @option{-mpcrel} option requires
+that the medium code model (@option{-mcmodel=medium}) and prefixed
+addressing (@option{-mprefixed}) options are enabled.
+
+@item -mprefixed
+@itemx -mno-prefixed
+@opindex mprefixed
+@opindex mno-prefixed
+Generate (do not generate) addressing modes using prefixed load and
+store instructions when the option @option{-mcpu=future} is used.
 @end table
 
 @node RX Options