165 lines
7.2 KiB
HTML
165 lines
7.2 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<!-- Copyright (C) 1988-2016 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: Accessors</title>
|
|
|
|
<meta name="description" content="GNU Compiler Collection (GCC) Internals: Accessors">
|
|
<meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Accessors">
|
|
<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="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.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="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">13.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 a <code>subreg</code> expression, you know that it has
|
|
two operands which can be correctly accessed as <code>XEXP (<var>x</var>, 0)</code>
|
|
and <code>XINT (<var>x</var>, 1)</code>. If you did <code>XINT (<var>x</var>, 0)</code>, you
|
|
would get the address of the expression operand but cast as an integer;
|
|
that might occasionally be useful, but it would be cleaner to write
|
|
<code>(int) XEXP (<var>x</var>, 0)</code>. <code>XEXP (<var>x</var>, 1)</code> would also
|
|
compile without error, and would return the second, integer operand cast as
|
|
an expression pointer, which would probably result in a crash when
|
|
accessed. 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>
|