PowerPC-Built_002din-Functions.html 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  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>Using the GNU Compiler Collection (GCC): PowerPC Built-in Functions</title>
  20. <meta name="description" content="Using the GNU Compiler Collection (GCC): PowerPC Built-in Functions">
  21. <meta name="keywords" content="Using the GNU Compiler Collection (GCC): PowerPC Built-in Functions">
  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-Builtins.html#Target-Builtins" rel="up" title="Target Builtins">
  30. <link href="PowerPC-AltiVec_002fVSX-Built_002din-Functions.html#PowerPC-AltiVec_002fVSX-Built_002din-Functions" rel="next" title="PowerPC AltiVec/VSX Built-in Functions">
  31. <link href="picoChip-Built_002din-Functions.html#picoChip-Built_002din-Functions" rel="prev" title="picoChip Built-in Functions">
  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="PowerPC-Built_002din-Functions"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="PowerPC-AltiVec_002fVSX-Built_002din-Functions.html#PowerPC-AltiVec_002fVSX-Built_002din-Functions" accesskey="n" rel="next">PowerPC AltiVec/VSX Built-in Functions</a>, Previous: <a href="picoChip-Built_002din-Functions.html#picoChip-Built_002din-Functions" accesskey="p" rel="prev">picoChip Built-in Functions</a>, Up: <a href="Target-Builtins.html#Target-Builtins" accesskey="u" rel="up">Target Builtins</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="PowerPC-Built_002din-Functions-1"></a>
  69. <h4 class="subsection">6.60.21 PowerPC Built-in Functions</h4>
  70. <p>The following built-in functions are always available and can be used to
  71. check the PowerPC target platform type:
  72. </p>
  73. <dl>
  74. <dt><a name="index-_005f_005fbuiltin_005fcpu_005finit"></a>Built-in Function: <em>void</em> <strong>__builtin_cpu_init</strong> <em>(void)</em></dt>
  75. <dd><p>This function is a <code>nop</code> on the PowerPC platform and is included solely
  76. to maintain API compatibility with the x86 builtins.
  77. </p></dd></dl>
  78. <dl>
  79. <dt><a name="index-_005f_005fbuiltin_005fcpu_005finit-1"></a>Built-in Function: <em>void</em> <strong>__builtin_cpu_init</strong> <em>(void)</em></dt>
  80. <dd><p>This function is a <code>nop</code> on the PowerPC platform and is included solely
  81. to maintain API compatibility with the x86 builtins.
  82. </p></dd></dl>
  83. <dl>
  84. <dt><a name="index-_005f_005fbuiltin_005fcpu_005fis"></a>Built-in Function: <em>int</em> <strong>__builtin_cpu_is</strong> <em>(const char *<var>cpuname</var>)</em></dt>
  85. <dd><p>This function returns a value of <code>1</code> if the run-time CPU is of type
  86. <var>cpuname</var> and returns <code>0</code> otherwise
  87. </p>
  88. <p>The <code>__builtin_cpu_is</code> function requires GLIBC 2.23 or newer
  89. which exports the hardware capability bits. GCC defines the macro
  90. <code>__BUILTIN_CPU_SUPPORTS__</code> if the <code>__builtin_cpu_supports</code>
  91. built-in function is fully supported.
  92. </p>
  93. <p>If GCC was configured to use a GLIBC before 2.23, the built-in
  94. function <code>__builtin_cpu_is</code> always returns a 0 and the compiler
  95. issues a warning.
  96. </p>
  97. <p>The following CPU names can be detected:
  98. </p>
  99. <dl compact="compact">
  100. <dt>&lsquo;<samp>power9</samp>&rsquo;</dt>
  101. <dd><p>IBM POWER9 Server CPU.
  102. </p></dd>
  103. <dt>&lsquo;<samp>power8</samp>&rsquo;</dt>
  104. <dd><p>IBM POWER8 Server CPU.
  105. </p></dd>
  106. <dt>&lsquo;<samp>power7</samp>&rsquo;</dt>
  107. <dd><p>IBM POWER7 Server CPU.
  108. </p></dd>
  109. <dt>&lsquo;<samp>power6x</samp>&rsquo;</dt>
  110. <dd><p>IBM POWER6 Server CPU (RAW mode).
  111. </p></dd>
  112. <dt>&lsquo;<samp>power6</samp>&rsquo;</dt>
  113. <dd><p>IBM POWER6 Server CPU (Architected mode).
  114. </p></dd>
  115. <dt>&lsquo;<samp>power5+</samp>&rsquo;</dt>
  116. <dd><p>IBM POWER5+ Server CPU.
  117. </p></dd>
  118. <dt>&lsquo;<samp>power5</samp>&rsquo;</dt>
  119. <dd><p>IBM POWER5 Server CPU.
  120. </p></dd>
  121. <dt>&lsquo;<samp>ppc970</samp>&rsquo;</dt>
  122. <dd><p>IBM 970 Server CPU (ie, Apple G5).
  123. </p></dd>
  124. <dt>&lsquo;<samp>power4</samp>&rsquo;</dt>
  125. <dd><p>IBM POWER4 Server CPU.
  126. </p></dd>
  127. <dt>&lsquo;<samp>ppca2</samp>&rsquo;</dt>
  128. <dd><p>IBM A2 64-bit Embedded CPU
  129. </p></dd>
  130. <dt>&lsquo;<samp>ppc476</samp>&rsquo;</dt>
  131. <dd><p>IBM PowerPC 476FP 32-bit Embedded CPU.
  132. </p></dd>
  133. <dt>&lsquo;<samp>ppc464</samp>&rsquo;</dt>
  134. <dd><p>IBM PowerPC 464 32-bit Embedded CPU.
  135. </p></dd>
  136. <dt>&lsquo;<samp>ppc440</samp>&rsquo;</dt>
  137. <dd><p>PowerPC 440 32-bit Embedded CPU.
  138. </p></dd>
  139. <dt>&lsquo;<samp>ppc405</samp>&rsquo;</dt>
  140. <dd><p>PowerPC 405 32-bit Embedded CPU.
  141. </p></dd>
  142. <dt>&lsquo;<samp>ppc-cell-be</samp>&rsquo;</dt>
  143. <dd><p>IBM PowerPC Cell Broadband Engine Architecture CPU.
  144. </p></dd>
  145. </dl>
  146. <p>Here is an example:
  147. </p><div class="smallexample">
  148. <pre class="smallexample">#ifdef __BUILTIN_CPU_SUPPORTS__
  149. if (__builtin_cpu_is (&quot;power8&quot;))
  150. {
  151. do_power8 (); // POWER8 specific implementation.
  152. }
  153. else
  154. #endif
  155. {
  156. do_generic (); // Generic implementation.
  157. }
  158. </pre></div>
  159. </dd></dl>
  160. <dl>
  161. <dt><a name="index-_005f_005fbuiltin_005fcpu_005fsupports"></a>Built-in Function: <em>int</em> <strong>__builtin_cpu_supports</strong> <em>(const char *<var>feature</var>)</em></dt>
  162. <dd><p>This function returns a value of <code>1</code> if the run-time CPU supports the HWCAP
  163. feature <var>feature</var> and returns <code>0</code> otherwise.
  164. </p>
  165. <p>The <code>__builtin_cpu_supports</code> function requires GLIBC 2.23 or
  166. newer which exports the hardware capability bits. GCC defines the
  167. macro <code>__BUILTIN_CPU_SUPPORTS__</code> if the
  168. <code>__builtin_cpu_supports</code> built-in function is fully supported.
  169. </p>
  170. <p>If GCC was configured to use a GLIBC before 2.23, the built-in
  171. function <code>__builtin_cpu_suports</code> always returns a 0 and the
  172. compiler issues a warning.
  173. </p>
  174. <p>The following features can be
  175. detected:
  176. </p>
  177. <dl compact="compact">
  178. <dt>&lsquo;<samp>4xxmac</samp>&rsquo;</dt>
  179. <dd><p>4xx CPU has a Multiply Accumulator.
  180. </p></dd>
  181. <dt>&lsquo;<samp>altivec</samp>&rsquo;</dt>
  182. <dd><p>CPU has a SIMD/Vector Unit.
  183. </p></dd>
  184. <dt>&lsquo;<samp>arch_2_05</samp>&rsquo;</dt>
  185. <dd><p>CPU supports ISA 2.05 (eg, POWER6)
  186. </p></dd>
  187. <dt>&lsquo;<samp>arch_2_06</samp>&rsquo;</dt>
  188. <dd><p>CPU supports ISA 2.06 (eg, POWER7)
  189. </p></dd>
  190. <dt>&lsquo;<samp>arch_2_07</samp>&rsquo;</dt>
  191. <dd><p>CPU supports ISA 2.07 (eg, POWER8)
  192. </p></dd>
  193. <dt>&lsquo;<samp>arch_3_00</samp>&rsquo;</dt>
  194. <dd><p>CPU supports ISA 3.0 (eg, POWER9)
  195. </p></dd>
  196. <dt>&lsquo;<samp>archpmu</samp>&rsquo;</dt>
  197. <dd><p>CPU supports the set of compatible performance monitoring events.
  198. </p></dd>
  199. <dt>&lsquo;<samp>booke</samp>&rsquo;</dt>
  200. <dd><p>CPU supports the Embedded ISA category.
  201. </p></dd>
  202. <dt>&lsquo;<samp>cellbe</samp>&rsquo;</dt>
  203. <dd><p>CPU has a CELL broadband engine.
  204. </p></dd>
  205. <dt>&lsquo;<samp>dfp</samp>&rsquo;</dt>
  206. <dd><p>CPU has a decimal floating point unit.
  207. </p></dd>
  208. <dt>&lsquo;<samp>dscr</samp>&rsquo;</dt>
  209. <dd><p>CPU supports the data stream control register.
  210. </p></dd>
  211. <dt>&lsquo;<samp>ebb</samp>&rsquo;</dt>
  212. <dd><p>CPU supports event base branching.
  213. </p></dd>
  214. <dt>&lsquo;<samp>efpdouble</samp>&rsquo;</dt>
  215. <dd><p>CPU has a SPE double precision floating point unit.
  216. </p></dd>
  217. <dt>&lsquo;<samp>efpsingle</samp>&rsquo;</dt>
  218. <dd><p>CPU has a SPE single precision floating point unit.
  219. </p></dd>
  220. <dt>&lsquo;<samp>fpu</samp>&rsquo;</dt>
  221. <dd><p>CPU has a floating point unit.
  222. </p></dd>
  223. <dt>&lsquo;<samp>htm</samp>&rsquo;</dt>
  224. <dd><p>CPU has hardware transaction memory instructions.
  225. </p></dd>
  226. <dt>&lsquo;<samp>htm-nosc</samp>&rsquo;</dt>
  227. <dd><p>Kernel aborts hardware transactions when a syscall is made.
  228. </p></dd>
  229. <dt>&lsquo;<samp>ic_snoop</samp>&rsquo;</dt>
  230. <dd><p>CPU supports icache snooping capabilities.
  231. </p></dd>
  232. <dt>&lsquo;<samp>ieee128</samp>&rsquo;</dt>
  233. <dd><p>CPU supports 128-bit IEEE binary floating point instructions.
  234. </p></dd>
  235. <dt>&lsquo;<samp>isel</samp>&rsquo;</dt>
  236. <dd><p>CPU supports the integer select instruction.
  237. </p></dd>
  238. <dt>&lsquo;<samp>mmu</samp>&rsquo;</dt>
  239. <dd><p>CPU has a memory management unit.
  240. </p></dd>
  241. <dt>&lsquo;<samp>notb</samp>&rsquo;</dt>
  242. <dd><p>CPU does not have a timebase (eg, 601 and 403gx).
  243. </p></dd>
  244. <dt>&lsquo;<samp>pa6t</samp>&rsquo;</dt>
  245. <dd><p>CPU supports the PA Semi 6T CORE ISA.
  246. </p></dd>
  247. <dt>&lsquo;<samp>power4</samp>&rsquo;</dt>
  248. <dd><p>CPU supports ISA 2.00 (eg, POWER4)
  249. </p></dd>
  250. <dt>&lsquo;<samp>power5</samp>&rsquo;</dt>
  251. <dd><p>CPU supports ISA 2.02 (eg, POWER5)
  252. </p></dd>
  253. <dt>&lsquo;<samp>power5+</samp>&rsquo;</dt>
  254. <dd><p>CPU supports ISA 2.03 (eg, POWER5+)
  255. </p></dd>
  256. <dt>&lsquo;<samp>power6x</samp>&rsquo;</dt>
  257. <dd><p>CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
  258. </p></dd>
  259. <dt>&lsquo;<samp>ppc32</samp>&rsquo;</dt>
  260. <dd><p>CPU supports 32-bit mode execution.
  261. </p></dd>
  262. <dt>&lsquo;<samp>ppc601</samp>&rsquo;</dt>
  263. <dd><p>CPU supports the old POWER ISA (eg, 601)
  264. </p></dd>
  265. <dt>&lsquo;<samp>ppc64</samp>&rsquo;</dt>
  266. <dd><p>CPU supports 64-bit mode execution.
  267. </p></dd>
  268. <dt>&lsquo;<samp>ppcle</samp>&rsquo;</dt>
  269. <dd><p>CPU supports a little-endian mode that uses address swizzling.
  270. </p></dd>
  271. <dt>&lsquo;<samp>smt</samp>&rsquo;</dt>
  272. <dd><p>CPU support simultaneous multi-threading.
  273. </p></dd>
  274. <dt>&lsquo;<samp>spe</samp>&rsquo;</dt>
  275. <dd><p>CPU has a signal processing extension unit.
  276. </p></dd>
  277. <dt>&lsquo;<samp>tar</samp>&rsquo;</dt>
  278. <dd><p>CPU supports the target address register.
  279. </p></dd>
  280. <dt>&lsquo;<samp>true_le</samp>&rsquo;</dt>
  281. <dd><p>CPU supports true little-endian mode.
  282. </p></dd>
  283. <dt>&lsquo;<samp>ucache</samp>&rsquo;</dt>
  284. <dd><p>CPU has unified I/D cache.
  285. </p></dd>
  286. <dt>&lsquo;<samp>vcrypto</samp>&rsquo;</dt>
  287. <dd><p>CPU supports the vector cryptography instructions.
  288. </p></dd>
  289. <dt>&lsquo;<samp>vsx</samp>&rsquo;</dt>
  290. <dd><p>CPU supports the vector-scalar extension.
  291. </p></dd>
  292. </dl>
  293. <p>Here is an example:
  294. </p><div class="smallexample">
  295. <pre class="smallexample">#ifdef __BUILTIN_CPU_SUPPORTS__
  296. if (__builtin_cpu_supports (&quot;fpu&quot;))
  297. {
  298. asm(&quot;fadd %0,%1,%2&quot; : &quot;=d&quot;(dst) : &quot;d&quot;(src1), &quot;d&quot;(src2));
  299. }
  300. else
  301. #endif
  302. {
  303. dst = __fadd (src1, src2); // Software FP addition function.
  304. }
  305. </pre></div>
  306. </dd></dl>
  307. <p>These built-in functions are available for the PowerPC family of
  308. processors:
  309. </p><div class="smallexample">
  310. <pre class="smallexample">float __builtin_recipdivf (float, float);
  311. float __builtin_rsqrtf (float);
  312. double __builtin_recipdiv (double, double);
  313. double __builtin_rsqrt (double);
  314. uint64_t __builtin_ppc_get_timebase ();
  315. unsigned long __builtin_ppc_mftb ();
  316. double __builtin_unpack_longdouble (long double, int);
  317. long double __builtin_pack_longdouble (double, double);
  318. </pre></div>
  319. <p>The <code>vec_rsqrt</code>, <code>__builtin_rsqrt</code>, and
  320. <code>__builtin_rsqrtf</code> functions generate multiple instructions to
  321. implement the reciprocal sqrt functionality using reciprocal sqrt
  322. estimate instructions.
  323. </p>
  324. <p>The <code>__builtin_recipdiv</code>, and <code>__builtin_recipdivf</code>
  325. functions generate multiple instructions to implement division using
  326. the reciprocal estimate instructions.
  327. </p>
  328. <p>The <code>__builtin_ppc_get_timebase</code> and <code>__builtin_ppc_mftb</code>
  329. functions generate instructions to read the Time Base Register. The
  330. <code>__builtin_ppc_get_timebase</code> function may generate multiple
  331. instructions and always returns the 64 bits of the Time Base Register.
  332. The <code>__builtin_ppc_mftb</code> function always generates one instruction and
  333. returns the Time Base Register value as an unsigned long, throwing away
  334. the most significant word on 32-bit environments.
  335. </p>
  336. <p>Additional built-in functions are available for the 64-bit PowerPC
  337. family of processors, for efficient use of 128-bit floating point
  338. (<code>__float128</code>) values.
  339. </p>
  340. <p>The following floating-point built-in functions are available with
  341. <code>-mfloat128</code> and Altivec support. All of them implement the
  342. function that is part of the name.
  343. </p>
  344. <div class="smallexample">
  345. <pre class="smallexample">__float128 __builtin_fabsq (__float128)
  346. __float128 __builtin_copysignq (__float128, __float128)
  347. </pre></div>
  348. <p>The following built-in functions are available with <code>-mfloat128</code>
  349. and Altivec support.
  350. </p>
  351. <dl compact="compact">
  352. <dt><code>__float128 __builtin_infq (void)</code></dt>
  353. <dd><p>Similar to <code>__builtin_inf</code>, except the return type is <code>__float128</code>.
  354. <a name="index-_005f_005fbuiltin_005finfq"></a>
  355. </p>
  356. </dd>
  357. <dt><code>__float128 __builtin_huge_valq (void)</code></dt>
  358. <dd><p>Similar to <code>__builtin_huge_val</code>, except the return type is <code>__float128</code>.
  359. <a name="index-_005f_005fbuiltin_005fhuge_005fvalq"></a>
  360. </p>
  361. </dd>
  362. <dt><code>__float128 __builtin_nanq (void)</code></dt>
  363. <dd><p>Similar to <code>__builtin_nan</code>, except the return type is <code>__float128</code>.
  364. <a name="index-_005f_005fbuiltin_005fnanq"></a>
  365. </p>
  366. </dd>
  367. <dt><code>__float128 __builtin_nansq (void)</code></dt>
  368. <dd><p>Similar to <code>__builtin_nans</code>, except the return type is <code>__float128</code>.
  369. <a name="index-_005f_005fbuiltin_005fnansq"></a>
  370. </p></dd>
  371. </dl>
  372. <p>The following built-in functions are available for the PowerPC family
  373. of processors, starting with ISA 2.06 or later (<samp>-mcpu=power7</samp>
  374. or <samp>-mpopcntd</samp>):
  375. </p><div class="smallexample">
  376. <pre class="smallexample">long __builtin_bpermd (long, long);
  377. int __builtin_divwe (int, int);
  378. unsigned int __builtin_divweu (unsigned int, unsigned int);
  379. long __builtin_divde (long, long);
  380. unsigned long __builtin_divdeu (unsigned long, unsigned long);
  381. unsigned int cdtbcd (unsigned int);
  382. unsigned int cbcdtd (unsigned int);
  383. unsigned int addg6s (unsigned int, unsigned int);
  384. </pre></div>
  385. <p>The <code>__builtin_divde</code> and <code>__builtin_divdeu</code> functions
  386. require a 64-bit environment supporting ISA 2.06 or later.
  387. </p>
  388. <p>The following built-in functions are available for the PowerPC family
  389. of processors, starting with ISA 3.0 or later (<samp>-mcpu=power9</samp>):
  390. </p><div class="smallexample">
  391. <pre class="smallexample">long long __builtin_darn (void);
  392. long long __builtin_darn_raw (void);
  393. int __builtin_darn_32 (void);
  394. unsigned int scalar_extract_exp (double source);
  395. unsigned long long int scalar_extract_sig (double source);
  396. double
  397. scalar_insert_exp (unsigned long long int significand, unsigned long long int exponent);
  398. double
  399. scalar_insert_exp (double significand, unsigned long long int exponent);
  400. int scalar_cmp_exp_gt (double arg1, double arg2);
  401. int scalar_cmp_exp_lt (double arg1, double arg2);
  402. int scalar_cmp_exp_eq (double arg1, double arg2);
  403. int scalar_cmp_exp_unordered (double arg1, double arg2);
  404. bool scalar_test_data_class (float source, const int condition);
  405. bool scalar_test_data_class (double source, const int condition);
  406. bool scalar_test_neg (float source);
  407. bool scalar_test_neg (double source);
  408. int __builtin_byte_in_set (unsigned char u, unsigned long long set);
  409. int __builtin_byte_in_range (unsigned char u, unsigned int range);
  410. int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
  411. int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
  412. int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
  413. int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
  414. int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
  415. int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
  416. int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
  417. int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
  418. int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
  419. int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
  420. int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
  421. int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
  422. int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
  423. int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
  424. int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
  425. int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
  426. int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
  427. </pre></div>
  428. <p>The <code>__builtin_darn</code> and <code>__builtin_darn_raw</code>
  429. functions require a
  430. 64-bit environment supporting ISA 3.0 or later.
  431. The <code>__builtin_darn</code> function provides a 64-bit conditioned
  432. random number. The <code>__builtin_darn_raw</code> function provides a
  433. 64-bit raw random number. The <code>__builtin_darn_32</code> function
  434. provides a 32-bit random number.
  435. </p>
  436. <p>The <code>scalar_extract_exp</code> and <code>scalar_extract_sig</code>
  437. functions require a 64-bit environment supporting ISA 3.0 or later.
  438. The <code>scalar_extract_exp</code> and <code>scalar_extract_sig</code> built-in
  439. functions return the significand and the biased exponent value
  440. respectively of their <code>source</code> arguments.
  441. Within the result returned by <code>scalar_extract_sig</code>,
  442. the <code>0x10000000000000</code> bit is set if the
  443. function&rsquo;s <code>source</code> argument is in normalized form.
  444. Otherwise, this bit is set to 0.
  445. Note that the sign of the significand is not represented in the result
  446. returned from the <code>scalar_extract_sig</code> function. Use the
  447. <code>scalar_test_neg</code> function to test the sign of its <code>double</code>
  448. argument.
  449. </p>
  450. <p>The <code>scalar_insert_exp</code>
  451. function requires a 64-bit environment supporting ISA 3.0 or later.
  452. The <code>scalar_insert_exp</code> built-in function returns a double-precision
  453. floating point value that is constructed by assembling the values of its
  454. <code>significand</code> and <code>exponent</code> arguments. The sign of the
  455. result is copied from the most significant bit of the
  456. <code>significand</code> argument. The significand and exponent components
  457. of the result are composed of the least significant 11 bits of the
  458. <code>exponent</code> argument and the least significant 52 bits of the
  459. <code>significand</code> argument.
  460. </p>
  461. <p>The <code>scalar_cmp_exp_gt</code>, <code>scalar_cmp_exp_lt</code>,
  462. <code>scalar_cmp_exp_eq</code>, and <code>scalar_cmp_exp_unordered</code> built-in
  463. functions return a non-zero value if <code>arg1</code> is greater than, less
  464. than, equal to, or not comparable to <code>arg2</code> respectively. The
  465. arguments are not comparable if one or the other equals NaN (not a
  466. number).
  467. </p>
  468. <p>The <code>scalar_test_data_class</code> built-in function returns 1
  469. if any of the condition tests enabled by the value of the
  470. <code>condition</code> variable are true, and 0 otherwise. The
  471. <code>condition</code> argument must be a compile-time constant integer with
  472. value not exceeding 127. The
  473. <code>condition</code> argument is encoded as a bitmask with each bit
  474. enabling the testing of a different condition, as characterized by the
  475. following:
  476. </p><div class="smallexample">
  477. <pre class="smallexample">0x40 Test for NaN
  478. 0x20 Test for +Infinity
  479. 0x10 Test for -Infinity
  480. 0x08 Test for +Zero
  481. 0x04 Test for -Zero
  482. 0x02 Test for +Denormal
  483. 0x01 Test for -Denormal
  484. </pre></div>
  485. <p>The <code>scalar_test_neg</code> built-in function returns 1 if its
  486. <code>source</code> argument holds a negative value, 0 otherwise.
  487. </p>
  488. <p>The <code>__builtin_byte_in_set</code> function requires a
  489. 64-bit environment supporting ISA 3.0 or later. This function returns
  490. a non-zero value if and only if its <code>u</code> argument exactly equals one of
  491. the eight bytes contained within its 64-bit <code>set</code> argument.
  492. </p>
  493. <p>The <code>__builtin_byte_in_range</code> and
  494. <code>__builtin_byte_in_either_range</code> require an environment
  495. supporting ISA 3.0 or later. For these two functions, the
  496. <code>range</code> argument is encoded as 4 bytes, organized as
  497. <code>hi_1:lo_1:hi_2:lo_2</code>.
  498. The <code>__builtin_byte_in_range</code> function returns a
  499. non-zero value if and only if its <code>u</code> argument is within the
  500. range bounded between <code>lo_2</code> and <code>hi_2</code> inclusive.
  501. The <code>__builtin_byte_in_either_range</code> function returns non-zero if
  502. and only if its <code>u</code> argument is within either the range bounded
  503. between <code>lo_1</code> and <code>hi_1</code> inclusive or the range bounded
  504. between <code>lo_2</code> and <code>hi_2</code> inclusive.
  505. </p>
  506. <p>The <code>__builtin_dfp_dtstsfi_lt</code> function returns a non-zero value
  507. if and only if the number of signficant digits of its <code>value</code> argument
  508. is less than its <code>comparison</code> argument. The
  509. <code>__builtin_dfp_dtstsfi_lt_dd</code> and
  510. <code>__builtin_dfp_dtstsfi_lt_td</code> functions behave similarly, but
  511. require that the type of the <code>value</code> argument be
  512. <code>__Decimal64</code> and <code>__Decimal128</code> respectively.
  513. </p>
  514. <p>The <code>__builtin_dfp_dtstsfi_gt</code> function returns a non-zero value
  515. if and only if the number of signficant digits of its <code>value</code> argument
  516. is greater than its <code>comparison</code> argument. The
  517. <code>__builtin_dfp_dtstsfi_gt_dd</code> and
  518. <code>__builtin_dfp_dtstsfi_gt_td</code> functions behave similarly, but
  519. require that the type of the <code>value</code> argument be
  520. <code>__Decimal64</code> and <code>__Decimal128</code> respectively.
  521. </p>
  522. <p>The <code>__builtin_dfp_dtstsfi_eq</code> function returns a non-zero value
  523. if and only if the number of signficant digits of its <code>value</code> argument
  524. equals its <code>comparison</code> argument. The
  525. <code>__builtin_dfp_dtstsfi_eq_dd</code> and
  526. <code>__builtin_dfp_dtstsfi_eq_td</code> functions behave similarly, but
  527. require that the type of the <code>value</code> argument be
  528. <code>__Decimal64</code> and <code>__Decimal128</code> respectively.
  529. </p>
  530. <p>The <code>__builtin_dfp_dtstsfi_ov</code> function returns a non-zero value
  531. if and only if its <code>value</code> argument has an undefined number of
  532. significant digits, such as when <code>value</code> is an encoding of <code>NaN</code>.
  533. The <code>__builtin_dfp_dtstsfi_ov_dd</code> and
  534. <code>__builtin_dfp_dtstsfi_ov_td</code> functions behave similarly, but
  535. require that the type of the <code>value</code> argument be
  536. <code>__Decimal64</code> and <code>__Decimal128</code> respectively.
  537. </p>
  538. <p>The following built-in functions are also available for the PowerPC family
  539. of processors, starting with ISA 3.0 or later
  540. (<samp>-mcpu=power9</samp>). These string functions are described
  541. separately in order to group the descriptions closer to the function
  542. prototypes:
  543. </p><div class="smallexample">
  544. <pre class="smallexample">int vec_all_nez (vector signed char, vector signed char);
  545. int vec_all_nez (vector unsigned char, vector unsigned char);
  546. int vec_all_nez (vector signed short, vector signed short);
  547. int vec_all_nez (vector unsigned short, vector unsigned short);
  548. int vec_all_nez (vector signed int, vector signed int);
  549. int vec_all_nez (vector unsigned int, vector unsigned int);
  550. int vec_any_eqz (vector signed char, vector signed char);
  551. int vec_any_eqz (vector unsigned char, vector unsigned char);
  552. int vec_any_eqz (vector signed short, vector signed short);
  553. int vec_any_eqz (vector unsigned short, vector unsigned short);
  554. int vec_any_eqz (vector signed int, vector signed int);
  555. int vec_any_eqz (vector unsigned int, vector unsigned int);
  556. vector bool char vec_cmpnez (vector signed char arg1, vector signed char arg2);
  557. vector bool char vec_cmpnez (vector unsigned char arg1, vector unsigned char arg2);
  558. vector bool short vec_cmpnez (vector signed short arg1, vector signed short arg2);
  559. vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short arg2);
  560. vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
  561. vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
  562. signed int vec_cntlz_lsbb (vector signed char);
  563. signed int vec_cntlz_lsbb (vector unsigned char);
  564. signed int vec_cnttz_lsbb (vector signed char);
  565. signed int vec_cnttz_lsbb (vector unsigned char);
  566. vector signed char vec_xl_len (signed char *addr, size_t len);
  567. vector unsigned char vec_xl_len (unsigned char *addr, size_t len);
  568. vector signed int vec_xl_len (signed int *addr, size_t len);
  569. vector unsigned int vec_xl_len (unsigned int *addr, size_t len);
  570. vector signed __int128 vec_xl_len (signed __int128 *addr, size_t len);
  571. vector unsigned __int128 vec_xl_len (unsigned __int128 *addr, size_t len);
  572. vector signed long long vec_xl_len (signed long long *addr, size_t len);
  573. vector unsigned long long vec_xl_len (unsigned long long *addr, size_t len);
  574. vector signed short vec_xl_len (signed short *addr, size_t len);
  575. vector unsigned short vec_xl_len (unsigned short *addr, size_t len);
  576. vector double vec_xl_len (double *addr, size_t len);
  577. vector float vec_xl_len (float *addr, size_t len);
  578. void vec_xst_len (vector signed char data, signed char *addr, size_t len);
  579. void vec_xst_len (vector unsigned char data, unsigned char *addr, size_t len);
  580. void vec_xst_len (vector signed int data, signed int *addr, size_t len);
  581. void vec_xst_len (vector unsigned int data, unsigned int *addr, size_t len);
  582. void vec_xst_len (vector unsigned __int128 data, unsigned __int128 *addr, size_t len);
  583. void vec_xst_len (vector signed long long data, signed long long *addr, size_t len);
  584. void vec_xst_len (vector unsigned long long data, unsigned long long *addr, size_t len);
  585. void vec_xst_len (vector signed short data, signed short *addr, size_t len);
  586. void vec_xst_len (vector unsigned short data, unsigned short *addr, size_t len);
  587. void vec_xst_len (vector signed __int128 data, signed __int128 *addr, size_t len);
  588. void vec_xst_len (vector double data, double *addr, size_t len);
  589. void vec_xst_len (vector float data, float *addr, size_t len);
  590. signed char vec_xlx (unsigned int index, vector signed char data);
  591. unsigned char vec_xlx (unsigned int index, vector unsigned char data);
  592. signed short vec_xlx (unsigned int index, vector signed short data);
  593. unsigned short vec_xlx (unsigned int index, vector unsigned short data);
  594. signed int vec_xlx (unsigned int index, vector signed int data);
  595. unsigned int vec_xlx (unsigned int index, vector unsigned int data);
  596. float vec_xlx (unsigned int index, vector float data);
  597. signed char vec_xrx (unsigned int index, vector signed char data);
  598. unsigned char vec_xrx (unsigned int index, vector unsigned char data);
  599. signed short vec_xrx (unsigned int index, vector signed short data);
  600. unsigned short vec_xrx (unsigned int index, vector unsigned short data);
  601. signed int vec_xrx (unsigned int index, vector signed int data);
  602. unsigned int vec_xrx (unsigned int index, vector unsigned int data);
  603. float vec_xrx (unsigned int index, vector float data);
  604. </pre></div>
  605. <p>The <code>vec_all_nez</code>, <code>vec_any_eqz</code>, and <code>vec_cmpnez</code>
  606. perform pairwise comparisons between the elements at the same
  607. positions within their two vector arguments.
  608. The <code>vec_all_nez</code> function returns a
  609. non-zero value if and only if all pairwise comparisons are not
  610. equal and no element of either vector argument contains a zero.
  611. The <code>vec_any_eqz</code> function returns a
  612. non-zero value if and only if at least one pairwise comparison is equal
  613. or if at least one element of either vector argument contains a zero.
  614. The <code>vec_cmpnez</code> function returns a vector of the same type as
  615. its two arguments, within which each element consists of all ones to
  616. denote that either the corresponding elements of the incoming arguments are
  617. not equal or that at least one of the corresponding elements contains
  618. zero. Otherwise, the element of the returned vector contains all zeros.
  619. </p>
  620. <p>The <code>vec_cntlz_lsbb</code> function returns the count of the number of
  621. consecutive leading byte elements (starting from position 0 within the
  622. supplied vector argument) for which the least-significant bit
  623. equals zero. The <code>vec_cnttz_lsbb</code> function returns the count of
  624. the number of consecutive trailing byte elements (starting from
  625. position 15 and counting backwards within the supplied vector
  626. argument) for which the least-significant bit equals zero.
  627. </p>
  628. <p>The <code>vec_xl_len</code> and <code>vec_xst_len</code> functions require a
  629. 64-bit environment supporting ISA 3.0 or later. The <code>vec_xl_len</code>
  630. function loads a variable length vector from memory. The
  631. <code>vec_xst_len</code> function stores a variable length vector to memory.
  632. With both the <code>vec_xl_len</code> and <code>vec_xst_len</code> functions, the
  633. <code>addr</code> argument represents the memory address to or from which
  634. data will be transferred, and the
  635. <code>len</code> argument represents the number of bytes to be
  636. transferred, as computed by the C expression <code>min((len &amp; 0xff), 16)</code>.
  637. If this expression&rsquo;s value is not a multiple of the vector element&rsquo;s
  638. size, the behavior of this function is undefined.
  639. In the case that the underlying computer is configured to run in
  640. big-endian mode, the data transfer moves bytes 0 to <code>(len - 1)</code> of
  641. the corresponding vector. In little-endian mode, the data transfer
  642. moves bytes <code>(16 - len)</code> to <code>15</code> of the corresponding
  643. vector. For the load function, any bytes of the result vector that
  644. are not loaded from memory are set to zero.
  645. The value of the <code>addr</code> argument need not be aligned on a
  646. multiple of the vector&rsquo;s element size.
  647. </p>
  648. <p>The <code>vec_xlx</code> and <code>vec_xrx</code> functions extract the single
  649. element selected by the <code>index</code> argument from the vector
  650. represented by the <code>data</code> argument. The <code>index</code> argument
  651. always specifies a byte offset, regardless of the size of the vector
  652. element. With <code>vec_xlx</code>, <code>index</code> is the offset of the first
  653. byte of the element to be extracted. With <code>vec_xrx</code>, <code>index</code>
  654. represents the last byte of the element to be extracted, measured
  655. from the right end of the vector. In other words, the last byte of
  656. the element to be extracted is found at position <code>(15 - index)</code>.
  657. There is no requirement that <code>index</code> be a multiple of the vector
  658. element size. However, if the size of the vector element added to
  659. <code>index</code> is greater than 15, the content of the returned value is
  660. undefined.
  661. </p>
  662. <p>The following built-in functions are available for the PowerPC family
  663. of processors when hardware decimal floating point
  664. (<samp>-mhard-dfp</samp>) is available:
  665. </p><div class="smallexample">
  666. <pre class="smallexample">long long __builtin_dxex (_Decimal64);
  667. long long __builtin_dxexq (_Decimal128);
  668. _Decimal64 __builtin_ddedpd (int, _Decimal64);
  669. _Decimal128 __builtin_ddedpdq (int, _Decimal128);
  670. _Decimal64 __builtin_denbcd (int, _Decimal64);
  671. _Decimal128 __builtin_denbcdq (int, _Decimal128);
  672. _Decimal64 __builtin_diex (long long, _Decimal64);
  673. _Decimal128 _builtin_diexq (long long, _Decimal128);
  674. _Decimal64 __builtin_dscli (_Decimal64, int);
  675. _Decimal128 __builtin_dscliq (_Decimal128, int);
  676. _Decimal64 __builtin_dscri (_Decimal64, int);
  677. _Decimal128 __builtin_dscriq (_Decimal128, int);
  678. unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
  679. _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
  680. </pre></div>
  681. <p>The following built-in functions are available for the PowerPC family
  682. of processors when the Vector Scalar (vsx) instruction set is
  683. available:
  684. </p><div class="smallexample">
  685. <pre class="smallexample">unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
  686. vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
  687. unsigned long long);
  688. </pre></div>
  689. <hr>
  690. <div class="header">
  691. <p>
  692. Next: <a href="PowerPC-AltiVec_002fVSX-Built_002din-Functions.html#PowerPC-AltiVec_002fVSX-Built_002din-Functions" accesskey="n" rel="next">PowerPC AltiVec/VSX Built-in Functions</a>, Previous: <a href="picoChip-Built_002din-Functions.html#picoChip-Built_002din-Functions" accesskey="p" rel="prev">picoChip Built-in Functions</a>, Up: <a href="Target-Builtins.html#Target-Builtins" accesskey="u" rel="up">Target Builtins</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>
  693. </div>
  694. </body>
  695. </html>