You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

192 lines
9.7KB

  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-2020 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 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>PowerPC AltiVec/VSX Built-in Functions (Using the GNU Compiler Collection (GCC))</title>
  21. <meta name="description" content="PowerPC AltiVec/VSX Built-in Functions (Using the GNU Compiler Collection (GCC))">
  22. <meta name="keywords" content="PowerPC AltiVec/VSX Built-in Functions (Using the GNU Compiler Collection (GCC))">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  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-Built_002din-Functions-on-ISA-2_002e05.html#PowerPC-AltiVec-Built_002din-Functions-on-ISA-2_002e05" rel="next" title="PowerPC AltiVec Built-in Functions on ISA 2.05">
  31. <link href="Basic-PowerPC-Built_002din-Functions-Available-on-ISA-3_002e0.html#Basic-PowerPC-Built_002din-Functions-Available-on-ISA-3_002e0" rel="prev" title="Basic PowerPC Built-in Functions Available on ISA 3.0">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  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.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="PowerPC-AltiVec_002fVSX-Built_002din-Functions"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="PowerPC-Hardware-Transactional-Memory-Built_002din-Functions.html#PowerPC-Hardware-Transactional-Memory-Built_002din-Functions" accesskey="n" rel="next">PowerPC Hardware Transactional Memory Built-in Functions</a>, Previous: <a href="Basic-PowerPC-Built_002din-Functions.html#Basic-PowerPC-Built_002din-Functions" accesskey="p" rel="prev">Basic PowerPC 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>
  65. </div>
  66. <hr>
  67. <a name="PowerPC-AltiVec_002fVSX-Built_002din-Functions-1"></a>
  68. <h4 class="subsection">6.60.23 PowerPC AltiVec/VSX Built-in Functions</h4>
  69. <p>GCC provides an interface for the PowerPC family of processors to access
  70. the AltiVec operations described in Motorola&rsquo;s AltiVec Programming
  71. Interface Manual. The interface is made available by including
  72. <code>&lt;altivec.h&gt;</code> and using <samp>-maltivec</samp> and
  73. <samp>-mabi=altivec</samp>. The interface supports the following vector
  74. types.
  75. </p>
  76. <div class="smallexample">
  77. <pre class="smallexample">vector unsigned char
  78. vector signed char
  79. vector bool char
  80. vector unsigned short
  81. vector signed short
  82. vector bool short
  83. vector pixel
  84. vector unsigned int
  85. vector signed int
  86. vector bool int
  87. vector float
  88. </pre></div>
  89. <p>GCC&rsquo;s implementation of the high-level language interface available from
  90. C and C++ code differs from Motorola&rsquo;s documentation in several ways.
  91. </p>
  92. <ul>
  93. <li> A vector constant is a list of constant expressions within curly braces.
  94. </li><li> A vector initializer requires no cast if the vector constant is of the
  95. same type as the variable it is initializing.
  96. </li><li> If <code>signed</code> or <code>unsigned</code> is omitted, the signedness of the
  97. vector type is the default signedness of the base type. The default
  98. varies depending on the operating system, so a portable program should
  99. always specify the signedness.
  100. </li><li> Compiling with <samp>-maltivec</samp> adds keywords <code>__vector</code>,
  101. <code>vector</code>, <code>__pixel</code>, <code>pixel</code>, <code>__bool</code> and
  102. <code>bool</code>. When compiling ISO C, the context-sensitive substitution
  103. of the keywords <code>vector</code>, <code>pixel</code> and <code>bool</code> is
  104. disabled. To use them, you must include <code>&lt;altivec.h&gt;</code> instead.
  105. </li><li> GCC allows using a <code>typedef</code> name as the type specifier for a
  106. vector type, but only under the following circumstances:
  107. <ul>
  108. <li> When using <code>__vector</code> instead of <code>vector</code>; for example,
  109. <div class="smallexample">
  110. <pre class="smallexample">typedef signed short int16;
  111. __vector int16 data;
  112. </pre></div>
  113. </li><li> When using <code>vector</code> in keyword-and-predefine mode; for example,
  114. <div class="smallexample">
  115. <pre class="smallexample">typedef signed short int16;
  116. vector int16 data;
  117. </pre></div>
  118. <p>Note that keyword-and-predefine mode is enabled by disabling GNU
  119. extensions (e.g., by using <code>-std=c11</code>) and including
  120. <code>&lt;altivec.h&gt;</code>.
  121. </p></li></ul>
  122. </li><li> For C, overloaded functions are implemented with macros so the following
  123. does not work:
  124. <div class="smallexample">
  125. <pre class="smallexample"> vec_add ((vector signed int){1, 2, 3, 4}, foo);
  126. </pre></div>
  127. <p>Since <code>vec_add</code> is a macro, the vector constant in the example
  128. is treated as four separate arguments. Wrap the entire argument in
  129. parentheses for this to work.
  130. </p></li></ul>
  131. <p><em>Note:</em> Only the <code>&lt;altivec.h&gt;</code> interface is supported.
  132. Internally, GCC uses built-in functions to achieve the functionality in
  133. the aforementioned header file, but they are not supported and are
  134. subject to change without notice.
  135. </p>
  136. <p>GCC complies with the OpenPOWER 64-Bit ELF V2 ABI Specification,
  137. which may be found at
  138. <a href="https://openpowerfoundation.org/?resource_lib=64-bit-elf-v2-abi-specification-power-architecture">https://openpowerfoundation.org/?resource_lib=64-bit-elf-v2-abi-specification-power-architecture</a>.
  139. Appendix A of this document lists the vector API interfaces that must be
  140. provided by compliant compilers. Programmers should preferentially use
  141. the interfaces described therein. However, historically GCC has provided
  142. additional interfaces for access to vector instructions. These are
  143. briefly described below.
  144. </p>
  145. <table class="menu" border="0" cellspacing="0">
  146. <tr><td align="left" valign="top">&bull; <a href="PowerPC-AltiVec-Built_002din-Functions-on-ISA-2_002e05.html#PowerPC-AltiVec-Built_002din-Functions-on-ISA-2_002e05" accesskey="1">PowerPC AltiVec Built-in Functions on ISA 2.05</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  147. </td></tr>
  148. <tr><td align="left" valign="top">&bull; <a href="PowerPC-AltiVec-Built_002din-Functions-Available-on-ISA-2_002e06.html#PowerPC-AltiVec-Built_002din-Functions-Available-on-ISA-2_002e06" accesskey="2">PowerPC AltiVec Built-in Functions Available on ISA 2.06</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  149. </td></tr>
  150. <tr><td align="left" valign="top">&bull; <a href="PowerPC-AltiVec-Built_002din-Functions-Available-on-ISA-2_002e07.html#PowerPC-AltiVec-Built_002din-Functions-Available-on-ISA-2_002e07" accesskey="3">PowerPC AltiVec Built-in Functions Available on ISA 2.07</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  151. </td></tr>
  152. <tr><td align="left" valign="top">&bull; <a href="PowerPC-AltiVec-Built_002din-Functions-Available-on-ISA-3_002e0.html#PowerPC-AltiVec-Built_002din-Functions-Available-on-ISA-3_002e0" accesskey="4">PowerPC AltiVec Built-in Functions Available on ISA 3.0</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  153. </td></tr>
  154. </table>
  155. <hr>
  156. <div class="header">
  157. <p>
  158. Next: <a href="PowerPC-Hardware-Transactional-Memory-Built_002din-Functions.html#PowerPC-Hardware-Transactional-Memory-Built_002din-Functions" accesskey="n" rel="next">PowerPC Hardware Transactional Memory Built-in Functions</a>, Previous: <a href="Basic-PowerPC-Built_002din-Functions.html#Basic-PowerPC-Built_002din-Functions" accesskey="p" rel="prev">Basic PowerPC 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>
  159. </div>
  160. </body>
  161. </html>