This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: more predicates
"Giovanni Bajo" <giovannibajo@libero.it> writes:
[...]
> It would be nice to introduce a couple of macros
> GLOBAL_REG_P()/SET_GLOBAL_REG() to handle this (and maybe find a way
> to prevent people from using global_regs directly... renaming
> it?). The SET macro would abort if used with a wrong register
> number.
Also fixed_regs, initial_fixed_regs, call_used_regs, etc ... see
hard-reg-set.h and regclass.c for the complete list. Note also that
some of them are duplicated by HARD_REG_SETs. It would be nifty to
get rid of the arrays and use HARD_REG_SETs exclusively.
Here's a way to prevent people from using global_regs directly:
extern char global_regs[FIRST_PSEUDO_REGISTER];
#define GLOBAL_REG_P(n) \
((n) < FIRST_PSEUDO_REGISTER && global_regs[n])
#define SET_GLOBAL_REG(n, val) do { \
if ((n) >= FIRST_PSEUDO_REGISTER) abort (); \
global_regs[n] = (val);
} while (0)
#pragma GCC poison global_regs
The poison directive won't affect the use of the macros. However, it
will interfere with *defining* global_regs; you could work around this
by having hard-reg-set.h do something like
#ifdef IN_REGCLASS_C
#define HRS_EXTERN /* nothing */
#else
#define HRS_EXTERN extern
#endif
...
HRS_EXTERN char global_regs[FIRST_PSEUDO_REGISTER];
and then you would put #define IN_REGCLASS_C at the top of regclass.c.
If you do that, make sure to #undef HRS_EXTERN at the end of
hard-reg-set.h.
zw