Skip to content

Conversation

@hirooih
Copy link

@hirooih hirooih commented Apr 16, 2022

In the table of A listing of standard RISC-V pseudoinstructions, for example, the base Instruction for la rd, symbol is described as:

auipc rd, symbol[31:12]; addi rd, rd, symbol[11:0]

In The RISC-V Instruction Set Manual Volume I: Unprivileged ISA, v20191213, Chapter 25 RISC-V Assembly Programmer’s Handbook (in the latest version the chapter is deleted), it is described as;

auipc rd, delta[31 : 12] + delta[11]
addi rd, rd, delta[11:0]
where delta = symbol − pc

The current description in this manual is wrong. It does not consider the signed immediate offset.

This PR proposes:

Note that I could not find clear description of %tprel_* and %tls_*. So they maybe still wrong. Please review them carefully.

@johnwinans
Copy link

I would prefer to see the LA and LI operations described along the lines of:

li rd,constant

        lui  rd,(constant+0x00000800) >> 12
        addi rd,rd,(constant & 0x00000fff)

Note that the LUI will sign-extend the 20-bit value on RV64 & RV128 systems.

@hirooih hirooih force-pushed the relocation-functions branch from 62250eb to 571f229 Compare April 17, 2022 06:29
@hirooih
Copy link
Author

hirooih commented Apr 17, 2022

@johnwinans

Thank you for your suggestion.
I borrowed the expression of the RISC-V specification, but the proposed expression is easier to understand. RISC-V ABIs Specification uses the similar expression.

And I also found I misunderstood the definition of %pcrel_lo(label). I fixed it, too.

@hirooih hirooih force-pushed the relocation-functions branch from 571f229 to 45d77ea Compare April 17, 2022 13:15
@hirooih
Copy link
Author

hirooih commented Apr 17, 2022

And I also found I misunderstood the definition of %pcrel_lo(label). I fixed it, too.

I did not fix the psedoinstructions table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants