[llvm] r243322 - MIR Serialization: Serialize the '.cfi_def_cfa_register' CFI instruction.
Alex Lorenz
arphaman at gmail.com
Mon Jul 27 13:39:03 PDT 2015
Author: arphaman
Date: Mon Jul 27 15:39:03 2015
New Revision: 243322
URL: http://llvm.org/viewvc/llvm-project?rev=243322&view=rev
Log:
MIR Serialization: Serialize the '.cfi_def_cfa_register' CFI instruction.
Added:
llvm/trunk/test/CodeGen/MIR/X86/cfi-def-cfa-register.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=243322&r1=243321&r2=243322&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp Mon Jul 27 15:39:03 2015
@@ -125,6 +125,7 @@ static MIToken::TokenKind getIdentifierK
.Case("frame-setup", MIToken::kw_frame_setup)
.Case("debug-location", MIToken::kw_debug_location)
.Case(".cfi_offset", MIToken::kw_cfi_offset)
+ .Case(".cfi_def_cfa_register", MIToken::kw_cfi_def_cfa_register)
.Case(".cfi_def_cfa_offset", MIToken::kw_cfi_def_cfa_offset)
.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=243322&r1=243321&r2=243322&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MILexer.h (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MILexer.h Mon Jul 27 15:39:03 2015
@@ -47,6 +47,7 @@ struct MIToken {
kw_frame_setup,
kw_debug_location,
kw_cfi_offset,
+ kw_cfi_def_cfa_register,
kw_cfi_def_cfa_offset,
// Identifier tokens
Modified: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp?rev=243322&r1=243321&r2=243322&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Mon Jul 27 15:39:03 2015
@@ -688,6 +688,12 @@ bool MIParser::parseCFIOperand(MachineOp
CFIIndex =
MMI.addFrameInst(MCCFIInstruction::createOffset(nullptr, Reg, Offset));
break;
+ case MIToken::kw_cfi_def_cfa_register:
+ if (parseCFIRegister(Reg))
+ return true;
+ CFIIndex =
+ MMI.addFrameInst(MCCFIInstruction::createDefCfaRegister(nullptr, Reg));
+ break;
case MIToken::kw_cfi_def_cfa_offset:
if (parseCFIOffset(Offset))
return true;
@@ -736,6 +742,7 @@ bool MIParser::parseMachineOperand(Machi
case MIToken::exclaim:
return parseMetadataOperand(Dest);
case MIToken::kw_cfi_offset:
+ case MIToken::kw_cfi_def_cfa_register:
case MIToken::kw_cfi_def_cfa_offset:
return parseCFIOperand(Dest);
case MIToken::Error:
Modified: llvm/trunk/lib/CodeGen/MIRPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRPrinter.cpp?rev=243322&r1=243321&r2=243322&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRPrinter.cpp Mon Jul 27 15:39:03 2015
@@ -528,6 +528,12 @@ void MIPrinter::print(const MCCFIInstruc
printCFIRegister(CFI.getRegister(), OS, TRI);
OS << ", " << CFI.getOffset();
break;
+ case MCCFIInstruction::OpDefCfaRegister:
+ OS << ".cfi_def_cfa_register ";
+ if (CFI.getLabel())
+ OS << "<mcsymbol> ";
+ printCFIRegister(CFI.getRegister(), OS, TRI);
+ break;
case MCCFIInstruction::OpDefCfaOffset:
OS << ".cfi_def_cfa_offset ";
if (CFI.getLabel())
Added: llvm/trunk/test/CodeGen/MIR/X86/cfi-def-cfa-register.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/X86/cfi-def-cfa-register.mir?rev=243322&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/X86/cfi-def-cfa-register.mir (added)
+++ llvm/trunk/test/CodeGen/MIR/X86/cfi-def-cfa-register.mir Mon Jul 27 15:39:03 2015
@@ -0,0 +1,33 @@
+# 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 .cfi_def_cfa_register
+# operands correctly.
+
+--- |
+
+ define void @func() #0 {
+ entry:
+ unreachable
+ }
+
+ attributes #0 = { "no-frame-pointer-elim"="true" }
+
+...
+---
+name: func
+tracksRegLiveness: true
+frameInfo:
+ stackSize: 8
+fixedStack:
+ - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16 }
+body:
+ - id: 0
+ name: entry
+ liveins: [ '%rbp' ]
+ instructions:
+ - 'PUSH64r killed %rbp, implicit-def %rsp, implicit %rsp'
+ - 'CFI_INSTRUCTION .cfi_def_cfa_offset 16'
+ - 'CFI_INSTRUCTION .cfi_offset %rbp, -16'
+ - '%rbp = MOV64rr %rsp'
+ # CHECK: CFI_INSTRUCTION .cfi_def_cfa_register %rbp
+ - 'CFI_INSTRUCTION .cfi_def_cfa_register %rbp'
+...
More information about the llvm-commits
mailing list