genopinit: Optimize optab pattern initialization by grouping conditions
genopinit: Reduces compilation time and code size by grouping optab patterns by availability.
The genopinit tool now groups optab patterns by their availability conditions, significantly reducing compilation time and code size for targets like aarch64 and riscv64. Instead of evaluating each HAVE_* macro individually, it now numbers distinct tests, maps patterns to these tests, and evaluates each test only once. This change dramatically cuts down on assignments and code bloat in init_all_optabs.
In Details
genopinit: Rewrites init_all_optabs to group optab patterns based on shared HAVE_<name> conditions. The previous approach involved numerous assignments, leading to pathological compilation times and large code bloat. The new strategy precomputes distinct conditions into a cond array and uses a pat_cond lookup table to enable patterns, reducing the number of distinct conditions evaluated per target and shrinking insn-opinit.cc significantly.
- optab
- Short for 'operation table', a data structure used by GCC to represent machine-dependent operations and their corresponding instruction patterns.
- genopinit
- A GCC internal utility that initializes the target-specific operation tables (optabs) based on machine descriptions.
- HAVE_<name>
- A macro used in GCC's machine description files to indicate the availability of a specific feature or instruction. Its evaluation determines if an optab pattern can be enabled.
- availability condition
- A condition, typically defined by a
HAVE_*macro, that determines whether a particular operation or instruction is supported by the target architecture.