-
Notifications
You must be signed in to change notification settings - Fork 2
Support 48 bit encodings #54
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
6 commits
Select commit
Hold shift + click to select a range
207dcff
[pattern-gen] Support 48-bit encodings
PhilippvK 04e4cc9
[pattern-gen] Support 48-bit instrs in InstrInfo.otd
PhilippvK 9b2a39b
Add CDSL examples for 48-bit instrs
PhilippvK 1659dec
[pattern-gen] Support const fields in encoding with total length of >…
PhilippvK c4d10f8
fix compiler warning
PhilippvK 2111b7b
[pattern-gen] Parser/InstrInfo: support 16 bit encoding
PhilippvK 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // RUN: pattern-gen %s -O 3 --mattr=+m --riscv-xlen 32 | FileCheck --check-prefixes=CHECK-RV32,CHECK-RV32-EXTEND -allow-unused-prefixes %s | ||
| // RUN: pattern-gen %s -O 3 --no-extend --mattr=+m --riscv-xlen 32 | FileCheck --check-prefixes=CHECK-RV32,CHECK-RV32-NOEXTED -allow-unused-prefixes %s | ||
|
|
||
| InstructionSet XExampleRV32 extends RISCVBase { | ||
| instructions { | ||
| // CHECK-RV32: Pattern for K_LLI: (i32 uimm32:$imm) | ||
| K_LLI { | ||
| encoding: 4'b0000 :: imm[31:0] :: rd[4:0] :: 7'b1011111; | ||
| assembly: {"k.lli", "{name(rd)}, {imm}"}; | ||
| behavior: { | ||
| if ((rd % RFS) != 0) | ||
| // imm -> unsigned! | ||
| // X[rd % RFS] = (unsigned<XLEN>) ((unsigned) imm); | ||
| X[rd] = (unsigned<XLEN>) ((unsigned) imm); | ||
| } | ||
| } | ||
| // CHECK-RV32: Pattern for K_ADDI: (add GPR:$rs1, (i32 uimm24:$imm)) | ||
| K_ADDI { | ||
| encoding: 4'b0001 :: imm[23:0] :: rs1[4:0] :: 3'b000 :: rd[4:0] :: 7'b1011111; | ||
| assembly: {"k.addi", "{name(rd)}, {name(rs1)}, {imm}"}; | ||
| behavior: { | ||
| if ((rd % RFS) != 0) { | ||
| // X[rd % RFS] = X[rs1 % RFS] + (signed)imm; | ||
| X[rd] = X[rs1] + (signed)imm; | ||
| } | ||
| } | ||
| } | ||
| // CHECK-RV32: Pattern for K_ANDI: (and GPR:$rs1, (i32 uimm24:$imm)) | ||
| K_ANDI { | ||
| encoding: 4'b0001 :: imm[23:0] :: rs1[4:0] :: 3'b001 :: rd[4:0] :: 7'b1011111; | ||
| assembly: {"k.andi", "{name(rd)}, {name(rs1)}, {imm}"}; | ||
| behavior: { | ||
| if ((rd % RFS) != 0) { | ||
| // X[rd % RFS] = X[rs1 % RFS] & (unsigned)imm; | ||
| X[rd] = X[rs1] & (unsigned)imm; | ||
| } | ||
| } | ||
| } | ||
| // CHECK-RV32: Pattern for K_XORI: (xor GPR:$rs1, (i32 uimm24:$imm)) | ||
| K_XORI { | ||
| encoding: 4'b0001 :: imm[23:0] :: rs1[4:0] :: 3'b010 :: rd[4:0] :: 7'b1011111; | ||
| assembly: {"k.xori", "{name(rd)}, {name(rs1)}, {imm}"}; | ||
| behavior: { | ||
| if ((rd % RFS) != 0) { | ||
| // X[rd % RFS] = X[rs1 % RFS] ^ (unsigned)imm; | ||
| X[rd] = X[rs1] ^ (unsigned)imm; | ||
| } | ||
| } | ||
| } | ||
| // CHECK-RV32: Pattern for K_ORI: (or GPR:$rs1, (i32 uimm24:$imm)) | ||
| K_ORI { | ||
| encoding: 4'b0001 :: imm[23:0] :: rs1[4:0] :: 3'b011 :: rd[4:0] :: 7'b1011111; | ||
| assembly: {"k.ori", "{name(rd)}, {name(rs1)}, {imm}"}; | ||
| behavior: { | ||
| if ((rd % RFS) != 0) { | ||
| // X[rd % RFS] = X[rs1 % RFS] | (unsigned)imm; | ||
| X[rd] = X[rs1] | (unsigned)imm; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
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,86 @@ | ||
| ; ModuleID = 'mod' | ||
| source_filename = "mod" | ||
|
|
||
| define void @implK_LLI(i32 %imm, ptr noalias %rd) { | ||
| %1 = and i32 %imm, -1 | ||
| %2 = icmp eq i32 %imm, %1 | ||
| call void @llvm.assume(i1 %2) | ||
| br i1 true, label %3, label %4 | ||
|
|
||
| 3: ; preds = %0 | ||
| store i32 %imm, ptr %rd, align 4 | ||
| br label %4 | ||
|
|
||
| 4: ; preds = %3, %0 | ||
| ret void | ||
| } | ||
|
|
||
| ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) | ||
| declare void @llvm.assume(i1 noundef) #0 | ||
|
|
||
| define void @implK_ADDI(i32 %imm, ptr %rs1, ptr noalias %rd) { | ||
| %1 = and i32 %imm, 16777215 | ||
| %2 = icmp eq i32 %imm, %1 | ||
| call void @llvm.assume(i1 %2) | ||
| br i1 true, label %3, label %5 | ||
|
|
||
| 3: ; preds = %0 | ||
| %rs1.v = load i32, ptr %rs1, align 4 | ||
| %4 = add i32 %rs1.v, %imm | ||
| store i32 %4, ptr %rd, align 4 | ||
| br label %5 | ||
|
|
||
| 5: ; preds = %3, %0 | ||
| ret void | ||
| } | ||
|
|
||
| define void @implK_ANDI(i32 %imm, ptr %rs1, ptr noalias %rd) { | ||
| %1 = and i32 %imm, 16777215 | ||
| %2 = icmp eq i32 %imm, %1 | ||
| call void @llvm.assume(i1 %2) | ||
| br i1 true, label %3, label %5 | ||
|
|
||
| 3: ; preds = %0 | ||
| %rs1.v = load i32, ptr %rs1, align 4 | ||
| %4 = and i32 %rs1.v, %imm | ||
| store i32 %4, ptr %rd, align 4 | ||
| br label %5 | ||
|
|
||
| 5: ; preds = %3, %0 | ||
| ret void | ||
| } | ||
|
|
||
| define void @implK_XORI(i32 %imm, ptr %rs1, ptr noalias %rd) { | ||
| %1 = and i32 %imm, 16777215 | ||
| %2 = icmp eq i32 %imm, %1 | ||
| call void @llvm.assume(i1 %2) | ||
| br i1 true, label %3, label %5 | ||
|
|
||
| 3: ; preds = %0 | ||
| %rs1.v = load i32, ptr %rs1, align 4 | ||
| %4 = xor i32 %rs1.v, %imm | ||
| store i32 %4, ptr %rd, align 4 | ||
| br label %5 | ||
|
|
||
| 5: ; preds = %3, %0 | ||
| ret void | ||
| } | ||
|
|
||
| define void @implK_ORI(i32 %imm, ptr %rs1, ptr noalias %rd) { | ||
| %1 = and i32 %imm, 16777215 | ||
| %2 = icmp eq i32 %imm, %1 | ||
| call void @llvm.assume(i1 %2) | ||
| br i1 true, label %3, label %5 | ||
|
|
||
| 3: ; preds = %0 | ||
| %rs1.v = load i32, ptr %rs1, align 4 | ||
| %4 = or i32 %rs1.v, %imm | ||
| store i32 %4, ptr %rd, align 4 | ||
| br label %5 | ||
|
|
||
| 5: ; preds = %3, %0 | ||
| ret void | ||
| } | ||
|
|
||
| attributes #0 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) } | ||
|
|
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 @@ | ||
| let Predicates = [HasVendorXCValu] in { | ||
|
|
||
| let hasSideEffects = 0, mayLoad = 0, mayStore = 0, isCodeGenOnly = 1, Constraints = "" in def K_LLI_ : RVInst_K_LLI<(outs GPR:$rd), (ins uimm32:$imm)>; | ||
|
|
||
| def : Pat< | ||
| (i32 (i32 uimm32:$imm)), | ||
| (K_LLI_ uimm32:$imm)>; | ||
|
|
||
| let hasSideEffects = 0, mayLoad = 0, mayStore = 0, isCodeGenOnly = 1, Constraints = "" in def K_ADDI_ : RVInst_K_ADDI<(outs GPR:$rd), (ins uimm24:$imm, GPR:$rs1)>; | ||
|
|
||
| def : Pat< | ||
| (i32 (add GPR:$rs1, (i32 uimm24:$imm))), | ||
| (K_ADDI_ uimm24:$imm, GPR:$rs1)>; | ||
|
|
||
| let hasSideEffects = 0, mayLoad = 0, mayStore = 0, isCodeGenOnly = 1, Constraints = "" in def K_ANDI_ : RVInst_K_ANDI<(outs GPR:$rd), (ins uimm24:$imm, GPR:$rs1)>; | ||
|
|
||
| def : Pat< | ||
| (i32 (and GPR:$rs1, (i32 uimm24:$imm))), | ||
| (K_ANDI_ uimm24:$imm, GPR:$rs1)>; | ||
|
|
||
| let hasSideEffects = 0, mayLoad = 0, mayStore = 0, isCodeGenOnly = 1, Constraints = "" in def K_XORI_ : RVInst_K_XORI<(outs GPR:$rd), (ins uimm24:$imm, GPR:$rs1)>; | ||
|
|
||
| def : Pat< | ||
| (i32 (xor GPR:$rs1, (i32 uimm24:$imm))), | ||
| (K_XORI_ uimm24:$imm, GPR:$rs1)>; | ||
|
|
||
| let hasSideEffects = 0, mayLoad = 0, mayStore = 0, isCodeGenOnly = 1, Constraints = "" in def K_ORI_ : RVInst_K_ORI<(outs GPR:$rd), (ins uimm24:$imm, GPR:$rs1)>; | ||
|
|
||
| def : Pat< | ||
| (i32 (or GPR:$rs1, (i32 uimm24:$imm))), | ||
| (K_ORI_ uimm24:$imm, GPR:$rs1)>; | ||
|
|
||
| } |
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
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.