Re: Add support for adjusting the number of units in a mode

2017-11-19 Thread Jeff Law
On 11/09/2017 04:08 AM, Richard Sandiford wrote:
> Jeff Law  writes:
>> On 10/25/2017 09:57 AM, Richard Sandiford wrote:
>>> We already allow the target to change the size and alignment of a mode.
>>> This patch does the same thing for the number of units, which is needed
>>> to give command-line control of the SVE vector length.
>>>
>>> Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu,
>>> on top of the poly_int series.  I think I can approve this under the
>>> gen* maintainership, so if there are no comments in the menatime,
>>> I'll apply it if the prerequisites are approved.
>>>
>>> Thanks,
>>> Richard
>>>
>>>
>>> 2017-10-25  Richard Sandiford  
>>> Alan Hayward  
>>> David Sherwood  
>>>
>>> gcc/
>>> * machmode.h (mode_precision): Prefix with CONST_MODE_PRECISION.
>>> (mode_nunits): Likewise CONST_MODE_NUNITS.
>>> * machmode.def (ADJUST_NUNITS): Document.
>>> * genmodes.c (mode_data::need_nunits_adj): New field.
>>> (blank_mode): Update accordingly.
>>> (adj_nunits): New variable.
>>> (print_maybe_const_decl): Replace CATEGORY with a NEEDS_ADJ
>>> parameter.
>>> (emit_mode_size_inline): Set need_bytesize_adj for all modes
>>> listed in adj_nunits.
>>> (emit_mode_nunits_inline): Set need_nunits_adj for all modes
>>> listed in adj_nunits.  Don't emit case statements for such modes.
>>> (emit_insn_modes_h): Emit definitions of CONST_MODE_NUNITS
>>> and CONST_MODE_PRECISION.  Make CONST_MODE_SIZE expand to
>>> nothing if adj_nunits is nonnull.
>>> (emit_mode_precision, emit_mode_nunits): Use print_maybe_const_decl.
>>> (emit_mode_unit_size, emit_mode_base_align, emit_mode_ibit)
>>> (emit_mode_fbit): Update use of print_maybe_const_decl.
>>> (emit_move_size): Likewise.  Treat the array as non-const
>>> if adj_nunits.
>>> (emit_mode_adjustments): Handle adj_nunits.
>> Were all the prereqs here approved?  Or does this depend on the poly_int
>> stuff?
> 
> Yeah, it depends on the poly_int stuff.  Not in a major way though --
> I could reorder it if necessary.
Your call.  I figure it's going to be at least a week working my way
through the rest of poly_int.  I keep hoping to see groups of patches
within that kit that I can trivially look at and say, yea, of course
this is good.  But it hasn't really happened yet.

jeff



Re: Add support for adjusting the number of units in a mode

2017-11-09 Thread Richard Sandiford
Jeff Law  writes:
> On 10/25/2017 09:57 AM, Richard Sandiford wrote:
>> We already allow the target to change the size and alignment of a mode.
>> This patch does the same thing for the number of units, which is needed
>> to give command-line control of the SVE vector length.
>> 
>> Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu,
>> on top of the poly_int series.  I think I can approve this under the
>> gen* maintainership, so if there are no comments in the menatime,
>> I'll apply it if the prerequisites are approved.
>> 
>> Thanks,
>> Richard
>> 
>> 
>> 2017-10-25  Richard Sandiford  
>>  Alan Hayward  
>>  David Sherwood  
>> 
>> gcc/
>>  * machmode.h (mode_precision): Prefix with CONST_MODE_PRECISION.
>>  (mode_nunits): Likewise CONST_MODE_NUNITS.
>>  * machmode.def (ADJUST_NUNITS): Document.
>>  * genmodes.c (mode_data::need_nunits_adj): New field.
>>  (blank_mode): Update accordingly.
>>  (adj_nunits): New variable.
>>  (print_maybe_const_decl): Replace CATEGORY with a NEEDS_ADJ
>>  parameter.
>>  (emit_mode_size_inline): Set need_bytesize_adj for all modes
>>  listed in adj_nunits.
>>  (emit_mode_nunits_inline): Set need_nunits_adj for all modes
>>  listed in adj_nunits.  Don't emit case statements for such modes.
>>  (emit_insn_modes_h): Emit definitions of CONST_MODE_NUNITS
>>  and CONST_MODE_PRECISION.  Make CONST_MODE_SIZE expand to
>>  nothing if adj_nunits is nonnull.
>>  (emit_mode_precision, emit_mode_nunits): Use print_maybe_const_decl.
>>  (emit_mode_unit_size, emit_mode_base_align, emit_mode_ibit)
>>  (emit_mode_fbit): Update use of print_maybe_const_decl.
>>  (emit_move_size): Likewise.  Treat the array as non-const
>>  if adj_nunits.
>>  (emit_mode_adjustments): Handle adj_nunits.
> Were all the prereqs here approved?  Or does this depend on the poly_int
> stuff?

