You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
178 lines
9.7 KiB
HTML
178 lines
9.7 KiB
HTML
4 years ago
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
|
<html>
|
||
|
<!-- Copyright (C) 1988-2018 Free Software Foundation, Inc.
|
||
|
|
||
|
Permission is granted to copy, distribute and/or modify this document
|
||
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||
|
any later version published by the Free Software Foundation; with the
|
||
|
Invariant Sections being "Funding Free Software", the Front-Cover
|
||
|
Texts being (a) (see below), and with the Back-Cover Texts being (b)
|
||
|
(see below). A copy of the license is included in the section entitled
|
||
|
"GNU Free Documentation License".
|
||
|
|
||
|
(a) The FSF's Front-Cover Text is:
|
||
|
|
||
|
A GNU Manual
|
||
|
|
||
|
(b) The FSF's Back-Cover Text is:
|
||
|
|
||
|
You have freedom to copy and modify this GNU Manual, like GNU
|
||
|
software. Copies published by the Free Software Foundation raise
|
||
|
funds for GNU development. -->
|
||
|
<!-- Created by GNU Texinfo 6.4, http://www.gnu.org/software/texinfo/ -->
|
||
|
<head>
|
||
|
<title>GIMPLE (GNU Compiler Collection (GCC) Internals)</title>
|
||
|
|
||
|
<meta name="description" content="GIMPLE (GNU Compiler Collection (GCC) Internals)">
|
||
|
<meta name="keywords" content="GIMPLE (GNU Compiler Collection (GCC) Internals)">
|
||
|
<meta name="resource-type" content="document">
|
||
|
<meta name="distribution" content="global">
|
||
|
<meta name="Generator" content="makeinfo">
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<link href="index.html#Top" rel="start" title="Top">
|
||
|
<link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
|
||
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||
|
<link href="index.html#Top" rel="up" title="Top">
|
||
|
<link href="Tuple-representation.html#Tuple-representation" rel="next" title="Tuple representation">
|
||
|
<link href="Java-Trees.html#Java-Trees" rel="prev" title="Java Trees">
|
||
|
<style type="text/css">
|
||
|
<!--
|
||
|
a.summary-letter {text-decoration: none}
|
||
|
blockquote.indentedblock {margin-right: 0em}
|
||
|
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
|
||
|
blockquote.smallquotation {font-size: smaller}
|
||
|
div.display {margin-left: 3.2em}
|
||
|
div.example {margin-left: 3.2em}
|
||
|
div.lisp {margin-left: 3.2em}
|
||
|
div.smalldisplay {margin-left: 3.2em}
|
||
|
div.smallexample {margin-left: 3.2em}
|
||
|
div.smalllisp {margin-left: 3.2em}
|
||
|
kbd {font-style: oblique}
|
||
|
pre.display {font-family: inherit}
|
||
|
pre.format {font-family: inherit}
|
||
|
pre.menu-comment {font-family: serif}
|
||
|
pre.menu-preformatted {font-family: serif}
|
||
|
pre.smalldisplay {font-family: inherit; font-size: smaller}
|
||
|
pre.smallexample {font-size: smaller}
|
||
|
pre.smallformat {font-family: inherit; font-size: smaller}
|
||
|
pre.smalllisp {font-size: smaller}
|
||
|
span.nolinebreak {white-space: nowrap}
|
||
|
span.roman {font-family: initial; font-weight: normal}
|
||
|
span.sansserif {font-family: sans-serif; font-weight: normal}
|
||
|
ul.no-bullet {list-style: none}
|
||
|
-->
|
||
|
</style>
|
||
|
|
||
|
|
||
|
</head>
|
||
|
|
||
|
<body lang="en">
|
||
|
<a name="GIMPLE"></a>
|
||
|
<div class="header">
|
||
|
<p>
|
||
|
Next: <a href="Tree-SSA.html#Tree-SSA" accesskey="n" rel="next">Tree SSA</a>, Previous: <a href="GENERIC.html#GENERIC" accesskey="p" rel="prev">GENERIC</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
|
||
|
</div>
|
||
|
<hr>
|
||
|
<a name="GIMPLE-1"></a>
|
||
|
<h2 class="chapter">12 GIMPLE</h2>
|
||
|
<a name="index-GIMPLE-2"></a>
|
||
|
|
||
|
<p>GIMPLE is a three-address representation derived from GENERIC by
|
||
|
breaking down GENERIC expressions into tuples of no more than 3
|
||
|
operands (with some exceptions like function calls). GIMPLE was
|
||
|
heavily influenced by the SIMPLE IL used by the McCAT compiler
|
||
|
project at McGill University, though we have made some different
|
||
|
choices. For one thing, SIMPLE doesn’t support <code>goto</code>.
|
||
|
</p>
|
||
|
<p>Temporaries are introduced to hold intermediate values needed to
|
||
|
compute complex expressions. Additionally, all the control
|
||
|
structures used in GENERIC are lowered into conditional jumps,
|
||
|
lexical scopes are removed and exception regions are converted
|
||
|
into an on the side exception region tree.
|
||
|
</p>
|
||
|
<p>The compiler pass which converts GENERIC into GIMPLE is referred to as
|
||
|
the ‘<samp>gimplifier</samp>’. The gimplifier works recursively, generating
|
||
|
GIMPLE tuples out of the original GENERIC expressions.
|
||
|
</p>
|
||
|
<p>One of the early implementation strategies used for the GIMPLE
|
||
|
representation was to use the same internal data structures used
|
||
|
by front ends to represent parse trees. This simplified
|
||
|
implementation because we could leverage existing functionality
|
||
|
and interfaces. However, GIMPLE is a much more restrictive
|
||
|
representation than abstract syntax trees (AST), therefore it
|
||
|
does not require the full structural complexity provided by the
|
||
|
main tree data structure.
|
||
|
</p>
|
||
|
<p>The GENERIC representation of a function is stored in the
|
||
|
<code>DECL_SAVED_TREE</code> field of the associated <code>FUNCTION_DECL</code>
|
||
|
tree node. It is converted to GIMPLE by a call to
|
||
|
<code>gimplify_function_tree</code>.
|
||
|
</p>
|
||
|
<p>If a front end wants to include language-specific tree codes in the tree
|
||
|
representation which it provides to the back end, it must provide a
|
||
|
definition of <code>LANG_HOOKS_GIMPLIFY_EXPR</code> which knows how to
|
||
|
convert the front end trees to GIMPLE. Usually such a hook will involve
|
||
|
much of the same code for expanding front end trees to RTL. This function
|
||
|
can return fully lowered GIMPLE, or it can return GENERIC trees and let the
|
||
|
main gimplifier lower them the rest of the way; this is often simpler.
|
||
|
GIMPLE that is not fully lowered is known as “High GIMPLE” and
|
||
|
consists of the IL before the pass <code>pass_lower_cf</code>. High GIMPLE
|
||
|
contains some container statements like lexical scopes
|
||
|
(represented by <code>GIMPLE_BIND</code>) and nested expressions (e.g.,
|
||
|
<code>GIMPLE_TRY</code>), while “Low GIMPLE” exposes all of the
|
||
|
implicit jumps for control and exception expressions directly in
|
||
|
the IL and EH region trees.
|
||
|
</p>
|
||
|
<p>The C and C++ front ends currently convert directly from front end
|
||
|
trees to GIMPLE, and hand that off to the back end rather than first
|
||
|
converting to GENERIC. Their gimplifier hooks know about all the
|
||
|
<code>_STMT</code> nodes and how to convert them to GENERIC forms. There
|
||
|
was some work done on a genericization pass which would run first, but
|
||
|
the existence of <code>STMT_EXPR</code> meant that in order to convert all
|
||
|
of the C statements into GENERIC equivalents would involve walking the
|
||
|
entire tree anyway, so it was simpler to lower all the way. This
|
||
|
might change in the future if someone writes an optimization pass
|
||
|
which would work better with higher-level trees, but currently the
|
||
|
optimizers all expect GIMPLE.
|
||
|
</p>
|
||
|
<p>You can request to dump a C-like representation of the GIMPLE form
|
||
|
with the flag <samp>-fdump-tree-gimple</samp>.
|
||
|
</p>
|
||
|
<table class="menu" border="0" cellspacing="0">
|
||
|
<tr><td align="left" valign="top">• <a href="Tuple-representation.html#Tuple-representation" accesskey="1">Tuple representation</a>:</td><td> </td><td align="left" valign="top">
|
||
|
</td></tr>
|
||
|
<tr><td align="left" valign="top">• <a href="Class-hierarchy-of-GIMPLE-statements.html#Class-hierarchy-of-GIMPLE-statements" accesskey="2">Class hierarchy of GIMPLE statements</a>:</td><td> </td><td align="left" valign="top">
|
||
|
</td></tr>
|
||
|
<tr><td align="left" valign="top">• <a href="GIMPLE-instruction-set.html#GIMPLE-instruction-set" accesskey="3">GIMPLE instruction set</a>:</td><td> </td><td align="left" valign="top">
|
||
|
</td></tr>
|
||
|
<tr><td align="left" valign="top">• <a href="GIMPLE-Exception-Handling.html#GIMPLE-Exception-Handling" accesskey="4">GIMPLE Exception Handling</a>:</td><td> </td><td align="left" valign="top">
|
||
|
</td></tr>
|
||
|
<tr><td align="left" valign="top">• <a href="Temporaries.html#Temporaries" accesskey="5">Temporaries</a>:</td><td> </td><td align="left" valign="top">
|
||
|
</td></tr>
|
||
|
<tr><td align="left" valign="top">• <a href="Operands.html#Operands" accesskey="6">Operands</a>:</td><td> </td><td align="left" valign="top">
|
||
|
</td></tr>
|
||
|
<tr><td align="left" valign="top">• <a href="Manipulating-GIMPLE-statements.html#Manipulating-GIMPLE-statements" accesskey="7">Manipulating GIMPLE statements</a>:</td><td> </td><td align="left" valign="top">
|
||
|
</td></tr>
|
||
|
<tr><td align="left" valign="top">• <a href="Tuple-specific-accessors.html#Tuple-specific-accessors" accesskey="8">Tuple specific accessors</a>:</td><td> </td><td align="left" valign="top">
|
||
|
</td></tr>
|
||
|
<tr><td align="left" valign="top">• <a href="GIMPLE-sequences.html#GIMPLE-sequences" accesskey="9">GIMPLE sequences</a>:</td><td> </td><td align="left" valign="top">
|
||
|
</td></tr>
|
||
|
<tr><td align="left" valign="top">• <a href="Sequence-iterators.html#Sequence-iterators">Sequence iterators</a>:</td><td> </td><td align="left" valign="top">
|
||
|
</td></tr>
|
||
|
<tr><td align="left" valign="top">• <a href="Adding-a-new-GIMPLE-statement-code.html#Adding-a-new-GIMPLE-statement-code">Adding a new GIMPLE statement code</a>:</td><td> </td><td align="left" valign="top">
|
||
|
</td></tr>
|
||
|
<tr><td align="left" valign="top">• <a href="Statement-and-operand-traversals.html#Statement-and-operand-traversals">Statement and operand traversals</a>:</td><td> </td><td align="left" valign="top">
|
||
|
</td></tr>
|
||
|
</table>
|
||
|
|
||
|
<hr>
|
||
|
<div class="header">
|
||
|
<p>
|
||
|
Next: <a href="Tree-SSA.html#Tree-SSA" accesskey="n" rel="next">Tree SSA</a>, Previous: <a href="GENERIC.html#GENERIC" accesskey="p" rel="prev">GENERIC</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|