-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[RISCV] Add Qualcomm uC Xqciac (Load-Store Adress calculation) extension #121037
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 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Xqciac - Qualcomm uC Load-Store Address Calculation Extension | ||
| # RUN: not llvm-mc -triple riscv32 -mattr=+experimental-xqciac < %s 2>&1 \ | ||
| # RUN: | FileCheck -check-prefixes=CHECK,CHECK-IMM %s | ||
| # RUN: not llvm-mc -triple riscv32 -mattr=-experimental-xqciac < %s 2>&1 \ | ||
| # RUN: | FileCheck -check-prefixes=CHECK,CHECK-EXT %s | ||
|
|
||
| # CHECK: :[[@LINE+1]]:14: error: invalid operand for instruction | ||
| qc.c.muladdi x5, x10, 4 | ||
|
|
||
| # CHECK: :[[@LINE+1]]:1: error: too few operands for instruction | ||
| qc.c.muladdi x15 | ||
|
|
||
| # CHECK-IMM: :[[@LINE+1]]:24: error: immediate must be an integer in the range [0, 31] | ||
| qc.c.muladdi x10, x15, 32 | ||
|
|
||
| # CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqciac' (Qualcomm uC Load-Store Address Calculation Extension) | ||
| qc.c.muladdi x10, x15, 20 | ||
|
|
||
|
|
||
| # CHECK: :[[@LINE+1]]:12: error: invalid operand for instruction | ||
| qc.muladdi x0, x10, 1048577 | ||
|
|
||
| # CHECK: :[[@LINE+1]]:1: error: too few operands for instruction | ||
| qc.muladdi x10 | ||
|
|
||
| # CHECK-IMM: :[[@LINE+1]]:22: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047] | ||
| qc.muladdi x10, x15, 8589934592 | ||
|
|
||
| # CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqciac' (Qualcomm uC Load-Store Address Calculation Extension) | ||
| qc.muladdi x10, x15, 577 | ||
|
|
||
|
|
||
| # CHECK: :[[@LINE+1]]:11: error: invalid operand for instruction | ||
| qc.shladd 0, x10, 1048577 | ||
|
|
||
| # CHECK: :[[@LINE+1]]:1: error: too few operands for instruction | ||
| qc.shladd x10 | ||
|
|
||
| # CHECK-IMM: :[[@LINE+1]]:26: error: immediate must be an integer in the range [4, 31] | ||
| qc.shladd x10, x15, x11, 2 | ||
|
|
||
| # CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqciac' (Qualcomm uC Load-Store Address Calculation Extension) | ||
| qc.shladd x10, x15, x11, 5 |
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,49 @@ | ||
| # Xqciac - Qualcomm uC Load-Store Address Calculation Extension | ||
| # RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqciac -riscv-no-aliases -show-encoding \ | ||
| # RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s | ||
| # RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqciac < %s \ | ||
| # RUN: | llvm-objdump --mattr=+experimental-xqciac -M no-aliases --no-print-imm-hex -d - \ | ||
| # RUN: | FileCheck -check-prefix=CHECK-INST %s | ||
| # RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqciac -show-encoding \ | ||
| # RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s | ||
| # RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqciac < %s \ | ||
| # RUN: | llvm-objdump --mattr=+experimental-xqciac --no-print-imm-hex -d - \ | ||
| # RUN: | FileCheck -check-prefix=CHECK-INST %s | ||
|
|
||
| # CHECK-INST: qc.c.muladdi a0, a1, 0 | ||
| # CHECK-ENC: encoding: [0x8a,0x21] | ||
| qc.c.muladdi x10, x11, 0 | ||
|
|
||
| # CHECK-INST: qc.c.muladdi a0, a1, 31 | ||
| # CHECK-ENC: encoding: [0xea,0x3d] | ||
| qc.c.muladdi x10, x11, 31 | ||
|
|
||
| # CHECK-INST: qc.c.muladdi a0, a1, 16 | ||
| # CHECK-ENC: encoding: [0xaa,0x21] | ||
| qc.c.muladdi x10, x11, 16 | ||
|
|
||
|
|
||
| # CHECK-INST: qc.muladdi tp, t0, 1234 | ||
| # CHECK-ENC: encoding: [0x0b,0xe2,0x22,0x4d] | ||
| qc.muladdi x4, x5, 1234 | ||
|
|
||
| # CHECK-INST: qc.muladdi a0, a1, -2048 | ||
| # CHECK-ENC: encoding: [0x0b,0xe5,0x05,0x80] | ||
| qc.muladdi x10, x11, -2048 | ||
|
|
||
| # CHECK-INST: qc.muladdi a0, a1, 2047 | ||
| # CHECK-ENC: encoding: [0x0b,0xe5,0xf5,0x7f] | ||
| qc.muladdi x10, x11, 2047 | ||
|
|
||
|
|
||
| # CHECK-INST: qc.shladd tp, t0, t1, 12 | ||
| # CHECK-ENC: encoding: [0x0b,0xb2,0x62,0x58] | ||
| qc.shladd x4, x5, x6, 12 | ||
|
|
||
| # CHECK-INST: qc.shladd a0, a1, a2, 4 | ||
| # CHECK-ENC: encoding: [0x0b,0xb5,0xc5,0x48] | ||
| qc.shladd x10, x11, x12, 4 | ||
|
|
||
| # CHECK-INST: qc.shladd a0, a1, a2, 31 | ||
| # CHECK-ENC: encoding: [0x0b,0xb5,0xc5,0x7e] | ||
| qc.shladd x10, x11, x12, 31 |
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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Should we add a
CompressPatto turnqc.muladditoqc.c.muladdiautomatically?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.
Given that this patch is mainly to add the instructions and basic assembler support, I think we can add patterns in follow up patches.
Uh oh!
There was an error while loading. Please reload this page.
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.
CompressPatis used by the assembler to turnadditoc.addi, for example. So it is considered an assembler feature.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.
Fair enough. However, the current implementation of the CompressPat assumes that there are no tied operands in the source dag which is not true for the case of
qc.muladdi. As a result I'm running into errors inverifyDagOpCountfromCompressInstEmitter.cppwhile writing these patterns. We will need to change this behaviour before we can write compressed patterns. I am happy to work on these changes.Can we merge this patch in its current state and re-visit the compress pattern once we have fixed the above issue?
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.
@topperc there are other issues with adding compresspats for Xqci instructions which we are aware of and making plans to address - mostly around the fact there's no way to switch compresspats off for a pat where the larger and smaller instruction are in the same extension. We have a sketch of the solution internally but I've not finished it because we see CompressPats as an optimisation, not part of base assembler/linker support.
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.
Why does the whole extension depend on Zca instead of just qc.c.muladdi?
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.
Unlike the main RISC-V ISA, the Xqci architects did not want to split instructions into (sub-)extensions by size (as you can see, they have been split by functionality). To make the ABI much easier, they agreed that all of the sub-extensions with any 16- or 48-bit instructions would require Zca, as the compiler will need to be able to insert
c.nopwhen aligning etc etc.Not splitting instructions into extensions by size does mean that existing assumptions used by
CompressPatno longer quite hold. At the moment, it is enough to do.option norvc(or an equivalent with.option arch) for theCextension to prevent compression, but you cannot disableqc.c.muladdiwithout disablingqc.muladdi, so we cannot just use architecture features to gate compression patterns (There are even more issues around our 48-bit instructions, which I don't want to write out here). As I said, I have been thinking about an approach for this, but I haven't had time to work through the patch, test it, and present it for review. This is why none of ourXqci*patches so far have hadCompressPats, and we do not intend to add them for the moment. Most of these issues are reasonably orthogonal to the issue that @svs-quic mentioned in the actual tablegen code forCompressPats.