[llvm] r243554 - MIR Serialization: Serialize the '.cfi_def_cfa' CFI instruction.
Alex Lorenz
arphaman at gmail.com
Wed Jul 29 11:57:23 PDT 2015
Author: arphaman
Date: Wed Jul 29 13:57:23 2015
New Revision: 243554
URL: http://llvm.org/viewvc/llvm-project?rev=243554&view=rev
Log:
MIR Serialization: Serialize the '.cfi_def_cfa' CFI instruction.
Added:
llvm/trunk/test/CodeGen/MIR/AArch64/cfi-def-cfa.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=243554&r1=243553&r2=243554&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp Wed Jul 29 13:57:23 2015
@@ -147,6 +147,7 @@ static MIToken::TokenKind getIdentifierK
.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)
+ .Case(".cfi_def_cfa", MIToken::kw_cfi_def_cfa)
.Case("blockaddress", MIToken::kw_blockaddress)
.Case("target-index", MIToken::kw_target_index)
.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=243554&r1=243553&r2=243554&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MILexer.h (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MILexer.h Wed Jul 29 13:57:23 2015
@@ -51,6 +51,7 @@ struct MIToken {
kw_cfi_offset,
kw_cfi_def_cfa_register,
kw_cfi_def_cfa_offset,
+ kw_cfi_def_cfa,
kw_blockaddress,
kw_target_index,
Modified: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp?rev=243554&r1=243553&r2=243554&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Wed Jul 29 13:57:23 2015
@@ -754,6 +754,14 @@ bool MIParser::parseCFIOperand(MachineOp
CFIIndex = MMI.addFrameInst(
MCCFIInstruction::createDefCfaOffset(nullptr, -Offset));
break;
+ case MIToken::kw_cfi_def_cfa:
+ if (parseCFIRegister(Reg) || expectAndConsume(MIToken::comma) ||
+ parseCFIOffset(Offset))
+ return true;
+ // NB: MCCFIInstruction::createDefCfa negates the offset.
+ CFIIndex =
+ MMI.addFrameInst(MCCFIInstruction::createDefCfa(nullptr, Reg, -Offset));
+ break;
default:
// TODO: Parse the other CFI operands.
llvm_unreachable("The current token should be a cfi operand");
@@ -874,6 +882,7 @@ bool MIParser::parseMachineOperand(Machi
case MIToken::kw_cfi_offset:
case MIToken::kw_cfi_def_cfa_register:
case MIToken::kw_cfi_def_cfa_offset:
+ case MIToken::kw_cfi_def_cfa:
return parseCFIOperand(Dest);
case MIToken::kw_blockaddress:
return parseBlockAddressOperand(Dest);
Modified: llvm/trunk/lib/CodeGen/MIRPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRPrinter.cpp?rev=243554&r1=243553&r2=243554&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRPrinter.cpp Wed Jul 29 13:57:23 2015
@@ -586,6 +586,13 @@ void MIPrinter::print(const MCCFIInstruc
OS << "<mcsymbol> ";
OS << CFI.getOffset();
break;
+ case MCCFIInstruction::OpDefCfa:
+ OS << ".cfi_def_cfa ";
+ if (CFI.getLabel())
+ OS << "<mcsymbol> ";
+ printCFIRegister(CFI.getRegister(), OS, TRI);
+ OS << ", " << CFI.getOffset();
+ break;
default:
// TODO: Print the other CFI Operations.
OS << "<unserializable cfi operation>";
Added: llvm/trunk/test/CodeGen/MIR/AArch64/cfi-def-cfa.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/AArch64/cfi-def-cfa.mir?rev=243554&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/AArch64/cfi-def-cfa.mir (added)
+++ llvm/trunk/test/CodeGen/MIR/AArch64/cfi-def-cfa.mir Wed Jul 29 13:57:23 2015
@@ -0,0 +1,32 @@
+# RUN: llc -mtriple=aarch64-none-linux-gnu -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 operands
+# correctly.
+
+--- |
+
+ declare void @foo()
+
+ define void @trivial_fp_func() {
+ entry:
+ call void @foo()
+ ret void
+ }
+
+...
+---
+name: trivial_fp_func
+body:
+ - id: 0
+ name: entry
+ liveins: [ '%lr', '%fp', '%lr', '%fp' ]
+ instructions:
+ - '%sp = frame-setup STPXpre killed %fp, killed %lr, %sp, -2'
+ - '%fp = frame-setup ADDXri %sp, 0, 0'
+ # CHECK: CFI_INSTRUCTION .cfi_def_cfa %w29, 16
+ - 'frame-setup CFI_INSTRUCTION .cfi_def_cfa %w29, 16'
+ - 'frame-setup CFI_INSTRUCTION .cfi_offset %w30, -8'
+ - 'frame-setup CFI_INSTRUCTION .cfi_offset %w29, -16'
+ - 'BL @foo, csr_aarch64_aapcs, implicit-def dead %lr, implicit %sp, implicit-def %sp'
+ - '%sp, %fp, %lr = LDPXpost %sp, 2'
+ - RET_ReallyLR
+...
More information about the llvm-commits
mailing list