[llvm] r241734 - MIR Serialization: Serialize the 'killed' register machine operand flag.
Alex Lorenz
arphaman at gmail.com
Wed Jul 8 14:23:34 PDT 2015
Author: arphaman
Date: Wed Jul 8 16:23:34 2015
New Revision: 241734
URL: http://llvm.org/viewvc/llvm-project?rev=241734&view=rev
Log:
MIR Serialization: Serialize the 'killed' register machine operand flag.
Added:
llvm/trunk/test/CodeGen/MIR/X86/killed-register-flag.mir
Modified:
llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp
llvm/trunk/lib/CodeGen/MIRParser/MILexer.h
llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
llvm/trunk/lib/CodeGen/MIRPrinter.cpp
Modified: llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp?rev=241734&r1=241733&r2=241734&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp Wed Jul 8 16:23:34 2015
@@ -71,6 +71,7 @@ static MIToken::TokenKind getIdentifierK
.Case("implicit", MIToken::kw_implicit)
.Case("implicit-def", MIToken::kw_implicit_define)
.Case("dead", MIToken::kw_dead)
+ .Case("killed", MIToken::kw_killed)
.Default(MIToken::Identifier);
}
Modified: llvm/trunk/lib/CodeGen/MIRParser/MILexer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MILexer.h?rev=241734&r1=241733&r2=241734&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MILexer.h (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MILexer.h Wed Jul 8 16:23:34 2015
@@ -40,6 +40,7 @@ struct MIToken {
kw_implicit,
kw_implicit_define,
kw_dead,
+ kw_killed,
// Identifier tokens
Identifier,
@@ -75,7 +76,8 @@ public:
}
bool isRegisterFlag() const {
- return Kind == kw_implicit || Kind == kw_implicit_define || Kind == kw_dead;
+ return Kind == kw_implicit || Kind == kw_implicit_define ||
+ Kind == kw_dead || Kind == kw_killed;
}
bool is(TokenKind K) const { return Kind == K; }
Modified: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp?rev=241734&r1=241733&r2=241734&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Wed Jul 8 16:23:34 2015
@@ -308,6 +308,9 @@ bool MIParser::parseRegisterFlag(unsigne
case MIToken::kw_dead:
Flags |= RegState::Dead;
break;
+ case MIToken::kw_killed:
+ Flags |= RegState::Kill;
+ break;
// TODO: report an error when we specify the same flag more than once.
// TODO: parse the other register flags.
default:
@@ -330,9 +333,9 @@ bool MIParser::parseRegisterOperand(Mach
return true;
lex();
// TODO: Parse subregister.
- Dest = MachineOperand::CreateReg(Reg, Flags & RegState::Define,
- Flags & RegState::Implicit, /*IsKill=*/false,
- Flags & RegState::Dead);
+ Dest = MachineOperand::CreateReg(
+ Reg, Flags & RegState::Define, Flags & RegState::Implicit,
+ Flags & RegState::Kill, Flags & RegState::Dead);
return false;
}
@@ -417,6 +420,7 @@ bool MIParser::parseMachineOperand(Machi
case MIToken::kw_implicit:
case MIToken::kw_implicit_define:
case MIToken::kw_dead:
+ case MIToken::kw_killed:
case MIToken::underscore:
case MIToken::NamedRegister:
return parseRegisterOperand(Dest);
Modified: llvm/trunk/lib/CodeGen/MIRPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRPrinter.cpp?rev=241734&r1=241733&r2=241734&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRPrinter.cpp Wed Jul 8 16:23:34 2015
@@ -218,6 +218,8 @@ void MIPrinter::print(const MachineOpera
OS << (Op.isDef() ? "implicit-def " : "implicit ");
if (Op.isDead())
OS << "dead ";
+ if (Op.isKill())
+ OS << "killed ";
printReg(Op.getReg(), OS, TRI);
// TODO: Print sub register.
break;
Added: llvm/trunk/test/CodeGen/MIR/X86/killed-register-flag.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/X86/killed-register-flag.mir?rev=241734&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/X86/killed-register-flag.mir (added)
+++ llvm/trunk/test/CodeGen/MIR/X86/killed-register-flag.mir Wed Jul 8 16:23:34 2015
@@ -0,0 +1,42 @@
+# RUN: llc -march=x86-64 -start-after branch-folder -stop-after branch-folder -o /dev/null %s | FileCheck %s
+# This test ensures that the MIR parser parses the 'killed' register flags
+# correctly.
+
+--- |
+
+ define i32 @foo(i32 %a) {
+ entry:
+ %0 = icmp sle i32 %a, 10
+ br i1 %0, label %less, label %exit
+
+ less:
+ ret i32 0
+
+ exit:
+ ret i32 %a
+ }
+
+...
+---
+name: foo
+body:
+ - id: 0
+ name: entry
+ instructions:
+ - 'CMP32ri8 %edi, 10, implicit-def %eflags'
+ - 'JG_1 %bb.2.exit, implicit %eflags'
+ - id: 1
+ name: less
+ instructions:
+ # CHECK: - '%eax = MOV32r0
+ # CHECK-NEXT: - 'RETQ killed %eax
+ - '%eax = MOV32r0 implicit-def %eflags'
+ - 'RETQ killed %eax'
+ - id: 2
+ name: exit
+ instructions:
+ # CHECK: - '%eax = COPY killed %edi
+ # CHECK-NEXT: - 'RETQ killed %eax
+ - '%eax = COPY killed %edi'
+ - 'RETQ killed %eax'
+...
More information about the llvm-commits
mailing list