forked from llvm/llvm-project
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GISel] Add RegState::Define to temporary defs in apply patterns (llv…
…m#77425) Previously, registers created for temporary defs in apply patterns were rendered as uses, resulting in machine verifier errors.
- Loading branch information
1 parent
71b28af
commit e862455
Showing
5 changed files
with
75 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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 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
56 changes: 56 additions & 0 deletions
56
llvm/test/TableGen/GlobalISelCombinerEmitter/match-table-temp-defs.td
This file contains 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,56 @@ | ||
// RUN: llvm-tblgen -I %p/../../../include -gen-global-isel-combiner \ | ||
// RUN: -combiners=MyCombiner %s | FileCheck %s | ||
|
||
// Checks that temporary registers defined in apply patterns | ||
// are emitted with RegState::Define. | ||
|
||
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_ADD $dst, $lhs, $rhs)), | ||
(apply (G_UDIVREM $tmp, $dst, $lhs, $rhs)) | ||
>; | ||
|
||
def Test1 : GICombineRule< | ||
(defs root:$dst), | ||
(match (G_ADD $dst, $lhs, $rhs)), | ||
(apply (G_UDIVREM $dst, $tmp, $lhs, $rhs)) | ||
>; | ||
|
||
def Test2 : GICombineRule< | ||
(defs root:$dst), | ||
(match (G_ADD $dst, $lhs, $rhs)), | ||
(apply (G_ADD $tmp, 0, $lhs), | ||
(G_ADD $dst, $tmp, $rhs)) | ||
>; | ||
|
||
def MyCombiner: GICombiner<"GenMyCombiner", [ | ||
Test0, | ||
Test1, | ||
Test2, | ||
]>; | ||
|
||
// CHECK: // Combiner Rule #0: Test0 | ||
// CHECK-NEXT: GIR_BuildMI, /*InsnID*/0, /*Opcode*/GIMT_Encode2(TargetOpcode::G_UDIVREM), | ||
// CHECK-NEXT: GIR_AddTempRegister, /*InsnID*/0, /*TempRegID*/0, /*TempRegFlags*/GIMT_Encode2(RegState::Define), | ||
// CHECK-NEXT: GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/0, /*OpIdx*/0, // dst | ||
// CHECK-NEXT: GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/0, /*OpIdx*/1, // lhs | ||
// CHECK-NEXT: GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/0, /*OpIdx*/2, // rhs | ||
|
||
// CHECK: // Combiner Rule #1: Test1 | ||
// CHECK-NEXT: GIR_BuildMI, /*InsnID*/0, /*Opcode*/GIMT_Encode2(TargetOpcode::G_UDIVREM), | ||
// CHECK-NEXT: GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/0, /*OpIdx*/0, // dst | ||
// CHECK-NEXT: GIR_AddTempRegister, /*InsnID*/0, /*TempRegID*/0, /*TempRegFlags*/GIMT_Encode2(RegState::Define), | ||
// CHECK-NEXT: GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/0, /*OpIdx*/1, // lhs | ||
// CHECK-NEXT: GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/0, /*OpIdx*/2, // rhs | ||
|
||
// CHECK: // Combiner Rule #2: Test2 | ||
// CHECK-NEXT: GIR_BuildMI, /*InsnID*/0, /*Opcode*/GIMT_Encode2(TargetOpcode::G_ADD), | ||
// CHECK-NEXT: GIR_AddTempRegister, /*InsnID*/0, /*TempRegID*/0, /*TempRegFlags*/GIMT_Encode2(RegState::Define), | ||
// CHECK-NEXT: GIR_AddSimpleTempRegister, /*InsnID*/0, /*TempRegID*/1, | ||
// CHECK-NEXT: GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/0, /*OpIdx*/1, // lhs |
This file contains 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 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