Skip to content

BP-GIMPLE, the GIMPLE statement representation

Status: partial Applies to: GCC 16.2.0 (tag releases/gcc-16.2.0) Target-dependent: no Generated sections: 2 Last verified: 2026-09-01 against releases/gcc-16.2.0

Section 2 is generated from gcc/gimple.def, gcc/gsstruct.def and gcc/gimple.h by bpc build. Nothing in it is typed by hand, and bpc check fails the build if what is in this file is not what the generator produces from the pinned tree today. Sections 3 to 9 are written by hand and land with the GIMPLE lessons in M4.

1. Purpose and scope

GIMPLE is the representation the middle end optimises. Every front end lowers to it, every target expands out of it, and between those two points every analysis and every transformation in GCC that is not target specific is written against it.

It is a three address representation over a fixed set of statement codes. A statement computes at most one value from at most a few operands, control flow is explicit as conditional and unconditional jumps rather than nested expressions, and the operands are tree nodes, which is the same node type GENERIC uses. That last point catches people out: GIMPLE did not replace tree, it constrained what may appear where. A GIMPLE operand is a tree, but it is a tree restricted to the shapes is_gimple_val accepts, and the restriction is what makes the middle end tractable.

What this document covers. The statement codes, the structures that hold them, the layout of those structures, the C++ classes a statement can be narrowed to, and the invariants a statement has to satisfy to be well formed.

What it does not cover. How GENERIC becomes GIMPLE, which is BP-GIMPLIFY. The basic block and edge structure the statements are hung on, which is BP-CFG. SSA names, which are a property of the operands rather than of the statements, and are BP-SSA and BP-VOPS. The passes, each of which has its own blueprint. GIMPLE is the noun, and almost everything else in the middle end is a verb.

Position in the pipeline. GIMPLE exists from the end of gimplification to the start of expansion. In pass property terms a function is in GIMPLE form when it has PROP_gimple, which is not one flag but four combined, at gcc/tree-pass.h:235@releases/gcc-16.2.0: the full grammar, lowered control flow, lowered exception handling, and lowered OpenMP. A pass that declares it requires PROP_gimple is asking for all four, and the reason they are separate bits is that they are established by different passes at different points, so there is a window in the pipeline where a function is in GIMPLE by one measure and not by another.

Inputs and outputs as properties. GIMPLE itself provides nothing and destroys nothing, because it is data rather than a pass. The properties belong to the passes that build and consume it, and the table of which pass provides which is in BP-PASSMGR.

2. Data structures

2.1 The statement codes

Generated by bpc build from the pinned GCC tree. Do not edit inside the markers, edit the generator.

GIMPLE has 47 statement codes in GCC 16.2.0, laid out in 27 of the 28 structures that gsstruct.def declares. 10 of the codes carry operands. The rest are markers, and a marker with no operands is still a statement that a pass has to handle.

The number in the first column is the value of the enumerator, which is also its position in gimple.def. It is not stable across releases and no code should depend on a particular value, but the order is depended on heavily, which section 2.2 covers.

# Code Printable name Layout C++ class Operands
0 GIMPLE_ERROR_MARK gimple_error_mark GSS_BASE none none
1 GIMPLE_COND gimple_cond GSS_WITH_OPS gcond registers
2 GIMPLE_DEBUG gimple_debug GSS_WITH_OPS gdebug registers
3 GIMPLE_GOTO gimple_goto GSS_WITH_OPS ggoto registers
4 GIMPLE_LABEL gimple_label GSS_WITH_OPS glabel registers
5 GIMPLE_SWITCH gimple_switch GSS_WITH_OPS gswitch registers
6 GIMPLE_ASSIGN gimple_assign GSS_WITH_MEM_OPS gassign registers and memory
7 GIMPLE_ASM gimple_asm GSS_ASM gasm registers and memory
8 GIMPLE_CALL gimple_call GSS_CALL gcall registers and memory
9 GIMPLE_TRANSACTION gimple_transaction GSS_TRANSACTION gtransaction registers and memory
10 GIMPLE_RETURN gimple_return GSS_WITH_MEM_OPS greturn registers and memory
11 GIMPLE_BIND gimple_bind GSS_BIND gbind none
12 GIMPLE_CATCH gimple_catch GSS_CATCH gcatch none
13 GIMPLE_EH_FILTER gimple_eh_filter GSS_EH_FILTER geh_filter none
14 GIMPLE_EH_MUST_NOT_THROW gimple_eh_must_not_throw GSS_EH_MNT geh_mnt none
15 GIMPLE_EH_ELSE gimple_eh_else GSS_EH_ELSE geh_else none
16 GIMPLE_RESX gimple_resx GSS_EH_CTRL gresx none
17 GIMPLE_EH_DISPATCH gimple_eh_dispatch GSS_EH_CTRL geh_dispatch none
18 GIMPLE_PHI gimple_phi GSS_PHI gphi none
19 GIMPLE_TRY gimple_try GSS_TRY gtry none
20 GIMPLE_NOP gimple_nop GSS_BASE none none
21 GIMPLE_OMP_ATOMIC_LOAD gimple_omp_atomic_load GSS_OMP_ATOMIC_LOAD gomp_atomic_load none
22 GIMPLE_OMP_ATOMIC_STORE gimple_omp_atomic_store GSS_OMP_ATOMIC_STORE_LAYOUT gomp_atomic_store none
23 GIMPLE_OMP_CONTINUE gimple_omp_continue GSS_OMP_CONTINUE gomp_continue none
24 GIMPLE_OMP_CRITICAL gimple_omp_critical GSS_OMP_CRITICAL gomp_critical none
25 GIMPLE_OMP_FOR gimple_omp_for GSS_OMP_FOR gomp_for none
26 GIMPLE_OMP_STRUCTURED_BLOCK gimple_omp_structured_block GSS_OMP none none
27 GIMPLE_OMP_MASTER gimple_omp_master GSS_OMP none none
28 GIMPLE_OMP_MASKED gimple_omp_masked GSS_OMP_SINGLE_LAYOUT none none
29 GIMPLE_OMP_TASKGROUP gimple_omp_taskgroup GSS_OMP_SINGLE_LAYOUT none none
30 GIMPLE_OMP_PARALLEL gimple_omp_parallel GSS_OMP_PARALLEL_LAYOUT gomp_parallel none
31 GIMPLE_OMP_TASK gimple_omp_task GSS_OMP_TASK gomp_task none
32 GIMPLE_OMP_RETURN gimple_omp_return GSS_OMP_ATOMIC_STORE_LAYOUT gimple_statement_omp_return none
33 GIMPLE_OMP_SCAN gimple_omp_scan GSS_OMP_SINGLE_LAYOUT gomp_scan none
34 GIMPLE_OMP_SCOPE gimple_omp_scope GSS_OMP_SINGLE_LAYOUT none none
35 GIMPLE_OMP_DISPATCH gimple_omp_dispatch GSS_OMP_SINGLE_LAYOUT none none
36 GIMPLE_OMP_INTEROP gimple_omp_interop GSS_OMP_SINGLE_LAYOUT none none
37 GIMPLE_OMP_SECTION gimple_omp_section GSS_OMP none none
38 GIMPLE_OMP_SECTIONS gimple_omp_sections GSS_OMP_SECTIONS gomp_sections none
39 GIMPLE_OMP_SECTIONS_SWITCH gimple_omp_sections_switch GSS_BASE none none
40 GIMPLE_OMP_SINGLE gimple_omp_single GSS_OMP_SINGLE_LAYOUT gomp_single none
41 GIMPLE_OMP_TARGET gimple_omp_target GSS_OMP_TARGET gomp_target none
42 GIMPLE_OMP_TEAMS gimple_omp_teams GSS_OMP_PARALLEL_LAYOUT gomp_teams none
43 GIMPLE_OMP_ORDERED gimple_omp_ordered GSS_OMP_SINGLE_LAYOUT gomp_ordered none
44 GIMPLE_PREDICT gimple_predict GSS_BASE none none
45 GIMPLE_WITH_CLEANUP_EXPR gimple_with_cleanup_expr GSS_WCE gimple_statement_wce none
46 GIMPLE_ASSUME gimple_assume GSS_ASSUME gimple_statement_assume none

Read from gcc/gimple.def, gcc/gsstruct.def and gcc/gimple.h.

2.2 Why the order of gimple.def is part of the interface

Generated by bpc build from the pinned GCC tree. Do not edit inside the markers, edit the generator.

Two predicates that every pass in the middle end calls are range checks over the code enum rather than flags on a statement. That makes the order of gimple.def part of the interface, and the file says so in comments that sit above the codes they protect.

Predicate Range Codes Which ones
gimple_has_ops GIMPLE_COND to GIMPLE_RETURN 10 GIMPLE_COND, GIMPLE_DEBUG, GIMPLE_GOTO, GIMPLE_LABEL, GIMPLE_SWITCH, GIMPLE_ASSIGN, GIMPLE_ASM, GIMPLE_CALL, GIMPLE_TRANSACTION, GIMPLE_RETURN
gimple_has_mem_ops GIMPLE_ASSIGN to GIMPLE_RETURN 5 GIMPLE_ASSIGN, GIMPLE_ASM, GIMPLE_CALL, GIMPLE_TRANSACTION, GIMPLE_RETURN

gimple.def carries 3 warnings of its own about the ordering. Each one sits directly above the first code it applies to.

Above GIMPLE_COND, which is defined at gcc/gimple.def:46:

IMPORTANT.  Do not rearrange the codes between GIMPLE_COND and
GIMPLE_RETURN.  The ordering is exposed by gimple_has_ops calls.
These are all the GIMPLE statements with register operands.

Above GIMPLE_ASSIGN, which is defined at gcc/gimple.def:101:

IMPORTANT.

Do not rearrange the codes between GIMPLE_ASSIGN and GIMPLE_RETURN.
It's exposed by GIMPLE_RANGE_CHECK calls. These are all the GIMPLE
statements with memory and register operands.

Above GIMPLE_OMP_ATOMIC_LOAD, which is defined at gcc/gimple.def:221:

IMPORTANT.

Do not rearrange any of the GIMPLE_OMP_* codes.  This ordering is
exposed by the range check in gimple_omp_subcode().

The consequence for anyone adding a statement code: a code with operands goes inside the existing run, a code without operands goes outside it, and putting one in the wrong place changes the meaning of every gimple_has_ops call in the compiler without changing a line of their source.

2.3 The layout structures

Generated by bpc build from the pinned GCC tree. Do not edit inside the markers, edit the generator.

A statement's layout is not its code. Several codes share one structure, and the structure is what decides how much memory the statement takes and where its operands live. gsstruct.def is the list of layouts, and the third argument says whether the layout carries a vector of tree operands.

Layout Structure Tree operands Codes Used by
GSS_BASE gimple no 4 GIMPLE_ERROR_MARK, GIMPLE_NOP, GIMPLE_OMP_SECTIONS_SWITCH, GIMPLE_PREDICT
GSS_WITH_OPS gimple_statement_with_ops yes 5 GIMPLE_COND, GIMPLE_DEBUG, GIMPLE_GOTO, GIMPLE_LABEL, GIMPLE_SWITCH
GSS_WITH_MEM_OPS_BASE gimple_statement_with_memory_ops_base no 0 none
GSS_WITH_MEM_OPS gimple_statement_with_memory_ops yes 2 GIMPLE_ASSIGN, GIMPLE_RETURN
GSS_CALL gcall yes 1 GIMPLE_CALL
GSS_ASM gasm yes 1 GIMPLE_ASM
GSS_BIND gbind no 1 GIMPLE_BIND
GSS_PHI gphi no 1 GIMPLE_PHI
GSS_TRY gtry no 1 GIMPLE_TRY
GSS_CATCH gcatch no 1 GIMPLE_CATCH
GSS_EH_FILTER geh_filter no 1 GIMPLE_EH_FILTER
GSS_EH_MNT geh_mnt no 1 GIMPLE_EH_MUST_NOT_THROW
GSS_EH_CTRL gimple_statement_eh_ctrl no 2 GIMPLE_RESX, GIMPLE_EH_DISPATCH
GSS_EH_ELSE geh_else no 1 GIMPLE_EH_ELSE
GSS_WCE gimple_statement_wce no 1 GIMPLE_WITH_CLEANUP_EXPR
GSS_OMP gimple_statement_omp no 3 GIMPLE_OMP_STRUCTURED_BLOCK, GIMPLE_OMP_MASTER, GIMPLE_OMP_SECTION
GSS_OMP_CRITICAL gomp_critical no 1 GIMPLE_OMP_CRITICAL
GSS_OMP_FOR gomp_for no 1 GIMPLE_OMP_FOR
GSS_OMP_PARALLEL_LAYOUT gimple_statement_omp_parallel_layout no 2 GIMPLE_OMP_PARALLEL, GIMPLE_OMP_TEAMS
GSS_OMP_TARGET gomp_target no 1 GIMPLE_OMP_TARGET
GSS_OMP_TASK gomp_task no 1 GIMPLE_OMP_TASK
GSS_OMP_SECTIONS gomp_sections no 1 GIMPLE_OMP_SECTIONS
GSS_OMP_SINGLE_LAYOUT gimple_statement_omp_single_layout no 8 GIMPLE_OMP_MASKED, GIMPLE_OMP_TASKGROUP, GIMPLE_OMP_SCAN, GIMPLE_OMP_SCOPE, GIMPLE_OMP_DISPATCH, GIMPLE_OMP_INTEROP, GIMPLE_OMP_SINGLE, GIMPLE_OMP_ORDERED
GSS_OMP_CONTINUE gomp_continue no 1 GIMPLE_OMP_CONTINUE
GSS_OMP_ATOMIC_LOAD gomp_atomic_load no 1 GIMPLE_OMP_ATOMIC_LOAD
GSS_OMP_ATOMIC_STORE_LAYOUT gomp_atomic_store no 2 GIMPLE_OMP_ATOMIC_STORE, GIMPLE_OMP_RETURN
GSS_ASSUME gimple_statement_assume no 1 GIMPLE_ASSUME
GSS_TRANSACTION gtransaction no 1 GIMPLE_TRANSACTION

Layouts with no code of their own: GSS_WITH_MEM_OPS_BASE. These are bases that other layouts extend, or layouts reached only through a subclass, and they are in the enum because the garbage collector needs a tag for every distinct shape it may walk.

The structures themselves form a single inheritance chain, and the chain is the reason a statement can be passed around as a gimple * and then narrowed:

