Re: PATCH: Add MaskNeeded property to option handling

2012-03-26 Thread H.J. Lu
On Mon, Mar 26, 2012 at 4:53 AM, Joseph S. Myers
 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.

Thanks.

-- 
H.J.


Re: PATCH: Add MaskNeeded property to option handling

2012-03-26 Thread Joseph S. Myers
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.

-- 
Joseph S. Myers
jos...@codesourcery.com


PATCH: Add MaskNeeded property to option handling

2012-03-25 Thread H.J. Lu
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?

Thanks.


H.J.

2012-03-25  H.J. Lu  

* opth-gen.awk: Handle MaskNeeded.

* doc/options.texi: Document MaskNeeded.

diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi
index 0a54183..fb501cf 100644
--- a/gcc/doc/options.texi
+++ b/gcc/doc/options.texi
@@ -364,6 +364,14 @@ 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 MaskNeeded
+It turns @samp{InverseMask(@var{othername})} into the inverse version of
+@samp{Mask(@var{othername})}.
+
+This property only applies to @samp{InverseMask(@var{othername})}.  Its
+main purpose is to support @samp{InverseMask(@var{othername})} without
+the corresponding @samp{Mask(@var{othername})}.
+
 @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..1885b2c 100644
--- a/gcc/opth-gen.awk
+++ b/gcc/opth-gen.awk
@@ -309,6 +309,21 @@ for (i = 0; i < n_opts; i++) {
if (name != "" && !flag_set_p("MaskExists", flags[i]))
print "#define " mask name " (" mask_1 " << " masknum[vname]++ 
")"
 }
+for (i = 0; i < n_opts; i++) {
+   name = opt_args("InverseMask", flags[i])
+   if (name != "" && flag_set_p("MaskNeeded", 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"
+   }
+   print "#define " mask name " (" mask_1 \
+ " << " masknum[vname]++ ")"
+   }
+}
 for (i = 0; i < n_extra_masks; i++) {
print "#define MASK_" extra_masks[i] " (1 << " masknum[""]++ ")"
 }
@@ -342,6 +357,21 @@ for (i = 0; i < n_opts; i++) {
print "#define " macro name \
  " ((" vname " & " mask name ") != 0)"
 }
+for (i = 0; i < n_opts; i++) {
+   name = opt_args("InverseMask", flags[i])
+   if (name != "" && flag_set_p("MaskNeeded", flags[i])) {
+   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] \
  " ((target_flags & MASK_" extra_masks[i] ") != 0)"