Yeah, it depends on the poly_int stuff.  Not in a major way though --
I could reorder it if necessary.

Thanks,
Richard


Re: Add support for adjusting the number of units in a mode

2017-11-08 Thread Jeff Law
On 10/25/2017 09:57 AM, Richard Sandiford wrote:
> We already allow the target to change the size and alignment of a mode.
> This patch does the same thing for the number of units, which is needed
> to give command-line control of the SVE vector length.
> 
> Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu,
> on top of the poly_int series.  I think I can approve this under the
> gen* maintainership, so if there are no comments in the menatime,
> I'll apply it if the prerequisites are approved.
> 
> Thanks,
> Richard
> 
> 
> 2017-10-25  Richard Sandiford  
>   Alan Hayward  
>   David Sherwood  
> 
> gcc/
>   * machmode.h (mode_precision): Prefix with CONST_MODE_PRECISION.
>   (mode_nunits): Likewise CONST_MODE_NUNITS.
>   * machmode.def (ADJUST_NUNITS): Document.
>   * genmodes.c (mode_data::need_nunits_adj): New field.
>   (blank_mode): Update accordingly.
>   (adj_nunits): New variable.
>   (print_maybe_const_decl): Replace CATEGORY with a NEEDS_ADJ
>   parameter.
>   (emit_mode_size_inline): Set need_bytesize_adj for all modes
>   listed in adj_nunits.
>   (emit_mode_nunits_inline): Set need_nunits_adj for all modes
>   listed in adj_nunits.  Don't emit case statements for such modes.
>   (emit_insn_modes_h): Emit definitions of CONST_MODE_NUNITS
>   and CONST_MODE_PRECISION.  Make CONST_MODE_SIZE expand to
>   nothing if adj_nunits is nonnull.
>   (emit_mode_precision, emit_mode_nunits): Use print_maybe_const_decl.
>   (emit_mode_unit_size, emit_mode_base_align, emit_mode_ibit)
>   (emit_mode_fbit): Update use of print_maybe_const_decl.
>   (emit_move_size): Likewise.  Treat the array as non-const
>   if adj_nunits.
>   (emit_mode_adjustments): Handle adj_nunits.
Were all the prereqs here approved?  Or does this depend on the poly_int
stuff?

jeff



Add support for adjusting the number of units in a mode

2017-10-25 Thread Richard Sandiford
We already allow the target to change the size and alignment of a mode.
This patch does the same thing for the number of units, which is needed
to give command-line control of the SVE vector length.

Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu,
on top of the poly_int series.  I think I can approve this under the
gen* maintainership, so if there are no comments in the menatime,
I'll apply it if the prerequisites are approved.

Thanks,
Richard


2017-10-25  Richard Sandiford  
Alan Hayward  
David Sherwood  

gcc/
* machmode.h (mode_precision): Prefix with CONST_MODE_PRECISION.
(mode_nunits): Likewise CONST_MODE_NUNITS.
* machmode.def (ADJUST_NUNITS): Document.
* genmodes.c (mode_data::need_nunits_adj): New field.
(blank_mode): Update accordingly.
(adj_nunits): New variable.
(print_maybe_const_decl): Replace CATEGORY with a NEEDS_ADJ
parameter.
(emit_mode_size_inline): Set need_bytesize_adj for all modes
listed in adj_nunits.
(emit_mode_nunits_inline): Set need_nunits_adj for all modes
listed in adj_nunits.  Don't emit case statements for such modes.
(emit_insn_modes_h): Emit definitions of CONST_MODE_NUNITS
and CONST_MODE_PRECISION.  Make CONST_MODE_SIZE expand to
nothing if adj_nunits is nonnull.
(emit_mode_precision, emit_mode_nunits): Use print_maybe_const_decl.
(emit_mode_unit_size, emit_mode_base_align, emit_mode_ibit)
(emit_mode_fbit): Update use of print_maybe_const_decl.
(emit_move_size): Likewise.  Treat the array as non-const
if adj_nunits.
(emit_mode_adjustments): Handle adj_nunits.

