Addressing-Modes.html 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2017 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>GNU Compiler Collection (GCC) Internals: Addressing Modes</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Addressing Modes">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Addressing Modes">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Target-Macros.html#Target-Macros" rel="up" title="Target Macros">
  30. <link href="Anchored-Addresses.html#Anchored-Addresses" rel="next" title="Anchored Addresses">
  31. <link href="Library-Calls.html#Library-Calls" rel="prev" title="Library Calls">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style:oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="Addressing-Modes"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Anchored-Addresses.html#Anchored-Addresses" accesskey="n" rel="next">Anchored Addresses</a>, Previous: <a href="Library-Calls.html#Library-Calls" accesskey="p" rel="prev">Library Calls</a>, Up: <a href="Target-Macros.html#Target-Macros" accesskey="u" rel="up">Target Macros</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>
  66. </div>
  67. <hr>
  68. <a name="Addressing-Modes-1"></a>
  69. <h3 class="section">17.13 Addressing Modes</h3>
  70. <a name="index-addressing-modes"></a>
  71. <p>This is about addressing modes.
  72. </p>
  73. <dl>
  74. <dt><a name="index-HAVE_005fPRE_005fINCREMENT"></a>Macro: <strong>HAVE_PRE_INCREMENT</strong></dt>
  75. <dt><a name="index-HAVE_005fPRE_005fDECREMENT"></a>Macro: <strong>HAVE_PRE_DECREMENT</strong></dt>
  76. <dt><a name="index-HAVE_005fPOST_005fINCREMENT"></a>Macro: <strong>HAVE_POST_INCREMENT</strong></dt>
  77. <dt><a name="index-HAVE_005fPOST_005fDECREMENT"></a>Macro: <strong>HAVE_POST_DECREMENT</strong></dt>
  78. <dd><p>A C expression that is nonzero if the machine supports pre-increment,
  79. pre-decrement, post-increment, or post-decrement addressing respectively.
  80. </p></dd></dl>
  81. <dl>
  82. <dt><a name="index-HAVE_005fPRE_005fMODIFY_005fDISP"></a>Macro: <strong>HAVE_PRE_MODIFY_DISP</strong></dt>
  83. <dt><a name="index-HAVE_005fPOST_005fMODIFY_005fDISP"></a>Macro: <strong>HAVE_POST_MODIFY_DISP</strong></dt>
  84. <dd><p>A C expression that is nonzero if the machine supports pre- or
  85. post-address side-effect generation involving constants other than
  86. the size of the memory operand.
  87. </p></dd></dl>
  88. <dl>
  89. <dt><a name="index-HAVE_005fPRE_005fMODIFY_005fREG"></a>Macro: <strong>HAVE_PRE_MODIFY_REG</strong></dt>
  90. <dt><a name="index-HAVE_005fPOST_005fMODIFY_005fREG"></a>Macro: <strong>HAVE_POST_MODIFY_REG</strong></dt>
  91. <dd><p>A C expression that is nonzero if the machine supports pre- or
  92. post-address side-effect generation involving a register displacement.
  93. </p></dd></dl>
  94. <dl>
  95. <dt><a name="index-CONSTANT_005fADDRESS_005fP"></a>Macro: <strong>CONSTANT_ADDRESS_P</strong> <em>(<var>x</var>)</em></dt>
  96. <dd><p>A C expression that is 1 if the RTX <var>x</var> is a constant which
  97. is a valid address. On most machines the default definition of
  98. <code>(CONSTANT_P (<var>x</var>) &amp;&amp; GET_CODE (<var>x</var>) != CONST_DOUBLE)</code>
  99. is acceptable, but a few machines are more restrictive as to which
  100. constant addresses are supported.
  101. </p></dd></dl>
  102. <dl>
  103. <dt><a name="index-CONSTANT_005fP"></a>Macro: <strong>CONSTANT_P</strong> <em>(<var>x</var>)</em></dt>
  104. <dd><p><code>CONSTANT_P</code>, which is defined by target-independent code,
  105. accepts integer-values expressions whose values are not explicitly
  106. known, such as <code>symbol_ref</code>, <code>label_ref</code>, and <code>high</code>
  107. expressions and <code>const</code> arithmetic expressions, in addition to
  108. <code>const_int</code> and <code>const_double</code> expressions.
  109. </p></dd></dl>
  110. <dl>
  111. <dt><a name="index-MAX_005fREGS_005fPER_005fADDRESS"></a>Macro: <strong>MAX_REGS_PER_ADDRESS</strong></dt>
  112. <dd><p>A number, the maximum number of registers that can appear in a valid
  113. memory address. Note that it is up to you to specify a value equal to
  114. the maximum number that <code>TARGET_LEGITIMATE_ADDRESS_P</code> would ever
  115. accept.
  116. </p></dd></dl>
  117. <dl>
  118. <dt><a name="index-TARGET_005fLEGITIMATE_005fADDRESS_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_LEGITIMATE_ADDRESS_P</strong> <em>(machine_mode <var>mode</var>, rtx <var>x</var>, bool <var>strict</var>)</em></dt>
  119. <dd><p>A function that returns whether <var>x</var> (an RTX) is a legitimate memory
  120. address on the target machine for a memory operand of mode <var>mode</var>.
  121. </p>
  122. <p>Legitimate addresses are defined in two variants: a strict variant and a
  123. non-strict one. The <var>strict</var> parameter chooses which variant is
  124. desired by the caller.
  125. </p>
  126. <p>The strict variant is used in the reload pass. It must be defined so
  127. that any pseudo-register that has not been allocated a hard register is
  128. considered a memory reference. This is because in contexts where some
  129. kind of register is required, a pseudo-register with no hard register
  130. must be rejected. For non-hard registers, the strict variant should look
  131. up the <code>reg_renumber</code> array; it should then proceed using the hard
  132. register number in the array, or treat the pseudo as a memory reference
  133. if the array holds <code>-1</code>.
  134. </p>
  135. <p>The non-strict variant is used in other passes. It must be defined to
  136. accept all pseudo-registers in every context where some kind of
  137. register is required.
  138. </p>
  139. <p>Normally, constant addresses which are the sum of a <code>symbol_ref</code>
  140. and an integer are stored inside a <code>const</code> RTX to mark them as
  141. constant. Therefore, there is no need to recognize such sums
  142. specifically as legitimate addresses. Normally you would simply
  143. recognize any <code>const</code> as legitimate.
  144. </p>
  145. <p>Usually <code>PRINT_OPERAND_ADDRESS</code> is not prepared to handle constant
  146. sums that are not marked with <code>const</code>. It assumes that a naked
  147. <code>plus</code> indicates indexing. If so, then you <em>must</em> reject such
  148. naked constant sums as illegitimate addresses, so that none of them will
  149. be given to <code>PRINT_OPERAND_ADDRESS</code>.
  150. </p>
  151. <a name="index-TARGET_005fENCODE_005fSECTION_005fINFO-and-address-validation"></a>
  152. <p>On some machines, whether a symbolic address is legitimate depends on
  153. the section that the address refers to. On these machines, define the
  154. target hook <code>TARGET_ENCODE_SECTION_INFO</code> to store the information
  155. into the <code>symbol_ref</code>, and then check for it here. When you see a
  156. <code>const</code>, you will have to look inside it to find the
  157. <code>symbol_ref</code> in order to determine the section. See <a href="Assembler-Format.html#Assembler-Format">Assembler Format</a>.
  158. </p>
  159. <a name="index-GO_005fIF_005fLEGITIMATE_005fADDRESS"></a>
  160. <p>Some ports are still using a deprecated legacy substitute for
  161. this hook, the <code>GO_IF_LEGITIMATE_ADDRESS</code> macro. This macro
  162. has this syntax:
  163. </p>
  164. <div class="example">
  165. <pre class="example">#define GO_IF_LEGITIMATE_ADDRESS (<var>mode</var>, <var>x</var>, <var>label</var>)
  166. </pre></div>
  167. <p>and should <code>goto <var>label</var></code> if the address <var>x</var> is a valid
  168. address on the target machine for a memory operand of mode <var>mode</var>.
  169. </p>
  170. <a name="index-REG_005fOK_005fSTRICT"></a>
  171. <p>Compiler source files that want to use the strict variant of this
  172. macro define the macro <code>REG_OK_STRICT</code>. You should use an
  173. <code>#ifdef REG_OK_STRICT</code> conditional to define the strict variant in
  174. that case and the non-strict variant otherwise.
  175. </p>
  176. <p>Using the hook is usually simpler because it limits the number of
  177. files that are recompiled when changes are made.
  178. </p></dd></dl>
  179. <dl>
  180. <dt><a name="index-TARGET_005fMEM_005fCONSTRAINT"></a>Macro: <strong>TARGET_MEM_CONSTRAINT</strong></dt>
  181. <dd><p>A single character to be used instead of the default <code>'m'</code>
  182. character for general memory addresses. This defines the constraint
  183. letter which matches the memory addresses accepted by
  184. <code>TARGET_LEGITIMATE_ADDRESS_P</code>. Define this macro if you want to
  185. support new address formats in your back end without changing the
  186. semantics of the <code>'m'</code> constraint. This is necessary in order to
  187. preserve functionality of inline assembly constructs using the
  188. <code>'m'</code> constraint.
  189. </p></dd></dl>
  190. <dl>
  191. <dt><a name="index-FIND_005fBASE_005fTERM"></a>Macro: <strong>FIND_BASE_TERM</strong> <em>(<var>x</var>)</em></dt>
  192. <dd><p>A C expression to determine the base term of address <var>x</var>,
  193. or to provide a simplified version of <var>x</var> from which <samp>alias.c</samp>
  194. can easily find the base term. This macro is used in only two places:
  195. <code>find_base_value</code> and <code>find_base_term</code> in <samp>alias.c</samp>.
  196. </p>
  197. <p>It is always safe for this macro to not be defined. It exists so
  198. that alias analysis can understand machine-dependent addresses.
  199. </p>
  200. <p>The typical use of this macro is to handle addresses containing
  201. a label_ref or symbol_ref within an UNSPEC.
  202. </p></dd></dl>
  203. <dl>
  204. <dt><a name="index-TARGET_005fLEGITIMIZE_005fADDRESS"></a>Target Hook: <em>rtx</em> <strong>TARGET_LEGITIMIZE_ADDRESS</strong> <em>(rtx <var>x</var>, rtx <var>oldx</var>, machine_mode <var>mode</var>)</em></dt>
  205. <dd><p>This hook is given an invalid memory address <var>x</var> for an
  206. operand of mode <var>mode</var> and should try to return a valid memory
  207. address.
  208. </p>
  209. <a name="index-break_005fout_005fmemory_005frefs"></a>
  210. <p><var>x</var> will always be the result of a call to <code>break_out_memory_refs</code>,
  211. and <var>oldx</var> will be the operand that was given to that function to produce
  212. <var>x</var>.
  213. </p>
  214. <p>The code of the hook should not alter the substructure of
  215. <var>x</var>. If it transforms <var>x</var> into a more legitimate form, it
  216. should return the new <var>x</var>.
  217. </p>
  218. <p>It is not necessary for this hook to come up with a legitimate address,
  219. with the exception of native TLS addresses (see <a href="Emulated-TLS.html#Emulated-TLS">Emulated TLS</a>).
  220. The compiler has standard ways of doing so in all cases. In fact, if
  221. the target supports only emulated TLS, it
  222. is safe to omit this hook or make it return <var>x</var> if it cannot find
  223. a valid way to legitimize the address. But often a machine-dependent
  224. strategy can generate better code.
  225. </p></dd></dl>
  226. <dl>
  227. <dt><a name="index-LEGITIMIZE_005fRELOAD_005fADDRESS"></a>Macro: <strong>LEGITIMIZE_RELOAD_ADDRESS</strong> <em>(<var>x</var>, <var>mode</var>, <var>opnum</var>, <var>type</var>, <var>ind_levels</var>, <var>win</var>)</em></dt>
  228. <dd><p>A C compound statement that attempts to replace <var>x</var>, which is an address
  229. that needs reloading, with a valid memory address for an operand of mode
  230. <var>mode</var>. <var>win</var> will be a C statement label elsewhere in the code.
  231. It is not necessary to define this macro, but it might be useful for
  232. performance reasons.
  233. </p>
  234. <p>For example, on the i386, it is sometimes possible to use a single
  235. reload register instead of two by reloading a sum of two pseudo
  236. registers into a register. On the other hand, for number of RISC
  237. processors offsets are limited so that often an intermediate address
  238. needs to be generated in order to address a stack slot. By defining
  239. <code>LEGITIMIZE_RELOAD_ADDRESS</code> appropriately, the intermediate addresses
  240. generated for adjacent some stack slots can be made identical, and thus
  241. be shared.
  242. </p>
  243. <p><em>Note</em>: This macro should be used with caution. It is necessary
  244. to know something of how reload works in order to effectively use this,
  245. and it is quite easy to produce macros that build in too much knowledge
  246. of reload internals.
  247. </p>
  248. <p><em>Note</em>: This macro must be able to reload an address created by a
  249. previous invocation of this macro. If it fails to handle such addresses
  250. then the compiler may generate incorrect code or abort.
  251. </p>
  252. <a name="index-push_005freload"></a>
  253. <p>The macro definition should use <code>push_reload</code> to indicate parts that
  254. need reloading; <var>opnum</var>, <var>type</var> and <var>ind_levels</var> are usually
  255. suitable to be passed unaltered to <code>push_reload</code>.
  256. </p>
  257. <p>The code generated by this macro must not alter the substructure of
  258. <var>x</var>. If it transforms <var>x</var> into a more legitimate form, it
  259. should assign <var>x</var> (which will always be a C variable) a new value.
  260. This also applies to parts that you change indirectly by calling
  261. <code>push_reload</code>.
  262. </p>
  263. <a name="index-strict_005fmemory_005faddress_005fp"></a>
  264. <p>The macro definition may use <code>strict_memory_address_p</code> to test if
  265. the address has become legitimate.
  266. </p>
  267. <a name="index-copy_005frtx"></a>
  268. <p>If you want to change only a part of <var>x</var>, one standard way of doing
  269. this is to use <code>copy_rtx</code>. Note, however, that it unshares only a
  270. single level of rtl. Thus, if the part to be changed is not at the
  271. top level, you&rsquo;ll need to replace first the top level.
  272. It is not necessary for this macro to come up with a legitimate
  273. address; but often a machine-dependent strategy can generate better code.
  274. </p></dd></dl>
  275. <dl>
  276. <dt><a name="index-TARGET_005fMODE_005fDEPENDENT_005fADDRESS_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_MODE_DEPENDENT_ADDRESS_P</strong> <em>(const_rtx <var>addr</var>, addr_space_t <var>addrspace</var>)</em></dt>
  277. <dd><p>This hook returns <code>true</code> if memory address <var>addr</var> in address
  278. space <var>addrspace</var> can have
  279. different meanings depending on the machine mode of the memory
  280. reference it is used for or if the address is valid for some modes
  281. but not others.
  282. </p>
  283. <p>Autoincrement and autodecrement addresses typically have mode-dependent
  284. effects because the amount of the increment or decrement is the size
  285. of the operand being addressed. Some machines have other mode-dependent
  286. addresses. Many RISC machines have no mode-dependent addresses.
  287. </p>
  288. <p>You may assume that <var>addr</var> is a valid address for the machine.
  289. </p>
  290. <p>The default version of this hook returns <code>false</code>.
  291. </p></dd></dl>
  292. <dl>
  293. <dt><a name="index-TARGET_005fLEGITIMATE_005fCONSTANT_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_LEGITIMATE_CONSTANT_P</strong> <em>(machine_mode <var>mode</var>, rtx <var>x</var>)</em></dt>
  294. <dd><p>This hook returns true if <var>x</var> is a legitimate constant for a
  295. <var>mode</var>-mode immediate operand on the target machine. You can assume that
  296. <var>x</var> satisfies <code>CONSTANT_P</code>, so you need not check this.
  297. </p>
  298. <p>The default definition returns true.
  299. </p></dd></dl>
  300. <dl>
  301. <dt><a name="index-TARGET_005fDELEGITIMIZE_005fADDRESS"></a>Target Hook: <em>rtx</em> <strong>TARGET_DELEGITIMIZE_ADDRESS</strong> <em>(rtx <var>x</var>)</em></dt>
  302. <dd><p>This hook is used to undo the possibly obfuscating effects of the
  303. <code>LEGITIMIZE_ADDRESS</code> and <code>LEGITIMIZE_RELOAD_ADDRESS</code> target
  304. macros. Some backend implementations of these macros wrap symbol
  305. references inside an <code>UNSPEC</code> rtx to represent PIC or similar
  306. addressing modes. This target hook allows GCC&rsquo;s optimizers to understand
  307. the semantics of these opaque <code>UNSPEC</code>s by converting them back
  308. into their original form.
  309. </p></dd></dl>
  310. <dl>
  311. <dt><a name="index-TARGET_005fCONST_005fNOT_005fOK_005fFOR_005fDEBUG_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_CONST_NOT_OK_FOR_DEBUG_P</strong> <em>(rtx <var>x</var>)</em></dt>
  312. <dd><p>This hook should return true if <var>x</var> should not be emitted into
  313. debug sections.
  314. </p></dd></dl>
  315. <dl>
  316. <dt><a name="index-TARGET_005fCANNOT_005fFORCE_005fCONST_005fMEM"></a>Target Hook: <em>bool</em> <strong>TARGET_CANNOT_FORCE_CONST_MEM</strong> <em>(machine_mode <var>mode</var>, rtx <var>x</var>)</em></dt>
  317. <dd><p>This hook should return true if <var>x</var> is of a form that cannot (or
  318. should not) be spilled to the constant pool. <var>mode</var> is the mode
  319. of <var>x</var>.
  320. </p>
  321. <p>The default version of this hook returns false.
  322. </p>
  323. <p>The primary reason to define this hook is to prevent reload from
  324. deciding that a non-legitimate constant would be better reloaded
  325. from the constant pool instead of spilling and reloading a register
  326. holding the constant. This restriction is often true of addresses
  327. of TLS symbols for various targets.
  328. </p></dd></dl>
  329. <dl>
  330. <dt><a name="index-TARGET_005fUSE_005fBLOCKS_005fFOR_005fCONSTANT_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_USE_BLOCKS_FOR_CONSTANT_P</strong> <em>(machine_mode <var>mode</var>, const_rtx <var>x</var>)</em></dt>
  331. <dd><p>This hook should return true if pool entries for constant <var>x</var> can
  332. be placed in an <code>object_block</code> structure. <var>mode</var> is the mode
  333. of <var>x</var>.
  334. </p>
  335. <p>The default version returns false for all constants.
  336. </p></dd></dl>
  337. <dl>
  338. <dt><a name="index-TARGET_005fUSE_005fBLOCKS_005fFOR_005fDECL_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_USE_BLOCKS_FOR_DECL_P</strong> <em>(const_tree <var>decl</var>)</em></dt>
  339. <dd><p>This hook should return true if pool entries for <var>decl</var> should
  340. be placed in an <code>object_block</code> structure.
  341. </p>
  342. <p>The default version returns true for all decls.
  343. </p></dd></dl>
  344. <dl>
  345. <dt><a name="index-TARGET_005fBUILTIN_005fRECIPROCAL"></a>Target Hook: <em>tree</em> <strong>TARGET_BUILTIN_RECIPROCAL</strong> <em>(tree <var>fndecl</var>)</em></dt>
  346. <dd><p>This hook should return the DECL of a function that implements the
  347. reciprocal of the machine-specific builtin function <var>fndecl</var>, or
  348. <code>NULL_TREE</code> if such a function is not available.
  349. </p></dd></dl>
  350. <dl>
  351. <dt><a name="index-TARGET_005fVECTORIZE_005fBUILTIN_005fMASK_005fFOR_005fLOAD"></a>Target Hook: <em>tree</em> <strong>TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD</strong> <em>(void)</em></dt>
  352. <dd><p>This hook should return the DECL of a function <var>f</var> that given an
  353. address <var>addr</var> as an argument returns a mask <var>m</var> that can be
  354. used to extract from two vectors the relevant data that resides in
  355. <var>addr</var> in case <var>addr</var> is not properly aligned.
  356. </p>
  357. <p>The autovectorizer, when vectorizing a load operation from an address
  358. <var>addr</var> that may be unaligned, will generate two vector loads from
  359. the two aligned addresses around <var>addr</var>. It then generates a
  360. <code>REALIGN_LOAD</code> operation to extract the relevant data from the
  361. two loaded vectors. The first two arguments to <code>REALIGN_LOAD</code>,
  362. <var>v1</var> and <var>v2</var>, are the two vectors, each of size <var>VS</var>, and
  363. the third argument, <var>OFF</var>, defines how the data will be extracted
  364. from these two vectors: if <var>OFF</var> is 0, then the returned vector is
  365. <var>v2</var>; otherwise, the returned vector is composed from the last
  366. <var>VS</var>-<var>OFF</var> elements of <var>v1</var> concatenated to the first
  367. <var>OFF</var> elements of <var>v2</var>.
  368. </p>
  369. <p>If this hook is defined, the autovectorizer will generate a call
  370. to <var>f</var> (using the DECL tree that this hook returns) and will
  371. use the return value of <var>f</var> as the argument <var>OFF</var> to
  372. <code>REALIGN_LOAD</code>. Therefore, the mask <var>m</var> returned by <var>f</var>
  373. should comply with the semantics expected by <code>REALIGN_LOAD</code>
  374. described above.
  375. If this hook is not defined, then <var>addr</var> will be used as
  376. the argument <var>OFF</var> to <code>REALIGN_LOAD</code>, in which case the low
  377. log2(<var>VS</var>) - 1 bits of <var>addr</var> will be considered.
  378. </p></dd></dl>
  379. <dl>
  380. <dt><a name="index-TARGET_005fVECTORIZE_005fBUILTIN_005fVECTORIZATION_005fCOST"></a>Target Hook: <em>int</em> <strong>TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST</strong> <em>(enum vect_cost_for_stmt <var>type_of_cost</var>, tree <var>vectype</var>, int <var>misalign</var>)</em></dt>
  381. <dd><p>Returns cost of different scalar or vector statements for vectorization cost model.
  382. For vector memory operations the cost may depend on type (<var>vectype</var>) and
  383. misalignment value (<var>misalign</var>).
  384. </p></dd></dl>
  385. <dl>
  386. <dt><a name="index-TARGET_005fVECTORIZE_005fVECTOR_005fALIGNMENT_005fREACHABLE"></a>Target Hook: <em>bool</em> <strong>TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE</strong> <em>(const_tree <var>type</var>, bool <var>is_packed</var>)</em></dt>
  387. <dd><p>Return true if vector alignment is reachable (by peeling N iterations) for the given scalar type <var>type</var>. <var>is_packed</var> is false if the scalar access using <var>type</var> is known to be naturally aligned.
  388. </p></dd></dl>
  389. <dl>
  390. <dt><a name="index-TARGET_005fVECTORIZE_005fVEC_005fPERM_005fCONST_005fOK"></a>Target Hook: <em>bool</em> <strong>TARGET_VECTORIZE_VEC_PERM_CONST_OK</strong> <em>(machine_mode, const unsigned char *<var>sel</var>)</em></dt>
  391. <dd><p>Return true if a vector created for <code>vec_perm_const</code> is valid.
  392. </p></dd></dl>
  393. <dl>
  394. <dt><a name="index-TARGET_005fVECTORIZE_005fBUILTIN_005fCONVERSION"></a>Target Hook: <em>tree</em> <strong>TARGET_VECTORIZE_BUILTIN_CONVERSION</strong> <em>(unsigned <var>code</var>, tree <var>dest_type</var>, tree <var>src_type</var>)</em></dt>
  395. <dd><p>This hook should return the DECL of a function that implements conversion of the
  396. input vector of type <var>src_type</var> to type <var>dest_type</var>.
  397. The value of <var>code</var> is one of the enumerators in <code>enum tree_code</code> and
  398. specifies how the conversion is to be applied
  399. (truncation, rounding, etc.).
  400. </p>
  401. <p>If this hook is defined, the autovectorizer will use the
  402. <code>TARGET_VECTORIZE_BUILTIN_CONVERSION</code> target hook when vectorizing
  403. conversion. Otherwise, it will return <code>NULL_TREE</code>.
  404. </p></dd></dl>
  405. <dl>
  406. <dt><a name="index-TARGET_005fVECTORIZE_005fBUILTIN_005fVECTORIZED_005fFUNCTION"></a>Target Hook: <em>tree</em> <strong>TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION</strong> <em>(unsigned <var>code</var>, tree <var>vec_type_out</var>, tree <var>vec_type_in</var>)</em></dt>
  407. <dd><p>This hook should return the decl of a function that implements the
  408. vectorized variant of the function with the <code>combined_fn</code> code
  409. <var>code</var> or <code>NULL_TREE</code> if such a function is not available.
  410. The return type of the vectorized function shall be of vector type
  411. <var>vec_type_out</var> and the argument types should be <var>vec_type_in</var>.
  412. </p></dd></dl>
  413. <dl>
  414. <dt><a name="index-TARGET_005fVECTORIZE_005fBUILTIN_005fMD_005fVECTORIZED_005fFUNCTION"></a>Target Hook: <em>tree</em> <strong>TARGET_VECTORIZE_BUILTIN_MD_VECTORIZED_FUNCTION</strong> <em>(tree <var>fndecl</var>, tree <var>vec_type_out</var>, tree <var>vec_type_in</var>)</em></dt>
  415. <dd><p>This hook should return the decl of a function that implements the
  416. vectorized variant of target built-in function <code>fndecl</code>. The
  417. return type of the vectorized function shall be of vector type
  418. <var>vec_type_out</var> and the argument types should be <var>vec_type_in</var>.
  419. </p></dd></dl>
  420. <dl>
  421. <dt><a name="index-TARGET_005fVECTORIZE_005fSUPPORT_005fVECTOR_005fMISALIGNMENT"></a>Target Hook: <em>bool</em> <strong>TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT</strong> <em>(machine_mode <var>mode</var>, const_tree <var>type</var>, int <var>misalignment</var>, bool <var>is_packed</var>)</em></dt>
  422. <dd><p>This hook should return true if the target supports misaligned vector
  423. store/load of a specific factor denoted in the <var>misalignment</var>
  424. parameter. The vector store/load should be of machine mode <var>mode</var> and
  425. the elements in the vectors should be of type <var>type</var>. <var>is_packed</var>
  426. parameter is true if the memory access is defined in a packed struct.
  427. </p></dd></dl>
  428. <dl>
  429. <dt><a name="index-TARGET_005fVECTORIZE_005fPREFERRED_005fSIMD_005fMODE"></a>Target Hook: <em>machine_mode</em> <strong>TARGET_VECTORIZE_PREFERRED_SIMD_MODE</strong> <em>(machine_mode <var>mode</var>)</em></dt>
  430. <dd><p>This hook should return the preferred mode for vectorizing scalar
  431. mode <var>mode</var>. The default is
  432. equal to <code>word_mode</code>, because the vectorizer can do some
  433. transformations even in absence of specialized <acronym>SIMD</acronym> hardware.
  434. </p></dd></dl>
  435. <dl>
  436. <dt><a name="index-TARGET_005fVECTORIZE_005fAUTOVECTORIZE_005fVECTOR_005fSIZES"></a>Target Hook: <em>unsigned int</em> <strong>TARGET_VECTORIZE_AUTOVECTORIZE_VECTOR_SIZES</strong> <em>(void)</em></dt>
  437. <dd><p>This hook should return a mask of sizes that should be iterated over
  438. after trying to autovectorize using the vector size derived from the
  439. mode returned by <code>TARGET_VECTORIZE_PREFERRED_SIMD_MODE</code>.
  440. The default is zero which means to not iterate over other vector sizes.
  441. </p></dd></dl>
  442. <dl>
  443. <dt><a name="index-TARGET_005fVECTORIZE_005fGET_005fMASK_005fMODE"></a>Target Hook: <em>machine_mode</em> <strong>TARGET_VECTORIZE_GET_MASK_MODE</strong> <em>(unsigned <var>nunits</var>, unsigned <var>length</var>)</em></dt>
  444. <dd><p>This hook returns mode to be used for a mask to be used for a vector
  445. of specified <var>length</var> with <var>nunits</var> elements. By default an integer
  446. vector mode of a proper size is returned.
  447. </p></dd></dl>
  448. <dl>
  449. <dt><a name="index-TARGET_005fVECTORIZE_005fINIT_005fCOST"></a>Target Hook: <em>void *</em> <strong>TARGET_VECTORIZE_INIT_COST</strong> <em>(struct loop *<var>loop_info</var>)</em></dt>
  450. <dd><p>This hook should initialize target-specific data structures in preparation for modeling the costs of vectorizing a loop or basic block. The default allocates three unsigned integers for accumulating costs for the prologue, body, and epilogue of the loop or basic block. If <var>loop_info</var> is non-NULL, it identifies the loop being vectorized; otherwise a single block is being vectorized.
  451. </p></dd></dl>
  452. <dl>
  453. <dt><a name="index-TARGET_005fVECTORIZE_005fADD_005fSTMT_005fCOST"></a>Target Hook: <em>unsigned</em> <strong>TARGET_VECTORIZE_ADD_STMT_COST</strong> <em>(void *<var>data</var>, int <var>count</var>, enum vect_cost_for_stmt <var>kind</var>, struct _stmt_vec_info *<var>stmt_info</var>, int <var>misalign</var>, enum vect_cost_model_location <var>where</var>)</em></dt>
  454. <dd><p>This hook should update the target-specific <var>data</var> in response to adding <var>count</var> copies of the given <var>kind</var> of statement to a loop or basic block. The default adds the builtin vectorizer cost for the copies of the statement to the accumulator specified by <var>where</var>, (the prologue, body, or epilogue) and returns the amount added. The return value should be viewed as a tentative cost that may later be revised.
  455. </p></dd></dl>
  456. <dl>
  457. <dt><a name="index-TARGET_005fVECTORIZE_005fFINISH_005fCOST"></a>Target Hook: <em>void</em> <strong>TARGET_VECTORIZE_FINISH_COST</strong> <em>(void *<var>data</var>, unsigned *<var>prologue_cost</var>, unsigned *<var>body_cost</var>, unsigned *<var>epilogue_cost</var>)</em></dt>
  458. <dd><p>This hook should complete calculations of the cost of vectorizing a loop or basic block based on <var>data</var>, and return the prologue, body, and epilogue costs as unsigned integers. The default returns the value of the three accumulators.
  459. </p></dd></dl>
  460. <dl>
  461. <dt><a name="index-TARGET_005fVECTORIZE_005fDESTROY_005fCOST_005fDATA"></a>Target Hook: <em>void</em> <strong>TARGET_VECTORIZE_DESTROY_COST_DATA</strong> <em>(void *<var>data</var>)</em></dt>
  462. <dd><p>This hook should release <var>data</var> and any related data structures allocated by TARGET_VECTORIZE_INIT_COST. The default releases the accumulator.
  463. </p></dd></dl>
  464. <dl>
  465. <dt><a name="index-TARGET_005fVECTORIZE_005fBUILTIN_005fGATHER"></a>Target Hook: <em>tree</em> <strong>TARGET_VECTORIZE_BUILTIN_GATHER</strong> <em>(const_tree <var>mem_vectype</var>, const_tree <var>index_type</var>, int <var>scale</var>)</em></dt>
  466. <dd><p>Target builtin that implements vector gather operation. <var>mem_vectype</var>
  467. is the vector type of the load and <var>index_type</var> is scalar type of
  468. the index, scaled by <var>scale</var>.
  469. The default is <code>NULL_TREE</code> which means to not vectorize gather
  470. loads.
  471. </p></dd></dl>
  472. <dl>
  473. <dt><a name="index-TARGET_005fVECTORIZE_005fBUILTIN_005fSCATTER"></a>Target Hook: <em>tree</em> <strong>TARGET_VECTORIZE_BUILTIN_SCATTER</strong> <em>(const_tree <var>vectype</var>, const_tree <var>index_type</var>, int <var>scale</var>)</em></dt>
  474. <dd><p>Target builtin that implements vector scatter operation. <var>vectype</var>
  475. is the vector type of the store and <var>index_type</var> is scalar type of
  476. the index, scaled by <var>scale</var>.
  477. The default is <code>NULL_TREE</code> which means to not vectorize scatter
  478. stores.
  479. </p></dd></dl>
  480. <dl>
  481. <dt><a name="index-TARGET_005fSIMD_005fCLONE_005fCOMPUTE_005fVECSIZE_005fAND_005fSIMDLEN"></a>Target Hook: <em>int</em> <strong>TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN</strong> <em>(struct cgraph_node *<var></var>, struct cgraph_simd_clone *<var></var>, <var>tree</var>, <var>int</var>)</em></dt>
  482. <dd><p>This hook should set <var>vecsize_mangle</var>, <var>vecsize_int</var>, <var>vecsize_float</var>
  483. fields in <var>simd_clone</var> structure pointed by <var>clone_info</var> argument and also
  484. <var>simdlen</var> field if it was previously 0.
  485. The hook should return 0 if SIMD clones shouldn&rsquo;t be emitted,
  486. or number of <var>vecsize_mangle</var> variants that should be emitted.
  487. </p></dd></dl>
  488. <dl>
  489. <dt><a name="index-TARGET_005fSIMD_005fCLONE_005fADJUST"></a>Target Hook: <em>void</em> <strong>TARGET_SIMD_CLONE_ADJUST</strong> <em>(struct cgraph_node *<var></var>)</em></dt>
  490. <dd><p>This hook should add implicit <code>attribute(target(&quot;...&quot;))</code> attribute
  491. to SIMD clone <var>node</var> if needed.
  492. </p></dd></dl>
  493. <dl>
  494. <dt><a name="index-TARGET_005fSIMD_005fCLONE_005fUSABLE"></a>Target Hook: <em>int</em> <strong>TARGET_SIMD_CLONE_USABLE</strong> <em>(struct cgraph_node *<var></var>)</em></dt>
  495. <dd><p>This hook should return -1 if SIMD clone <var>node</var> shouldn&rsquo;t be used
  496. in vectorized loops in current function, or non-negative number if it is
  497. usable. In that case, the smaller the number is, the more desirable it is
  498. to use it.
  499. </p></dd></dl>
  500. <dl>
  501. <dt><a name="index-TARGET_005fSIMT_005fVF"></a>Target Hook: <em>int</em> <strong>TARGET_SIMT_VF</strong> <em>(void)</em></dt>
  502. <dd><p>Return number of threads in SIMT thread group on the target.
  503. </p></dd></dl>
  504. <dl>
  505. <dt><a name="index-TARGET_005fGOACC_005fVALIDATE_005fDIMS"></a>Target Hook: <em>bool</em> <strong>TARGET_GOACC_VALIDATE_DIMS</strong> <em>(tree <var>decl</var>, int *<var>dims</var>, int <var>fn_level</var>)</em></dt>
  506. <dd><p>This hook should check the launch dimensions provided for an OpenACC
  507. compute region, or routine. Defaulted values are represented as -1
  508. and non-constant values as 0. The <var>fn_level</var> is negative for the
  509. function corresponding to the compute region. For a routine is is the
  510. outermost level at which partitioned execution may be spawned. The hook
  511. should verify non-default values. If DECL is NULL, global defaults
  512. are being validated and unspecified defaults should be filled in.
  513. Diagnostics should be issued as appropriate. Return
  514. true, if changes have been made. You must override this hook to
  515. provide dimensions larger than 1.
  516. </p></dd></dl>
  517. <dl>
  518. <dt><a name="index-TARGET_005fGOACC_005fDIM_005fLIMIT"></a>Target Hook: <em>int</em> <strong>TARGET_GOACC_DIM_LIMIT</strong> <em>(int <var>axis</var>)</em></dt>
  519. <dd><p>This hook should return the maximum size of a particular dimension,
  520. or zero if unbounded.
  521. </p></dd></dl>
  522. <dl>
  523. <dt><a name="index-TARGET_005fGOACC_005fFORK_005fJOIN"></a>Target Hook: <em>bool</em> <strong>TARGET_GOACC_FORK_JOIN</strong> <em>(gcall *<var>call</var>, const int *<var>dims</var>, bool <var>is_fork</var>)</em></dt>
  524. <dd><p>This hook can be used to convert IFN_GOACC_FORK and IFN_GOACC_JOIN
  525. function calls to target-specific gimple, or indicate whether they
  526. should be retained. It is executed during the oacc_device_lower pass.
  527. It should return true, if the call should be retained. It should
  528. return false, if it is to be deleted (either because target-specific
  529. gimple has been inserted before it, or there is no need for it).
  530. The default hook returns false, if there are no RTL expanders for them.
  531. </p></dd></dl>
  532. <dl>
  533. <dt><a name="index-TARGET_005fGOACC_005fREDUCTION"></a>Target Hook: <em>void</em> <strong>TARGET_GOACC_REDUCTION</strong> <em>(gcall *<var>call</var>)</em></dt>
  534. <dd><p>This hook is used by the oacc_transform pass to expand calls to the
  535. <var>GOACC_REDUCTION</var> internal function, into a sequence of gimple
  536. instructions. <var>call</var> is gimple statement containing the call to
  537. the function. This hook removes statement <var>call</var> after the
  538. expanded sequence has been inserted. This hook is also responsible
  539. for allocating any storage for reductions when necessary.
  540. </p></dd></dl>
  541. <hr>
  542. <div class="header">
  543. <p>
  544. Next: <a href="Anchored-Addresses.html#Anchored-Addresses" accesskey="n" rel="next">Anchored Addresses</a>, Previous: <a href="Library-Calls.html#Library-Calls" accesskey="p" rel="prev">Library Calls</a>, Up: <a href="Target-Macros.html#Target-Macros" accesskey="u" rel="up">Target Macros</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>
  545. </div>
  546. </body>
  547. </html>