Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update assembler relocation function related descriptions #77

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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
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
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