gimple  [GSS_BASE]
  gimple_statement_with_ops_base
    gimple_statement_with_ops  [GSS_WITH_OPS]
      gcond  [GSS_WITH_OPS]
      gdebug  [GSS_WITH_OPS]
      ggoto  [GSS_WITH_OPS]
      glabel  [GSS_WITH_OPS]
      gswitch  [GSS_WITH_OPS]
    gimple_statement_with_memory_ops_base  [GSS_WITH_MEM_OPS_BASE]
      gimple_statement_with_memory_ops  [GSS_WITH_MEM_OPS]
        gassign  [GSS_WITH_MEM_OPS]
        greturn  [GSS_WITH_MEM_OPS]
      gcall  [GSS_CALL]
      gasm  [GSS_ASM]
      gtransaction  [GSS_TRANSACTION]
  gimple_statement_omp  [GSS_OMP]
    gomp_critical  [GSS_OMP_CRITICAL]
    gomp_for  [GSS_OMP_FOR]
    gimple_statement_omp_parallel_layout  [GSS_OMP_PARALLEL_LAYOUT]
      gimple_statement_omp_taskreg  [GSS_OMP_PARALLEL_LAYOUT]
        gomp_parallel  [GSS_OMP_PARALLEL_LAYOUT]
        gomp_task  [GSS_OMP_TASK]
        gomp_teams  [GSS_OMP_PARALLEL_LAYOUT]
      gomp_target  [GSS_OMP_TARGET]
    gomp_sections  [GSS_OMP_SECTIONS]
    gimple_statement_omp_single_layout  [GSS_OMP_SINGLE_LAYOUT]
      gomp_single  [GSS_OMP_SINGLE_LAYOUT]
      gomp_ordered  [GSS_OMP_SINGLE_LAYOUT]
      gomp_scan  [GSS_OMP_SINGLE_LAYOUT]
  gbind  [GSS_BIND]
  gcatch  [GSS_CATCH]
  geh_filter  [GSS_EH_FILTER]
  geh_else  [GSS_EH_ELSE]
  geh_mnt  [GSS_EH_MNT]
  gphi  [GSS_PHI]
  gimple_statement_eh_ctrl  [GSS_EH_CTRL]
    gresx  [GSS_EH_CTRL]
    geh_dispatch  [GSS_EH_CTRL]
  gtry  [GSS_TRY]
  gimple_statement_wce  [GSS_WCE]
  gomp_continue  [GSS_OMP_CONTINUE]
  gomp_atomic_load  [GSS_OMP_ATOMIC_LOAD]
  gimple_statement_omp_atomic_store_layout  [GSS_OMP_ATOMIC_STORE_LAYOUT]
    gomp_atomic_store  [GSS_OMP_ATOMIC_STORE_LAYOUT]
    gimple_statement_omp_return  [GSS_OMP_ATOMIC_STORE_LAYOUT]
  gimple_statement_assume  [GSS_ASSUME]
gimple_omp_for_iter

A name in square brackets is the GTY tag the garbage collector uses to decide which structure it is looking at, and several structures share a tag because they share a layout exactly.

2.4 Every structure, field by field

Generated by bpc build from the pinned GCC tree. Do not edit inside the markers, edit the generator.

Every structure that holds a GIMPLE statement, field by field, in declaration order. 30 of them declare fields of their own. The word column is GCC's own marker for which 64 bit word of the object the field lands in, which is the only place the layout is written down, and it is a comment rather than anything the compiler enforces.

A field carrying no GTY marker is walked by the garbage collector in the ordinary way. skip means the collector does not follow it, which is a claim that the object is reachable by another route and a leak or a stale pointer if it is not.

gimple

Data structure definitions for GIMPLE tuples.  NOTE: word markers
are for 64 bit hosts.

Tag GSS_BASE, gcc/gimple.h:220.

Word Field Type GTY Meaning
WORD 1 code ENUM_BITFIELD(gimple_code) : 8 Main identifying code for a tuple.
no_warning unsigned int : 1 Nonzero if a warning should not be emitted on this tuple.
visited unsigned int : 1 Nonzero if this tuple has been visited. Passes are responsible for clearing this bit before using it.
nontemporal_move unsigned int : 1 Nonzero if this tuple represents a non-temporal move; currently only stores are supported.
plf unsigned int : 2 Pass local flags. These flags are free for any pass to use as they see fit. Passes should not assume that these flags contain any useful value when the pass starts. Any initial state that the pass requires should be set on entry to the pass. See gimple_set_plf and gimple_plf for usage.
modified unsigned : 1 Nonzero if this statement has been modified and needs to have its operands rescanned.
has_volatile_ops unsigned : 1 Nonzero if this statement contains volatile operands.
ilf unsigned : 1 Infrastructure local flag. Always clear.
subcode unsigned int : 16 The SUBCODE field can be used for tuple-specific flags for tuples that do not require subcodes. Note that SUBCODE should be at least as wide as tree codes, as several tuples store tree codes in there.
uid unsigned UID of this statement. This is used by passes that want to assign IDs to statements. It must be assigned and used by each pass. By default it should be assumed to contain garbage.
WORD 2 num_ops unsigned Number of operands in this tuple.
WORD 3 location location_t Locus information for debug info.
WORD 4 bb basic_block Basic block holding this statement.
WORD 5-6 next gimple * Linked lists of gimple statements. The next pointers form a NULL terminated list, the prev pointers are a cyclic list. A gimple statement is hence also a double-ended list of statements, with the pointer itself being the first element, and the prev pointer being the last.
prev gimple * skip no comment in the header

Layout notes written in the header alongside these fields:

Unused 32 bits padding on 64-bit hosts.

gimple_statement_with_ops_base

This gimple subclass has no tag value.

Extends gimple, inherits word 1-6, gcc/gimple.h:295.

Word Field Type GTY Meaning
WORD 7 use_ops struct use_optype_d * skip ("") SSA operand vectors. NOTE: It should be possible to amalgamate these vectors with the operand vector OP. However, the SSA operand vectors are organized differently and contain more information (like immediate use chaining).

gimple_statement_with_ops

Statements that take register operands.

Extends gimple_statement_with_ops_base, tag GSS_WITH_OPS, inherits word 1-7, gcc/gimple.h:311.

Word Field Type GTY Meaning
WORD 8 op tree[1] length ("%h.num_ops") Operand vector. NOTE! This must always be the last field of this structure. In particular, this means that this structure cannot be embedded inside another one.

gimple_statement_with_memory_ops_base

Base for statements that take both memory and register operands.

Extends gimple_statement_with_ops_base, tag GSS_WITH_MEM_OPS_BASE, inherits word 1-7, gcc/gimple.h:326.

Word Field Type GTY Meaning
WORD 8-9 vdef tree skip ("") Virtual operands for this statement. The GC will pick them up via the ssa_names array.
vuse tree skip ("") no comment in the header

gimple_statement_with_memory_ops

Statements that take both memory and register operands.

Extends gimple_statement_with_memory_ops_base, tag GSS_WITH_MEM_OPS, inherits word 1-9, gcc/gimple.h:341.

Word Field Type GTY Meaning
WORD 10 op tree[1] length ("%h.num_ops") Operand vector. NOTE! This must always be the last field of this structure. In particular, this means that this structure cannot be embedded inside another one.

gcall

Call statements that take both memory and register operands.

Extends gimple_statement_with_memory_ops_base, tag GSS_CALL, inherits word 1-9, holds only GIMPLE_CALL, gcc/gimple.h:357.

Word Field Type GTY Meaning
WORD 10-13 call_used struct pt_solution no comment in the header
call_clobbered struct pt_solution no comment in the header
WORD 14 u union desc ("%1.subcode & GF_CALL_INTERNAL") no comment in the header
u.fntype tree tag ("0") one alternative of the u union
u.internal_fn enum internal_fn tag ("GF_CALL_INTERNAL") one alternative of the u union
WORD 15 op tree[1] length ("%h.num_ops") Operand vector. NOTE! This must always be the last field of this structure. In particular, this means that this structure cannot be embedded inside another one.

gimple_statement_omp

OMP statements.

Extends gimple, tag GSS_OMP, inherits word 1-6, gcc/gimple.h:384.

Word Field Type GTY Meaning
WORD 7 body gimple_seq no comment in the header

gbind

GIMPLE_BIND

Extends gimple, tag GSS_BIND, inherits word 1-6, gcc/gimple.h:396.

