1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AMDGPU Instruction Syntax — LLVM 13 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/llvm-theme.css" type="text/css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="AMDGPU Instructions Notation" href="AMDGPUInstructionNotation.html" />
<link rel="prev" title="Syntax of AMDGPU Instruction Operands" href="AMDGPUOperandSyntax.html" />
<style type="text/css">
table.right { float: right; margin-left: 20px; }
table.right td { border: 1px solid #ccc; }
</style>
</head><body>
<div class="logo">
<a href="index.html">
<img src="_static/logo.png"
alt="LLVM Logo" width="250" height="88"/></a>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="AMDGPUInstructionNotation.html" title="AMDGPU Instructions Notation"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="AMDGPUOperandSyntax.html" title="Syntax of AMDGPU Instruction Operands"
accesskey="P">previous</a> |</li>
<li><a href="https://llvm.org/">LLVM Home</a> | </li>
<li><a href="index.html">Documentation</a>»</li>
<li class="nav-item nav-item-1"><a href="UserGuides.html" >User Guides</a> »</li>
<li class="nav-item nav-item-2"><a href="AMDGPUUsage.html" accesskey="U">User Guide for AMDGPU Backend</a> »</li>
<li class="nav-item nav-item-this"><a href="">AMDGPU Instruction Syntax</a></li>
</ul>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3>Documentation</h3>
<ul class="want-points">
<li><a href="https://llvm.org/docs/GettingStartedTutorials.html">Getting Started/Tutorials</a></li>
<li><a href="https://llvm.org/docs/UserGuides.html">User Guides</a></li>
<li><a href="https://llvm.org/docs/Reference.html">Reference</a></li>
</ul>
<h3>Getting Involved</h3>
<ul class="want-points">
<li><a href="https://llvm.org/docs/Contributing.html">Contributing to LLVM</a></li>
<li><a href="https://llvm.org/docs/HowToSubmitABug.html">Submitting Bug Reports</a></li>
<li><a href="https://llvm.org/docs/GettingInvolved.html#mailing-lists">Mailing Lists</a></li>
<li><a href="https://llvm.org/docs/GettingInvolved.html#irc">IRC</a></li>
<li><a href="https://llvm.org/docs/GettingInvolved.html#meetups-and-social-events">Meetups and Social Events</a></li>
</ul>
<h3>Additional Links</h3>
<ul class="want-points">
<li><a href="https://llvm.org/docs/FAQ.html">FAQ</a></li>
<li><a href="https://llvm.org/docs/Lexicon.html">Glossary</a></li>
<li><a href="https://llvm.org/pubs">Publications</a></li>
<li><a href="https://github.com/llvm/llvm-project//">Github Repository</a></li>
</ul>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/AMDGPUInstructionSyntax.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="amdgpu-instruction-syntax">
<h1>AMDGPU Instruction Syntax<a class="headerlink" href="#amdgpu-instruction-syntax" title="Permalink to this headline">¶</a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#instructions" id="id3">Instructions</a></p>
<ul>
<li><p><a class="reference internal" href="#syntax" id="id4">Syntax</a></p></li>
<li><p><a class="reference internal" href="#opcode-mnemonic" id="id5">Opcode Mnemonic</a></p></li>
<li><p><a class="reference internal" href="#packing-suffix" id="id6">Packing Suffix</a></p></li>
<li><p><a class="reference internal" href="#type-and-size-suffices" id="id7">Type and Size Suffices</a></p></li>
<li><p><a class="reference internal" href="#encoding-suffices" id="id8">Encoding Suffices</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#operands" id="id9">Operands</a></p>
<ul>
<li><p><a class="reference internal" href="#id1" id="id10">Syntax</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#modifiers" id="id11">Modifiers</a></p>
<ul>
<li><p><a class="reference internal" href="#id2" id="id12">Syntax</a></p></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="instructions">
<span id="amdgpu-syn-instructions"></span><h2><a class="toc-backref" href="#id3">Instructions</a><a class="headerlink" href="#instructions" title="Permalink to this headline">¶</a></h2>
<div class="section" id="syntax">
<h3><a class="toc-backref" href="#id4">Syntax</a><a class="headerlink" href="#syntax" title="Permalink to this headline">¶</a></h3>
<p>An instruction has the following syntax:</p>
<blockquote>
<div><p><code class="docutils literal notranslate"><span class="pre"><</span></code><em>opcode mnemonic</em><code class="docutils literal notranslate"><span class="pre">></span>    <span class="pre"><</span></code><em>operand0</em><code class="docutils literal notranslate"><span class="pre">>,</span> <span class="pre"><</span></code><em>operand1</em><code class="docutils literal notranslate"><span class="pre">>,...</span>    <span class="pre"><</span></code><em>modifier0</em><code class="docutils literal notranslate"><span class="pre">></span> <span class="pre"><</span></code><em>modifier1</em><code class="docutils literal notranslate"><span class="pre">>...</span></code></p>
</div></blockquote>
<p><a class="reference internal" href="AMDGPUOperandSyntax.html"><span class="doc">Operands</span></a> are normally comma-separated while
<a class="reference internal" href="AMDGPUModifierSyntax.html"><span class="doc">modifiers</span></a> are space-separated.</p>
<p>The order of <em>operands</em> and <em>modifiers</em> is fixed.
Most <em>modifiers</em> are optional and may be omitted.</p>
</div>
<div class="section" id="opcode-mnemonic">
<span id="amdgpu-syn-instruction-mnemo"></span><h3><a class="toc-backref" href="#id5">Opcode Mnemonic</a><a class="headerlink" href="#opcode-mnemonic" title="Permalink to this headline">¶</a></h3>
<p>Opcode mnemonic describes opcode semantics and may include one or more suffices in this order:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#amdgpu-syn-instruction-pk"><span class="std std-ref">Packing suffix</span></a>.</p></li>
<li><p><a class="reference internal" href="#amdgpu-syn-instruction-type"><span class="std std-ref">Destination operand type suffix</span></a>.</p></li>
<li><p><a class="reference internal" href="#amdgpu-syn-instruction-type"><span class="std std-ref">Source operand type suffix</span></a>.</p></li>
<li><p><a class="reference internal" href="#amdgpu-syn-instruction-enc"><span class="std std-ref">Encoding suffix</span></a>.</p></li>
</ul>
</div>
<div class="section" id="packing-suffix">
<span id="amdgpu-syn-instruction-pk"></span><h3><a class="toc-backref" href="#id6">Packing Suffix</a><a class="headerlink" href="#packing-suffix" title="Permalink to this headline">¶</a></h3>
<p>Most instructions which operate on packed data have a <em>_pk</em> suffix.
Unless otherwise <a class="reference internal" href="AMDGPUInstructionNotation.html#amdgpu-syn-instruction-operand-tags"><span class="std std-ref">noted</span></a>,
these instructions operate on and produce packed data composed of
two values. The type of values is indicated by
<a class="reference internal" href="#amdgpu-syn-instruction-type"><span class="std std-ref">type suffices</span></a>.</p>
<p>For example, the following instruction sums up two pairs of f16 values
and produces a pair of f16 values:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">v_pk_add_f16</span> <span class="n">v1</span><span class="p">,</span> <span class="n">v2</span><span class="p">,</span> <span class="n">v3</span> <span class="o">//</span> <span class="n">Each</span> <span class="n">operand</span> <span class="n">has</span> <span class="n">f16x2</span> <span class="nb">type</span>
</pre></div>
</div>
</div>
<div class="section" id="type-and-size-suffices">
<span id="amdgpu-syn-instruction-type"></span><h3><a class="toc-backref" href="#id7">Type and Size Suffices</a><a class="headerlink" href="#type-and-size-suffices" title="Permalink to this headline">¶</a></h3>
<p>Instructions which operate with data have an implied type of <em>data</em> operands.
This data type is specified as a suffix of instruction mnemonic.</p>
<p>There are instructions which have 2 type suffices:
the first is the data type of the destination operand,
the second is the data type of source <em>data</em> operand(s).</p>
<p>Note that data type specified by an instruction does not apply
to other kinds of operands such as <em>addresses</em>, <em>offsets</em> and so on.</p>
<p>The following table enumerates the most frequently used type suffices.</p>
<blockquote>
<div><table class="docutils align-default">
<colgroup>
<col style="width: 46%" />
<col style="width: 24%" />
<col style="width: 29%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Type Suffices</p></th>
<th class="head"><p>Packed instruction?</p></th>
<th class="head"><p>Data Type</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>_b512, _b256, _b128, _b64, _b32, _b16, _b8</p></td>
<td><p>No</p></td>
<td><p>Bits.</p></td>
</tr>
<tr class="row-odd"><td><p>_u64, _u32, _u16, _u8</p></td>
<td><p>No</p></td>
<td><p>Unsigned integer.</p></td>
</tr>
<tr class="row-even"><td><p>_i64, _i32, _i16, _i8</p></td>
<td><p>No</p></td>
<td><p>Signed integer.</p></td>
</tr>
<tr class="row-odd"><td><p>_f64, _f32, _f16</p></td>
<td><p>No</p></td>
<td><p>Floating-point.</p></td>
</tr>
<tr class="row-even"><td><p>_b16, _u16, _i16, _f16</p></td>
<td><p>Yes</p></td>
<td><p>Packed (b16x2, u16x2, etc).</p></td>
</tr>
</tbody>
</table>
</div></blockquote>
<p>Instructions which have no type suffices are assumed to operate with typeless data.
The size of data is specified by size suffices:</p>
<blockquote>
<div><table class="docutils align-default">
<colgroup>
<col style="width: 23%" />
<col style="width: 26%" />
<col style="width: 51%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Size Suffix</p></th>
<th class="head"><p>Implied data type</p></th>
<th class="head"><p>Required register size in dwords</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>-</p></td>
<td><p>b32</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p>x2</p></td>
<td><p>b64</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p>x3</p></td>
<td><p>b96</p></td>
<td><p>3</p></td>
</tr>
<tr class="row-odd"><td><p>x4</p></td>
<td><p>b128</p></td>
<td><p>4</p></td>
</tr>
<tr class="row-even"><td><p>x8</p></td>
<td><p>b256</p></td>
<td><p>8</p></td>
</tr>
<tr class="row-odd"><td><p>x16</p></td>
<td><p>b512</p></td>
<td><p>16</p></td>
</tr>
<tr class="row-even"><td><p>x</p></td>
<td><p>b32</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p>xy</p></td>
<td><p>b64</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p>xyz</p></td>
<td><p>b96</p></td>
<td><p>3</p></td>
</tr>
<tr class="row-odd"><td><p>xyzw</p></td>
<td><p>b128</p></td>
<td><p>4</p></td>
</tr>
<tr class="row-even"><td><p>d16_x</p></td>
<td><p>b16</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p>d16_xy</p></td>
<td><p>b16x2</p></td>
<td><p>2 for GFX8.0, 1 for GFX8.1 and GFX9+</p></td>
</tr>
<tr class="row-even"><td><p>d16_xyz</p></td>
<td><p>b16x3</p></td>
<td><p>3 for GFX8.0, 2 for GFX8.1 and GFX9+</p></td>
</tr>
<tr class="row-odd"><td><p>d16_xyzw</p></td>
<td><p>b16x4</p></td>
<td><p>4 for GFX8.0, 2 for GFX8.1 and GFX9+</p></td>
</tr>
</tbody>
</table>
</div></blockquote>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>There are exceptions from rules described above.
Operands which have type different from type specified by the opcode are
<a class="reference internal" href="AMDGPUInstructionNotation.html#amdgpu-syn-instruction-operand-tags"><span class="std std-ref">tagged</span></a> in the description.</p>
</div>
<p>Examples of instructions with different types of source and destination operands:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">s_bcnt0_i32_b64</span>
<span class="n">v_cvt_f32_u32</span>
</pre></div>
</div>
<p>Examples of instructions with one data type:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">v_max3_f32</span>
<span class="n">v_max3_i16</span>
</pre></div>
</div>
<p>Examples of instructions which operate with packed data:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">v_pk_add_u16</span>
<span class="n">v_pk_add_i16</span>
<span class="n">v_pk_add_f16</span>
</pre></div>
</div>
<p>Examples of typeless instructions which operate on b128 data:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">buffer_store_dwordx4</span>
<span class="n">flat_load_dwordx4</span>
</pre></div>
</div>
</div>
<div class="section" id="encoding-suffices">
<span id="amdgpu-syn-instruction-enc"></span><h3><a class="toc-backref" href="#id8">Encoding Suffices</a><a class="headerlink" href="#encoding-suffices" title="Permalink to this headline">¶</a></h3>
<p>Most <em>VOP1</em>, <em>VOP2</em> and <em>VOPC</em> instructions have several variants:
they may also be encoded in <em>VOP3</em>, <em>DPP</em> and <em>SDWA</em> formats.</p>
<p>The assembler will automatically use optimal encoding based on instruction operands.
To force specific encoding, one can add a suffix to the opcode of the instruction:</p>
<blockquote>
<div><table class="docutils align-default">
<colgroup>
<col style="width: 75%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Encoding</p></th>
<th class="head"><p>Encoding Suffix</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><em>VOP1</em>, <em>VOP2</em> and <em>VOPC</em> (32-bit) encoding</p></td>
<td><p>_e32</p></td>
</tr>
<tr class="row-odd"><td><p><em>VOP3</em> (64-bit) encoding</p></td>
<td><p>_e64</p></td>
</tr>
<tr class="row-even"><td><p><em>DPP</em> encoding</p></td>
<td><p>_dpp</p></td>
</tr>
<tr class="row-odd"><td><p><em>SDWA</em> encoding</p></td>
<td><p>_sdwa</p></td>
</tr>
</tbody>
</table>
</div></blockquote>
<p>These suffices are used in this reference to indicate the assumed encoding.
When no suffix is specified, native instruction encoding is implied.</p>
</div>
</div>
<div class="section" id="operands">
<h2><a class="toc-backref" href="#id9">Operands</a><a class="headerlink" href="#operands" title="Permalink to this headline">¶</a></h2>
<div class="section" id="id1">
<h3><a class="toc-backref" href="#id10">Syntax</a><a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
<p>Syntax of generic operands is described <a class="reference internal" href="AMDGPUOperandSyntax.html"><span class="doc">in this document</span></a>.</p>
<p>For detailed information about operands follow <em>operand links</em> in GPU-specific documents:</p>
<ul class="simple">
<li><p><a class="reference internal" href="AMDGPU/AMDGPUAsmGFX7.html"><span class="doc">GFX7</span></a></p></li>
<li><p><a class="reference internal" href="AMDGPU/AMDGPUAsmGFX8.html"><span class="doc">GFX8</span></a></p></li>
<li><p><a class="reference internal" href="AMDGPU/AMDGPUAsmGFX9.html"><span class="doc">GFX9</span></a></p></li>
<li><p><a class="reference internal" href="AMDGPU/AMDGPUAsmGFX10.html"><span class="doc">GFX10</span></a></p></li>
</ul>
</div>
</div>
<div class="section" id="modifiers">
<h2><a class="toc-backref" href="#id11">Modifiers</a><a class="headerlink" href="#modifiers" title="Permalink to this headline">¶</a></h2>
<div class="section" id="id2">
<h3><a class="toc-backref" href="#id12">Syntax</a><a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3>
<p>Syntax of modifiers is described <a class="reference internal" href="AMDGPUModifierSyntax.html"><span class="doc">in this document</span></a>.</p>
<p>Information about modifiers supported for individual instructions may be found in GPU-specific documents:</p>
<ul class="simple">
<li><p><a class="reference internal" href="AMDGPU/AMDGPUAsmGFX7.html"><span class="doc">GFX7</span></a></p></li>
<li><p><a class="reference internal" href="AMDGPU/AMDGPUAsmGFX8.html"><span class="doc">GFX8</span></a></p></li>
<li><p><a class="reference internal" href="AMDGPU/AMDGPUAsmGFX9.html"><span class="doc">GFX9</span></a></p></li>
<li><p><a class="reference internal" href="AMDGPU/AMDGPUAsmGFX10.html"><span class="doc">GFX10</span></a></p></li>
</ul>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="AMDGPUInstructionNotation.html" title="AMDGPU Instructions Notation"
>next</a> |</li>
<li class="right" >
<a href="AMDGPUOperandSyntax.html" title="Syntax of AMDGPU Instruction Operands"
>previous</a> |</li>
<li><a href="https://llvm.org/">LLVM Home</a> | </li>
<li><a href="index.html">Documentation</a>»</li>
<li class="nav-item nav-item-1"><a href="UserGuides.html" >User Guides</a> »</li>
<li class="nav-item nav-item-2"><a href="AMDGPUUsage.html" >User Guide for AMDGPU Backend</a> »</li>
<li class="nav-item nav-item-this"><a href="">AMDGPU Instruction Syntax</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2003-2021, LLVM Project.
Last updated on 2021-09-18.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.5.4.
</div>
</body>
</html>
|