-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[RISCV] Vendor Relocations for Xqci extension #135400
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
df04e31
[RISCV] Vendor Relocations for Xqci extension
lenary 1e43085
clang-format
lenary 1133c3d
Merge branch 'main' into vendorsym
lenary 98dfeed
Merge branch 'main' into vendorsym
lenary 723863f
Address Review Feedback
lenary 123e312
Address review comments
lenary 0f84104
Merge branch 'main' into vendorsym
lenary acc71d4
Merge branch 'main' into vendorsym
lenary d408f17
Address feedback
lenary 241ea1b
clang-format
lenary 6b3ba87
Address review feedback
lenary 7234bf4
Merge branch 'main' into vendorsym
lenary File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| #include "MCTargetDesc/RISCVBaseInfo.h" | ||
| #include "MCTargetDesc/RISCVFixupKinds.h" | ||
| #include "MCTargetDesc/RISCVMCTargetDesc.h" | ||
| #include "llvm/ADT/StringMap.h" | ||
| #include "llvm/MC/MCAsmBackend.h" | ||
| #include "llvm/MC/MCFixupKindInfo.h" | ||
| #include "llvm/MC/MCSubtargetInfo.h" | ||
|
|
@@ -20,6 +21,7 @@ namespace llvm { | |
| class MCAssembler; | ||
| class MCObjectTargetWriter; | ||
| class raw_ostream; | ||
| class MCSymbolELF; | ||
|
||
|
|
||
| class RISCVAsmBackend : public MCAsmBackend { | ||
| const MCSubtargetInfo &STI; | ||
|
|
@@ -28,6 +30,8 @@ class RISCVAsmBackend : public MCAsmBackend { | |
| bool ForceRelocs = false; | ||
| const MCTargetOptions &TargetOptions; | ||
|
|
||
| StringMap<MCSymbolELF *> VendorSymbols; | ||
|
|
||
| public: | ||
| RISCVAsmBackend(const MCSubtargetInfo &STI, uint8_t OSABI, bool Is64Bit, | ||
| const MCTargetOptions &Options); | ||
|
|
@@ -45,8 +49,15 @@ class RISCVAsmBackend : public MCAsmBackend { | |
|
|
||
| bool evaluateTargetFixup(const MCAssembler &Asm, const MCFixup &Fixup, | ||
| const MCFragment *DF, const MCValue &Target, | ||
| const MCSubtargetInfo *STI, | ||
| uint64_t &Value) override; | ||
| const MCSubtargetInfo *STI, uint64_t &Value, | ||
| bool RecordReloc) override; | ||
|
|
||
| bool evaluateVendorFixup(const MCAssembler &Asm, const MCFixup &Fixup, | ||
| const MCFragment *DF, const MCValue &Target, | ||
| const MCSubtargetInfo *STI, uint64_t &Value, | ||
| bool RecordReloc); | ||
|
|
||
| StringRef getVendorSymbolNameForRelocation(unsigned TargetFixupKind) const; | ||
|
|
||
| bool handleAddSubRelocations(const MCAssembler &Asm, const MCFragment &F, | ||
| const MCFixup &Fixup, const MCValue &Target, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # RUN: llvm-mc -triple riscv32 -mattr=+experimental-xqcibi %s \ | ||
| # RUN: | FileCheck -check-prefix=ASM %s | ||
| # RUN: llvm-mc -triple riscv32 -mattr=+experimental-xqcibi %s \ | ||
| # RUN: -filetype=obj -o - \ | ||
| # RUN: | llvm-objdump -dr --mattr=+experimental-xqcibi - \ | ||
| # RUN: | FileCheck -check-prefix=OBJ %s | ||
|
|
||
| ## This test checks that we emit the right relocations for Xqcibi | ||
| ## relative branches, when relaxations are enabled. These require a relocation. | ||
| ## The QC.E.B<op>I instructions also require a vendor relocation. | ||
|
|
||
| # These are required to turn off autocompression, but to re-enable | ||
| # linker relaxation. | ||
| .option exact | ||
| .option relax | ||
|
|
||
| # ASM-LABEL: this_section: | ||
| # OBJ-LABEL: <this_section>: | ||
| this_section: | ||
|
|
||
| # ASM: qc.bnei t2, 11, same_section | ||
| # OBJ: qc.bnei t2, 0xb, 0x0 <this_section> | ||
| # OBJ-NEXT: R_RISCV_BRANCH same_section{{$}} | ||
| # OBJ-NOT: R_RISCV | ||
| qc.bnei t2, 11, same_section | ||
|
|
||
| # ASM: qc.e.bgeui s1, 21, same_section | ||
| # OBJ: qc.e.bgeui s1, 0x15, 0x4 <this_section+0x4> | ||
| # OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}} | ||
| # OBJ-NEXT: R_RISCV_CUSTOM193 same_section{{$}} | ||
| # OBJ-NOT: R_RISCV | ||
| qc.e.bgeui s1, 21, same_section | ||
|
|
||
| # ASM-LABEL: same_section: | ||
| # OBJ-LABEL: <same_section>: | ||
| same_section: | ||
| nop | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The symbol is by default NOTYPE and LOCAL. In the rare scenario that the users changes the type/binding, we should respect that.
So setType/setBinding should be omitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.