Word Field Type GTY Meaning
WORD 7 vars tree Variables declared in this scope.
WORD 8 block tree This is different than the BLOCK field in gimple, which is analogous to TREE_BLOCK (i.e., the lexical block holding this statement). This field is the equivalent of BIND_EXPR_BLOCK in tree land (i.e., the lexical scope defined by this bind). See gimple-low.cc.
WORD 9 body gimple_seq no comment in the header

gcatch

GIMPLE_CATCH

Extends gimple, tag GSS_CATCH, inherits word 1-6, gcc/gimple.h:420.

Word Field Type GTY Meaning
WORD 7 types tree no comment in the header
WORD 8 handler gimple_seq no comment in the header

geh_filter

GIMPLE_EH_FILTER

Extends gimple, tag GSS_EH_FILTER, inherits word 1-6, gcc/gimple.h:435.

Word Field Type GTY Meaning
WORD 7 types tree Filter types.
WORD 8 failure gimple_seq Failure actions.

geh_else

GIMPLE_EH_ELSE

Extends gimple, tag GSS_EH_ELSE, inherits word 1-6, gcc/gimple.h:451.

Word Field Type GTY Meaning
WORD 7,8 e_body gimple_seq n_body, no comment in the header

geh_mnt

GIMPLE_EH_MUST_NOT_THROW

Extends gimple, tag GSS_EH_MNT, inherits word 1-6, gcc/gimple.h:462.

Word Field Type GTY Meaning
WORD 7 fndecl tree Abort function decl.

gphi

GIMPLE_PHI

Extends gimple, tag GSS_PHI, inherits word 1-6, gcc/gimple.h:473.

Word Field Type GTY Meaning
WORD 7 capacity unsigned no comment in the header
nargs unsigned no comment in the header
WORD 8 result tree no comment in the header
WORD 9-14 args struct phi_arg_d[1] length ("%h.nargs") no comment in the header

gimple_statement_eh_ctrl

GIMPLE_RESX, GIMPLE_EH_DISPATCH

Extends gimple, tag GSS_EH_CTRL, inherits word 1-6, gcc/gimple.h:492.

Word Field Type GTY Meaning
WORD 7 region int Exception region number.

gtry

GIMPLE_TRY

Extends gimple, tag GSS_TRY, inherits word 1-6, gcc/gimple.h:519.

Word Field Type GTY Meaning
WORD 7 eval gimple_seq Expression to evaluate.
WORD 8 cleanup gimple_seq Cleanup expression.

gimple_statement_wce

GIMPLE_WITH_CLEANUP_EXPR

Extends gimple, tag GSS_WCE, inherits word 1-6, gcc/gimple.h:549.

Word Field Type GTY Meaning
WORD 7 cleanup gimple_seq Cleanup expression.

Layout notes written in the header alongside these fields:

Subcode: CLEANUP_EH_ONLY.  True if the cleanup should only be
           executed if an exception is thrown, not on normal exit of its
           scope.  This flag is analogous to the CLEANUP_EH_ONLY flag
           in TARGET_EXPRs.

gasm

GIMPLE_ASM

Extends gimple_statement_with_memory_ops_base, tag GSS_ASM, inherits word 1-9, gcc/gimple.h:567.

Word Field Type GTY Meaning
WORD 10 string const char * asm statement.
WORD 11 ni unsigned char Number of inputs, outputs, clobbers, labels.
no unsigned char no comment in the header
nc unsigned char no comment in the header
nl unsigned char no comment in the header
WORD 12 op tree[1] length ("%h.num_ops") Operand vector. NOTE! This must always be the last field of this structure. In particular, this means that this structure cannot be embedded inside another one.

gomp_critical

GIMPLE_OMP_CRITICAL

Extends gimple_statement_omp, tag GSS_OMP_CRITICAL, inherits word 1-7, gcc/gimple.h:592.

Word Field Type GTY Meaning
WORD 8 clauses tree no comment in the header
WORD 9 name tree Critical section name.

gimple_omp_for_iter

gcc/gimple.h:606.

Word Field Type GTY Meaning
cond enum tree_code Condition code.
index tree Index variable.
initial tree Initial value.
final tree Final value.
incr tree Increment.

gomp_for

GIMPLE_OMP_FOR

Extends gimple_statement_omp, tag GSS_OMP_FOR, inherits word 1-7, gcc/gimple.h:625.

Word Field Type GTY Meaning
WORD 8 clauses tree no comment in the header
WORD 9 collapse size_t Number of elements in iter array.
WORD 10 iter struct gimple_omp_for_iter * length ("%h.collapse") no comment in the header
WORD 11 pre_body gimple_seq Pre-body evaluated before the loop body begins.

gimple_statement_omp_parallel_layout

GIMPLE_OMP_PARALLEL, GIMPLE_OMP_TARGET, GIMPLE_OMP_TASK, GIMPLE_OMP_TEAMS

Extends gimple_statement_omp, tag GSS_OMP_PARALLEL_LAYOUT, inherits word 1-7, gcc/gimple.h:648.

Word Field Type GTY Meaning
WORD 8 clauses tree Clauses.
WORD 9 child_fn tree Child function holding the body of the parallel region.
WORD 10 data_arg tree Shared data argument.

gomp_target

GIMPLE_OMP_TARGET

Extends gimple_statement_omp_parallel_layout, tag GSS_OMP_TARGET, inherits word 1-10, gcc/gimple.h:685.

Word Field Type GTY Meaning
WORD 11 iterator_loops gimple_seq Iterator loops.

gomp_task

GIMPLE_OMP_TASK

Extends gimple_statement_omp_taskreg, tag GSS_OMP_TASK, inherits word 1-10, gcc/gimple.h:697.

Word Field Type GTY Meaning
WORD 11 copy_fn tree Child function holding firstprivate initialization if needed.
WORD 12-13 arg_size tree Size and alignment in bytes of the argument data block.
arg_align tree no comment in the header

gomp_sections

GIMPLE_OMP_SECTIONS

Extends gimple_statement_omp, tag GSS_OMP_SECTIONS, inherits word 1-7, gcc/gimple.h:719.

Word Field Type GTY Meaning
WORD 8 clauses tree no comment in the header
WORD 9 control tree The control variable used for deciding which of the sections to execute.

gomp_continue

GIMPLE_OMP_CONTINUE.

Note: This does not inherit from gimple_statement_omp, because we
      do not need the body field.

Extends gimple, tag GSS_OMP_CONTINUE, inherits word 1-6, gcc/gimple.h:738.

Word Field Type GTY Meaning
WORD 7 control_def tree no comment in the header
WORD 8 control_use tree no comment in the header

gimple_statement_omp_single_layout

GIMPLE_OMP_SINGLE, GIMPLE_OMP_ORDERED, GIMPLE_OMP_TASKGROUP,
GIMPLE_OMP_SCAN, GIMPLE_OMP_MASKED, GIMPLE_OMP_SCOPE, GIMPLE_OMP_DISPATCH,
GIMPLE_OMP_INTEROP.

Extends gimple_statement_omp, tag GSS_OMP_SINGLE_LAYOUT, inherits word 1-7, gcc/gimple.h:754.

Word Field Type GTY Meaning
WORD 8 clauses tree no comment in the header

gomp_atomic_load

GIMPLE_OMP_ATOMIC_LOAD.
Note: This is based on gimple, not g_s_omp, because g_s_omp
contains a sequence, which we don't need here.

Extends gimple, tag GSS_OMP_ATOMIC_LOAD, inherits word 1-6, gcc/gimple.h:796.

Word Field Type GTY Meaning
WORD 7-8 lhs tree rhs, no comment in the header

gimple_statement_omp_atomic_store_layout

GIMPLE_OMP_ATOMIC_STORE.
See note on GIMPLE_OMP_ATOMIC_LOAD.

