title: ABI Register Names for RISC-V Calling Convention
body: <p>I'm confused about the RISC-V ABI Register Names. For example, Table 18.2 in the "RISC-V Instruction Set Manual, Volume I: User-Level ISA, Version 2.0" at page 85 specifies that the stack pointer <code>sp</code> is register <code>x14</code>. However, the instruction</p>
  
  <pre><code>addi sp,zero,0
  </code></pre>
  
  <p>is compiled to 0x00000113 by riscv64-unknown-elf-as (<code>-m32</code> does not make a difference). In binary:</p>
  
  <pre><code>000000000000 00000 000 00010 0010011
  ^imm         ^rs1  ^f3 ^rd   ^opcode
  </code></pre>
  
  <p>So here <code>sp</code> seems to be <code>x2</code>. Then I googled a bit and found the <a href="https://www.ocf.berkeley.edu/~qmn/linux/riscv.html">RISC-V Linux User's Manual</a>. This document states that <code>sp</code> is <code>x30</code>.</p>
  
  <p>So what is it? Are there different ABIs? Can I set the ABI with a command line option to <code>riscv64-unknown-elf-*</code>? Is there a comprehensive table somewhere?</p>