-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[RISCV] Add symbol parsing support for XAndesPerf branch instructions #137748
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
tclin914
merged 5 commits into
llvm:main
from
tclin914:andes-mc-perf-extension-relocation
Jun 20, 2025
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
347384f
[RISCV] Add relocation support for XAndesperf branch and gp-related i…
tclin914 4674083
Remove symbol parsing support for gp-related instruction
tclin914 cf62ebd
Add vendor symbol `ANDES`
tclin914 6e991cc
Add description for R_RISCV_NDS_BRANCH_10
tclin914 2baf0f0
Remove the test for fixup output
tclin914 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
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
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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # RUN: not llvm-mc -triple riscv32 -filetype obj -mattr=+xandesperf < %s -o /dev/null 2>&1 | FileCheck %s | ||
|
|
||
| nds.bbc t0, 7, far_distant # CHECK: :[[@LINE]]:3: error: fixup value out of range | ||
| nds.bbc t0, 7, unaligned # CHECK: :[[@LINE]]:3: error: fixup value must be 2-byte aligned | ||
|
|
||
| .byte 0 | ||
| unaligned: | ||
| .byte 0 | ||
| .byte 0 | ||
| .byte 0 | ||
|
|
||
| .space 1<<10 | ||
| far_distant: |
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,33 @@ | ||
| # RUN: llvm-mc -triple riscv32 -mattr=+xandesperf -M no-aliases < %s -show-encoding \ | ||
| # RUN: | FileCheck -check-prefix=CHECK-FIXUP %s | ||
| # RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+xandesperf < %s \ | ||
| # RUN: | llvm-objdump --mattr=+xandesperf --no-print-imm-hex -M no-aliases -d - \ | ||
| # RUN: | FileCheck -check-prefix=CHECK-INSTR %s | ||
| # RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+xandesperf %s \ | ||
| # RUN: | llvm-readobj -r - | FileCheck %s -check-prefix=CHECK-REL | ||
|
|
||
| .LBB0: | ||
|
|
||
| .fill 1000 | ||
|
|
||
| nds.bbc t0, 7, .LBB0 | ||
| # CHECK-FIXUP: fixup A - offset: 0, value: .LBB0, kind: fixup_riscv_nds_branch_10 | ||
| # CHECK-INSTR: nds.bbc t0, 7, 0 | ||
|
|
||
| nds.bbs t0, 7, .LBB1 | ||
| # CHECK-FIXUP: fixup A - offset: 0, value: .LBB1, kind: fixup_riscv_nds_branch_10 | ||
| # CHECK-INSTR: nds.bbs t0, 7, 0x7e0 | ||
|
|
||
| nds.beqc t0, 7, .LBB0 | ||
| # CHECK-FIXUP: fixup A - offset: 0, value: .LBB0, kind: fixup_riscv_nds_branch_10 | ||
| # CHECK-INSTR: nds.beqc t0, 7, 0 | ||
|
|
||
| nds.bnec t0, 7, .LBB1 | ||
| # CHECK-FIXUP: fixup A - offset: 0, value: .LBB1, kind: fixup_riscv_nds_branch_10 | ||
| # CHECK-INSTR: nds.bnec t0, 7, 0x7e0 | ||
|
|
||
| .fill 1000 | ||
|
|
||
| .LBB1: | ||
|
|
||
| # CHECK-REL-NOT: R_RISCV | ||
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,36 @@ | ||
| # RUN: llvm-mc -triple riscv32 -mattr=+xandesperf -M no-aliases < %s -show-encoding \ | ||
| # RUN: | FileCheck -check-prefix=ASM %s | ||
| # RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+xandesperf < %s \ | ||
| # RUN: | llvm-objdump -dr --mattr=+xandesperf - \ | ||
| # RUN: | FileCheck -check-prefix=OBJ %s | ||
| # RUN: llvm-mc -triple riscv64 -mattr=+xandesperf -M no-aliases < %s -show-encoding \ | ||
| # RUN: | FileCheck -check-prefix=ASM %s | ||
| # RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+xandesperf < %s \ | ||
| # RUN: | llvm-objdump -dr --mattr=+xandesperf - \ | ||
| # RUN: | FileCheck -check-prefix=OBJ %s | ||
|
|
||
| .long foo | ||
|
|
||
| # ASM: nds.bbc t0, 7, foo | ||
| # OBJ: nds.bbc t0, 0x7, 0x4 <.text+0x4> | ||
| # OBJ-NEXT: R_RISCV_VENDOR ANDES{{$}} | ||
| # OBJ-NEXT: R_RISCV_CUSTOM241 foo{{$}} | ||
| nds.bbc t0, 7, foo | ||
|
|
||
| # ASM: nds.bbs t0, 7, foo | ||
| # OBJ-NEXT: nds.bbs t0, 0x7, 0x8 <.text+0x8> | ||
| # OBJ-NEXT: R_RISCV_VENDOR ANDES{{$}} | ||
| # OBJ-NEXT: R_RISCV_CUSTOM241 foo{{$}} | ||
| nds.bbs t0, 7, foo | ||
|
|
||
| # ASM: nds.beqc t0, 7, foo | ||
| # OBJ-NEXT: nds.beqc t0, 0x7, 0xc <.text+0xc> | ||
| # OBJ-NEXT: R_RISCV_VENDOR ANDES{{$}} | ||
| # OBJ-NEXT: R_RISCV_CUSTOM241 foo{{$}} | ||
| nds.beqc t0, 7, foo | ||
|
|
||
| # ASM: nds.bnec t0, 7, foo | ||
| # OBJ-NEXT: nds.bnec t0, 0x7, 0x10 <.text+0x10> | ||
| # OBJ-NEXT: R_RISCV_VENDOR ANDES{{$}} | ||
| # OBJ-NEXT: R_RISCV_CUSTOM241 foo{{$}} | ||
| nds.bnec t0, 7, foo |
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 test can be merged into -relocation.s.
Please drop -show-encoding and remove CHECK-FIXUP check lines for fixup/relocations. They are not useful.
I have noticed that this was an anti-pattern within MC/RISCV and cleaned up many tests.
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.
Remove this testcase. Thanks.