This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Use .opt for the SPARC port
Eric Botcazou <ebotcazou@libertysurf.fr> writes:
>> So no configuration actually accepts an option called -mv8? You just
>> define it so that you can add the mask?
>
> Yes. :-) We accept -mcpu=v8 and -mcpu=v9 but not -mv8 and -mv9.
Yeah, I don't really like this fake option thing much ;)
>> I wonder if would be better to have a separate RegisterMask record,
>> a bit like the existing Language records. E.g.:
>>
>> RegisterMask
>> V8 SPARC SPARCLITE V9 DEPRECATED_V8_INSNS
>>
>> It would avoid confusion about having .opt files that don't correspond
>> to real options. Also (having recently been burned by gcc.pot ;)
>> it would stop us adding strings to gcc.pot that don't actually need
>> translation. (Although you could of course just leave the dummy
>> options as undocumented instead.)
>
> I thought it would be more consistent to define all the masks the same way,
> whether they be associated with options or not. But I have no strong
> feeling about this.
Oh well, it seems I do have quite strong feelings about it ;) (Sorry!)
And that means I should really stump up a patch.
Here's the sort of thing I had in mind. Does it look OK to you?
I tested it by changing mips.opt to use the new record type and
verifying that it had no effect on the options.h output.
I agree about the consistency thing though. It might be better to
define _all_ target masks this way. We could then remove the double
meaning of Mask(...) property and also remove the slightly-controversial
MaskExists thing.
If this patch is OK, and if folks agree that it would be cleaner to
define all masks in this way, I'll volunteer to change all the existing
.opt files.
Sorry for being so awkward, and sorry for the churn.
Richard
* doc/options.texi: Document TargetMasks records.
* opth-gen.awk (masks): New array
(n_masks): New variable.
Handle TargetMasks records, adding each mask to "masks". Add the
names of Mask(...) entries to "masks" when the option is first
encountered. Adjust MASK_* and TARGET_* code accordingly.
Index: doc/options.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/options.texi,v
retrieving revision 1.2
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.2 options.texi
*** doc/options.texi 30 Mar 2005 06:26:20 -0000 1.2
--- doc/options.texi 9 Apr 2005 08:39:28 -0000
*************** blank lines. Comments may appear on the
*** 25,39 ****
the file and are preceded by semicolons. Whitespace is allowed before
the semicolon.
! The files can contain two types of record: language definitions and
! option definitions.
! A language definition record has two fields: the string
! @samp{Language} and the name of the language. Once a language has
! been declared in this way, it can be used as an option property.
@xref{Option properties}.
! An option definition record has the following fields:
@enumerate
@item
--- 25,50 ----
the file and are preceded by semicolons. Whitespace is allowed before
the semicolon.
! The files can contain the following types of record:
! @itemize @bullet
! @item
! A language definition record. These records have two fields: the
! string @samp{Language} and the name of the language. Once a language
! has been declared in this way, it can be used as an option property.
@xref{Option properties}.
! @item
! A target mask record. These records have two fields: the string
! @samp{TargetMasks} and a list of space-separated mask names. The
! options-processing script will automatically allocate a bit in
! @code{target_flags} for each mask name @var{x} and set the macro
! @code{MASK_@var{x}} to the appropriate bitmask. It will also declare
! a @code{TARGET_@var{x}} macro that has the value 1 when bit
! @code{MASK_@var{x}} is set and 0 otherwise.
!
! @item
! An option definition record. These records have the following fields:
@enumerate
@item
*************** help text contains a tab character, the
*** 58,63 ****
--- 69,75 ----
used instead of the option's name and the text to the right of the
tab forms the help text. This allows you to elaborate on what type
of argument the option takes.
+ @end itemize
@node Option properties
@section Option properties
Index: opth-gen.awk
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opth-gen.awk,v
retrieving revision 2.4
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r2.4 opth-gen.awk
*** opth-gen.awk 30 Mar 2005 06:26:19 -0000 2.4
--- opth-gen.awk 9 Apr 2005 08:39:28 -0000
***************
*** 26,31 ****
--- 26,32 ----
BEGIN {
n_opts = 0
n_langs = 0
+ n_masks = 0
quote = "\042"
comma = ","
FS=SUBSEP
*************** BEGIN {
*** 35,47 ****
{
if ($1 == "Language") {
langs[n_langs] = $2
! n_langs++;
! }
! else {
opts[n_opts] = $1
flags[n_opts] = $2
help[n_opts] = $3
! n_opts++;
}
}
--- 36,54 ----
{
if ($1 == "Language") {
langs[n_langs] = $2
! n_langs++
! } else if ($1 == "TargetMasks") {
! split($2, submasks, " ")
! for (i in submasks)
! masks[n_masks++] = submasks[i]
! } else {
opts[n_opts] = $1
flags[n_opts] = $2
help[n_opts] = $3
! n_opts++
! mask = opt_args("Mask", $2)
! if (mask != "" && !flag_set_p("MaskExists", $2))
! masks[n_masks++] = mask
}
}
*************** for (i = 0; i < n_opts; i++) {
*** 67,88 ****
}
! masknum = 0
! for (i = 0; i < n_opts; i++) {
! name = opt_args("Mask", flags[i])
! if (name != "" && !flag_set_p("MaskExists", flags[i]))
! print "#define MASK_" name " (1 << " masknum++ ")"
! }
! if (masknum > 31)
print "#error too many target masks"
print ""
!
! for (i = 0; i < n_opts; i++) {
! name = opt_args("Mask", flags[i])
! if (name != "" && !flag_set_p("MaskExists", flags[i]))
! print "#define TARGET_" name \
! " ((target_flags & MASK_" name ") != 0)"
! }
print ""
for (i = 0; i < n_opts; i++) {
--- 74,87 ----
}
! if (n_masks > 31)
print "#error too many target masks"
+ for (i = 0; i < n_masks; i++)
+ print "#define MASK_" masks[i] " (1 << " i ")"
print ""
! for (i = 0; i < n_masks; i++)
! print "#define TARGET_" masks[i] \
! " ((target_flags & MASK_" masks[i] ") != 0)"
print ""
for (i = 0; i < n_opts; i++) {
Index: optc-gen.awk
===================================================================
RCS file: /cvs/gcc/gcc/gcc/optc-gen.awk,v
retrieving revision 2.3
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r2.3 optc-gen.awk
*** optc-gen.awk 6 Apr 2005 22:42:27 -0000 2.3
--- optc-gen.awk 9 Apr 2005 08:39:28 -0000
*************** BEGIN {
*** 41,51 ****
langs[n_langs] = $2
n_langs++;
}
else {
opts[n_opts] = $1
flags[n_opts] = $2
help[n_opts] = $3
! n_opts++;
}
}
--- 41,53 ----
langs[n_langs] = $2
n_langs++;
}
+ else if ($1 == "TargetMasks") {
+ }
else {
opts[n_opts] = $1
flags[n_opts] = $2
help[n_opts] = $3
! n_opts++
}
}