Extends gimple, tag GSS_OMP_ATOMIC_STORE_LAYOUT, inherits word 1-6, gcc/gimple.h:808.

Word Field Type GTY Meaning
WORD 7 val tree no comment in the header

gimple_statement_assume

Assumptions.

Extends gimple, tag GSS_ASSUME, inherits word 1-6, gcc/gimple.h:835.

Word Field Type GTY Meaning
WORD 7 guard tree no comment in the header
WORD 8 body gimple_seq no comment in the header

gtransaction

Extends gimple_statement_with_memory_ops_base, tag GSS_TRANSACTION, inherits word 1-9, gcc/gimple.h:875.

Word Field Type GTY Meaning
WORD 10 body gimple_seq no comment in the header
WORD 11-13 label_norm tree no comment in the header
label_uninst tree no comment in the header
label_over tree no comment in the header

2.5 The statement classes and which codes they accept

Generated by bpc build from the pinned GCC tree. Do not edit inside the markers, edit the generator.

GIMPLE statements are all gimple * at rest and are narrowed on use, with as_a when the code is already known and dyn_cast when it is being tested. Which narrowings are legal is not held in a table anywhere in GCC. It is 36 template specialisations of is_a_helper::test, each of which compares the statement's code against one or more constants. This is that map.

Class Accepts Extends Declares code_ Defined at
gasm GIMPLE_ASM gimple_statement_with_memory_ops_base no gcc/gimple.h:567
gassign GIMPLE_ASSIGN gimple_statement_with_memory_ops yes gcc/gimple.h:951
gbind GIMPLE_BIND gimple no gcc/gimple.h:396
gcall GIMPLE_CALL gimple_statement_with_memory_ops_base yes gcc/gimple.h:357
gcatch GIMPLE_CATCH gimple no gcc/gimple.h:420
gcond GIMPLE_COND gimple_statement_with_ops yes gcc/gimple.h:900
gdebug GIMPLE_DEBUG gimple_statement_with_ops no gcc/gimple.h:911
geh_dispatch GIMPLE_EH_DISPATCH gimple_statement_eh_ctrl no gcc/gimple.h:509
geh_else GIMPLE_EH_ELSE gimple no gcc/gimple.h:451
geh_filter GIMPLE_EH_FILTER gimple no gcc/gimple.h:435
geh_mnt GIMPLE_EH_MUST_NOT_THROW gimple no gcc/gimple.h:462
ggoto GIMPLE_GOTO gimple_statement_with_ops no gcc/gimple.h:921
gimple_statement_assume GIMPLE_ASSUME gimple no gcc/gimple.h:835
gimple_statement_omp_return GIMPLE_OMP_RETURN gimple_statement_omp_atomic_store_layout no gcc/gimple.h:825
gimple_statement_omp_taskreg GIMPLE_OMP_PARALLEL, GIMPLE_OMP_TASK, GIMPLE_OMP_TEAMS gimple_statement_omp_parallel_layout no gcc/gimple.h:667
gimple_statement_wce GIMPLE_WITH_CLEANUP_EXPR gimple no gcc/gimple.h:549
glabel GIMPLE_LABEL gimple_statement_with_ops no gcc/gimple.h:931
gomp_atomic_load GIMPLE_OMP_ATOMIC_LOAD gimple no gcc/gimple.h:796
gomp_atomic_store GIMPLE_OMP_ATOMIC_STORE gimple_statement_omp_atomic_store_layout no gcc/gimple.h:817
gomp_continue GIMPLE_OMP_CONTINUE gimple no gcc/gimple.h:738
gomp_critical GIMPLE_OMP_CRITICAL gimple_statement_omp no gcc/gimple.h:592
gomp_for GIMPLE_OMP_FOR gimple_statement_omp no gcc/gimple.h:625
gomp_ordered GIMPLE_OMP_ORDERED gimple_statement_omp_single_layout no gcc/gimple.h:777
gomp_parallel GIMPLE_OMP_PARALLEL gimple_statement_omp_taskreg no gcc/gimple.h:677
gomp_scan GIMPLE_OMP_SCAN gimple_statement_omp_single_layout no gcc/gimple.h:784
gomp_sections GIMPLE_OMP_SECTIONS gimple_statement_omp no gcc/gimple.h:719
gomp_single GIMPLE_OMP_SINGLE gimple_statement_omp_single_layout no gcc/gimple.h:763
gomp_target GIMPLE_OMP_TARGET gimple_statement_omp_parallel_layout no gcc/gimple.h:685
gomp_task GIMPLE_OMP_TASK gimple_statement_omp_taskreg no gcc/gimple.h:697
gomp_teams GIMPLE_OMP_TEAMS gimple_statement_omp_taskreg no gcc/gimple.h:770
gphi GIMPLE_PHI gimple no gcc/gimple.h:473
gresx GIMPLE_RESX gimple_statement_eh_ctrl no gcc/gimple.h:502
greturn GIMPLE_RETURN gimple_statement_with_memory_ops no gcc/gimple.h:962
gswitch GIMPLE_SWITCH gimple_statement_with_ops no gcc/gimple.h:941
gtransaction GIMPLE_TRANSACTION gimple_statement_with_memory_ops_base no gcc/gimple.h:875
gtry GIMPLE_TRY gimple no gcc/gimple.h:519

The code_ column matters more than it looks. A class that declares it can be built by the generic gimple_build machinery and checked at compile time. A class that does not is narrowed at run time only.

Only gimple_statement_omp_taskreg accepts more than one code. That is the deliberate grouping, and a cast to it is how a pass handles a family of statements without listing its members.

2 more classes are narrowed by a range check over the code enum rather than by naming codes, so they do not appear in the table: gimple_statement_with_memory_ops, gimple_statement_with_ops. They are the two operand carrying layouts from section 2.3, and they are the reason section 2.2 exists.

2.6 Every code, with the shape gimple.def gives it

Generated by bpc build from the pinned GCC tree. Do not edit inside the markers, edit the generator.

All 47 codes, with the operand shape and the description exactly as gimple.def states them. Where a code has no description of its own, the file documents it together with the code above it and this says so rather than inventing one.

GIMPLE_ERROR_MARK

Error marker.  This is used in similar ways as ERROR_MARK in tree.def.

Printable name gimple_error_mark, layout GSS_BASE, operands: none, gcc/gimple.def:27.

GIMPLE_COND

GIMPLE_COND <COND_CODE, OP1, OP2, TRUE_LABEL, FALSE_LABEL>
represents the conditional jump:

if (OP1 COND_CODE OP2) goto TRUE_LABEL else goto FALSE_LABEL

COND_CODE is the tree code used as the comparison predicate.  It
must be of class tcc_comparison.

OP1 and OP2 are the operands used in the comparison.  They must be
accepted by is_gimple_operand.

TRUE_LABEL and FALSE_LABEL are the LABEL_DECL nodes used as the
jump target for the comparison.

Printable name gimple_cond, layout GSS_WITH_OPS, operands: registers, cast to gcond, gcc/gimple.def:46.

GIMPLE_DEBUG

GIMPLE_DEBUG represents a debug statement.

Printable name gimple_debug, layout GSS_WITH_OPS, operands: registers, cast to gdebug, gcc/gimple.def:49.

GIMPLE_GOTO

GIMPLE_GOTO <TARGET> represents unconditional jumps.
TARGET is a LABEL_DECL or an expression node for computed GOTOs.

Printable name gimple_goto, layout GSS_WITH_OPS, operands: registers, cast to ggoto, gcc/gimple.def:53.

GIMPLE_LABEL

GIMPLE_LABEL <LABEL> represents label statements.  LABEL is a
LABEL_DECL representing a jump target.

