genattrtab: Table-drives attributes defined by other attributes
Improves genattrtab by generating more efficient code for attributes derived from others.
This commit enhances genattrtab to generate more efficient code for machine attributes that are directly defined as functions of other attributes. Previously, such definitions were expanded and evaluated repeatedly for each instruction. The new approach directly represents these functional relationships, similar to how run-time evaluated attributes are handled, leading to more optimized generated code and reducing redundancy in attribute lookup tables.
In Details
This change modifies genattrtab to recognize and table-drive attributes that are direct functions of other attributes, avoiding the redundant expansion and per-insn code generation previously performed by optimize_attrs. It leverages the structure used for case -1: arms (runtime evaluation) to directly implement the functional mapping. This is demonstrated with mul32 being a function of type in arm/types.md, resulting in generated code that evaluates the source attribute once per recog_memoized lookup rather than per insn code, improving generated code efficiency.
- genattrtab
- A GCC machine description generator responsible for producing C code that handles machine-specific attributes of instructions.
- attribute
- A property of a machine instruction, such as its cost, latency, or type, which is used by the compiler for optimization and code generation.
- machine description (MD)
- A set of files that describe the instruction set architecture (ISA) of a target processor to GCC, including instruction formats, operands, and attributes.
- optimize_attrs
- A function or pass within GCC's machine description processing that attempts to optimize the generation and lookup of instruction attributes.
- recog_memoized
- A function or mechanism in GCC that memoizes (caches) the results of instruction recognition, speeding up repeated checks for the same instruction pattern.