GIMPLE instructions are tuples of variable size divided in two groups: a header describing the instruction and its locations, and a variable length body with all the operands. Tuples are organized into a hierarchy with 3 main classes of tuples.
This is the root of the hierarchy, it holds basic information needed by most GIMPLE statements. There are some fields that may not be relevant to every GIMPLE statement, but those were moved into the base structure to take advantage of holes left by other fields (thus making the structure more compact). The structure takes 4 words (32 bytes) on 64 bit hosts:
|Total size||32 bytes|
codeMain identifier for a GIMPLE instruction.
subcodeUsed to distinguish different variants of the same basic instruction or provide flags applicable to a given code. The
subcodeflags field has different uses depending on the code of the instruction, but mostly it distinguishes instructions of the same family. The most prominent use of this field is in assignments, where subcode indicates the operation done on the RHS of the assignment. For example, a = b + c is encoded as
GIMPLE_ASSIGN <PLUS_EXPR, a, b, c>.
no_warningBitflag to indicate whether a warning has already been issued on this statement.
visitedGeneral purpose “visited” marker. Set and cleared by each pass when needed.
nontemporal_moveBitflag used in assignments that represent non-temporal moves. Although this bitflag is only used in assignments, it was moved into the base to take advantage of the bit holes left by the previous fields.
plfPass Local Flags. This 2-bit mask can be used as general purpose markers by any pass. Passes are responsible for clearing and setting these two flags accordingly.
modifiedBitflag to indicate whether the statement has been modified. Used mainly by the operand scanner to determine when to re-scan a statement for operands.
has_volatile_opsBitflag to indicate whether this statement contains operands that have been marked volatile.
references_memory_pBitflag to indicate whether this statement contains memory references (i.e., its operands are either global variables, or pointer dereferences or anything that must reside in memory).
uidThis is an unsigned integer used by passes that want to assign IDs to every statement. These IDs must be assigned and used by each pass.
locationThis is a
location_tidentifier to specify source code location for this statement. It is inherited from the front end.
num_opsNumber of operands that this statement has. This specifies the size of the operand vector embedded in the tuple. Only used in some tuples, but it is declared in the base tuple to take advantage of the 32-bit hole left by the previous fields.
bbBasic block holding the instruction.
blockLexical block holding this statement. Also used for debug information generation.
This tuple is actually split in two:
gimple_statement_with_ops. This is needed to accommodate the
way the operand vector is allocated. The operand vector is
defined to be an array of 1 element. So, to allocate a dynamic
number of operands, the memory allocator (
allocates enough memory to hold the structure itself plus
- 1 operands which run “off the end” of the structure. For
example, to allocate space for a tuple with 3 operands,
gimple_statement_with_ops) + 2 * sizeof (tree) bytes.
On the other hand, several fields in this tuple need to be shared
gimple_statement_with_memory_ops tuple. So, these
common fields are placed in
is then inherited from the other two tuples.
|Total size||48 + 8 * |
def_opsArray of pointers into the operand array indicating all the slots that contain a variable written-to by the statement. This array is also used for immediate use chaining. Note that it would be possible to not rely on this array, but the changes required to implement this are pretty invasive.
def_opsbut for variables read by the statement.
opArray of trees with
This tuple is essentially identical to
except that it contains 4 additional fields to hold vectors
related memory stores and loads. Similar to the previous case,
the structure is split in two to accommodate for the operand
|Total size||80 + 8 * |
VDEFoperators. There is one entry per memory symbol written by this statement. This is used to maintain the memory SSA use-def and def-def chains.
VUSEoperators. There is one entry per memory symbol loaded by this statement. This is used to maintain the memory SSA use-def chains.
storesBitset with all the UIDs for the symbols written-to by the statement. This is different than
vdef_opsin that all the affected symbols are mentioned in this set. If memory partitioning is enabled, the
vdef_opsvector will refer to memory partitions. Furthermore, no SSA information is stored in this set.
stores, but for memory loads. (Note that there is some amount of redundancy here, it should be possible to reduce memory utilization further by removing these sets).
All the other tuples are defined in terms of these three basic ones. Each tuple will add some fields.
The following diagram shows the C++ inheritance hierarchy of statement
kinds, along with their relationships to
GSS_ values (layouts) and
GIMPLE_ values (codes):
+- gimple_statement_base | layout: GSS_BASE | used for 4 codes: GIMPLE_ERROR_MARK | GIMPLE_NOP | GIMPLE_OMP_SECTIONS_SWITCH | GIMPLE_PREDICT | + gimple_statement_with_ops_base | | (no GSS layout) | | | + gimple_statement_with_ops | | layout: GSS_WITH_OPS | | Used for 5 codes: GIMPLE_COND | | GIMPLE_DEBUG | | GIMPLE_GOTO | | GIMPLE_LABEL | | GIMPLE_SWITCH | | | + gimple_statement_with_memory_ops_base | | layout: GSS_WITH_MEM_OPS_BASE | | | + gimple_statement_with_memory_ops | | layout: GSS_WITH_MEM_OPS. | | used for codes GIMPLE_ASSIGN and GIMPLE_RETURN. | | | + gimple_statement_call | | layout: GSS_CALL, code: GIMPLE_CALL | | | + gimple_statement_asm | | layout: GSS_ASM, code: GIMPLE_ASM | | | + gimple_statement_transaction | layout: GSS_TRANSACTION, code: GIMPLE_TRANSACTION | + gimple_statement_omp | | layout: GSS_OMP. Used for code GIMPLE_OMP_SECTION | | | + gimple_statement_omp_critical | | layout: GSS_OMP_CRITICAL, code: GIMPLE_OMP_CRITICAL | | | + gimple_statement_omp_for | | layout: GSS_OMP_FOR, code: GIMPLE_OMP_FOR | | | + gimple_statement_omp_parallel_layout | | | layout: GSS_OMP_PARALLEL_LAYOUT | | | | | + gimple_statement_omp_taskreg | | | | | | | + gimple_statement_omp_parallel | | | | code: GIMPLE_OMP_PARALLEL | | | | | | | + gimple_statement_omp_task | | | code: GIMPLE_OMP_TASK | | | | | + gimple_statement_omp_target | | code: GIMPLE_OMP_TARGET | | | + gimple_statement_omp_sections | | layout: GSS_OMP_SECTIONS, code: GIMPLE_OMP_SECTIONS | | | + gimple_statement_omp_single_layout | | layout: GSS_OMP_SINGLE_LAYOUT | | | + gimple_statement_omp_single | | code: GIMPLE_OMP_SINGLE | | | + gimple_statement_omp_teams | code: GIMPLE_OMP_TEAMS | + gimple_statement_bind | layout: GSS_BIND, code: GIMPLE_BIND | + gimple_statement_catch | layout: GSS_CATCH, code: GIMPLE_CATCH | + gimple_statement_eh_filter | layout: GSS_EH_FILTER, code: GIMPLE_EH_FILTER | + gimple_statement_eh_else | layout: GSS_EH_ELSE, code: GIMPLE_EH_ELSE | + gimple_statement_eh_mnt | layout: GSS_EH_MNT, code: GIMPLE_EH_MUST_NOT_THROW | + gimple_statement_phi | layout: GSS_PHI, code: GIMPLE_PHI | + gimple_statement_eh_ctrl | | layout: GSS_EH_CTRL | | | + gimple_statement_resx | | code: GIMPLE_RESX | | | + gimple_statement_eh_dispatch | code: GIMPLE_EH_DISPATCH | + gimple_statement_try | layout: GSS_TRY, code: GIMPLE_TRY | + gimple_statement_wce | layout: GSS_WCE, code: GIMPLE_WITH_CLEANUP_EXPR | + gimple_statement_omp_continue | layout: GSS_OMP_CONTINUE, code: GIMPLE_OMP_CONTINUE | + gimple_statement_omp_atomic_load | layout: GSS_OMP_ATOMIC_LOAD, code: GIMPLE_OMP_ATOMIC_LOAD | + gimple_statement_omp_atomic_store_layout | layout: GSS_OMP_ATOMIC_STORE_LAYOUT, | code: GIMPLE_OMP_ATOMIC_STORE | + gimple_statement_omp_atomic_store | code: GIMPLE_OMP_ATOMIC_STORE | + gimple_statement_omp_return code: GIMPLE_OMP_RETURN