[llvm] r241624 - MIR Serialization: Serialize the 'dead' register machine operand flag.
Alex Lorenz
arphaman at gmail.com
Tue Jul 7 13:34:53 PDT 2015
Author: arphaman
Date: Tue Jul 7 15:34:53 2015
New Revision: 241624
URL: http://llvm.org/viewvc/llvm-project?rev=241624&view=rev
Log:
MIR Serialization: Serialize the 'dead' register machine operand flag.
Added:
llvm/trunk/test/CodeGen/MIR/X86/dead-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=241624&r1=241623&r2=241624&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp Tue Jul 7 15:34:53 2015
@@ -70,6 +70,7 @@ static MIToken::TokenKind getIdentifierK
.Case("_", MIToken::underscore)
.Case("implicit", MIToken::kw_implicit)
.Case("implicit-def", MIToken::kw_implicit_define)
+ .Case("dead", MIToken::kw_dead)
.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=241624&r1=241623&r2=241624&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MILexer.h (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MILexer.h Tue Jul 7 15:34:53 2015
@@ -39,6 +39,7 @@ struct MIToken {
// Keywords
kw_implicit,
kw_implicit_define,
+ kw_dead,
// Identifier tokens
Identifier,
@@ -74,7 +75,7 @@ public:
}
bool isRegisterFlag() const {
- return Kind == kw_implicit || Kind == kw_implicit_define;
+ return Kind == kw_implicit || Kind == kw_implicit_define || Kind == kw_dead;
}
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=241624&r1=241623&r2=241624&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Tue Jul 7 15:34:53 2015
@@ -305,6 +305,9 @@ bool MIParser::parseRegisterFlag(unsigne
case MIToken::kw_implicit_define:
Flags |= RegState::ImplicitDefine;
break;
+ case MIToken::kw_dead:
+ Flags |= RegState::Dead;
+ break;
// TODO: report an error when we specify the same flag more than once.
// TODO: parse the other register flags.
default:
@@ -328,7 +331,8 @@ bool MIParser::parseRegisterOperand(Mach
lex();
// TODO: Parse subregister.
Dest = MachineOperand::CreateReg(Reg, Flags & RegState::Define,
- Flags & RegState::Implicit);
+ Flags & RegState::Implicit, /*IsKill=*/false,
+ Flags & RegState::Dead);
return false;
}
@@ -412,6 +416,7 @@ bool MIParser::parseMachineOperand(Machi
switch (Token.kind()) {
case MIToken::kw_implicit:
case MIToken::kw_implicit_define:
+ case MIToken::kw_dead:
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=241624&r1=241623&r2=241624&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRPrinter.cpp Tue Jul 7 15:34:53 2015
@@ -214,6 +214,8 @@ void MIPrinter::print(const MachineOpera
// TODO: Print the other register flags.
if (Op.isImplicit())
OS << (Op.isDef() ? "implicit-def " : "implicit ");
+ if (Op.isDead())
+ OS << "dead ";
printReg(Op.getReg(), OS, TRI);
// TODO: Print sub register.
break;
Added: llvm/trunk/test/CodeGen/MIR/X86/dead-register-flag.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/X86/dead-register-flag.mir?rev=241624&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/X86/dead-register-flag.mir (added)
+++ llvm/trunk/test/CodeGen/MIR/X86/dead-register-flag.mir Tue Jul 7 15:34:53 2015
@@ -0,0 +1,26 @@
+# 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 'dead' register flags
+# correctly.
+
+--- |
+
+ define i32 @foo(i32 %a) #0 {
+ body:
+ %c = mul i32 %a, 11
+ ret i32 %c
+ }
+
+ attributes #0 = { "no-frame-pointer-elim"="false" }
+
+...
+---
+name: foo
+body:
+ # CHECK: name: body
+ - id: 0
+ name: body
+ instructions:
+ # CHECK: - '%eax = IMUL32rri8 %edi, 11, implicit-def dead %eflags'
+ - '%eax = IMUL32rri8 %edi, 11, implicit-def dead %eflags'
+ - 'RETQ %eax'
+...
More information about the llvm-commits
mailing list