blob: fb6c16d924edc32a445c54ab9abaec48a3b5677a [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1988-2015 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.2, 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="prev" 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="prev">Machine Modes</a>, Up: <a href="RTL.html#RTL" accesskey="u" rel="up">RTL</a> &nbsp; [<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">13.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> &hellip;)</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&rsquo;s or host machine&rsquo;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_005fWIDE_005fINT"></a>
</dd>
<dt><code>(const_wide_int:<var>m</var> <var>nunits</var> <var>elt0</var> &hellip;)</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_NUNITS (<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> &hellip;)</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_005fvector"></a>
</dd>
<dt><code>(const_vector:<var>m</var> [<var>x0</var> <var>x1</var> &hellip;])</code></dt>
<dd><p>Represents a vector constant. The square brackets stand for the vector
containing the constant elements. <var>x0</var>, <var>x1</var> and so on are
the <code>const_int</code>, <code>const_double</code> or <code>const_fixed</code> elements.
</p>
<p>The number of units in a <code>const_vector</code> is obtained with the macro
<code>CONST_VECTOR_NUNITS</code> as in <code>CONST_VECTOR_NUNITS (<var>v</var>)</code>.
</p>
<p>Individual elements in a vector constant are accessed with the macro
<code>CONST_VECTOR_ELT</code> as in <code>CONST_VECTOR_ELT (<var>v</var>, <var>n</var>)</code>
where <var>v</var> is the vector constant and <var>n</var> is the element
desired.
</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 &lsquo;<samp>*</samp>&rsquo;, the label is the rest of <var>symbol</var> not including
the &lsquo;<samp>*</samp>&rsquo;. Otherwise, the label is <var>symbol</var>, usually prefixed
with &lsquo;<samp>_</samp>&rsquo;.
</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>, is an expression that
contains only constants (<code>const_int</code>, <code>symbol_ref</code> and
<code>label_ref</code> expressions) combined with <code>plus</code> and
<code>minus</code>. However, not all combinations are valid, since the
assembler cannot do arbitrary arithmetic on relocatable symbols.
</p>
<p><var>m</var> should be <code>Pmode</code>.
</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>, usually a
<code>symbol_ref</code>. 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 a global memory location.
</p>
<p><var>m</var> should be <code>Pmode</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="prev">Machine Modes</a>, Up: <a href="RTL.html#RTL" accesskey="u" rel="up">RTL</a> &nbsp; [<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>