From f4f14f68f6078ea6681ee27b5bf42719d7db3441 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sun, 25 Nov 2012 15:14:49 +0000 Subject: Add support for .cfi_register now that it is easy to extent the representation to support it. Original patch with the parsing and plumbing by the PaX team and Roman Divacky. I added the bits in MCDwarf.cpp and the test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168565 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCDwarf.h | 29 ++++++++++++++++++++++++----- include/llvm/MC/MCStreamer.h | 1 + 2 files changed, 25 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCDwarf.h b/include/llvm/MC/MCDwarf.h index a7f40cc759..92e76121c0 100644 --- a/include/llvm/MC/MCDwarf.h +++ b/include/llvm/MC/MCDwarf.h @@ -267,18 +267,27 @@ namespace llvm { public: enum OpType { OpSameValue, OpRememberState, OpRestoreState, OpOffset, OpDefCfaRegister, OpDefCfaOffset, OpDefCfa, OpRelOffset, - OpAdjustCfaOffset, OpEscape, OpRestore, OpUndefined }; + OpAdjustCfaOffset, OpEscape, OpRestore, OpUndefined, + OpRegister }; private: OpType Operation; MCSymbol *Label; unsigned Register; - int Offset; + union { + int Offset; + unsigned Register2; + }; std::vector Values; - MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, - int O, StringRef V) : + MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int O, StringRef V) : Operation(Op), Label(L), Register(R), Offset(O), Values(V.begin(), V.end()) { + assert(Op != OpRegister); + } + + MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R1, unsigned R2) : + Operation(Op), Label(L), Register(R1), Register2(R2) { + assert(Op == OpRegister); } public: @@ -335,6 +344,11 @@ namespace llvm { return MCCFIInstruction(OpEscape, L, 0, 0, Vals); } + static MCCFIInstruction + createRegister(MCSymbol *L, unsigned Register1, unsigned Register2) { + return MCCFIInstruction(OpRegister, L, Register1, Register2); + } + OpType getOperation() const { return Operation; } MCSymbol *getLabel() const { return Label; } @@ -342,10 +356,15 @@ namespace llvm { assert(Operation == OpDefCfa || Operation == OpOffset || Operation == OpRestore || Operation == OpUndefined || Operation == OpSameValue || Operation == OpDefCfaRegister || - Operation == OpRelOffset); + Operation == OpRelOffset || Operation == OpRegister); return Register; } + unsigned getRegister2() const { + assert(Operation == OpRegister); + return Register2; + } + int getOffset() const { assert(Operation == OpDefCfa || Operation == OpOffset || Operation == OpRelOffset || Operation == OpDefCfaOffset || diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 47cea038c3..9dc8405483 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -517,6 +517,7 @@ namespace llvm { virtual void EmitCFIEscape(StringRef Values); virtual void EmitCFISignalFrame(); virtual void EmitCFIUndefined(int64_t Register); + virtual void EmitCFIRegister(int64_t Register1, int64_t Register2); virtual void EmitWin64EHStartProc(const MCSymbol *Symbol); virtual void EmitWin64EHEndProc(); -- cgit v1.2.3