gcc/config/arch/arch.opt: Option mask gen problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

gcc/config/arch/arch.opt: Option mask gen problem

Maxim Blinov-2
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
Reply | Threaded
Open this post in threaded view
|

Re: gcc/config/arch/arch.opt: Option mask gen problem

Jim Wilson-2
On Mon, Jul 22, 2019 at 4:05 AM Maxim Blinov <[hidden email]> 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