(opcode: string | undefined)
| 1 | import type {AssemblyInstructionInfo} from '../../../types/assembly-docs.interfaces.js'; |
| 2 | |
| 3 | export function getAsmOpcode(opcode: string | undefined): AssemblyInstructionInfo | undefined { |
| 4 | if (!opcode) return; |
| 5 | switch (opcode.toUpperCase()) { |
| 6 | case 'RET': |
| 7 | return { |
| 8 | url: `https://llvm.org/docs/LangRef.html#ret-instruction`, |
| 9 | html: `<html><head></head><body><span id="i-ret"></span><h4><a class="toc-backref" href="#id2156" role="doc-backlink">‘<code class="docutils literal notranslate"><span class="pre">ret</span></code>’ Instruction</a></h4> |
| 10 | <section id="id32"> |
| 11 | <h5>Syntax:</h5> |
| 12 | <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ret</span> <span class="o"><</span><span class="nb">type</span><span class="o">></span> <span class="o"><</span><span class="n">value</span><span class="o">></span> <span class="p">;</span> <span class="n">Return</span> <span class="n">a</span> <span class="n">value</span> <span class="kn">from</span> <span class="nn">a</span> <span class="n">non</span><span class="o">-</span><span class="n">void</span> <span class="n">function</span> |
| 13 | <span class="n">ret</span> <span class="n">void</span> <span class="p">;</span> <span class="n">Return</span> <span class="kn">from</span> <span class="nn">void</span> <span class="n">function</span> |
| 14 | </pre></div> |
| 15 | </div> |
| 16 | </section> |
| 17 | <section id="overview"> |
| 18 | <h5>Overview:</h5> |
| 19 | <p>The ‘<code class="docutils literal notranslate"><span class="pre">ret</span></code>’ instruction is used to return control flow (and optionally |
| 20 | a value) from a function back to the caller.</p> |
| 21 | <p>There are two forms of the ‘<code class="docutils literal notranslate"><span class="pre">ret</span></code>’ instruction: one that returns a |
| 22 | value and then causes control flow, and one that just causes control |
| 23 | flow to occur.</p> |
| 24 | </section> |
| 25 | <section id="arguments"> |
| 26 | <h5>Arguments:</h5> |
| 27 | <p>The ‘<code class="docutils literal notranslate"><span class="pre">ret</span></code>’ instruction optionally accepts a single argument, the |
| 28 | return value. The type of the return value must be a ‘<a class="reference internal" href="#t-firstclass"><span class="std std-ref">first |
| 29 | class</span></a>’ type.</p> |
| 30 | <p>A function is not <a class="reference internal" href="#wellformed"><span class="std std-ref">well formed</span></a> if it has a non-void |
| 31 | return type and contains a ‘<code class="docutils literal notranslate"><span class="pre">ret</span></code>’ instruction with no return value or |
| 32 | a return value with a type that does not match its type, or if it has a |
| 33 | void return type and contains a ‘<code class="docutils literal notranslate"><span class="pre">ret</span></code>’ instruction with a return |
| 34 | value.</p> |
| 35 | </section> |
| 36 | <section id="id33"> |
| 37 | <h5>Semantics:</h5> |
| 38 | <p>When the ‘<code class="docutils literal notranslate"><span class="pre">ret</span></code>’ instruction is executed, control flow returns back to |
| 39 | the calling function’s context. If the caller is a |
| 40 | “<a class="reference internal" href="#i-call"><span class="std std-ref">call</span></a>” instruction, execution continues at the |
| 41 | instruction after the call. If the caller was an |
| 42 | “<a class="reference internal" href="#i-invoke"><span class="std std-ref">invoke</span></a>” instruction, execution continues at the |
| 43 | beginning of the “normal” destination block. If the instruction returns |
| 44 | a value, that value shall set the call or invoke instruction’s return |
| 45 | value.</p> |
| 46 | </section> |
| 47 | <section id="example"> |
| 48 | <h5>Example:</h5> |
| 49 | <div class="highlight-llvm notranslate"><div class="highlight"><pre><span></span><span class="k">ret</span><span class="w"> </span><span class="kt">i32</span><span class="w"> </span><span class="m">5</span><span class="w"> </span><span class="c">; Return an integer value of 5</span> |
| 50 | <span class="k">ret</span><span class="w"> </span><span class="k">void</span><span class="w"> </span><span class="c">; Return from a void function</span> |
| 51 | <span class="k">ret</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="kt">i32</span><span class="p">,</span><span class="w"> </span><span class="kt">i8</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="kt">i32</span><span class="w"> </span><span class="m">4</span><span class="p">,</span><span class="w"> </span><span class="kt">i8</span><span class="w"> </span><span class="m">2</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c">; Return a struct of values 4 and 2</span> |
| 52 | </pre></div> |
| 53 | </div> |
| 54 | </section> |
| 55 | </body></html>`, |
| 56 | tooltip: `The ‘ret’ instruction is used to return control flow (and optionallya value) from a function back to the caller.There are two forms of the ‘ret’ instruction: one that returns avalue and then causes control flow, and one that just causes controlflow to occur.`, |
| 57 | }; |
| 58 | case 'BR': |
| 59 | return { |
| 60 | url: `https://llvm.org/docs/LangRef.html#br-instruction`, |
nothing calls this directly
no outgoing calls
no test coverage detected