diff mbox

PATCH: Remove MaskExists property from option handling

Message ID CAMe9rOrepRFS7xOJ7qvtuaiF2LuoAX5c4b2yVDtCHusej1EEnA@mail.gmail.com
State New
Headers show

Commit Message

H.J. Lu March 26, 2012, 5:20 p.m. UTC
On Mon, Mar 26, 2012 at 7:47 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, Mar 26, 2012 at 4:53 AM, Joseph S. Myers
> <joseph@codesourcery.com> wrote:
>> On Sun, 25 Mar 2012, H.J. Lu wrote:
>>
>>> Hi Joseph,
>>>
>>> I need to support InverseMask(XXX) in options without the corresponding
>>> Mask(XXX) since XXX is never set directly via a command line option. This
>>> patch adds a MaskNeeded property which turns InverseMask(XXX) into
>>> the inverse version of Mask(XXX), which allocates a unique bit and defines
>>> the same set of macros as Mask(XXX).  Does it look OK?
>>
>> I'd have thought that either Mask or InverseMask with a given mask name
>> (or a standalone target mask record) should cause allocation (only once,
>> no matter how many options use the same mask name), and MaskExists should
>> be removed, rather than adding MaskNeeded - if I understood correctly the
>> purpose for which you are adding MaskNeeded.
>>
>
> That is correct.  I will work on a patch to remove  MaskExists.
>

Here is a patch to remove MaskExists.  The difference between the old
options.h and the new options.h on Linux/x86-64 are

 #define OPTION_ANDROID ((flag_android & OPTION_MASK_ANDROID) != 0)
 #define OPTION_ISA_AVX ((ix86_isa_flags & OPTION_MASK_ISA_AVX) != 0)
 #define OPTION_ISA_AVX2 ((ix86_isa_flags & OPTION_MASK_ISA_AVX2) != 0)
@@ -3762,6 +3763,7 @@ extern void cl_target_option_print (FILE
 #define OPTION_ISA_CRC32 ((ix86_isa_flags & OPTION_MASK_ISA_CRC32) != 0)
 #define OPTION_ISA_CX16 ((ix86_isa_flags & OPTION_MASK_ISA_CX16) != 0)
 #define OPTION_ISA_F16C ((ix86_isa_flags & OPTION_MASK_ISA_F16C) != 0)
+#define TARGET_NO_FANCY_MATH_387 ((target_flags & MASK_NO_FANCY_MATH_387) != 0)
 #define OPTION_ISA_FMA ((ix86_isa_flags & OPTION_MASK_ISA_FMA) != 0)
 #define OPTION_ISA_FMA4 ((ix86_isa_flags & OPTION_MASK_ISA_FMA4) != 0)
 #define TARGET_FLOAT_RETURNS ((target_flags & MASK_FLOAT_RETURNS) != 0)
@@ -3774,10 +3776,9 @@ extern void cl_target_option_print (FILE
 #define OPTION_ISA_MMX ((ix86_isa_flags & OPTION_MASK_ISA_MMX) != 0)
 #define OPTION_ISA_MOVBE ((ix86_isa_flags & OPTION_MASK_ISA_MOVBE) != 0)
 #define TARGET_MS_BITFIELD_LAYOUT ((target_flags &
MASK_MS_BITFIELD_LAYOUT) != 0)
-#define TARGET_NO_ALIGN_STRINGOPS ((target_flags &
MASK_NO_ALIGN_STRINGOPS) != 0)
-#define TARGET_NO_FANCY_MATH_387 ((target_flags & MASK_NO_FANCY_MATH_387) != 0)
 #define TARGET_NO_PUSH_ARGS ((target_flags & MASK_NO_PUSH_ARGS) != 0)
 #define TARGET_NO_RED_ZONE ((target_flags & MASK_NO_RED_ZONE) != 0)
+#define OPTION_ISA_SSE4_1 ((ix86_isa_flags & OPTION_MASK_ISA_SSE4_1) != 0)
 #define TARGET_OMIT_LEAF_FRAME_POINTER ((target_flags &