Printable name gimple_label, layout GSS_WITH_OPS, operands: registers, cast to glabel, gcc/gimple.def:57.

GIMPLE_SWITCH

GIMPLE_SWITCH <INDEX, DEFAULT_LAB, LAB1, ..., LABN> represents the
multiway branch:

switch (INDEX)
{
  case LAB1: ...; break;
  ...
  case LABN: ...; break;
  default: ...
}

INDEX is the variable evaluated to decide which label to jump to.

DEFAULT_LAB, LAB1 ... LABN are the tree nodes representing case labels.
They must be CASE_LABEL_EXPR nodes.

Printable name gimple_switch, layout GSS_WITH_OPS, operands: registers, cast to gswitch, gcc/gimple.def:74.

GIMPLE_ASSIGN

GIMPLE_ASSIGN <SUBCODE, LHS, RHS1[, RHS2]> represents the assignment
statement

LHS = RHS1 SUBCODE RHS2.

SUBCODE is the tree code for the expression computed by the RHS of the
assignment.  It must be one of the tree codes accepted by
get_gimple_rhs_class.  If LHS is not a gimple register according to
is_gimple_reg, SUBCODE must be of class GIMPLE_SINGLE_RHS.

LHS is the operand on the LHS of the assignment.  It must be a tree node
accepted by is_gimple_lvalue.

RHS1 is the first operand on the RHS of the assignment.  It must always be
present.  It must be a tree node accepted by is_gimple_val.

RHS2 is the second operand on the RHS of the assignment.  It must be a tree
node accepted by is_gimple_val.  This argument exists only if SUBCODE is
of class GIMPLE_BINARY_RHS.

Printable name gimple_assign, layout GSS_WITH_MEM_OPS, operands: registers and memory, cast to gassign, gcc/gimple.def:101.

GIMPLE_ASM

GIMPLE_ASM <STRING, I1, ..., IN, O1, ... OM, C1, ..., CP>
represents inline assembly statements.

STRING is the string containing the assembly statements.
I1 ... IN are the N input operands.
O1 ... OM are the M output operands.
C1 ... CP are the P clobber operands.
L1 ... LQ are the Q label operands.

Printable name gimple_asm, layout GSS_ASM, operands: registers and memory, cast to gasm, gcc/gimple.def:111.

GIMPLE_CALL

GIMPLE_CALL <FN, LHS, ARG1, ..., ARGN[, CHAIN]> represents function
calls.

FN is the callee.  It must be accepted by is_gimple_call_addr.

LHS is the operand where the return value from FN is stored.  It may
be NULL.

ARG1 ... ARGN are the arguments.  They must all be accepted by
is_gimple_operand.

 CHAIN is the optional static chain link for nested functions.

Printable name gimple_call, layout GSS_CALL, operands: registers and memory, cast to gcall, gcc/gimple.def:125.

GIMPLE_TRANSACTION

GIMPLE_TRANSACTION <BODY, LABEL> represents __transaction_atomic and
__transaction_relaxed blocks.
BODY is the sequence of statements inside the transaction.
LABEL is a label for the statement immediately following the
transaction.  This is before RETURN so that it has MEM_OPS,
so that it can clobber global memory.

Printable name gimple_transaction, layout GSS_TRANSACTION, operands: registers and memory, cast to gtransaction, gcc/gimple.def:133.

GIMPLE_RETURN

GIMPLE_RETURN <RETVAL> represents return statements.

RETVAL is the value to return or NULL.  If a value is returned it
must be accepted by is_gimple_operand.

Printable name gimple_return, layout GSS_WITH_MEM_OPS, operands: registers and memory, cast to greturn, gcc/gimple.def:139.

GIMPLE_BIND

GIMPLE_BIND <VARS, BLOCK, BODY> represents a lexical scope.
VARS is the set of variables declared in that scope.
BLOCK is the symbol binding block used for debug information.
BODY is the sequence of statements in the scope.

Printable name gimple_bind, layout GSS_BIND, operands: none, cast to gbind, gcc/gimple.def:145.

GIMPLE_CATCH

GIMPLE_CATCH <TYPES, HANDLER> represents a typed exception handler.
TYPES is the type (or list of types) handled.  HANDLER is the
sequence of statements that handle these types.

Printable name gimple_catch, layout GSS_CATCH, operands: none, cast to gcatch, gcc/gimple.def:150.

GIMPLE_EH_FILTER

GIMPLE_EH_FILTER <TYPES, FAILURE> represents an exception
specification.  TYPES is a list of allowed types and FAILURE is the
sequence of statements to execute on failure.

Printable name gimple_eh_filter, layout GSS_EH_FILTER, operands: none, cast to geh_filter, gcc/gimple.def:155.

GIMPLE_EH_MUST_NOT_THROW

GIMPLE_EH_MUST_NOT_THROW <DECL> represents an exception barrier.
DECL is a noreturn function decl taking no arguments that will
be invoked if an exception propagates to this point.

Printable name gimple_eh_must_not_throw, layout GSS_EH_MNT, operands: none, cast to geh_mnt, gcc/gimple.def:160.

GIMPLE_EH_ELSE

GIMPLE_EH_ELSE <N_BODY, E_BODY> must be the sole contents of
a GIMPLE_TRY_FINALLY node.  For all normal exits from the try block,
N_BODY is run; for all exception exits from the try block,
E_BODY is run.

Printable name gimple_eh_else, layout GSS_EH_ELSE, operands: none, cast to geh_else, gcc/gimple.def:166.

GIMPLE_RESX

GIMPLE_RESX resumes execution after an exception.

Printable name gimple_resx, layout GSS_EH_CTRL, operands: none, cast to gresx, gcc/gimple.def:169.

GIMPLE_EH_DISPATCH

GIMPLE_EH_DISPATCH demultiplexes an exception edge based on
the FILTER argument.

Printable name gimple_eh_dispatch, layout GSS_EH_CTRL, operands: none, cast to geh_dispatch, gcc/gimple.def:173.

GIMPLE_PHI

GIMPLE_PHI <RESULT, ARG1, ..., ARGN> represents the PHI node

RESULT = PHI <ARG1, ..., ARGN>

RESULT is the SSA name created by this PHI node.

ARG1 ... ARGN are the arguments to the PHI node.  N must be
exactly the same as the number of incoming edges to the basic block
holding the PHI node.  Every argument is either an SSA name or a
tree node of class tcc_constant.

Printable name gimple_phi, layout GSS_PHI, operands: none, cast to gphi, gcc/gimple.def:185.

GIMPLE_TRY

GIMPLE_TRY <TRY_KIND, EVAL, CLEANUP>
represents a try/catch or a try/finally statement.

TRY_KIND is either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY.

EVAL is the sequence of statements to execute on entry to GIMPLE_TRY.

CLEANUP is the sequence of statements to execute according to
TRY_KIND.  If TRY_KIND is GIMPLE_TRY_CATCH, CLEANUP is only exected
if an exception is thrown during execution of EVAL.  If TRY_KIND is
GIMPLE_TRY_FINALLY, CLEANUP is always executed after executing EVAL
(regardless of whether EVAL finished normally, or jumped out or an
exception was thrown).

Printable name gimple_try, layout GSS_TRY, operands: none, cast to gtry, gcc/gimple.def:200.

GIMPLE_NOP

GIMPLE_NOP represents the "do nothing" statement.

Printable name gimple_nop, layout GSS_BASE, operands: none, gcc/gimple.def:203.

GIMPLE_OMP_ATOMIC_LOAD

Tuples used for lowering of OMP_ATOMIC.  Although the form of the OMP_ATOMIC
expression is very simple (just in form mem op= expr), various implicit
conversions may cause the expression to become more complex, so that it does
not fit the gimple grammar very well.  To overcome this problem, OMP_ATOMIC
is rewritten as a sequence of two codes in gimplification:

