diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2011-12-29 21:43:03 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2011-12-29 21:43:03 +0000 |
commit | ed23bdb65fe86cdb7a38c8c1998ec965e6973966 (patch) | |
tree | 711101bb120aec9cb2c5d824bbfb9a4bdd964244 /lib/MC | |
parent | c25680f728f89dd43939b00049ee524fbf59b7be (diff) | |
download | external_llvm-ed23bdb65fe86cdb7a38c8c1998ec965e6973966.zip external_llvm-ed23bdb65fe86cdb7a38c8c1998ec965e6973966.tar.gz external_llvm-ed23bdb65fe86cdb7a38c8c1998ec965e6973966.tar.bz2 |
Implement cfi_restore. Patch by Brian Anderson!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147356 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r-- | lib/MC/MCDwarf.cpp | 9 | ||||
-rw-r--r-- | lib/MC/MCParser/AsmParser.cpp | 16 | ||||
-rw-r--r-- | lib/MC/MCStreamer.cpp | 9 |
3 files changed, 34 insertions, 0 deletions
diff --git a/lib/MC/MCDwarf.cpp b/lib/MC/MCDwarf.cpp index 881fed4..986b8b6 100644 --- a/lib/MC/MCDwarf.cpp +++ b/lib/MC/MCDwarf.cpp @@ -987,6 +987,15 @@ void FrameEmitterImpl::EmitCFIInstruction(MCStreamer &Streamer, Streamer.EmitULEB128IntValue(Reg); return; } + case MCCFIInstruction::Restore: { + unsigned Reg = Instr.getDestination().getReg(); + if (VerboseAsm) { + Streamer.AddComment("DW_CFA_restore"); + Streamer.AddComment(Twine("Reg ") + Twine(Reg)); + } + Streamer.EmitIntValue(dwarf::DW_CFA_restore | Reg, 1); + return; + } case MCCFIInstruction::Escape: if (VerboseAsm) Streamer.AddComment("Escape bytes"); Streamer.EmitBytes(Instr.getValues(), 0); diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index 2ccea78..5a69bea 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -302,6 +302,8 @@ public: AddDirectiveHandler< &GenericAsmParser::ParseDirectiveCFISameValue>(".cfi_same_value"); AddDirectiveHandler< + &GenericAsmParser::ParseDirectiveCFIRestore>(".cfi_restore"); + AddDirectiveHandler< &GenericAsmParser::ParseDirectiveCFIEscape>(".cfi_escape"); // Macro directives. @@ -336,6 +338,7 @@ public: bool ParseDirectiveCFIRememberState(StringRef, SMLoc DirectiveLoc); bool ParseDirectiveCFIRestoreState(StringRef, SMLoc DirectiveLoc); bool ParseDirectiveCFISameValue(StringRef, SMLoc DirectiveLoc); + bool ParseDirectiveCFIRestore(StringRef, SMLoc DirectiveLoc); bool ParseDirectiveCFIEscape(StringRef, SMLoc DirectiveLoc); bool ParseDirectiveMacrosOnOff(StringRef, SMLoc DirectiveLoc); @@ -2815,6 +2818,19 @@ bool GenericAsmParser::ParseDirectiveCFISameValue(StringRef IDVal, return false; } +/// ParseDirectiveCFIRestore +/// ::= .cfi_restore register +bool GenericAsmParser::ParseDirectiveCFIRestore(StringRef IDVal, + SMLoc DirectiveLoc) { + int64_t Register = 0; + if (ParseRegisterOrRegisterNumber(Register, DirectiveLoc)) + return true; + + getStreamer().EmitCFIRestore(Register); + + return false; +} + /// ParseDirectiveCFIEscape /// ::= .cfi_escape expression[,...] bool GenericAsmParser::ParseDirectiveCFIEscape(StringRef IDVal, diff --git a/lib/MC/MCStreamer.cpp b/lib/MC/MCStreamer.cpp index 4169188..8567941 100644 --- a/lib/MC/MCStreamer.cpp +++ b/lib/MC/MCStreamer.cpp @@ -408,6 +408,15 @@ void MCStreamer::EmitCFISameValue(int64_t Register) { CurFrame->Instructions.push_back(Instruction); } +void MCStreamer::EmitCFIRestore(int64_t Register) { + EnsureValidFrame(); + MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo(); + MCSymbol *Label = getContext().CreateTempSymbol(); + EmitLabel(Label); + MCCFIInstruction Instruction(MCCFIInstruction::Restore, Label, Register); + CurFrame->Instructions.push_back(Instruction); +} + void MCStreamer::EmitCFIEscape(StringRef Values) { EnsureValidFrame(); MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo(); |