ABI Register for RISC-V Calling Convention

I am confused about the names of the RISC-V ABI Register. For example, in table 18.2 in the β€œRISC-V Installation Manual, Volume I: ISA User Level Version 2.0” on page 85, indicates that the stack pointer sp is x14 . However instruction

 addi sp,zero,0 

compiled at 0x00000113 by riscv64-unknown-elf-as ( -m32 doesn't matter). In binary format:

 000000000000 00000 000 00010 0010011 ^imm ^rs1 ^f3 ^rd ^opcode 

So here sp seems x2 . Then I searched Google a bit and found the RISC-V Linux User Guide . This document states that sp x30 .

So what is it? Are there different ABIs? Can I install ABI with command line option on riscv64-unknown-elf-* ? Is there an exhaustive table somewhere?

+8
riscv
source share
1 answer

Now the stack pointer is x2 .

Here is the current ABI documentation that has been ported from the user level ISA specification , which now contains the same link.

The ABI has been modified to better accommodate the new concise RISC-V specification, which puts the 8 most used registers next to each other in x8-x15.

Note. do not trust any riscv.org web page. Quan Nguyen clearly explains in his introduction that the β€œRISC-V Linux User Guide” is intended to document the migration process and that accuracy is NOT guaranteed.

+6
source share

All Articles