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

Add an "lga" pseudoinstruction for GOT loads even in non-PIC #50

Closed
aswaterman opened this issue Aug 19, 2020 · 0 comments
Closed

Add an "lga" pseudoinstruction for GOT loads even in non-PIC #50

aswaterman opened this issue Aug 19, 2020 · 0 comments

Comments

@aswaterman
Copy link
Contributor

Following is a duplicate of @jrtc27's proposal from riscv/riscv-isa-manual#539.

This is useful for cases where compilers and/or assembly writers want to force the use of a GOT. For example, this could be used to address [1], but more generally it's a useful thing to have, and is a strange hole in the set of pseudoinstructions provided.

Whilst here, alter the description of "la" to not mention absolute. All addresses are absolute, but highlighting it for "la" specifically is confusing as it potentially implies that it's using an absolute lui/addi sequence rather than a PC-relative sequence.

[1] riscv-non-isa/riscv-elf-psabi-doc#126

I have not yet created patches against riscv-asm-manual and riscv-elf-psabi-doc. However, those are already outdated and only mention la without lla. Defining lga will also make it far less confusing to fix that; then, lla and lga can be documented individually, with la simply saying it's equivalent to the relevant one depending on -fPIC.

jrtc27 added a commit to llvm/llvm-project that referenced this issue May 31, 2023
This mirrors lla and is always GOT-relative, allowing an explicit
request to use the GOT without having to expand the instruction. This
then means la is just defined in terms of lla and lga in the assembler,
based on whether PIC is enabled, and at the codegen level we replace la
entirely with lga since we only ever use la there when we want to load
from the GOT (and assert that to be the case).

See riscv-non-isa/riscv-asm-manual#50

Reviewed By: asb, MaskRay

Differential Revision: https://reviews.llvm.org/D107278
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

No branches or pull requests

1 participant