Skip to content

Commit

Permalink
[TableGen][GISel] Fix IMPLICIT_DEF operand being added as a use (#121…
Browse files Browse the repository at this point in the history
…283)

`IMPLICIT_DEF` has one operand that is a def, not a use.
  • Loading branch information
s-barannikov authored Dec 29, 2024
1 parent db7123f commit 6cbc64e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions llvm/test/TableGen/GlobalISelEmitter/undef-tied-input.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// RUN: llvm-tblgen -gen-global-isel -I %p/../../../include -I %p/../Common %s | FileCheck %s

include "llvm/Target/Target.td"
include "GlobalISelEmitterCommon.td"

def undef_tied : OperandWithDefaultOps<untyped, (ops (i32 undef_tied_input))> {
let MIOperandInfo = (ops GPR32:$inactive);
}

let Constraints = "$opt.inactive = $rd" in
def I1 : I<(outs GPR32:$rd), (ins GPR32:$rs, undef_tied:$opt),
[(set GPR32:$rd, (abs i32:$rs))]>;

// CHECK-LABEL: // (abs:{ *:[i32] } i32:{ *:[i32] }:$rs) => (I1:{ *:[i32] } i32:{ *:[i32] }:$rs)
// CHECK-NEXT: GIR_MakeTempReg, /*TempRegID*/0, /*TypeID*/GILLT_s32,
// CHECK-NEXT: GIR_BuildMI, /*InsnID*/1, /*Opcode*/GIMT_Encode2(TargetOpcode::IMPLICIT_DEF),
// CHECK-NEXT: GIR_AddTempRegister, /*InsnID*/1, /*TempRegID*/0, /*TempRegFlags*/GIMT_Encode2(RegState::Define),
// CHECK-NEXT: GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::I1),
// CHECK-NEXT: GIR_RootToRootCopy, /*OpIdx*/0, // DstI[rd]
// CHECK-NEXT: GIR_RootToRootCopy, /*OpIdx*/1, // rs
// CHECK-NEXT: GIR_AddSimpleTempRegister, /*InsnID*/0, /*TempRegID*/0,
// CHECK-NEXT: GIR_RootConstrainSelectedInstOperands,
// CHECK-NEXT: // GIR_Coverage, 0,
// CHECK-NEXT: GIR_EraseRootFromParent_Done,
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/GlobalISelEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1756,7 +1756,7 @@ Error GlobalISelEmitter::importDefaultOperandRenderers(
&Target.getInstruction(RK.getDef("IMPLICIT_DEF")));
BuildMIAction &IDMIBuilder =
*static_cast<BuildMIAction *>(InsertPt->get());
IDMIBuilder.addRenderer<TempRegRenderer>(TempRegID);
IDMIBuilder.addRenderer<TempRegRenderer>(TempRegID, /*IsDef=*/true);
DstMIBuilder.addRenderer<TempRegRenderer>(TempRegID);
} else {
DstMIBuilder.addRenderer<AddRegisterRenderer>(Target, Def);
Expand Down

0 comments on commit 6cbc64e

Please sign in to comment.