[v2] genopinit: Allow more than 256 modes.
Checks
Commit Message
Attached is v2 that does not switch to uint64_t but stays within
32 bits by shifting the optab by 20 and the mode(s) by 10 bits.
Regards
Robin
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.
---
gcc/genopinit.cc | 5 ++---
gcc/gensupport.cc | 2 +-
gcc/optabs-query.h | 4 ++--
3 files changed, 5 insertions(+), 6 deletions(-)
Comments
On Tue, 11 Jul 2023, Robin Dapp wrote:
> Attached is v2 that does not switch to uint64_t but stays within
> 32 bits by shifting the optab by 20 and the mode(s) by 10 bits.
LGTM.
> Regards
> Robin
>
> 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.
> ---
> gcc/genopinit.cc | 5 ++---
> gcc/gensupport.cc | 2 +-
> gcc/optabs-query.h | 4 ++--
> 3 files changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/gcc/genopinit.cc b/gcc/genopinit.cc
> index 6bd8858a1d9..2a841006884 100644
> --- a/gcc/genopinit.cc
> +++ b/gcc/genopinit.cc
> @@ -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"
> diff --git a/gcc/gensupport.cc b/gcc/gensupport.cc
> index e39e6dacce2..959d1d9c83c 100644
> --- a/gcc/gensupport.cc
> +++ b/gcc/gensupport.cc
> @@ -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;
> }
> }
> diff --git a/gcc/optabs-query.h b/gcc/optabs-query.h
> index 043e9791bc1..920eb6a1b67 100644
> --- a/gcc/optabs-query.h
> +++ b/gcc/optabs-query.h
> @@ -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);
> }
>
@@ -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"
@@ -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;
}
}
@@ -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);
}