GIMPLE_OMP_LOAD (tmp, mem)
val = some computations involving tmp;
GIMPLE_OMP_STORE (val).

Printable name gimple_omp_atomic_load, layout GSS_OMP_ATOMIC_LOAD, operands: none, cast to gomp_atomic_load, gcc/gimple.def:221.

GIMPLE_OMP_ATOMIC_STORE

gimple.def has no comment of its own for this code. It is described together with GIMPLE_OMP_ATOMIC_LOAD above it.

Printable name gimple_omp_atomic_store, layout GSS_OMP_ATOMIC_STORE_LAYOUT, operands: none, cast to gomp_atomic_store, gcc/gimple.def:223.

GIMPLE_OMP_CONTINUE

GIMPLE_OMP_CONTINUE marks the location of the loop or sections
iteration in partially lowered OpenMP code.

Printable name gimple_omp_continue, layout GSS_OMP_CONTINUE, operands: none, cast to gomp_continue, gcc/gimple.def:228.

GIMPLE_OMP_CRITICAL

GIMPLE_OMP_CRITICAL <NAME, BODY> represents

#pragma omp critical [name]

NAME is the name given to the critical section.
BODY is the sequence of statements that are inside the critical section.

Printable name gimple_omp_critical, layout GSS_OMP_CRITICAL, operands: none, cast to gomp_critical, gcc/gimple.def:236.

GIMPLE_OMP_FOR

GIMPLE_OMP_FOR <BODY, CLAUSES, INDEX, INITIAL, FINAL, COND, INCR, PRE_BODY>
represents

PRE_BODY
#pragma omp for [clause1 ... clauseN]
for (INDEX = INITIAL; INDEX COND FINAL; INDEX {+=,-=} INCR)
BODY

Likewise for:
#pragma acc loop [clause1 ... clauseN]

BODY is the loop body.

CLAUSES is the list of clauses.

INDEX must be an integer or pointer variable, which is implicitly thread
private.  It must be accepted by is_gimple_operand.

INITIAL is the initial value given to INDEX. It must be
accepted by is_gimple_operand.

FINAL is the final value that INDEX should take. It must
be accepted by is_gimple_operand.

COND is the condition code for the controlling predicate.  It must
be one of { <, >, <=, >= }

INCR is the loop index increment.  It must be tree node of type
tcc_constant.

PRE_BODY is a landing pad filled by the gimplifier with things from
INIT, COND, and INCR that are technically part of the OMP_FOR
structured block, but are evaluated before the loop body begins.

INITIAL, FINAL and INCR are required to be loop invariant integer
expressions that are evaluated without any synchronization.
The evaluation order, frequency of evaluation and side-effects are
unspecified by the standards.

Printable name gimple_omp_for, layout GSS_OMP_FOR, operands: none, cast to gomp_for, gcc/gimple.def:276.

GIMPLE_OMP_STRUCTURED_BLOCK

GIMPLE_STRUCTURED_BLOCK <BODY> is an internal construct used to assert
that BODY is a structured block sequence, with no other semantics.  It is
used to allow error-checking of intervening code in OMP_FOR constructs.

Printable name gimple_omp_structured_block, layout GSS_OMP, operands: none, gcc/gimple.def:281.

GIMPLE_OMP_MASTER

GIMPLE_OMP_MASTER <BODY> represents #pragma omp master.
BODY is the sequence of statements to execute in the master section.

Printable name gimple_omp_master, layout GSS_OMP, operands: none, gcc/gimple.def:285.

GIMPLE_OMP_MASKED

GIMPLE_OMP_MASKED <BODY, CLAUSES> represents #pragma omp masked.
BODY is the sequence of statements to execute in the masked section.

Printable name gimple_omp_masked, layout GSS_OMP_SINGLE_LAYOUT, operands: none, gcc/gimple.def:289.

GIMPLE_OMP_TASKGROUP

GIMPLE_OMP_TASKGROUP <BODY, CLAUSES> represents #pragma omp taskgroup.
BODY is the sequence of statements inside the taskgroup section.
CLAUSES is an OMP_CLAUSE chain holding the associated clauses.

Printable name gimple_omp_taskgroup, layout GSS_OMP_SINGLE_LAYOUT, operands: none, gcc/gimple.def:294.

GIMPLE_OMP_PARALLEL

GIMPLE_OMP_PARALLEL <BODY, CLAUSES, CHILD_FN, DATA_ARG> represents

#pragma omp parallel [CLAUSES]
BODY

BODY is a the sequence of statements to be executed by all threads.

CLAUSES is an OMP_CLAUSE chain with all the clauses.

CHILD_FN is set when outlining the body of the parallel region.
All the statements in BODY are moved into this newly created
function when converting OMP constructs into low-GIMPLE.

DATA_ARG is a local variable in the parent function containing data
to be shared with CHILD_FN.  This is used to implement all the data
sharing clauses.

Printable name gimple_omp_parallel, layout GSS_OMP_PARALLEL_LAYOUT, operands: none, cast to gomp_parallel, gcc/gimple.def:312.

GIMPLE_OMP_TASK

GIMPLE_OMP_TASK <BODY, CLAUSES, CHILD_FN, DATA_ARG, COPY_FN,
                 ARG_SIZE, ARG_ALIGN> represents

#pragma omp task [CLAUSES]
BODY

BODY is a the sequence of statements to be executed by all threads.

CLAUSES is an OMP_CLAUSE chain with all the clauses.

CHILD_FN is set when outlining the body of the explicit task region.
All the statements in BODY are moved into this newly created
function when converting OMP constructs into low-GIMPLE.

DATA_ARG is a local variable in the parent function containing data
to be shared with CHILD_FN.  This is used to implement all the data
sharing clauses.

COPY_FN is set when outlining the firstprivate var initialization.
All the needed statements are emitted into the newly created
function, or when only memcpy is needed, it is NULL.

ARG_SIZE and ARG_ALIGN are the size and alignment of the incoming
data area allocated by GOMP_task and passed to CHILD_FN.

Printable name gimple_omp_task, layout GSS_OMP_TASK, operands: none, cast to gomp_task, gcc/gimple.def:338.

GIMPLE_OMP_RETURN

OMP_RETURN marks the end of an OpenMP directive.

Printable name gimple_omp_return, layout GSS_OMP_ATOMIC_STORE_LAYOUT, operands: none, cast to gimple_statement_omp_return, gcc/gimple.def:341.

GIMPLE_OMP_SCAN

GIMPLE_OMP_SCAN <BODY, CLAUSES> represents #pragma omp scan
BODY is the sequence of statements inside the single section.
CLAUSES is an OMP_CLAUSE chain holding the associated clauses.

Printable name gimple_omp_scan, layout GSS_OMP_SINGLE_LAYOUT, operands: none, cast to gomp_scan, gcc/gimple.def:346.

GIMPLE_OMP_SCOPE

GIMPLE_OMP_SCOPE <BODY, CLAUSES> represents #pragma omp scope
BODY is the sequence of statements inside the single section.
CLAUSES is an OMP_CLAUSE chain holding the associated clauses.

Printable name gimple_omp_scope, layout GSS_OMP_SINGLE_LAYOUT, operands: none, gcc/gimple.def:351.

GIMPLE_OMP_DISPATCH

GIMPLE_OMP_DISPATCH <BODY, CLAUSES> represents #pragma omp dispatch
BODY is the target function call to be dispatched.
CLAUSES is an OMP_CLAUSE chain holding the associated clauses.

Printable name gimple_omp_dispatch, layout GSS_OMP_SINGLE_LAYOUT, operands: none, gcc/gimple.def:356.

