-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[GlobalISel] Add GITypeOf
special type
#66079
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
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
49 changes: 49 additions & 0 deletions
49
llvm/test/TableGen/GlobalISelCombinerEmitter/match-table-typeof.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,49 @@ | ||
// RUN: llvm-tblgen -I %p/../../../include -gen-global-isel-combiner \ | ||
// RUN: -combiners=MyCombiner %s | \ | ||
// RUN: FileCheck %s | ||
|
||
include "llvm/Target/Target.td" | ||
include "llvm/Target/GlobalISel/Combine.td" | ||
|
||
def MyTargetISA : InstrInfo; | ||
def MyTarget : Target { let InstructionSet = MyTargetISA; } | ||
|
||
def Test0 : GICombineRule< | ||
(defs root:$dst), | ||
(match (G_MUL $dst, $src, -1)), | ||
(apply (G_SUB $dst, (GITypeOf<"$src"> 0), $tmp), | ||
(G_CONSTANT GITypeOf<"$dst">:$tmp, (GITypeOf<"$src"> 42)))>; | ||
|
||
// CHECK: const int64_t *GenMyCombiner::getMatchTable() const { | ||
// CHECK-NEXT: constexpr static int64_t MatchTable0[] = { | ||
// CHECK-NEXT: GIM_Try, /*On fail goto*//*Label 0*/ 57, // Rule ID 0 // | ||
// CHECK-NEXT: GIM_CheckSimplePredicate, GICXXPred_Simple_IsRule0Enabled, | ||
// CHECK-NEXT: GIM_CheckOpcode, /*MI*/0, TargetOpcode::G_MUL, | ||
// CHECK-NEXT: // MIs[0] dst | ||
// CHECK-NEXT: GIM_RecordRegType, /*MI*/0, /*Op*/0, /*TempTypeIdx*/-1, | ||
// CHECK-NEXT: // MIs[0] src | ||
// CHECK-NEXT: GIM_RecordRegType, /*MI*/0, /*Op*/1, /*TempTypeIdx*/-2, | ||
// CHECK-NEXT: // MIs[0] Operand 2 | ||
// CHECK-NEXT: GIM_CheckConstantInt, /*MI*/0, /*Op*/2, -1, | ||
// CHECK-NEXT: GIR_MakeTempReg, /*TempRegID*/1, /*TypeID*/-2, | ||
// CHECK-NEXT: GIR_BuildConstant, /*TempRegID*/1, /*Val*/0, | ||
// CHECK-NEXT: GIR_MakeTempReg, /*TempRegID*/0, /*TypeID*/-1, | ||
// CHECK-NEXT: // Combiner Rule #0: Test0 | ||
// CHECK-NEXT: GIR_BuildMI, /*InsnID*/0, /*Opcode*/TargetOpcode::G_CONSTANT, | ||
// CHECK-NEXT: GIR_AddTempRegister, /*InsnID*/0, /*TempRegID*/0, /*TempRegFlags*/0, | ||
// CHECK-NEXT: GIR_AddCImm, /*InsnID*/0, /*Type*/-2, /*Imm*/42, | ||
// CHECK-NEXT: GIR_EraseFromParent, /*InsnID*/0, | ||
// CHECK-NEXT: GIR_BuildMI, /*InsnID*/1, /*Opcode*/TargetOpcode::G_SUB, | ||
// CHECK-NEXT: GIR_Copy, /*NewInsnID*/1, /*OldInsnID*/0, /*OpIdx*/0, // dst | ||
// CHECK-NEXT: GIR_AddTempRegister, /*InsnID*/1, /*TempRegID*/1, /*TempRegFlags*/0, | ||
// CHECK-NEXT: GIR_AddTempRegister, /*InsnID*/1, /*TempRegID*/0, /*TempRegFlags*/0, | ||
// CHECK-NEXT: GIR_Done, | ||
// CHECK-NEXT: // Label 0: @57 | ||
// CHECK-NEXT: GIM_Reject, | ||
// CHECK-NEXT: }; | ||
// CHECK-NEXT: return MatchTable0; | ||
// CHECK-NEXT: } | ||
|
||
def MyCombiner: GICombiner<"GenMyCombiner", [ | ||
Test0 | ||
]>; |
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
72 changes: 72 additions & 0 deletions
72
llvm/test/TableGen/GlobalISelCombinerEmitter/typeof-errors.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,72 @@ | ||
// RUN: not llvm-tblgen -I %p/../../../include -gen-global-isel-combiner \ | ||
// RUN: -combiners=MyCombiner %s 2>&1| \ | ||
// RUN: FileCheck %s -implicit-check-not=error: | ||
|
||
include "llvm/Target/Target.td" | ||
include "llvm/Target/GlobalISel/Combine.td" | ||
|
||
def MyTargetISA : InstrInfo; | ||
def MyTarget : Target { let InstructionSet = MyTargetISA; } | ||
|
||
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: invalid operand name format 'unknown' in GITypeOf: expected '$' followed by an operand name | ||
def NoDollarSign : GICombineRule< | ||
(defs root:$dst), | ||
(match (G_ZEXT $dst, $src)), | ||
(apply (G_ANYEXT $dst, (GITypeOf<"unknown"> 0)))>; | ||
|
||
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: 'unknown' ('GITypeOf<$unknown>') does not refer to a matched operand! | ||
def UnknownOperand : GICombineRule< | ||
(defs root:$dst), | ||
(match (G_ZEXT $dst, $src)), | ||
(apply (G_ANYEXT $dst, (GITypeOf<"$unknown"> 0)))>; | ||
|
||
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: GISpecialType is not supported in 'match' patterns | ||
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: note: operand 1 of '__UseInMatch_match_0' has type 'GITypeOf<$dst>' | ||
def UseInMatch : GICombineRule< | ||
(defs root:$dst), | ||
(match (G_ZEXT $dst, (GITypeOf<"$dst"> 0))), | ||
(apply (G_ANYEXT $dst, (i32 0)))>; | ||
|
||
// CHECK: :[[@LINE+3]]:{{[0-9]+}}: error: GISpecialType is not supported in GICombinePatFrag | ||
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: note: operand 1 of '__PFWithTypeOF_alt0_pattern_0' has type 'GITypeOf<$dst> | ||
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Could not parse GICombinePatFrag 'PFWithTypeOF' | ||
def PFWithTypeOF: GICombinePatFrag< | ||
(outs $dst), (ins), | ||
[(pattern (G_ANYEXT $dst, (GITypeOf<"$dst"> 0)))]>; | ||
|
||
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(PFWithTypeOF ?:$dst)' | ||
def UseInPF: GICombineRule< | ||
(defs root:$dst), | ||
(match (PFWithTypeOF $dst)), | ||
(apply (G_ANYEXT $dst, (i32 0)))>; | ||
|
||
// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: GISpecialType is not supported in 'match' patterns | ||
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: note: operand 1 of '__InferredUseInMatch_match_0' has type 'GITypeOf<$dst>' | ||
def InferredUseInMatch : GICombineRule< | ||
(defs root:$dst), | ||
(match (G_ZEXT $dst, $src)), | ||
(apply (G_ANYEXT $dst, GITypeOf<"$dst">:$src))>; | ||
|
||
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: conflicting types for operand 'src': first seen with 'i32' in '__InferenceConflict_match_0, now seen with 'GITypeOf<$dst>' in '__InferenceConflict_apply_0' | ||
def InferenceConflict : GICombineRule< | ||
(defs root:$dst), | ||
(match (G_ZEXT $dst, i32:$src)), | ||
(apply (G_ANYEXT $dst, GITypeOf<"$dst">:$src))>; | ||
|
||
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: 'tmp' ('GITypeOf<$tmp>') does not refer to a matched operand! | ||
def TypeOfApplyTmp : GICombineRule< | ||
(defs root:$dst), | ||
(match (G_ZEXT $dst, $src)), | ||
(apply (G_ANYEXT $dst, i32:$tmp), | ||
(G_ANYEXT $tmp, (GITypeOf<"$tmp"> 0)))>; | ||
|
||
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse one or more rules | ||
def MyCombiner: GICombiner<"GenMyCombiner", [ | ||
NoDollarSign, | ||
UnknownOperand, | ||
UseInMatch, | ||
UseInPF, | ||
InferredUseInMatch, | ||
InferenceConflict, | ||
TypeOfApplyTmp | ||
]>; |
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.