This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Add MaskNeeded property to option handling


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  <hongjiu.lu@intel.com>

	* 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)"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]