Support multi-character output operand modifiers for extended asm
Extends GCC's assembly output modifiers to support multi-character names, enabling more expressive and less cryptic inline assembly.
GCC’s inline assembly syntax for output operand modifiers, traditionally limited to single characters (e.g., %w0), has been expanded to support multi-character names. This enhancement uses a bracketed notation, such as %[name:0], allowing targets to define more descriptive modifiers. This change avoids the need for cryptic single-character modifiers or falling back to C output blocks for target-specific printing, making inline assembly more readable and maintainable.
In Details
This commit introduces a new form of output operand modifier in GCC's extended assembler syntax, allowing for multi-character names like %%[modifier:operand_number]. This extends the existing single-character modifiers (e.g., %%w0) and the symbolic operand notation (%%[value]). The compiler parses these new bracketed names and queries a new TARGET_PRINT_OPERAND_MODIFIER hook to obtain the integer code for the PRINT_OPERAND macro. Target implementers can define their own modifier names and associated codes, which must be outside the single-character range. This provides a richer name…
- extended asm
- A more powerful form of inline assembly in C/C++ that allows specifying input and output operands, constraints, and Clobber lists, enabling better integration with the compiler's optimization passes.
- output operand modifier
- A character or sequence following an operand specifier in inline assembly that controls how the operand is formatted or interpreted when generating assembly code. For example, 'w' might signify a word-sized operand.
- TARGET_PRINT_OPERAND_MODIFIER
- A target-specific hook in GCC that allows ports to define custom multi-character modifiers for printing assembly operands.
- PRINT_OPERAND
- A GCC macro used by target-specific code to format and print operands in the generated assembly output.