-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[TableGen][DecoderEmitter] Fix decoder reading bytes past instruction #154916
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
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
44 changes: 44 additions & 0 deletions
44
llvm/test/TableGen/FixedLenDecoderEmitter/var-len-conflict-1.td
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,44 @@ | ||
| // RUN: llvm-tblgen -gen-disassembler -I %p/../../../include %s | FileCheck %s | ||
|
|
||
| include "llvm/Target/Target.td" | ||
|
|
||
| class I : Instruction { | ||
| let InOperandList = (ins i32imm:$op); | ||
| let OutOperandList = (outs); | ||
| } | ||
|
|
||
| // Check that we don't try to read the second byte without ruling out | ||
| // 1-byte encodings first. This should actually be a decoding conflict, | ||
| // but DecoderEmitter heuristics decide that I8_0 and I8_1 are more specific | ||
| // than the rest and give them priority. | ||
|
|
||
| // _______0 I8_0 | ||
| // _______1 I8_1 | ||
| // 00000000 ________ I16_0 | ||
| // 00000001 ________ I16_1 | ||
| // 00000010 ________ I16_2 | ||
|
|
||
| // CHECK: MCD::OPC_ExtractField, 0, 1, // Inst{0} ... | ||
| // CHECK-NEXT: MCD::OPC_FilterValue, 0, 4, 0, // Skip to: 11 | ||
| // CHECK-NEXT: MCD::OPC_Decode, {{[0-9]+}}, 2, 0, // Opcode: I8_0, DecodeIdx: 0 | ||
| // CHECK-NEXT: MCD::OPC_FilterValue, 1, 4, 0, // Skip to: 19 | ||
| // CHECK-NEXT: MCD::OPC_Decode, {{[0-9]+}}, 2, 0, // Opcode: I8_1, DecodeIdx: 0 | ||
| // CHECK-NEXT: MCD::OPC_ExtractField, 8, 8, // Inst{15-8} ... | ||
| // CHECK-NEXT: MCD::OPC_FilterValue, 0, 4, 0, // Skip to: 30 | ||
| // CHECK-NEXT: MCD::OPC_Decode, {{[0-9]+}}, 2, 1, // Opcode: I16_0, DecodeIdx: 1 | ||
| // CHECK-NEXT: MCD::OPC_FilterValue, 1, 4, 0, // Skip to: 38 | ||
| // CHECK-NEXT: MCD::OPC_Decode, {{[0-9]+}}, 2, 1, // Opcode: I16_1, DecodeIdx: 1 | ||
| // CHECK-NEXT: MCD::OPC_FilterValueOrFail, 2, | ||
| // CHECK-NEXT: MCD::OPC_Decode, {{[0-9]+}}, 2, 1, // Opcode: I16_2, DecodeIdx: 1 | ||
|
|
||
| def I8_0 : I { dag Inst = (descend (operand "$op", 7), 0b0); } | ||
| def I8_1 : I { dag Inst = (descend (operand "$op", 7), 0b1); } | ||
| def I16_0 : I { dag Inst = (descend 0b00000000, (operand "$op", 8)); } | ||
| def I16_1 : I { dag Inst = (descend 0b00000001, (operand "$op", 8)); } | ||
| def I16_2 : I { dag Inst = (descend 0b00000010, (operand "$op", 8)); } | ||
|
|
||
| def II : InstrInfo; | ||
|
|
||
| def MyTarget : Target { | ||
| let InstructionSet = II; | ||
| } |
35 changes: 35 additions & 0 deletions
35
llvm/test/TableGen/FixedLenDecoderEmitter/var-len-conflict-2.td
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,35 @@ | ||
| // RUN: not llvm-tblgen -gen-disassembler -I %p/../../../include %s -o /dev/null 2>&1 \ | ||
| // RUN: | FileCheck --strict-whitespace %s | ||
|
|
||
| include "llvm/Target/Target.td" | ||
|
|
||
| class I : Instruction { | ||
| let InOperandList = (ins i32imm:$op, i32imm:$op2, i32imm:$op3); | ||
| let OutOperandList = (outs); | ||
| } | ||
|
|
||
| // Check pretty printing of decoding conflicts. | ||
|
|
||
| // CHECK: {{^}}Decoding Conflict: | ||
| // CHECK-NEXT: {{^}} ........ | ||
| // CHECK-NEXT: {{^}} ..............11 | ||
| // CHECK-NEXT: {{^}} .......0......11 | ||
| // CHECK-NEXT: {{^}} _______0______11 I16_0 | ||
| // CHECK-NEXT: {{^}} _______0______11 I16_1 | ||
| // CHECK-NEXT: {{^}} _______0_______0______11 I24_0 | ||
|
|
||
| def I8_0 : I { dag Inst = (descend (operand "$op", 6), 0b00); } | ||
| def I8_1 : I { dag Inst = (descend (operand "$op", 6), 0b01); } | ||
| def I16_0 : I { dag Inst = (descend (operand "$op2", 7), 0b0, | ||
| (operand "$op", 6), 0b11); } | ||
| def I16_1 : I { dag Inst = (descend (operand "$op2", 7), 0b0, | ||
| (operand "$op", 6), 0b11); } | ||
| def I24_0 : I { dag Inst = (descend (operand "$op3", 7), 0b0, | ||
| (operand "$op2", 7), 0b0, | ||
| (operand "$op", 6), 0b11); } | ||
|
|
||
| def II : InstrInfo; | ||
|
|
||
| def MyTarget : Target { | ||
| let InstructionSet = II; | ||
| } |
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.