binutils Newspaper
JULY 29, 2026
x86 Proposed

x86: copy template's .operand_types[] into global insn data

Copies operand types from instruction templates to global data to prepare for further refactoring.

Jan Beulich’s first patch in a series introduces a change to how operand types are handled in the x86 assembler (gas). It copies the operand_types array from the insn_template into a global _i386_insn structure (tm_types). This is a preparatory step to enable future modifications that will remove operand_types from being directly embedded in templates, aiming to reduce churn and improve code organization.

In Details

This patch is the initial step in a series refactoring operand type handling within the x86 assembler (gas). It modifies the _i386_insn structure definition in gas/config/tc-i386.c to include tm_types, an array for operand types. The install_template function is updated to copy t->operand_types into i.tm_types. This change is a prerequisite for subsequent patches that will eventually move operand type definitions out of insn_template structs, reducing memory footprint and improving cache efficiency by enabling deduplication.

For Context
operand_types[]
An array specifying the type of each operand for an instruction.
insn_template
A structure defining the properties and operands of an assembly instruction.
_i386_insn
A structure holding the current state and data related to an instruction being assembled for the x86 architecture within gas.
tm_types
A member within the _i386_insn structure that stores the operand types associated with the current instruction template.
churn
In software development, 'churn' refers to the amount of code that is changed or modified, often indicating instability or frequent refactoring.
Filed Under: x86gasrefactoringcode-organization