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.
125 lines
6.2 KiB
HTML
125 lines
6.2 KiB
HTML
<html lang="en">
|
|
<head>
|
|
<title>Anchored Addresses - GNU Compiler Collection (GCC) Internals</title>
|
|
<meta http-equiv="Content-Type" content="text/html">
|
|
<meta name="description" content="GNU Compiler Collection (GCC) Internals">
|
|
<meta name="generator" content="makeinfo 4.13">
|
|
<link title="Top" rel="start" href="index.html#Top">
|
|
<link rel="up" href="Target-Macros.html#Target-Macros" title="Target Macros">
|
|
<link rel="prev" href="Addressing-Modes.html#Addressing-Modes" title="Addressing Modes">
|
|
<link rel="next" href="Condition-Code.html#Condition-Code" title="Condition Code">
|
|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
|
|
<!--
|
|
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.-->
|
|
<meta http-equiv="Content-Style-Type" content="text/css">
|
|
<style type="text/css"><!--
|
|
pre.display { font-family:inherit }
|
|
pre.format { font-family:inherit }
|
|
pre.smalldisplay { font-family:inherit; font-size:smaller }
|
|
pre.smallformat { font-family:inherit; font-size:smaller }
|
|
pre.smallexample { font-size:smaller }
|
|
pre.smalllisp { font-size:smaller }
|
|
span.sc { font-variant:small-caps }
|
|
span.roman { font-family:serif; font-weight:normal; }
|
|
span.sansserif { font-family:sans-serif; font-weight:normal; }
|
|
--></style>
|
|
</head>
|
|
<body>
|
|
<div class="node">
|
|
<a name="Anchored-Addresses"></a>
|
|
<p>
|
|
Next: <a rel="next" accesskey="n" href="Condition-Code.html#Condition-Code">Condition Code</a>,
|
|
Previous: <a rel="previous" accesskey="p" href="Addressing-Modes.html#Addressing-Modes">Addressing Modes</a>,
|
|
Up: <a rel="up" accesskey="u" href="Target-Macros.html#Target-Macros">Target Macros</a>
|
|
<hr>
|
|
</div>
|
|
|
|
<h3 class="section">17.14 Anchored Addresses</h3>
|
|
|
|
<p><a name="index-anchored-addresses-4421"></a><a name="index-g_t_0040option_007b_002dfsection_002danchors_007d-4422"></a>
|
|
GCC usually addresses every static object as a separate entity.
|
|
For example, if we have:
|
|
|
|
<pre class="smallexample"> static int a, b, c;
|
|
int foo (void) { return a + b + c; }
|
|
</pre>
|
|
<p>the code for <code>foo</code> will usually calculate three separate symbolic
|
|
addresses: those of <code>a</code>, <code>b</code> and <code>c</code>. On some targets,
|
|
it would be better to calculate just one symbolic address and access
|
|
the three variables relative to it. The equivalent pseudocode would
|
|
be something like:
|
|
|
|
<pre class="smallexample"> int foo (void)
|
|
{
|
|
register int *xr = &x;
|
|
return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
|
|
}
|
|
</pre>
|
|
<p>(which isn't valid C). We refer to shared addresses like <code>x</code> as
|
|
“section anchors”. Their use is controlled by <samp><span class="option">-fsection-anchors</span></samp>.
|
|
|
|
<p>The hooks below describe the target properties that GCC needs to know
|
|
in order to make effective use of section anchors. It won't use
|
|
section anchors at all unless either <code>TARGET_MIN_ANCHOR_OFFSET</code>
|
|
or <code>TARGET_MAX_ANCHOR_OFFSET</code> is set to a nonzero value.
|
|
|
|
<div class="defun">
|
|
— Target Hook: HOST_WIDE_INT <b>TARGET_MIN_ANCHOR_OFFSET</b><var><a name="index-TARGET_005fMIN_005fANCHOR_005fOFFSET-4423"></a></var><br>
|
|
<blockquote><p>The minimum offset that should be applied to a section anchor.
|
|
On most targets, it should be the smallest offset that can be
|
|
applied to a base register while still giving a legitimate address
|
|
for every mode. The default value is 0.
|
|
</p></blockquote></div>
|
|
|
|
<div class="defun">
|
|
— Target Hook: HOST_WIDE_INT <b>TARGET_MAX_ANCHOR_OFFSET</b><var><a name="index-TARGET_005fMAX_005fANCHOR_005fOFFSET-4424"></a></var><br>
|
|
<blockquote><p>Like <code>TARGET_MIN_ANCHOR_OFFSET</code>, but the maximum (inclusive)
|
|
offset that should be applied to section anchors. The default
|
|
value is 0.
|
|
</p></blockquote></div>
|
|
|
|
<div class="defun">
|
|
— Target Hook: void <b>TARGET_ASM_OUTPUT_ANCHOR</b> (<var>rtx x</var>)<var><a name="index-TARGET_005fASM_005fOUTPUT_005fANCHOR-4425"></a></var><br>
|
|
<blockquote><p>Write the assembly code to define section anchor <var>x</var>, which is a
|
|
<code>SYMBOL_REF</code> for which ‘<samp><span class="samp">SYMBOL_REF_ANCHOR_P (</span><var>x</var><span class="samp">)</span></samp>’ is true.
|
|
The hook is called with the assembly output position set to the beginning
|
|
of <code>SYMBOL_REF_BLOCK (</code><var>x</var><code>)</code>.
|
|
|
|
<p>If <code>ASM_OUTPUT_DEF</code> is available, the hook's default definition uses
|
|
it to define the symbol as ‘<samp><span class="samp">. + SYMBOL_REF_BLOCK_OFFSET (</span><var>x</var><span class="samp">)</span></samp>’.
|
|
If <code>ASM_OUTPUT_DEF</code> is not available, the hook's default definition
|
|
is <code>NULL</code>, which disables the use of section anchors altogether.
|
|
</p></blockquote></div>
|
|
|
|
<div class="defun">
|
|
— Target Hook: bool <b>TARGET_USE_ANCHORS_FOR_SYMBOL_P</b> (<var>const_rtx x</var>)<var><a name="index-TARGET_005fUSE_005fANCHORS_005fFOR_005fSYMBOL_005fP-4426"></a></var><br>
|
|
<blockquote><p>Return true if GCC should attempt to use anchors to access <code>SYMBOL_REF</code>
|
|
<var>x</var>. You can assume ‘<samp><span class="samp">SYMBOL_REF_HAS_BLOCK_INFO_P (</span><var>x</var><span class="samp">)</span></samp>’ and
|
|
‘<samp><span class="samp">!SYMBOL_REF_ANCHOR_P (</span><var>x</var><span class="samp">)</span></samp>’.
|
|
|
|
<p>The default version is correct for most targets, but you might need to
|
|
intercept this hook to handle things like target-specific attributes
|
|
or target-specific sections.
|
|
</p></blockquote></div>
|
|
|
|
</body></html>
|
|
|