-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[TableGen][GISel] Fix importing frameindex node #120921
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
s-barannikov
merged 2 commits into
llvm:main
from
s-barannikov:tablegen/gisel/frame-index
Dec 23, 2024
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,67 @@ | ||
// RUN: llvm-tblgen -gen-global-isel -optimize-match-table=false -I %p/../../include -I %p/Common %s -o - < %s | FileCheck %s | ||
// RUN: llvm-tblgen -gen-global-isel -optimize-match-table=false -I %p/../../include -I %p/Common %s | FileCheck %s | ||
|
||
include "llvm/Target/Target.td" | ||
include "GlobalISelEmitterCommon.td" | ||
|
||
def ADD : I<(outs GPR32:$dst), (ins GPR32:$src1, GPR32:$src2), []>; | ||
|
||
//===- Test a simple pattern with frame index operands. ----------------------===// | ||
// | ||
// CHECK: GIM_Try, /*On fail goto*//*Label [[LABEL_NUM:[0-9]+]]*/ GIMT_Encode4([[LABEL:[0-9]+]]), | ||
// CHECK-NEXT: GIM_CheckNumOperands, /*MI*/0, /*Expected*/2, | ||
// CHECK-NEXT: GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_FRAME_INDEX), | ||
// CHECK-NEXT: // MIs[0] DstI[dst] | ||
// CHECK-NEXT: GIM_RootCheckType, /*Op*/0, /*Type*/GILLT_p0s32, | ||
// CHECK-NEXT: GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID), | ||
// CHECK-NEXT: // MIs[0] fi | ||
// CHECK-NEXT: // No operand predicates | ||
// CHECK-NEXT: // (frameindex:{ *:[i32] }):$fi => (ADD:{ *:[i32] } (tframeindex:{ *:[i32] }):$fi, 0:{ *:[i32] }) | ||
// CHECK-NEXT: GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::ADD), | ||
// CHECK-NEXT: GIR_RootToRootCopy, /*OpIdx*/0, // DstI[dst] | ||
// CHECK-NEXT: GIR_RootToRootCopy, /*OpIdx*/1, // fi | ||
// CHECK-NEXT: GIR_AddImm8, /*InsnID*/0, /*Imm*/0, | ||
// CHECK-NEXT: GIR_RootConstrainSelectedInstOperands, | ||
// CHECK-NEXT: // GIR_Coverage, 0, | ||
// CHECK-NEXT: GIR_EraseRootFromParent_Done, | ||
// CHECK-NEXT: // Label [[LABEL_NUM]]: @[[LABEL]] | ||
// CHECK-NEXT: GIM_Reject, | ||
|
||
def : Pat<(p0 frameindex:$fi), (ADD tframeindex:$fi, 0)>; | ||
def ADDI : I<(outs GPR32:$dst), (ins GPR32:$src1, i32imm:$src2), []>; | ||
|
||
def to_tframeindex : SDNodeXForm<frameindex, [{}]>; | ||
|
||
def : GICustomOperandRenderer<"renderFrameIndex">, | ||
GISDNodeXFormEquiv<to_tframeindex>; | ||
|
||
def : Pat<(frameindex:$fi), (ADDI (to_tframeindex $fi), 0)>; | ||
|
||
def : Pat<(ptradd frameindex:$fi, (i32 imm:$offset)), | ||
(ADDI (to_tframeindex $fi), imm:$offset)>; | ||
|
||
// CHECK-LABEL: GIM_Try, /*On fail goto*//*Label 0*/ GIMT_Encode4(74), // Rule ID 1 // | ||
// CHECK-NEXT: GIM_CheckNumOperands, /*MI*/0, /*Expected*/3, | ||
// CHECK-NEXT: GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_PTR_ADD), | ||
// CHECK-NEXT: // MIs[0] DstI[dst] | ||
// CHECK-NEXT: GIM_CheckPointerToAny, /*MI*/0, /*Op*/0, /*SizeInBits*/32, | ||
// CHECK-NEXT: GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID), | ||
// CHECK-NEXT: // MIs[0] fi | ||
// CHECK-NEXT: GIM_CheckPointerToAny, /*MI*/0, /*Op*/1, /*SizeInBits*/32, | ||
// CHECK-NEXT: GIM_RecordInsn, /*DefineMI*/1, /*MI*/0, /*OpIdx*/1, // MIs[1] | ||
// CHECK-NEXT: GIM_CheckNumOperands, /*MI*/1, /*Expected*/2, | ||
// CHECK-NEXT: GIM_CheckOpcode, /*MI*/1, GIMT_Encode2(TargetOpcode::G_FRAME_INDEX), | ||
// CHECK-NEXT: // MIs[1] Operand 0 | ||
// CHECK-NEXT: GIM_CheckPointerToAny, /*MI*/1, /*Op*/0, /*SizeInBits*/32, | ||
// CHECK-NEXT: // MIs[1] Operand 1 | ||
// CHECK-NEXT: // No operand predicates | ||
// CHECK-NEXT: // MIs[0] offset | ||
// CHECK-NEXT: GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s32, | ||
// CHECK-NEXT: GIM_RecordInsn, /*DefineMI*/2, /*MI*/0, /*OpIdx*/2, // MIs[2] | ||
// CHECK-NEXT: GIM_CheckNumOperands, /*MI*/2, /*Expected*/2, | ||
// CHECK-NEXT: GIM_CheckOpcode, /*MI*/2, GIMT_Encode2(TargetOpcode::G_CONSTANT), | ||
// CHECK-NEXT: // MIs[2] Operand 0 | ||
// CHECK-NEXT: GIM_CheckType, /*MI*/2, /*Op*/0, /*Type*/GILLT_s32, | ||
// CHECK-NEXT: // MIs[2] Operand 1 | ||
// CHECK-NEXT: // No operand predicates | ||
// CHECK-NEXT: GIM_CheckIsSafeToFold, /*NumInsns*/2, | ||
// CHECK-NEXT: // (ptradd:{ *:[i32] } (frameindex:{ *:[i32] }):$fi, (imm:{ *:[i32] }):$offset) => (ADDI:{ *:[i32] } (to_tframeindex:{ *:[i32] } ?:{ *:[i32] }:$fi), (imm:{ *:[i32] }):$offset) | ||
// CHECK-NEXT: GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::ADDI), | ||
// CHECK-NEXT: GIR_RootToRootCopy, /*OpIdx*/0, // DstI[dst] | ||
// CHECK-NEXT: GIR_CustomRenderer, /*InsnID*/0, /*OldInsnID*/1, /*Renderer*/GIMT_Encode2(GICR_renderFrameIndex), // fi | ||
// CHECK-NEXT: GIR_CopyConstantAsSImm, /*NewInsnID*/0, /*OldInsnID*/2, // offset | ||
// CHECK-NEXT: GIR_RootConstrainSelectedInstOperands, | ||
// CHECK-NEXT: // GIR_Coverage, 1, | ||
// CHECK-NEXT: GIR_EraseRootFromParent_Done, | ||
|
||
// CHECK-LABEL: GIM_Try, /*On fail goto*//*Label 1*/ GIMT_Encode4(109), // Rule ID 0 // | ||
// CHECK-NEXT: GIM_CheckNumOperands, /*MI*/0, /*Expected*/2, | ||
// CHECK-NEXT: GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_FRAME_INDEX), | ||
// CHECK-NEXT: // MIs[0] DstI[dst] | ||
// CHECK-NEXT: GIM_CheckPointerToAny, /*MI*/0, /*Op*/0, /*SizeInBits*/32, | ||
// CHECK-NEXT: GIM_RootCheckRegBankForClass, /*Op*/0, /*RC*/GIMT_Encode2(MyTarget::GPR32RegClassID), | ||
// CHECK-NEXT: // MIs[0] Operand 1 | ||
// CHECK-NEXT: // No operand predicates | ||
// CHECK-NEXT: // (frameindex:{ *:[i32] }):$fi => (ADDI:{ *:[i32] } (to_tframeindex:{ *:[i32] } ?:{ *:[i32] }:$fi), 0:{ *:[i32] }) | ||
// CHECK-NEXT: GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::ADDI), | ||
// CHECK-NEXT: GIR_RootToRootCopy, /*OpIdx*/0, // DstI[dst] | ||
// CHECK-NEXT: GIR_CustomRenderer, /*InsnID*/0, /*OldInsnID*/0, /*Renderer*/GIMT_Encode2(GICR_renderFrameIndex), // fi | ||
// CHECK-NEXT: GIR_AddImm8, /*InsnID*/0, /*Imm*/0, | ||
// CHECK-NEXT: GIR_RootConstrainSelectedInstOperands, | ||
// CHECK-NEXT: // GIR_Coverage, 0, | ||
// CHECK-NEXT: GIR_EraseRootFromParent_Done, |
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
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.
G_GLOBAL_VALUE should be the same
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'll add it in a future PR along with a test.