Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions llvm/lib/CodeGen/MIRParser/MILexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions llvm/lib/CodeGen/MIRParser/MILexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ struct MIToken {
kw_call_frame_size,
kw_noconvergent,
kw_mmra,
kw_lr_split,

// Metadata types.
kw_distinct,
Expand Down
5 changes: 4 additions & 1 deletion llvm/lib/CodeGen/MIRParser/MIParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/CodeGen/MIRPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/CodeGen/MachineInstr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 25 additions & 0 deletions llvm/test/CodeGen/MIR/AMDGPU/lr-split-flag.mir
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion llvm/utils/UpdateTestChecks/mir.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 )*"

Expand Down