gccint: GIMPLE

1 
1 12 GIMPLE
1 *********
1 
1 GIMPLE is a three-address representation derived from GENERIC by
1 breaking down GENERIC expressions into tuples of no more than 3 operands
1 (with some exceptions like function calls).  GIMPLE was heavily
1 influenced by the SIMPLE IL used by the McCAT compiler project at McGill
1 University, though we have made some different choices.  For one thing,
1 SIMPLE doesn't support 'goto'.
1 
1  Temporaries are introduced to hold intermediate values needed to
1 compute complex expressions.  Additionally, all the control structures
1 used in GENERIC are lowered into conditional jumps, lexical scopes are
1 removed and exception regions are converted into an on the side
1 exception region tree.
1 
1  The compiler pass which converts GENERIC into GIMPLE is referred to as
1 the 'gimplifier'.  The gimplifier works recursively, generating GIMPLE
1 tuples out of the original GENERIC expressions.
1 
1  One of the early implementation strategies used for the GIMPLE
1 representation was to use the same internal data structures used by
1 front ends to represent parse trees.  This simplified implementation
1 because we could leverage existing functionality and interfaces.
1 However, GIMPLE is a much more restrictive representation than abstract
1 syntax trees (AST), therefore it does not require the full structural
1 complexity provided by the main tree data structure.
1 
1  The GENERIC representation of a function is stored in the
1 'DECL_SAVED_TREE' field of the associated 'FUNCTION_DECL' tree node.  It
1 is converted to GIMPLE by a call to 'gimplify_function_tree'.
1 
1  If a front end wants to include language-specific tree codes in the
1 tree representation which it provides to the back end, it must provide a
1 definition of 'LANG_HOOKS_GIMPLIFY_EXPR' which knows how to convert the
1 front end trees to GIMPLE.  Usually such a hook will involve much of the
1 same code for expanding front end trees to RTL.  This function can
1 return fully lowered GIMPLE, or it can return GENERIC trees and let the
1 main gimplifier lower them the rest of the way; this is often simpler.
1 GIMPLE that is not fully lowered is known as "High GIMPLE" and consists
1 of the IL before the pass 'pass_lower_cf'.  High GIMPLE contains some
1 container statements like lexical scopes (represented by 'GIMPLE_BIND')
1 and nested expressions (e.g., 'GIMPLE_TRY'), while "Low GIMPLE" exposes
1 all of the implicit jumps for control and exception expressions directly
1 in the IL and EH region trees.
1 
1  The C and C++ front ends currently convert directly from front end
1 trees to GIMPLE, and hand that off to the back end rather than first
1 converting to GENERIC.  Their gimplifier hooks know about all the
1 '_STMT' nodes and how to convert them to GENERIC forms.  There was some
1 work done on a genericization pass which would run first, but the
1 existence of 'STMT_EXPR' meant that in order to convert all of the C
1 statements into GENERIC equivalents would involve walking the entire
1 tree anyway, so it was simpler to lower all the way.  This might change
1 in the future if someone writes an optimization pass which would work
1 better with higher-level trees, but currently the optimizers all expect
1 GIMPLE.
1 
1  You can request to dump a C-like representation of the GIMPLE form with
1 the flag '-fdump-tree-gimple'.
1 

Menu