genopinit: Allow more than 256 modes.

Upcoming changes for RISC-V will have us exceed 255 modes or 8 bits.
This patch increases the limit to 10 bits and adjusts the hashing
function for the gen* and optabs-query lookups accordingly.
Consequently, the number of optabs is limited to 4095.

gcc/ChangeLog:

	* genopinit.cc (main): Adjust maximal number of optabs and
	machine modes.
	* gensupport.cc (find_optab): Shift optab by 20 and mode by
	10 bits.
	* optabs-query.h (optab_handler): Ditto.
	(convert_optab_handler): Ditto.
This commit is contained in:
Robin Dapp 2023-07-10 22:00:08 +02:00
parent 450b05ce54
commit a454325bea
3 changed files with 5 additions and 6 deletions

View file

@ -182,8 +182,7 @@ main (int argc, const char **argv)
progname = "genopinit";
if (NUM_OPTABS > 0xffff
|| MAX_MACHINE_MODE >= ((1 << MACHINE_MODE_BITSIZE) - 1))
if (NUM_OPTABS > 0xfff || NUM_MACHINE_MODES > 0x3ff)
fatal ("genopinit range assumptions invalid");
if (!init_rtx_reader_args_cb (argc, argv, handle_arg))
@ -439,7 +438,7 @@ main (int argc, const char **argv)
"bool\n"
"swap_optab_enable (optab op, machine_mode m, bool set)\n"
"{\n"
" unsigned scode = (op << 16) | m;\n"
" unsigned scode = (op << 20) | m;\n"
" int i = lookup_handler (scode);\n"
" if (i >= 0)\n"
" {\n"

View file

@ -3806,7 +3806,7 @@ find_optab (optab_pattern *p, const char *name)
{
p->name = name;
p->op = optabs[pindex].op;
p->sort_num = (p->op << 16) | (p->m2 << 8) | p->m1;
p->sort_num = (p->op << 20) | (p->m2 << 10) | p->m1;
return true;
}
}

View file

@ -37,7 +37,7 @@ convert_optab_p (optab op)
inline enum insn_code
optab_handler (optab op, machine_mode mode)
{
unsigned scode = (op << 16) | mode;
unsigned scode = (op << 20) | mode;
gcc_assert (op > LAST_CONV_OPTAB);
return raw_optab_handler (scode);
}
@ -50,7 +50,7 @@ inline enum insn_code
convert_optab_handler (convert_optab op, machine_mode to_mode,
machine_mode from_mode)
{
unsigned scode = (op << 16) | (from_mode << 8) | to_mode;
unsigned scode = (op << 20) | (from_mode << 10) | to_mode;
gcc_assert (convert_optab_p (op));
return raw_optab_handler (scode);
}