Using .opt files for target options

Richard Sandiford rsandifo@redhat.com
Mon Mar 14 09:19:00 GMT 2005


Mike Stump <mrs@apple.com> writes:
> On Sunday, March 13, 2005, at 09:16  AM, Richard Sandiford wrote:
>> The aim of this patch is to extend the front- and middle-end
>> options-handling machinery so that it can be used for target
>> options as well.  In other words, it lets you specify target
>> options using target-specific .opt files.
>
> I like it...  nice step forward.  Thanks.
>
> [ just thinking out loud ]  Next to do would be to overflow from 31 to
> an array of ints, some ports like the ppc really want a few more (<64
> but >32).

Does it need all >31 bits to be real target_flag bits?  I realised
after posting the patch that I forgot to say what main motiviation
was up-front.  The idea is that, if you specify options using .opt
files, you can use separate variables instead of target_flags for
the options that don't really need associated MASK_* constants.

Or to put it another way: most target code just wants a TARGET_*
identifier it can test.  It doesn't really matter whether that TARGET_*
thing is a macro that checks target_flags or whether it's a separate
variable.  The only switches that really "need" to be target_flags are
those that have different default settings for different configurations.

(Well, OK, another use of MASK_* constants is in checks of
target_flags_explicit, but such checks could be rewritten to use the
target hook instead.  Using target_flags also helps because you get the
default PCH validity checks, but long term, I think it would be better
to have an "AffectsPCH" .opt flag.)


We've run out target_flags bits for MIPS too, and I recently had to
add an on/off switch to TARGET_OPTIONS (pretending it took an argument)
in order to get around this.  But quite a few of the existing MIPS
target_flags don't really need to be there: a separate variable would
be just as good.  So part of the MIPS conversion involved replacing
MASK_FOO/TARGET_FOO with Var(TARGET_FOO) where possible.  It also moved
the boolean TARGET_OPTIONS switch to the .opt file and marked it with
Var(TARGET_*).

Richard



More information about the Gcc-patches mailing list