AArch64 adds hooks for shared jump tables
AArch64 gains new hooks to control shared jump table usage based on target options and assembly requirements.
This commit introduces two new target hooks for AArch64: TARGET_CAN_SHARE_JUMP_TABLE_P and TARGET_ASM_JUMP_TABLE_BASE. The former allows ports to refuse sharing for specific dispatches under current target options, defaulting to true. The latter allows specifying a base label for shared jump tables, which is needed when entries are relative to that base. These hooks are essential for correctly handling shared jump tables, especially on architectures like AArch64 where address calculation methods can vary and require careful management of base labels and offsets to avoid assembler symbol redefinition or incorrect address computations.
In Details
This patch introduces TARGET_CAN_SHARE_JUMP_TABLE_P and TARGET_ASM_JUMP_TABLE_BASE hooks for targets that need fine-grained control over shared jump table usage. TARGET_CAN_SHARE_JUMP_TABLE_P is a boolean hook queried before table duplication, allowing targets to refuse sharing based on function options (e.g., code model). TARGET_ASM_JUMP_TABLE_BASE is an asm_out hook called once per shared table to emit a base label, which is necessary for targets like AArch64 where entries are relative to a synthetic label defined at the table's location. The AArch64 implementation uses ADRP and A…
- jump table
- A data structure used to implement efficient multi-way branching. It typically contains addresses of target code blocks, allowing a program to jump to a specific block based on an index.
- AArch64
- The 64-bit ARM architecture, known for its high performance and power efficiency.
- hook
- A mechanism in GCC that allows target-specific code to be called at certain points during compilation, enabling customization for different architectures.
- PIC
- Position-Independent Code. Code that can be loaded and executed at any memory address without modification. Crucial for shared libraries.
- ADRP
- A 64-bit ARM instruction that adds a 20-bit immediate to the PC, setting the upper 32 bits of the destination register. Used for PC-relative addressing.