MASK_OMIT_LEAF_FRAME_POINTER) != 0)
 #define OPTION_ISA_PCLMUL ((ix86_isa_flags & OPTION_MASK_ISA_PCLMUL) != 0)
 #define OPTION_ISA_POPCNT ((ix86_isa_flags & OPTION_MASK_ISA_POPCNT) != 0)
@@ -3790,7 +3791,6 @@ extern void cl_target_option_print (FILE
 #define OPTION_ISA_SSE ((ix86_isa_flags & OPTION_MASK_ISA_SSE) != 0)
 #define OPTION_ISA_SSE2 ((ix86_isa_flags & OPTION_MASK_ISA_SSE2) != 0)
 #define OPTION_ISA_SSE3 ((ix86_isa_flags & OPTION_MASK_ISA_SSE3) != 0)
-#define OPTION_ISA_SSE4_1 ((ix86_isa_flags & OPTION_MASK_ISA_SSE4_1) != 0)
 #define OPTION_ISA_SSE4_2 ((ix86_isa_flags & OPTION_MASK_ISA_SSE4_2) != 0)
 #define OPTION_ISA_SSE4A ((ix86_isa_flags & OPTION_MASK_ISA_SSE4A) != 0)
 #define TARGET_SSEREGPARM ((target_flags & MASK_SSEREGPARM) != 0)

The same set of macros are provided.  The only differences are the
order of bits used and macro definitions.  I am doing a full bootstrap and
test on Linux/x86-64.  OK for trunk if there are no regressions?

I will submit a separate patch to remove MaskExists from all *.opt files after
this patch is installed.

Thanks.

Comments

H.J. Lu March 26, 2012, 6:45 p.m. UTC | #1
On Mon, Mar 26, 2012 at 10:20 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, Mar 26, 2012 at 7:47 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Mon, Mar 26, 2012 at 4:53 AM, Joseph S. Myers
>> <joseph@codesourcery.com> wrote:
>>> On Sun, 25 Mar 2012, H.J. Lu wrote:
>>>
>>>> Hi Joseph,
>>>>
>>>> I need to support InverseMask(XXX) in options without the corresponding
>>>> Mask(XXX) since XXX is never set directly via a command line option. This
>>>> patch adds a MaskNeeded property which turns InverseMask(XXX) into
>>>> the inverse version of Mask(XXX), which allocates a unique bit and defines
>>>> the same set of macros as Mask(XXX).  Does it look OK?
>>>
>>> I'd have thought that either Mask or InverseMask with a given mask name
>>> (or a standalone target mask record) should cause allocation (only once,
>>> no matter how many options use the same mask name), and MaskExists should
>>> be removed, rather than adding MaskNeeded - if I understood correctly the
>>> purpose for which you are adding MaskNeeded.
>>>
>>
>> That is correct.  I will work on a patch to remove  MaskExists.
>>
>
> Here is a patch to remove MaskExists.  The difference between the old
> options.h and the new options.h on Linux/x86-64 are
>
...
> The same set of macros are provided.  The only differences are the
> order of bits used and macro definitions.  I am doing a full bootstrap and
> test on Linux/x86-64.  OK for trunk if there are no regressions?
>
> I will submit a separate patch to remove MaskExists from all *.opt files after
> this patch is installed.
>
> Thanks.
>
>
> --
> H.J.
> ----
> 2012-03-26  H.J. Lu  <hongjiu.lu@intel.com>
>
>        * opth-gen.awk: Allocated a bit for Mask and InverseMask if it
>        hasn't been allocated.  Define a target macro for Mask and
>        InverseMask if it hasn't been defined.  Remove MaskExists
>        handling.
>
>        * doc/options.texi: Remove MaskNeeded.

There are no regressions on Linux/x86-64.  OK for trunk?

Thanks.
Joseph Myers March 27, 2012, 2:20 p.m. UTC | #2
On Mon, 26 Mar 2012, H.J. Lu wrote:

> The same set of macros are provided.  The only differences are the
> order of bits used and macro definitions.  I am doing a full bootstrap and
> test on Linux/x86-64.  OK for trunk if there are no regressions?

OK.
diff mbox

Patch

2012-03-26  H.J. Lu  <hongjiu.lu@intel.com>

	* opth-gen.awk: Allocated a bit for Mask and InverseMask if it
	hasn't been allocated.  Define a target macro for Mask and
	InverseMask if it hasn't been defined.  Remove MaskExists
	handling.

	* doc/options.texi: Remove MaskNeeded.

diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi
index 0a54183..08b8b79 100644
--- a/gcc/doc/options.texi
+++ b/gcc/doc/options.texi
@@ -346,8 +346,6 @@  the value 1 when the option is active and 0 otherwise.  If you use @code{Var}
 to attach the option to a different variable, the associated macros are
 called @code{OPTION_MASK_@var{name}} and @code{OPTION_@var{name}} respectively.
 
-You can disable automatic bit allocation using @code{MaskExists}.
-
 @item InverseMask(@var{othername})
 @itemx InverseMask(@var{othername}, @var{thisname})
 The option is the inverse of another option that has the
@@ -355,15 +353,6 @@  The option is the inverse of another option that has the
 the options-processing script will declare a @code{TARGET_@var{thisname}}
 macro that is 1 when the option is active and 0 otherwise.
 
-@item MaskExists
-The mask specified by the @code{Mask} property already exists.
-No @code{MASK} or @code{TARGET} definitions should be added to
-@file{options.h} in response to this option record.
-
-The main purpose of this property is to support synonymous options.
-The first option should use @samp{Mask(@var{name})} and the others
-should use @samp{Mask(@var{name}) MaskExists}.
-
 @item Enum(@var{name})
 The option's argument is a string from the set of strings associated
 with the corresponding @samp{Enum} record.  The string is checked and
diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk
index 541bc3e..9a7b6c3 100644
--- a/gcc/opth-gen.awk
+++ b/gcc/opth-gen.awk
@@ -298,16 +298,25 @@  print "";
 
 for (i = 0; i < n_opts; i++) {
 	name = opt_args("Mask", flags[i])
-	vname = var_name(flags[i])
-	mask = "MASK_"
-	mask_1 = "1"
-	if (vname != "") {
-		mask = "OPTION_MASK_"
-		if (host_wide_int[vname] == "yes")
-			mask_1 = "HOST_WIDE_INT_1"
+	if (name == "") {
+		opt = opt_args("InverseMask", flags[i])
+		if (opt ~ ",")
+			name = nth_arg(0, opt)
+		else
+			name = opt
 	}
-	if (name != "" && !flag_set_p("MaskExists", flags[i]))
+	if (name != "" && mask_bits[name] == 0) {
+		mask_bits[name] = 1
+		vname = var_name(flags[i])
+		mask = "MASK_"
+		mask_1 = "1"
+		if (vname != "") {
+			mask = "OPTION_MASK_"
+			if (host_wide_int[vname] == "yes")
+				mask_1 = "HOST_WIDE_INT_1"
+		}
 		print "#define " mask name " (" mask_1 " << " masknum[vname]++ ")"
+	}
 }
 for (i = 0; i < n_extra_masks; i++) {
 	print "#define MASK_" extra_masks[i] " (1 << " masknum[""]++ ")"
@@ -330,17 +339,26 @@  print ""
 
 for (i = 0; i < n_opts; i++) {
 	name = opt_args("Mask", flags[i])
-	vname = var_name(flags[i])
-	macro = "OPTION_"
-	mask = "OPTION_MASK_"
-	if (vname == "") {
-		vname = "target_flags"
-		macro = "TARGET_"
-		mask = "MASK_"
+	if (name == "") {
+		opt = opt_args("InverseMask", flags[i])
+		if (opt ~ ",")
+			name = nth_arg(0, opt)
+		else
+			name = opt
 	}
-	if (name != "" && !flag_set_p("MaskExists", flags[i]))
+	if (name != "" && mask_macros[name] == 0) {
+		mask_macros[name] = 1
+		vname = var_name(flags[i])
+		macro = "OPTION_"
+		mask = "OPTION_MASK_"
+		if (vname == "") {
+			vname = "target_flags"
+			macro = "TARGET_"
+			mask = "MASK_"
+		}
 		print "#define " macro name \
 		      " ((" vname " & " mask name ") != 0)"
+	}
 }
 for (i = 0; i < n_extra_masks; i++) {
 	print "#define TARGET_" extra_masks[i] \