Index: gcc/machmode.h
===
--- gcc/machmode.h  2017-10-25 16:50:35.628184659 +0100
+++ gcc/machmode.h  2017-10-25 16:55:00.469175980 +0100
@@ -23,9 +23,9 @@ #define HAVE_MACHINE_MODES
 typedef opt_mode opt_machine_mode;
 
 extern CONST_MODE_SIZE poly_uint16_pod mode_size[NUM_MACHINE_MODES];
-extern const poly_uint16_pod mode_precision[NUM_MACHINE_MODES];
+extern CONST_MODE_PRECISION poly_uint16_pod mode_precision[NUM_MACHINE_MODES];
 extern const unsigned char mode_inner[NUM_MACHINE_MODES];
-extern const poly_uint16_pod mode_nunits[NUM_MACHINE_MODES];
+extern CONST_MODE_NUNITS poly_uint16_pod mode_nunits[NUM_MACHINE_MODES];
 extern CONST_MODE_UNIT_SIZE unsigned char mode_unit_size[NUM_MACHINE_MODES];
 extern const unsigned short mode_unit_precision[NUM_MACHINE_MODES];
 extern const unsigned char mode_wider[NUM_MACHINE_MODES];
Index: gcc/machmode.def
===
--- gcc/machmode.def2017-10-25 16:50:35.628184659 +0100
+++ gcc/machmode.def2017-10-25 16:55:00.468176022 +0100
@@ -169,6 +169,12 @@ along with GCC; see the file COPYING3.
Unlike a FORMAT argument, if you are adjusting a float format
you must put an & in front of the name of each format structure.
 
+ ADJUST_NUNITS (MODE, EXPR);
+   Like the above, but set the number of nunits of MODE to EXPR.
+   This changes the size and precision of the mode in proportion
+   to the change in the number of units; for example, doubling
+   the number of units doubles the size and precision as well.
+
Note: If a mode is ever made which is more than 255 bytes wide,
machmode.h and genmodes.c will have to be changed to allocate
more space for the mode_size and mode_alignment arrays.  */
Index: gcc/genmodes.c
===
--- gcc/genmodes.c  2017-10-25 16:50:35.627184698 +0100
+++ gcc/genmodes.c  2017-10-25 16:55:00.468176022 +0100
@@ -72,7 +72,9 @@ struct mode_data
   unsigned int counter;/* Rank ordering of modes */
   unsigned int ibit;   /* the number of integral bits */
   unsigned int fbit;   /* the number of fractional bits */
-  bool need_bytesize_adj;  /* true if this mode need dynamic size
+  bool need_nunits_adj;/* true if this mode needs dynamic 
nunits
+  adjustment */
+  bool need_bytesize_adj;  /* true if this mode needs dynamic size
   adjustment */
   unsigned int int_n;  /* If nonzero, then __int will be 
defined */
 };
@@ -85,7 +87,7 @@ static const struct mode_data blank_mode
   0, "", MAX_MODE_CLASS,
   -1U, -1U, -1U, -1U,
   0, 0, 0, 0, 0, 0,
-  "", 0, 0, 0, 0, false, 0
+  "", 0, 0, 0, 0, false, false, 0
 };
 
 static htab_t modes_by_name;
@@ -103,6 +105,7 @@ struct mode_adjust
   unsigned int line;
 };
 
+static struct mode_adjust *adj_nunits;
 static struct mode_adjust *adj_bytesize;
 static struct mode_adjust *adj_alignment;
 static struct mode_adjust *adj_format;
@@ -786,6 +789,7 @@