|
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <!-- Copyright (C) 1988-2020 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.5, http://www.gnu.org/software/texinfo/ -->
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Accessors (GNU Compiler Collection (GCC) Internals)</title>
-
- <meta name="description" content="Accessors (GNU Compiler Collection (GCC) Internals)">
- <meta name="keywords" content="Accessors (GNU Compiler Collection (GCC) Internals)">
- <meta name="resource-type" content="document">
- <meta name="distribution" content="global">
- <meta name="Generator" content="makeinfo">
- <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="Special-Accessors.html#Special-Accessors" rel="next" title="Special Accessors">
- <link href="RTL-Classes.html#RTL-Classes" rel="prev" title="RTL Classes">
- <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="Accessors"></a>
- <div class="header">
- <p>
- Next: <a href="Special-Accessors.html#Special-Accessors" accesskey="n" rel="next">Special Accessors</a>, Previous: <a href="RTL-Classes.html#RTL-Classes" accesskey="p" rel="prev">RTL Classes</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="Access-to-Operands"></a>
- <h3 class="section">14.3 Access to Operands</h3>
- <a name="index-accessors"></a>
- <a name="index-access-to-operands"></a>
- <a name="index-operand-access"></a>
-
- <a name="index-XEXP"></a>
- <a name="index-XINT"></a>
- <a name="index-XWINT"></a>
- <a name="index-XSTR"></a>
- <p>Operands of expressions are accessed using the macros <code>XEXP</code>,
- <code>XINT</code>, <code>XWINT</code> and <code>XSTR</code>. Each of these macros takes
- two arguments: an expression-pointer (RTX) and an operand number
- (counting from zero). Thus,
- </p>
- <div class="smallexample">
- <pre class="smallexample">XEXP (<var>x</var>, 2)
- </pre></div>
-
- <p>accesses operand 2 of expression <var>x</var>, as an expression.
- </p>
- <div class="smallexample">
- <pre class="smallexample">XINT (<var>x</var>, 2)
- </pre></div>
-
- <p>accesses the same operand as an integer. <code>XSTR</code>, used in the same
- fashion, would access it as a string.
- </p>
- <p>Any operand can be accessed as an integer, as an expression or as a string.
- You must choose the correct method of access for the kind of value actually
- stored in the operand. You would do this based on the expression code of
- the containing expression. That is also how you would know how many
- operands there are.
- </p>
- <p>For example, if <var>x</var> is an <code>int_list</code> expression, you know that it has
- two operands which can be correctly accessed as <code>XINT (<var>x</var>, 0)</code>
- and <code>XEXP (<var>x</var>, 1)</code>. Incorrect accesses like
- <code>XEXP (<var>x</var>, 0)</code> and <code>XINT (<var>x</var>, 1)</code> would compile,
- but would trigger an internal compiler error when rtl checking is enabled.
- Nothing stops you from writing <code>XEXP (<var>x</var>, 28)</code> either, but
- this will access memory past the end of the expression with
- unpredictable results.
- </p>
- <p>Access to operands which are vectors is more complicated. You can use the
- macro <code>XVEC</code> to get the vector-pointer itself, or the macros
- <code>XVECEXP</code> and <code>XVECLEN</code> to access the elements and length of a
- vector.
- </p>
- <dl compact="compact">
- <dd><a name="index-XVEC"></a>
- </dd>
- <dt><code>XVEC (<var>exp</var>, <var>idx</var>)</code></dt>
- <dd><p>Access the vector-pointer which is operand number <var>idx</var> in <var>exp</var>.
- </p>
- <a name="index-XVECLEN"></a>
- </dd>
- <dt><code>XVECLEN (<var>exp</var>, <var>idx</var>)</code></dt>
- <dd><p>Access the length (number of elements) in the vector which is
- in operand number <var>idx</var> in <var>exp</var>. This value is an <code>int</code>.
- </p>
- <a name="index-XVECEXP"></a>
- </dd>
- <dt><code>XVECEXP (<var>exp</var>, <var>idx</var>, <var>eltnum</var>)</code></dt>
- <dd><p>Access element number <var>eltnum</var> in the vector which is
- in operand number <var>idx</var> in <var>exp</var>. This value is an RTX.
- </p>
- <p>It is up to you to make sure that <var>eltnum</var> is not negative
- and is less than <code>XVECLEN (<var>exp</var>, <var>idx</var>)</code>.
- </p></dd>
- </dl>
-
- <p>All the macros defined in this section expand into lvalues and therefore
- can be used to assign the operands, lengths and vector elements as well as
- to access them.
- </p>
- <hr>
- <div class="header">
- <p>
- Next: <a href="Special-Accessors.html#Special-Accessors" accesskey="n" rel="next">Special Accessors</a>, Previous: <a href="RTL-Classes.html#RTL-Classes" accesskey="p" rel="prev">RTL Classes</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>
|