Skip to content

Commit 2e6242d

Browse files
committed
Use assembler relocation functions in the psedoinstructions table
1 parent bad3a5f commit 2e6242d

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

riscv-asm.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -608,14 +608,14 @@ fail_msg:
608608

609609
Pseudoinstruction | Base Instruction(s) | Meaning | Comment
610610
:----------------------------|:--------------------------------------------------------------|:----------|:--------|
611-
la rd, symbol | auipc rd, symbol[31:12]; addi rd, rd, symbol[11:0] | Load address | With `.option nopic` (Default)
612-
la rd, symbol | auipc rd, symbol@GOT[31:12]; l{w\|d} rd, symbol@GOT[11:0]\(rd\) | Load address | With `.option pic`
613-
lla rd, symbol | auipc rd, symbol[31:12]; addi rd, rd, symbol[11:0] | Load local address
614-
lga rd, symbol | auipc rd, symbol@GOT[31:12]; l{w\|d} rd, symbol@GOT[11:0]\(rd\) | Load global address
615-
l{b\|h\|w\|d} rd, symbol | auipc rd, symbol[31:12]; l{b\|h\|w\|d} rd, symbol[11:0]\(rd\) | Load global
616-
s{b\|h\|w\|d} rd, symbol, rt | auipc rt, symbol[31:12]; s{b\|h\|w\|d} rd, symbol[11:0]\(rt\) | Store global
617-
fl{w\|d} rd, symbol, rt | auipc rt, symbol[31:12]; fl{w\|d} rd, symbol[11:0]\(rt\) | Floating-point load global
618-
fs{w\|d} rd, symbol, rt | auipc rt, symbol[31:12]; fs{w\|d} rd, symbol[11:0]\(rt\) | Floating-point store global
611+
la rd, symbol | 1: auipc rd, %pcrel_hi(symbol); addi rd, rd, %pcrel_lo(1b) | Load address | With `.option nopic` (Default)
612+
la rd, symbol | 1: auipc rd, %got_pcrel_hi(symbol); l{w\|d} rd, %pcrel_lo(1b)(rd) | Load address | With `.option pic`
613+
lla rd, symbol | 1: auipc rd, %pcrel_hi(symbol); addi rd, rd, %pcrel_lo(1b) | Load local address
614+
lga rd, symbol | 1: auipc rd, %got_pcrel_hi(symbol); l{w\|d} rd, %pcrel_lo(1b)(rd) | Load global address
615+
l{b\|h\|w\|d} rd, symbol | 1: auipc rd, %pcrel_hi(symbol); l{b\|h\|w\|d} rd, %pcrel_lo(1b)(rd) | Load global
616+
s{b\|h\|w\|d} rd, symbol, rt | 1: auipc rt, %pcrel_hi(symbol); s{b\|h\|w\|d} rd, %pcrel_lo(1b)(rt) | Store global
617+
fl{w\|d} rd, symbol, rt | 1: auipc rt, %pcrel_hi(symbol); fl{w\|d} rd, %pcrel_lo(1b)(rt) | Floating-point load global
618+
fs{w\|d} rd, symbol, rt | 1: auipc rt, %pcrel_hi(symbol); fs{w\|d} rd, %pcrel_lo(1b)(rt) | Floating-point store global
619619
nop | addi x0, x0, 0 | No operation
620620
li rd, immediate | *Myriad sequences* | Load immediate
621621
mv rd, rs | addi rd, rs, 0 | Copy register
@@ -653,8 +653,8 @@ jal offset | jal x1, offset
653653
jr rs | jalr x0, rs, 0 | Jump register
654654
jalr rs | jalr x1, rs, 0 | Jump and link register
655655
ret | jalr x0, x1, 0 | Return from subroutine
656-
call offset | auipc x6, offset[31:12]; jalr x1, x6, offset[11:0] | Call far-away subroutine
657-
tail offset | auipc x6, offset[31:12]; jalr x0, x6, offset[11:0] | Tail call far-away subroutine
656+
call offset | 1: auipc x6, %pcrel_hi(offset); jalr x1, x6, %pcrel_lo(1b) | Call far-away subroutine
657+
tail offset | 1: auipc x6, %pcrel_hi(offset); jalr x0, x6, %pcrel_lo(1b) | Tail call far-away subroutine
658658
fence | fence iorw, iorw | Fence on all memory and I/O
659659

660660
* [1] We don't specify the code sequence when the B-extension is present, since B-extension still not ratified or frozen. We will specify the expansion sequence once it's frozen.

0 commit comments

Comments
 (0)