diff options
Diffstat (limited to 'share/doc/gccint/Constants.html')
-rw-r--r-- | share/doc/gccint/Constants.html | 396 |
1 files changed, 396 insertions, 0 deletions
diff --git a/share/doc/gccint/Constants.html b/share/doc/gccint/Constants.html new file mode 100644 index 0000000..57d657f --- /dev/null +++ b/share/doc/gccint/Constants.html @@ -0,0 +1,396 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<!-- Copyright (C) 1988-2023 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 5.1, http://www.gnu.org/software/texinfo/ --> +<head> +<title>GNU Compiler Collection (GCC) Internals: Constants</title> + +<meta name="description" content="GNU Compiler Collection (GCC) Internals: Constants"> +<meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Constants"> +<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="RTL.html#RTL" rel="up" title="RTL"> +<link href="Regs-and-Memory.html#Regs-and-Memory" rel="next" title="Regs and Memory"> +<link href="Machine-Modes.html#Machine-Modes" rel="previous" title="Machine Modes"> +<style type="text/css"> +<!-- +a.summary-letter {text-decoration: none} +blockquote.smallquotation {font-size: smaller} +div.display {margin-left: 3.2em} +div.example {margin-left: 3.2em} +div.indentedblock {margin-left: 3.2em} +div.lisp {margin-left: 3.2em} +div.smalldisplay {margin-left: 3.2em} +div.smallexample {margin-left: 3.2em} +div.smallindentedblock {margin-left: 3.2em; font-size: smaller} +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.nocodebreak {white-space:nowrap} +span.nolinebreak {white-space:nowrap} +span.roman {font-family:serif; font-weight:normal} +span.sansserif {font-family:sans-serif; font-weight:normal} +ul.no-bullet {list-style: none} +--> +</style> + + +</head> + +<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> +<a name="Constants"></a> +<div class="header"> +<p> +Next: <a href="Regs-and-Memory.html#Regs-and-Memory" accesskey="n" rel="next">Regs and Memory</a>, Previous: <a href="Machine-Modes.html#Machine-Modes" accesskey="p" rel="previous">Machine Modes</a>, Up: <a href="RTL.html#RTL" accesskey="u" rel="up">RTL</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="Constant-Expression-Types"></a> +<h3 class="section">14.7 Constant Expression Types</h3> +<a name="index-RTL-constants"></a> +<a name="index-RTL-constant-expression-types"></a> + +<p>The simplest RTL expressions are those that represent constant values. +</p> +<dl compact="compact"> +<dd><a name="index-const_005fint"></a> +</dd> +<dt><code>(const_int <var>i</var>)</code></dt> +<dd><p>This type of expression represents the integer value <var>i</var>. <var>i</var> +is customarily accessed with the macro <code>INTVAL</code> as in +<code>INTVAL (<var>exp</var>)</code>, which is equivalent to <code>XWINT (<var>exp</var>, 0)</code>. +</p> +<p>Constants generated for modes with fewer bits than in +<code>HOST_WIDE_INT</code> must be sign extended to full width (e.g., with +<code>gen_int_mode</code>). For constants for modes with more bits than in +<code>HOST_WIDE_INT</code> the implied high order bits of that constant are +copies of the top bit. Note however that values are neither +inherently signed nor inherently unsigned; where necessary, signedness +is determined by the rtl operation instead. +</p> +<a name="index-const0_005frtx"></a> +<a name="index-const1_005frtx"></a> +<a name="index-const2_005frtx"></a> +<a name="index-constm1_005frtx"></a> +<p>There is only one expression object for the integer value zero; it is +the value of the variable <code>const0_rtx</code>. Likewise, the only +expression for integer value one is found in <code>const1_rtx</code>, the only +expression for integer value two is found in <code>const2_rtx</code>, and the +only expression for integer value negative one is found in +<code>constm1_rtx</code>. Any attempt to create an expression of code +<code>const_int</code> and value zero, one, two or negative one will return +<code>const0_rtx</code>, <code>const1_rtx</code>, <code>const2_rtx</code> or +<code>constm1_rtx</code> as appropriate. +</p> +<a name="index-const_005ftrue_005frtx"></a> +<p>Similarly, there is only one object for the integer whose value is +<code>STORE_FLAG_VALUE</code>. It is found in <code>const_true_rtx</code>. If +<code>STORE_FLAG_VALUE</code> is one, <code>const_true_rtx</code> and +<code>const1_rtx</code> will point to the same object. If +<code>STORE_FLAG_VALUE</code> is -1, <code>const_true_rtx</code> and +<code>constm1_rtx</code> will point to the same object. +</p> +<a name="index-const_005fdouble"></a> +</dd> +<dt><code>(const_double:<var>m</var> <var>i0</var> <var>i1</var> …)</code></dt> +<dd><p>This represents either a floating-point constant of mode <var>m</var> or +(on older ports that do not define +<code>TARGET_SUPPORTS_WIDE_INT</code>) an integer constant too large to fit +into <code>HOST_BITS_PER_WIDE_INT</code> bits but small enough to fit within +twice that number of bits. In the latter case, <var>m</var> will be +<code>VOIDmode</code>. For integral values constants for modes with more +bits than twice the number in <code>HOST_WIDE_INT</code> the implied high +order bits of that constant are copies of the top bit of +<code>CONST_DOUBLE_HIGH</code>. Note however that integral values are +neither inherently signed nor inherently unsigned; where necessary, +signedness is determined by the rtl operation instead. +</p> +<p>On more modern ports, <code>CONST_DOUBLE</code> only represents floating +point values. New ports define <code>TARGET_SUPPORTS_WIDE_INT</code> to +make this designation. +</p> +<a name="index-CONST_005fDOUBLE_005fLOW"></a> +<p>If <var>m</var> is <code>VOIDmode</code>, the bits of the value are stored in +<var>i0</var> and <var>i1</var>. <var>i0</var> is customarily accessed with the macro +<code>CONST_DOUBLE_LOW</code> and <var>i1</var> with <code>CONST_DOUBLE_HIGH</code>. +</p> +<p>If the constant is floating point (regardless of its precision), then +the number of integers used to store the value depends on the size of +<code>REAL_VALUE_TYPE</code> (see <a href="Floating-Point.html#Floating-Point">Floating Point</a>). The integers +represent a floating point number, but not precisely in the target +machine’s or host machine’s floating point format. To convert them to +the precise bit pattern used by the target machine, use the macro +<code>REAL_VALUE_TO_TARGET_DOUBLE</code> and friends (see <a href="Data-Output.html#Data-Output">Data Output</a>). +</p> +<a name="index-const_005fdouble_005fzero"></a> +<p>The host dependency for the number of integers used to store a double +value makes it problematic for machine descriptions to use expressions +of code <code>const_double</code> and therefore a syntactic alias has been +provided: +</p> +<div class="smallexample"> +<pre class="smallexample">(const_double_zero:<var>m</var>) +</pre></div> + +<p>standing for: +</p> +<div class="smallexample"> +<pre class="smallexample">(const_double:<var>m</var> 0 0 …) +</pre></div> + +<p>for matching the floating-point value zero, possibly the only useful one. +</p> +<a name="index-CONST_005fWIDE_005fINT"></a> +</dd> +<dt><code>(const_wide_int:<var>m</var> <var>nunits</var> <var>elt0</var> …)</code></dt> +<dd><p>This contains an array of <code>HOST_WIDE_INT</code>s that is large enough +to hold any constant that can be represented on the target. This form +of rtl is only used on targets that define +<code>TARGET_SUPPORTS_WIDE_INT</code> to be nonzero and then +<code>CONST_DOUBLE</code>s are only used to hold floating-point values. If +the target leaves <code>TARGET_SUPPORTS_WIDE_INT</code> defined as 0, +<code>CONST_WIDE_INT</code>s are not used and <code>CONST_DOUBLE</code>s are as +they were before. +</p> +<p>The values are stored in a compressed format. The higher-order +0s or -1s are not represented if they are just the logical sign +extension of the number that is represented. +</p> +<a name="index-CONST_005fWIDE_005fINT_005fVEC"></a> +</dd> +<dt><code>CONST_WIDE_INT_VEC (<var>code</var>)</code></dt> +<dd><p>Returns the entire array of <code>HOST_WIDE_INT</code>s that are used to +store the value. This macro should be rarely used. +</p> +<a name="index-CONST_005fWIDE_005fINT_005fNUNITS"></a> +</dd> +<dt><code>CONST_WIDE_INT_NUNITS (<var>code</var>)</code></dt> +<dd><p>The number of <code>HOST_WIDE_INT</code>s used to represent the number. +Note that this generally is smaller than the number of +<code>HOST_WIDE_INT</code>s implied by the mode size. +</p> +<a name="index-CONST_005fWIDE_005fINT_005fELT"></a> +</dd> +<dt><code>CONST_WIDE_INT_ELT (<var>code</var>,<var>i</var>)</code></dt> +<dd><p>Returns the <code>i</code>th element of the array. Element 0 is contains +the low order bits of the constant. +</p> +<a name="index-const_005ffixed"></a> +</dd> +<dt><code>(const_fixed:<var>m</var> …)</code></dt> +<dd><p>Represents a fixed-point constant of mode <var>m</var>. +The operand is a data structure of type <code>struct fixed_value</code> and +is accessed with the macro <code>CONST_FIXED_VALUE</code>. The high part of +data is accessed with <code>CONST_FIXED_VALUE_HIGH</code>; the low part is +accessed with <code>CONST_FIXED_VALUE_LOW</code>. +</p> +<a name="index-const_005fpoly_005fint"></a> +</dd> +<dt><code>(const_poly_int:<var>m</var> [<var>c0</var> <var>c1</var> …])</code></dt> +<dd><p>Represents a <code>poly_int</code>-style polynomial integer with coefficients +<var>c0</var>, <var>c1</var>, …. The coefficients are <code>wide_int</code>-based +integers rather than rtxes. <code>CONST_POLY_INT_COEFFS</code> gives the +values of individual coefficients (which is mostly only useful in +low-level routines) and <code>const_poly_int_value</code> gives the full +<code>poly_int</code> value. +</p> +<a name="index-const_005fvector"></a> +</dd> +<dt><code>(const_vector:<var>m</var> [<var>x0</var> <var>x1</var> …])</code></dt> +<dd><p>Represents a vector constant. The values in square brackets are +elements of the vector, which are always <code>const_int</code>, +<code>const_wide_int</code>, <code>const_double</code> or <code>const_fixed</code> +expressions. +</p> +<p>Each vector constant <var>v</var> is treated as a specific instance of an +arbitrary-length sequence that itself contains +‘<samp>CONST_VECTOR_NPATTERNS (<var>v</var>)</samp>’ interleaved patterns. Each +pattern has the form: +</p> +<div class="smallexample"> +<pre class="smallexample">{ <var>base0</var>, <var>base1</var>, <var>base1</var> + <var>step</var>, <var>base1</var> + <var>step</var> * 2, … } +</pre></div> + +<p>The first three elements in each pattern are enough to determine the +values of the other elements. However, if all <var>step</var>s are zero, +only the first two elements are needed. If in addition each <var>base1</var> +is equal to the corresponding <var>base0</var>, only the first element in +each pattern is needed. The number of determining elements per pattern +is given by ‘<samp>CONST_VECTOR_NELTS_PER_PATTERN (<var>v</var>)</samp>’. +</p> +<p>For example, the constant: +</p> +<div class="smallexample"> +<pre class="smallexample">{ 0, 1, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8, 18 } +</pre></div> + +<p>is interpreted as an interleaving of the sequences: +</p> +<div class="smallexample"> +<pre class="smallexample">{ 0, 2, 3, 4, 5, 6, 7, 8 } +{ 1, 6, 8, 10, 12, 14, 16, 18 } +</pre></div> + +<p>where the sequences are represented by the following patterns: +</p> +<div class="smallexample"> +<pre class="smallexample"><var>base0</var> == 0, <var>base1</var> == 2, <var>step</var> == 1 +<var>base0</var> == 1, <var>base1</var> == 6, <var>step</var> == 2 +</pre></div> + +<p>In this case: +</p> +<div class="smallexample"> +<pre class="smallexample">CONST_VECTOR_NPATTERNS (<var>v</var>) == 2 +CONST_VECTOR_NELTS_PER_PATTERN (<var>v</var>) == 3 +</pre></div> + +<p>Thus the first 6 elements (‘<samp>{ 0, 1, 2, 6, 3, 8 }</samp>’) are enough +to determine the whole sequence; we refer to them as the “encoded” +elements. They are the only elements present in the square brackets +for variable-length <code>const_vector</code>s (i.e. for +<code>const_vector</code>s whose mode <var>m</var> has a variable number of +elements). However, as a convenience to code that needs to handle +both <code>const_vector</code>s and <code>parallel</code>s, all elements are +present in the square brackets for fixed-length <code>const_vector</code>s; +the encoding scheme simply reduces the amount of work involved in +processing constants that follow a regular pattern. +</p> +<p>Sometimes this scheme can create two possible encodings of the same +vector. For example { 0, 1 } could be seen as two patterns with +one element each or one pattern with two elements (<var>base0</var> and +<var>base1</var>). The canonical encoding is always the one with the +fewest patterns or (if both encodings have the same number of +petterns) the one with the fewest encoded elements. +</p> +<p>‘<samp>const_vector_encoding_nelts (<var>v</var>)</samp>’ gives the total number of +encoded elements in <var>v</var>, which is 6 in the example above. +<code>CONST_VECTOR_ENCODED_ELT (<var>v</var>, <var>i</var>)</code> accesses the value +of encoded element <var>i</var>. +</p> +<p>‘<samp>CONST_VECTOR_DUPLICATE_P (<var>v</var>)</samp>’ is true if <var>v</var> simply contains +repeated instances of ‘<samp>CONST_VECTOR_NPATTERNS (<var>v</var>)</samp>’ values. This is +a shorthand for testing ‘<samp>CONST_VECTOR_NELTS_PER_PATTERN (<var>v</var>) == 1</samp>’. +</p> +<p>‘<samp>CONST_VECTOR_STEPPED_P (<var>v</var>)</samp>’ is true if at least one +pattern in <var>v</var> has a nonzero step. This is a shorthand for +testing ‘<samp>CONST_VECTOR_NELTS_PER_PATTERN (<var>v</var>) == 3</samp>’. +</p> +<p><code>CONST_VECTOR_NUNITS (<var>v</var>)</code> gives the total number of elements +in <var>v</var>; it is a shorthand for getting the number of units in +‘<samp>GET_MODE (<var>v</var>)</samp>’. +</p> +<p>The utility function <code>const_vector_elt</code> gives the value of an +arbitrary element as an <code>rtx</code>. <code>const_vector_int_elt</code> gives +the same value as a <code>wide_int</code>. +</p> +<a name="index-const_005fstring"></a> +</dd> +<dt><code>(const_string <var>str</var>)</code></dt> +<dd><p>Represents a constant string with value <var>str</var>. Currently this is +used only for insn attributes (see <a href="Insn-Attributes.html#Insn-Attributes">Insn Attributes</a>) since constant +strings in C are placed in memory. +</p> +<a name="index-symbol_005fref"></a> +</dd> +<dt><code>(symbol_ref:<var>mode</var> <var>symbol</var>)</code></dt> +<dd><p>Represents the value of an assembler label for data. <var>symbol</var> is +a string that describes the name of the assembler label. If it starts +with a ‘<samp>*</samp>’, the label is the rest of <var>symbol</var> not including +the ‘<samp>*</samp>’. Otherwise, the label is <var>symbol</var>, usually prefixed +with ‘<samp>_</samp>’. +</p> +<p>The <code>symbol_ref</code> contains a mode, which is usually <code>Pmode</code>. +Usually that is the only mode for which a symbol is directly valid. +</p> +<a name="index-label_005fref"></a> +</dd> +<dt><code>(label_ref:<var>mode</var> <var>label</var>)</code></dt> +<dd><p>Represents the value of an assembler label for code. It contains one +operand, an expression, which must be a <code>code_label</code> or a <code>note</code> +of type <code>NOTE_INSN_DELETED_LABEL</code> that appears in the instruction +sequence to identify the place where the label should go. +</p> +<p>The reason for using a distinct expression type for code label +references is so that jump optimization can distinguish them. +</p> +<p>The <code>label_ref</code> contains a mode, which is usually <code>Pmode</code>. +Usually that is the only mode for which a label is directly valid. +</p> +<a name="index-const"></a> +</dd> +<dt><code>(const:<var>m</var> <var>exp</var>)</code></dt> +<dd><p>Represents a constant that is the result of an assembly-time +arithmetic computation. The operand, <var>exp</var>, contains only +<code>const_int</code>, <code>symbol_ref</code>, <code>label_ref</code> or <code>unspec</code> +expressions, combined with <code>plus</code> and <code>minus</code>. Any such +<code>unspec</code>s are target-specific and typically represent some form +of relocation operator. <var>m</var> should be a valid address mode. +</p> +<a name="index-high"></a> +</dd> +<dt><code>(high:<var>m</var> <var>exp</var>)</code></dt> +<dd><p>Represents the high-order bits of <var>exp</var>. +The number of bits is machine-dependent and is +normally the number of bits specified in an instruction that initializes +the high order bits of a register. It is used with <code>lo_sum</code> to +represent the typical two-instruction sequence used in RISC machines to +reference large immediate values and/or link-time constants such +as global memory addresses. In the latter case, <var>m</var> is <code>Pmode</code> +and <var>exp</var> is usually a constant expression involving <code>symbol_ref</code>. +</p></dd> +</dl> + +<a name="index-CONST0_005fRTX"></a> +<a name="index-CONST1_005fRTX"></a> +<a name="index-CONST2_005fRTX"></a> +<p>The macro <code>CONST0_RTX (<var>mode</var>)</code> refers to an expression with +value 0 in mode <var>mode</var>. If mode <var>mode</var> is of mode class +<code>MODE_INT</code>, it returns <code>const0_rtx</code>. If mode <var>mode</var> is of +mode class <code>MODE_FLOAT</code>, it returns a <code>CONST_DOUBLE</code> +expression in mode <var>mode</var>. Otherwise, it returns a +<code>CONST_VECTOR</code> expression in mode <var>mode</var>. Similarly, the macro +<code>CONST1_RTX (<var>mode</var>)</code> refers to an expression with value 1 in +mode <var>mode</var> and similarly for <code>CONST2_RTX</code>. The +<code>CONST1_RTX</code> and <code>CONST2_RTX</code> macros are undefined +for vector modes. +</p> +<hr> +<div class="header"> +<p> +Next: <a href="Regs-and-Memory.html#Regs-and-Memory" accesskey="n" rel="next">Regs and Memory</a>, Previous: <a href="Machine-Modes.html#Machine-Modes" accesskey="p" rel="previous">Machine Modes</a>, Up: <a href="RTL.html#RTL" accesskey="u" rel="up">RTL</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> |