forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 1
Initial RVY support #1
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
Open
arichardson
wants to merge
6
commits into
upstream-basline
Choose a base branch
from
2025-rvy-initial
base: upstream-basline
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7769137
[RISC-V][MC] Add a RegisterClass definition for Y extension (CHERI)
arichardson 91fb498
[RISC-V][MC] Introduce RVY extension feature
veselypeta 3c009d2
[RISC-V][MC] Introduce initial support for Y extension (CHERI)
arichardson 02a8278
[AsmMatcher] Add support for conflicting features
arichardson 9b7a809
[RISC-V][MC] Add support for RVY loads/stores
arichardson d7af9f1
[DO_NOT_MERGE][RVY] Add a call to RISCV_MC::verifyInstructionPredicates
arichardson 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| //===-- RISCVInstrFormatsY.td --------------------------------*- tablegen -*-=// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file describes the RISC-V Y extension instruction formats. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Operand definitions. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| def YBNDSWImmOperand : AsmOperandClass { | ||
| let Name = "YBNDSWImm"; | ||
| let RenderMethod = "addImmOperands"; | ||
| let DiagnosticType = "InvalidYBNDSWImm"; | ||
| } | ||
|
|
||
| def ybndsw_imm : Operand<XLenVT>, ImmLeaf<XLenVT, [{ | ||
| return (Imm >= 1 && Imm <= 256) || | ||
| (Imm >= 258 && Imm <= 768 && (Imm % 2) == 0) || | ||
| (Imm >= 772 && Imm <= 1792 && (Imm % 4) == 0) || | ||
| (Imm >= 1800 && Imm <= 3840 && (Imm % 8) == 0); | ||
| }]> { | ||
| let EncoderMethod = "getYBNDSWImmOpValue"; | ||
| let ParserMatchClass = YBNDSWImmOperand; | ||
| let DecoderMethod = "DecodeYBNDSWImm"; | ||
| let MIOperandInfo = (ops i32imm); | ||
| } | ||
|
|
||
| def uimm7_srliy : RISCVUImmOp<7>, ImmLeaf<XLenVT, [{ | ||
| return Subtarget->is64Bit() ? Imm == 64 : Imm == 32; | ||
| }]> { | ||
| let ParserMatchClass = UImmAsmOperand<7, "Srliy">; | ||
| let DecoderMethod = "decodeUImm7SrliyOperand"; | ||
| let MCOperandPredicate = [{ | ||
| int64_t Imm; | ||
| if (!MCOp.evaluateAsConstantImm(Imm)) | ||
| return false; | ||
| return Subtarget->is64Bit() ? Imm == 64 : Imm == 32; | ||
| }]; | ||
| let OperandType = "OPERAND_UIMM7_SRLIY"; | ||
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Instruction Formats | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // Like an RVInstR, except rs2 is now an additional function code. | ||
| class RVYInstSrcDst<bits<7> funct7, bits<5> funct5, bits<3> funct3, | ||
| RISCVOpcode opcode, dag outs, dag ins, string opcodestr, | ||
| string argstr> | ||
| : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> { | ||
| bits<5> rs1; | ||
| bits<5> rd; | ||
|
|
||
| let Inst{31 -25} = funct7; | ||
| let Inst{24 -20} = funct5; | ||
| let Inst{19 -15} = rs1; | ||
| let Inst{14 -12} = funct3; | ||
| let Inst{11 -7} = rd; | ||
| let Inst{6 -0} = opcode.Value; | ||
| } | ||
|
|
||
| class RVYInstSetBoundsImmFmt<dag outs, dag ins, string opcodestr, string argstr> | ||
| : RVInstIBase<0b011, OPC_OP_IMM_32, outs, ins, opcodestr, argstr> { | ||
| bits<5> rd; | ||
| bits<5> rs1; | ||
| bits<10> imm; | ||
|
|
||
| let Inst{31 -30} = 0b00; | ||
| let Inst{29 -20} = imm; | ||
| } |
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.
We renamed this to
XCheriPureCapusingRISCVExtension, so that it plays nice with the rest of the RISCV extension infrastructure. That enables us to do things like haveXCheriotautomatically implyXCheriPureCap.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.
Though given the direction of the Y standard, perhaps we should invert the sense of the feature bit?
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.
Thoughts on this part?
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.
Hmm can't you have XCheriot imply the CapMode subtargetfeature?
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.
It likely shouldn't have a x prefix since that is for vendor-extensions and the standard will have this.
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.
We could do that in code, but the generic infrastructure for RV features implying other RV features only works for things declared as standard extensions or vendor extensions, and it then enforces the naming scheme.
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.
Trying to page it all back in now, I think the issue might have been that
CapModecan't implyXCheri(or Y in the future) because extensions can imply features, but features can't imply extensions.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.
Ah I was not aware that upstream introduced this restriction. I'm pretty sure you used to be able to imply certain non-extension features like CapMode.