Next: , Up: GIMPLE

12.1 Tuple representation

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.

12.1.1 gimple_statement_base (gsbase)

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:

Field Size (bits)
code 8
subcode 16
no_warning 1
visited 1
nontemporal_move 1
plf 2
modified 1
has_volatile_ops 1
references_memory_p 1
uid 32
location 32
num_ops 32
bb 64
block 63
Total size 32 bytes

12.1.2 gimple_statement_with_ops

This tuple is actually split in two: gimple_statement_with_ops_base and 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 (gimple_alloc) simply allocates enough memory to hold the structure itself plus N - 1 operands which run “off the end” of the structure. For example, to allocate space for a tuple with 3 operands, gimple_alloc reserves sizeof (struct gimple_statement_with_ops) + 2 * sizeof (tree) bytes.

On the other hand, several fields in this tuple need to be shared with the gimple_statement_with_memory_ops tuple. So, these common fields are placed in gimple_statement_with_ops_base which is then inherited from the other two tuples.

gsbase 256
addresses_taken 64
def_ops 64
use_ops 64
op num_ops * 64
Total size 56 + 8 * num_ops bytes

12.1.3 gimple_statement_with_memory_ops

This tuple is essentially identical to gimple_statement_with_ops, 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 vector (gimple_statement_with_memory_ops_base and gimple_statement_with_memory_ops).

Field Size (bits)
gsbase 256
addresses_taken 64
def_ops 64
use_ops 64
vdef_ops 64
vuse_ops 64
stores 64
loads 64
op num_ops * 64
Total size 88 + 8 * num_ops bytes

All the other tuples are defined in terms of these three basic ones. Each tuple will add some fields. The main gimple type is defined to be the union of all these structures (GTY markers elided for clarity):

     union gimple_statement_d
       struct gimple_statement_base gsbase;
       struct gimple_statement_with_ops gsops;
       struct gimple_statement_with_memory_ops gsmem;
       struct gimple_statement_omp omp;
       struct gimple_statement_bind gimple_bind;
       struct gimple_statement_catch gimple_catch;
       struct gimple_statement_eh_filter gimple_eh_filter;
       struct gimple_statement_phi gimple_phi;
       struct gimple_statement_resx gimple_resx;
       struct gimple_statement_try gimple_try;
       struct gimple_statement_wce gimple_wce;
       struct gimple_statement_asm gimple_asm;
       struct gimple_statement_omp_critical gimple_omp_critical;
       struct gimple_statement_omp_for gimple_omp_for;
       struct gimple_statement_omp_parallel gimple_omp_parallel;
       struct gimple_statement_omp_task gimple_omp_task;
       struct gimple_statement_omp_sections gimple_omp_sections;
       struct gimple_statement_omp_single gimple_omp_single;
       struct gimple_statement_omp_continue gimple_omp_continue;
       struct gimple_statement_omp_atomic_load gimple_omp_atomic_load;
       struct gimple_statement_omp_atomic_store gimple_omp_atomic_store;