public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc/config/arch/arch.opt: Option mask gen problem
@ 2019-07-22 11:05 Maxim Blinov
  2019-07-22 18:54 ` Jim Wilson
  0 siblings, 1 reply; 2+ messages in thread
From: Maxim Blinov @ 2019-07-22 11:05 UTC (permalink / raw)
  To: gcc

Hi all,

Is it possible, in the arch.opt file, to have GCC generate a bitmask
relative to a user-defined variable without an associated name? To
illustrate my problem, consider the following option file snippet:

...
Variable
HOST_WIDE_INT riscv_bitmanip_flags = 0
...
mbmi-zbb
Target Mask(BITMANIP_ZBB) Var(riscv_bitmanip_flags)
Support the base subset of the Bitmanip extension.
...

This generates the following lines in the build/gcc/options.h (marker
added by me for clarity):

...
#define OPTION_MASK_BITMANIP_ZBB (HOST_WIDE_INT_1U << 0) // <<<<
#define OPTION_MASK_BITMANIP_ZBC (HOST_WIDE_INT_1U << 1)
#define OPTION_MASK_BITMANIP_ZBE (HOST_WIDE_INT_1U << 2)
#define OPTION_MASK_BITMANIP_ZBF (HOST_WIDE_INT_1U << 3)
#define OPTION_MASK_BITMANIP_ZBM (HOST_WIDE_INT_1U << 4)
#define OPTION_MASK_BITMANIP_ZBP (HOST_WIDE_INT_1U << 5)
#define OPTION_MASK_BITMANIP_ZBR (HOST_WIDE_INT_1U << 6)
#define OPTION_MASK_BITMANIP_ZBS (HOST_WIDE_INT_1U << 7)
#define OPTION_MASK_BITMANIP_ZBT (HOST_WIDE_INT_1U << 8)
#define MASK_DIV (1U << 0)
#define MASK_EXPLICIT_RELOCS (1U << 1)
#define MASK_FDIV (1U << 2)
#define MASK_SAVE_RESTORE (1U << 3)
#define MASK_STRICT_ALIGN (1U << 4)
#define MASK_64BIT (1U << 5)
#define MASK_ATOMIC (1U << 6)
#define MASK_BITMANIP (1U << 7)
#define MASK_DOUBLE_FLOAT (1U << 8)
#define MASK_HARD_FLOAT (1U << 9)
#define MASK_MUL (1U << 10)
#define MASK_RVC (1U << 11)
#define MASK_RVE (1U << 12)
...

But, I don't want the user to be able to pass "-mbmi-zbb" or
"-mno-bmi-zbb" on the command line: I only want the generation of the
`x_riscv_bitmanip_flags` variable, and the associated bitmasks so that
I can use them elsewhere in the backend code. So, I remove the name
and description from the entry, like so:

...
Target Mask(BITMANIP_ZBB) Var(riscv_bitmanip_flags)
...

But now, in the build/gcc/options.h file, the bitmask becomes relative
to the generic `x_target_flags` variable:

#define OPTION_MASK_BITMANIP_ZBC (HOST_WIDE_INT_1U << 0)
#define OPTION_MASK_BITMANIP_ZBE (HOST_WIDE_INT_1U << 1)
#define OPTION_MASK_BITMANIP_ZBF (HOST_WIDE_INT_1U << 2)
#define OPTION_MASK_BITMANIP_ZBM (HOST_WIDE_INT_1U << 3)
#define OPTION_MASK_BITMANIP_ZBP (HOST_WIDE_INT_1U << 4)
#define OPTION_MASK_BITMANIP_ZBR (HOST_WIDE_INT_1U << 5)
#define OPTION_MASK_BITMANIP_ZBS (HOST_WIDE_INT_1U << 6)
#define OPTION_MASK_BITMANIP_ZBT (HOST_WIDE_INT_1U << 7)
#define MASK_DIV (1U << 0)
#define MASK_EXPLICIT_RELOCS (1U << 1)
#define MASK_FDIV (1U << 2)
#define MASK_SAVE_RESTORE (1U << 3)
#define MASK_STRICT_ALIGN (1U << 4)
#define MASK_64BIT (1U << 5)
#define MASK_ATOMIC (1U << 6)
#define MASK_BITMANIP (1U << 7)
#define MASK_DOUBLE_FLOAT (1U << 8)
#define MASK_HARD_FLOAT (1U << 9)
#define MASK_MUL (1U << 10)
#define MASK_RVC (1U << 11)
#define MASK_RVE (1U << 12)
#define MASK_BITMANIP_ZBB (1U << 13) // <<<<

Could someone suggest as to a way to get around this problem in the .opt file?

Best Regards,
Maxim

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: gcc/config/arch/arch.opt: Option mask gen problem
  2019-07-22 11:05 gcc/config/arch/arch.opt: Option mask gen problem Maxim Blinov
@ 2019-07-22 18:54 ` Jim Wilson
  0 siblings, 0 replies; 2+ messages in thread
From: Jim Wilson @ 2019-07-22 18:54 UTC (permalink / raw)
  To: Maxim Blinov; +Cc: GCC Development

On Mon, Jul 22, 2019 at 4:05 AM Maxim Blinov <maxim.blinov@embecosm.com> wrote:
> Is it possible, in the arch.opt file, to have GCC generate a bitmask
> relative to a user-defined variable without an associated name? To
> illustrate my problem, consider the following option file snippet:
> ...
> But, I don't want the user to be able to pass "-mbmi-zbb" or
> "-mno-bmi-zbb" on the command line:

If you don't want an option, why are you making changes to the
riscv.opt file?  This is specifically for supporting command line
options.

Adding a variable here does mean that it will automatically be saved
and restored, and I can see the advantage of doing that, even if it is
only indirectly tied to options.  You could add a variable here, and
then manually define the bitmasks yourself in riscv-opt.h or riscv.h.
Or you could just add the variable to the machine_function struct in
riscv.c, which will also automatically save and restore the variable.

Jim

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-22 18:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-22 11:05 gcc/config/arch/arch.opt: Option mask gen problem Maxim Blinov
2019-07-22 18:54 ` Jim Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).