-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[RISCV][MC] Create an AsmOperand for carry-in vmask #124317
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 all commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,13 +50,25 @@ def VMaskAsmOperand : AsmOperandClass { | |
| let DiagnosticType = "InvalidVMaskRegister"; | ||
| } | ||
|
|
||
| def VMaskCarryInAsmOperand : AsmOperandClass { | ||
| let Name = "RVVMaskCarryInRegOpOperand"; | ||
| let RenderMethod = "addRegOperands"; | ||
| let PredicateMethod = "isV0Reg"; | ||
| let DiagnosticType = "InvalidVMaskCarryInRegister"; | ||
| } | ||
|
|
||
| def VMaskOp : RegisterOperand<VMV0> { | ||
| let ParserMatchClass = VMaskAsmOperand; | ||
| let PrintMethod = "printVMaskReg"; | ||
| let EncoderMethod = "getVMaskReg"; | ||
| let DecoderMethod = "decodeVMaskReg"; | ||
| } | ||
|
|
||
| def VMaskCarryInOp : RegisterOperand<VMV0> { | ||
| let ParserMatchClass = VMaskCarryInAsmOperand; | ||
| let EncoderMethod = "getVMaskReg"; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if we want to create another encoder method here. On one hand, it's impossible for codegen to create a MCOperand with register other than V0. But on the other hand, if the MCInst is created "manually", I'm not sure if it will validate the register class. |
||
| } | ||
|
|
||
| def simm5 : RISCVSImmLeafOp<5> { | ||
| let MCOperandPredicate = [{ | ||
| int64_t Imm; | ||
|
|
@@ -442,10 +454,8 @@ class VALUVV<bits<6> funct6, RISCVVFormat opv, string opcodestr> | |
| // op vd, vs2, vs1, v0 (without mask, use v0 as carry input) | ||
| class VALUmVV<bits<6> funct6, RISCVVFormat opv, string opcodestr> | ||
| : RVInstVV<funct6, opv, (outs VR:$vd), | ||
| (ins VR:$vs2, VR:$vs1, VMV0:$v0), | ||
| opcodestr, "$vd, $vs2, $vs1, v0"> { | ||
| let vm = 0; | ||
| } | ||
| (ins VR:$vs2, VR:$vs1, VMaskCarryInOp:$vm), | ||
| opcodestr, "$vd, $vs2, $vs1, $vm">; | ||
|
|
||
| // op vd, vs1, vs2, vm (reverse the order of vs1 and vs2) | ||
| class VALUrVV<bits<6> funct6, RISCVVFormat opv, string opcodestr, | ||
|
|
@@ -474,10 +484,8 @@ class VALUVX<bits<6> funct6, RISCVVFormat opv, string opcodestr> | |
| // op vd, vs2, rs1, v0 (without mask, use v0 as carry input) | ||
| class VALUmVX<bits<6> funct6, RISCVVFormat opv, string opcodestr> | ||
| : RVInstVX<funct6, opv, (outs VR:$vd), | ||
| (ins VR:$vs2, GPR:$rs1, VMV0:$v0), | ||
| opcodestr, "$vd, $vs2, $rs1, v0"> { | ||
| let vm = 0; | ||
| } | ||
| (ins VR:$vs2, GPR:$rs1, VMaskCarryInOp:$vm), | ||
| opcodestr, "$vd, $vs2, $rs1, $vm">; | ||
|
|
||
| // op vd, rs1, vs2, vm (reverse the order of rs1 and vs2) | ||
| class VALUrVX<bits<6> funct6, RISCVVFormat opv, string opcodestr, | ||
|
|
@@ -506,10 +514,8 @@ class VALUVI<bits<6> funct6, string opcodestr, Operand optype = simm5> | |
| // op vd, vs2, imm, v0 (without mask, use v0 as carry input) | ||
| class VALUmVI<bits<6> funct6, string opcodestr, Operand optype = simm5> | ||
| : RVInstIVI<funct6, (outs VR:$vd), | ||
| (ins VR:$vs2, optype:$imm, VMV0:$v0), | ||
| opcodestr, "$vd, $vs2, $imm, v0"> { | ||
| let vm = 0; | ||
| } | ||
| (ins VR:$vs2, optype:$imm, VMaskCarryInOp:$vm), | ||
| opcodestr, "$vd, $vs2, $imm, $vm">; | ||
|
|
||
| // op vd, vs2, imm, vm | ||
| class VALUVINoVm<bits<6> funct6, string opcodestr, Operand optype = simm5> | ||
|
|
@@ -1458,10 +1464,9 @@ defm VFCLASS_V : VCLS_FV_VS2<"vfclass.v", 0b010011, 0b10000>; | |
| let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in { | ||
|
|
||
| // Vector Floating-Point Merge Instruction | ||
| let vm = 0 in | ||
| def VFMERGE_VFM : RVInstVX<0b010111, OPFVF, (outs VR:$vd), | ||
| (ins VR:$vs2, FPR32:$rs1, VMV0:$v0), | ||
| "vfmerge.vfm", "$vd, $vs2, $rs1, v0">, | ||
| (ins VR:$vs2, FPR32:$rs1, VMaskCarryInOp:$vm), | ||
| "vfmerge.vfm", "$vd, $vs2, $rs1, $vm">, | ||
| SchedBinaryMC<"WriteVFMergeV", "ReadVFMergeV", "ReadVFMergeF">; | ||
|
|
||
| // Vector Floating-Point Move Instruction | ||
|
|
||
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,69 @@ | ||
| # RUN: llvm-mc -triple=riscv64 -disassemble -show-inst --mattr=+v %s \ | ||
| # RUN: --M no-aliases | FileCheck %s | ||
|
|
||
| # Check if there is a MCOperand for the carry-in mask. | ||
|
|
||
| [0x57,0x04,0x4a,0x5c] | ||
| # CHECK: <MCInst #{{[0-9]+}} VMERGE_VVM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| [0x57,0x44,0x45,0x5c] | ||
| # CHECK: <MCInst #{{[0-9]+}} VMERGE_VXM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| [0x57,0xb4,0x47,0x5c] | ||
| # CHECK: <MCInst #{{[0-9]+}} VMERGE_VIM | ||
| # CHECK-NEXT: MCOperand Reg | ||
| # CHECK-NEXT: MCOperand Reg | ||
| # CHECK-NEXT: MCOperand Imm | ||
| # CHECK-NEXT: MCOperand Reg | ||
|
|
||
| [0x57,0x04,0x4a,0x40] | ||
| # CHECK: <MCInst #{{[0-9]+}} VADC_VVM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| [0x57,0x44,0x45,0x40] | ||
| # CHECK: <MCInst #{{[0-9]+}} VADC_VXM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| [0x57,0xb4,0x47,0x40] | ||
| # CHECK: <MCInst #{{[0-9]+}} VADC_VIM | ||
| # CHECK-NEXT: MCOperand Reg | ||
| # CHECK-NEXT: MCOperand Reg | ||
| # CHECK-NEXT: MCOperand Imm | ||
| # CHECK-NEXT: MCOperand Reg | ||
|
|
||
| [0x57,0x04,0x4a,0x44] | ||
| # CHECK: <MCInst #{{[0-9]+}} VMADC_VVM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| [0x57,0x44,0x45,0x44] | ||
| # CHECK: <MCInst #{{[0-9]+}} VMADC_VXM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| [0x57,0xb4,0x47,0x44] | ||
| # CHECK: <MCInst #{{[0-9]+}} VMADC_VIM | ||
| # CHECK-NEXT: MCOperand Reg | ||
| # CHECK-NEXT: MCOperand Reg | ||
| # CHECK-NEXT: MCOperand Imm | ||
| # CHECK-NEXT: MCOperand Reg | ||
|
|
||
| [0x57,0x04,0x4a,0x48] | ||
| # CHECK: <MCInst #{{[0-9]+}} VSBC_VVM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| [0x57,0x44,0x45,0x48] | ||
| # CHECK: <MCInst #{{[0-9]+}} VSBC_VXM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| [0x57,0x04,0x4a,0x4c] | ||
| # CHECK: <MCInst #{{[0-9]+}} VMSBC_VVM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| [0x57,0x44,0x45,0x4c] | ||
| # CHECK: <MCInst #{{[0-9]+}} VMSBC_VXM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| [0x57,0x54,0x45,0x5c] | ||
| # CHECK: <MCInst #{{[0-9]+}} VFMERGE_VFM | ||
| # CHECK-COUNT-4: MCOperand Reg |
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,69 @@ | ||
| # RUN: llvm-mc -triple=riscv64 -show-inst --mattr=+v %s \ | ||
| # RUN: --M no-aliases | FileCheck %s | ||
|
|
||
| # Check if there is a MCOperand for the carry-in mask. | ||
|
|
||
| vmerge.vvm v8, v4, v20, v0 | ||
| # CHECK: <MCInst #{{[0-9]+}} VMERGE_VVM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| vmerge.vxm v8, v4, a0, v0 | ||
| # CHECK: <MCInst #{{[0-9]+}} VMERGE_VXM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| vmerge.vim v8, v4, 15, v0 | ||
| # CHECK: <MCInst #{{[0-9]+}} VMERGE_VIM | ||
| # CHECK-NEXT: MCOperand Reg | ||
| # CHECK-NEXT: MCOperand Reg | ||
| # CHECK-NEXT: MCOperand Imm | ||
| # CHECK-NEXT: MCOperand Reg | ||
|
|
||
| vadc.vvm v8, v4, v20, v0 | ||
| # CHECK: <MCInst #{{[0-9]+}} VADC_VVM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| vadc.vxm v8, v4, a0, v0 | ||
| # CHECK: <MCInst #{{[0-9]+}} VADC_VXM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| vadc.vim v8, v4, 15, v0 | ||
| # CHECK: <MCInst #{{[0-9]+}} VADC_VIM | ||
| # CHECK-NEXT: MCOperand Reg | ||
| # CHECK-NEXT: MCOperand Reg | ||
| # CHECK-NEXT: MCOperand Imm | ||
| # CHECK-NEXT: MCOperand Reg | ||
|
|
||
| vmadc.vvm v8, v4, v20, v0 | ||
| # CHECK: <MCInst #{{[0-9]+}} VMADC_VVM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| vmadc.vxm v8, v4, a0, v0 | ||
| # CHECK: <MCInst #{{[0-9]+}} VMADC_VXM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| vmadc.vim v8, v4, 15, v0 | ||
| # CHECK: <MCInst #{{[0-9]+}} VMADC_VIM | ||
| # CHECK-NEXT: MCOperand Reg | ||
| # CHECK-NEXT: MCOperand Reg | ||
| # CHECK-NEXT: MCOperand Imm | ||
| # CHECK-NEXT: MCOperand Reg | ||
|
|
||
| vsbc.vvm v8, v4, v20, v0 | ||
| # CHECK: <MCInst #{{[0-9]+}} VSBC_VVM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| vsbc.vxm v8, v4, a0, v0 | ||
| # CHECK: <MCInst #{{[0-9]+}} VSBC_VXM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| vmsbc.vvm v8, v4, v20, v0 | ||
| # CHECK: <MCInst #{{[0-9]+}} VMSBC_VVM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| vmsbc.vxm v8, v4, a0, v0 | ||
| # CHECK: <MCInst #{{[0-9]+}} VMSBC_VXM | ||
| # CHECK-COUNT-4: MCOperand Reg | ||
|
|
||
| vfmerge.vfm v8, v4, fa0, v0 | ||
| # CHECK: <MCInst #{{[0-9]+}} VFMERGE_VFM | ||
| # CHECK-COUNT-4: MCOperand Reg |
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.
I didn't reuse
decodeVMaskReghere because it accepts arbitraryvmfield value, while we only acceptvm = 0for carry-in vmask. Put it differently, if the input is an invalid encoding withvm=1on instruction with carry-in mask,decodeVMaskRegputs a NoRegister as the MCOperand and crashes the program, rather than printing out a nice error message.