diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.cpp b/llvm/lib/CodeGen/MIRParser/MILexer.cpp index fd14d118a9afcc..88a79ecb3d6212 100644 --- a/llvm/lib/CodeGen/MIRParser/MILexer.cpp +++ b/llvm/lib/CodeGen/MIRParser/MILexer.cpp @@ -295,6 +295,7 @@ static MIToken::TokenKind getIdentifierKind(StringRef Identifier) { .Case("call-frame-size", MIToken::kw_call_frame_size) .Case("noconvergent", MIToken::kw_noconvergent) .Case("mmra", MIToken::kw_mmra) + .Case("lr-split", MIToken::kw_lr_split) .Default(MIToken::Identifier); } diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.h b/llvm/lib/CodeGen/MIRParser/MILexer.h index 1284973df5dd22..c36940c346ad36 100644 --- a/llvm/lib/CodeGen/MIRParser/MILexer.h +++ b/llvm/lib/CodeGen/MIRParser/MILexer.h @@ -148,6 +148,7 @@ struct MIToken { kw_call_frame_size, kw_noconvergent, kw_mmra, + kw_lr_split, // Metadata types. kw_distinct, diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp index 84b806ae81f39c..df8d7d780f925d 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp @@ -1535,7 +1535,8 @@ bool MIParser::parseInstruction(unsigned &OpCode, unsigned &Flags) { Token.is(MIToken::kw_disjoint) || Token.is(MIToken::kw_nusw) || Token.is(MIToken::kw_samesign) || - Token.is(MIToken::kw_inbounds)) { + Token.is(MIToken::kw_inbounds) || + Token.is(MIToken::kw_lr_split)) { // clang-format on // Mine frame and fast math flags if (Token.is(MIToken::kw_frame_setup)) @@ -1578,6 +1579,8 @@ bool MIParser::parseInstruction(unsigned &OpCode, unsigned &Flags) { Flags |= MachineInstr::SameSign; if (Token.is(MIToken::kw_inbounds)) Flags |= MachineInstr::InBounds; + if (Token.is(MIToken::kw_lr_split)) + Flags |= MachineInstr::LRSplit; lex(); } diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp index 9e9fa07d7e8da5..ae3dab09265f12 100644 --- a/llvm/lib/CodeGen/MIRPrinter.cpp +++ b/llvm/lib/CodeGen/MIRPrinter.cpp @@ -899,6 +899,8 @@ static void printMI(raw_ostream &OS, MFPrintState &State, OS << "samesign "; if (MI.getFlag(MachineInstr::InBounds)) OS << "inbounds "; + if (MI.getFlag(MachineInstr::LRSplit)) + OS << "lr-split "; // NOTE: Please add new MIFlags also to the MI_FLAGS_STR in // llvm/utils/update_mir_test_checks.py. diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index cc3dae91c16d22..19c64aa5579b52 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -1901,6 +1901,8 @@ void MachineInstr::print(raw_ostream &OS, ModuleSlotTracker &MST, OS << "samesign "; if (getFlag(MachineInstr::InBounds)) OS << "inbounds "; + if (getFlag(MachineInstr::LRSplit)) + OS << "lr-split "; // Print the opcode name. if (TII) diff --git a/llvm/test/CodeGen/MIR/AMDGPU/lr-split-flag.mir b/llvm/test/CodeGen/MIR/AMDGPU/lr-split-flag.mir new file mode 100644 index 00000000000000..ed1680e3545c2f --- /dev/null +++ b/llvm/test/CodeGen/MIR/AMDGPU/lr-split-flag.mir @@ -0,0 +1,25 @@ +# RUN: llc -mtriple=amdgcn -mcpu=gfx950 -run-pass=none -o - %s | FileCheck %s +# +# Round-trip test for the 'lr-split' MIR text spelling of +# MachineInstr::LRSplit. The flag is set by SplitKit on copies inserted for +# live-range splitting; AMDGPU's SIInstrInfo::canAddToBBProlog uses it to +# recognize WWM_COPY / IMPLICIT_DEF instructions as part of the BB prologue. + +--- +name: lr_split_roundtrip +tracksRegLiveness: true +machineFunctionInfo: + isEntryFunction: true +registers: + - { id: 0, class: vgpr_32, flags: [ WWM_REG ] } + - { id: 1, class: vgpr_32, flags: [ WWM_REG ] } +body: | + bb.0: + liveins: $vgpr0 + %0:vgpr_32 = COPY $vgpr0 + %1:vgpr_32 = lr-split WWM_COPY %0:vgpr_32 + S_ENDPGM 0, implicit %1 +... + +# CHECK-LABEL: name: lr_split_roundtrip +# CHECK: %1:vgpr_32 = lr-split WWM_COPY %0 diff --git a/llvm/utils/UpdateTestChecks/mir.py b/llvm/utils/UpdateTestChecks/mir.py index b6fa324d0565e3..e75d3dd2ff368f 100644 --- a/llvm/utils/UpdateTestChecks/mir.py +++ b/llvm/utils/UpdateTestChecks/mir.py @@ -21,7 +21,7 @@ MI_FLAGS_STR = ( r"(frame-setup |frame-destroy |nnan |ninf |nsz |arcp |contract |afn " r"|reassoc |nuw |nsw |exact |nofpexcept |nomerge |unpredictable " - r"|noconvergent |nneg |disjoint |nusw |samesign |inbounds )*" + r"|noconvergent |nneg |disjoint |nusw |samesign |inbounds |lr-split )*" ) VREG_DEF_FLAGS_STR = r"(?:dead |undef )*"