GIMPLE_OMP_INTEROP

GIMPLE_OMP_INTEROP <CLAUSES> represents #pragma omp interop
CLAUSES is an OMP_CLAUSE chain holding the associated clauses.

Printable name gimple_omp_interop, layout GSS_OMP_SINGLE_LAYOUT, operands: none, gcc/gimple.def:360.

GIMPLE_OMP_SECTION

OMP_SECTION <BODY> represents #pragma omp section.
BODY is the sequence of statements in the section body.

Printable name gimple_omp_section, layout GSS_OMP, operands: none, gcc/gimple.def:364.

GIMPLE_OMP_SECTIONS

OMP_SECTIONS <BODY, CLAUSES, CONTROL> represents #pragma omp sections.

BODY is the sequence of statements in the sections body.
CLAUSES is an OMP_CLAUSE chain holding the list of associated clauses.
CONTROL is a VAR_DECL used for deciding which of the sections
to execute.

Printable name gimple_omp_sections, layout GSS_OMP_SECTIONS, operands: none, cast to gomp_sections, gcc/gimple.def:372.

GIMPLE_OMP_SECTIONS_SWITCH

GIMPLE_OMP_SECTIONS_SWITCH is a marker placed immediately after
OMP_SECTIONS.  It represents the GIMPLE_SWITCH used to decide which
branch is taken.

Printable name gimple_omp_sections_switch, layout GSS_BASE, operands: none, gcc/gimple.def:377.

GIMPLE_OMP_SINGLE

GIMPLE_OMP_SINGLE <BODY, CLAUSES> represents #pragma omp single
BODY is the sequence of statements inside the single section.
CLAUSES is an OMP_CLAUSE chain holding the associated clauses.

Printable name gimple_omp_single, layout GSS_OMP_SINGLE_LAYOUT, operands: none, cast to gomp_single, gcc/gimple.def:382.

GIMPLE_OMP_TARGET

GIMPLE_OMP_TARGET <BODY, CLAUSES, CHILD_FN> represents
#pragma acc {kernels,parallel,serial,data,enter data,exit data,update}
#pragma omp target {,data,update}
BODY is the sequence of statements inside the construct
(NULL for some variants).
CLAUSES is an OMP_CLAUSE chain holding the associated clauses.
CHILD_FN is set when outlining the body of the offloaded region.
All the statements in BODY are moved into this newly created
function when converting OMP constructs into low-GIMPLE.
DATA_ARG is a vec of 3 local variables in the parent function
containing data to be mapped to CHILD_FN.  This is used to
implement the MAP clauses.

Printable name gimple_omp_target, layout GSS_OMP_TARGET, operands: none, cast to gomp_target, gcc/gimple.def:396.

GIMPLE_OMP_TEAMS

GIMPLE_OMP_TEAMS <BODY, CLAUSES, CHILD_FN, DATA_ARG> represents
#pragma omp teams
BODY is the sequence of statements inside the single section.
CLAUSES is an OMP_CLAUSE chain holding the associated clauses.
CHILD_FN and DATA_ARG like for GIMPLE_OMP_PARALLEL.

Printable name gimple_omp_teams, layout GSS_OMP_PARALLEL_LAYOUT, operands: none, cast to gomp_teams, gcc/gimple.def:403.

GIMPLE_OMP_ORDERED

GIMPLE_OMP_ORDERED <BODY, CLAUSES> represents #pragma omp ordered.
BODY is the sequence of statements to execute in the ordered section.
CLAUSES is an OMP_CLAUSE chain holding the associated clauses.

Printable name gimple_omp_ordered, layout GSS_OMP_SINGLE_LAYOUT, operands: none, cast to gomp_ordered, gcc/gimple.def:408.

GIMPLE_PREDICT

GIMPLE_PREDICT <PREDICT, OUTCOME> specifies a hint for branch prediction.

PREDICT is one of the predictors from predict.def.

OUTCOME is NOT_TAKEN or TAKEN.

Printable name gimple_predict, layout GSS_BASE, operands: none, gcc/gimple.def:415.

GIMPLE_WITH_CLEANUP_EXPR

This node represents a cleanup expression.  It is ONLY USED INTERNALLY
 by the gimplifier as a placeholder for cleanups, and its uses will be
 cleaned up by the time gimplification is done.

 This tuple should not exist outside of the gimplifier proper.

Printable name gimple_with_cleanup_expr, layout GSS_WCE, operands: none, cast to gimple_statement_wce, gcc/gimple.def:422.

GIMPLE_ASSUME

GIMPLE_ASSUME <GUARD, BODY> represents [[assume(cond)]].
BODY is the GIMPLE_BIND with the condition which sets GUARD to true
(otherwise UB).

Printable name gimple_assume, layout GSS_ASSUME, operands: none, cast to gimple_statement_assume, gcc/gimple.def:427.

3. Algorithms

TODO. Lands in M4.

This section covers the accessor contracts rather than an optimisation algorithm, because the operations GIMPLE owns are building a statement, reading and writing its operands, walking a sequence, and moving a statement between blocks. Each of those has preconditions that are asserted under --enable-checking and silently assumed without it, and writing them down is the point.

4. Invariants

TODO. Lands in M4, in step with BP-IR-INVARIANTS.

The material is in verify_gimple_stmt, verify_gimple_in_cfg and the gcc_assert calls in the accessors. The two invariants already visible from section 2 are worth stating early, because both are enforced by nothing but the ordering of a file.

I1. A statement code that carries operands has an enumerator value inside the run from GIMPLE_COND to GIMPLE_RETURN. Established by: the order of gcc/gimple.def. Checked by: nothing. Adding a code in the wrong place changes the answer gimple_has_ops gives for other codes and produces no diagnostic at all.

I2. A statement code that carries memory operands has an enumerator value inside the run from GIMPLE_ASSIGN to GIMPLE_RETURN, which is a subrange of I1. Established by: the order of gcc/gimple.def. Checked by: nothing, with the same consequence.

5. Observable behaviour

TODO. Lands in M4.

The dump text is the observable surface, and the corpus entries to cross-reference are the tree-ssa and tree-optimized dumps of the three canonical programs. What a reader can see: the printable name of each code appears in the dump for some codes and a punctuation form appears for others, and which one you get depends on the pretty printer rather than on anything in this document.

6. Edge cases and error paths

TODO. Lands in M4.

The list to work through: a statement with zero operands, a call with no left hand side, a PHI in a block with one predecessor, the maximum operand count and what happens past it, a statement whose code is GIMPLE_ERROR_MARK, and the two codes that are documented as never surviving the pass that creates them.

7. Interactions

TODO. Lands in M4.

8. Conformance

TODO. Lands in M4.

9. Port notes

GIMPLE is target independent, and that is the whole reason it exists. A reimplementation does not have to make any of the choices in section 2 the way GCC made them.

Three of GCC's choices here are historical rather than forced, and section 2 shows all three.

The operand type. GIMPLE operands are tree nodes, the same type GENERIC uses, restricted by predicates rather than by the type system. Nothing requires that. A reimplementation can give the mid level IR its own operand type and get the restriction checked by the compiler that builds it, at the cost of a conversion at the boundary that GCC does not pay.

The layout family. GCC has a structure per shape of statement and a tag enum to tell them apart at run time, because the representation predates the C++ that would express it and because the garbage collector needs to know the shape of anything it walks. A reimplementation with a tracing collector that already knows its object layouts does not need gsstruct.def at all.

The range checks. Whether a statement has operands is a comparison against two enumerator values rather than a field or a table lookup. It is fast and it is free of storage, and it costs an ordering constraint on a file that a hundred people edit. A reimplementation can pay one bit per code instead and delete the constraint.