mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-25 04:39:44 +00:00
Implement cfi_restore. Patch by Brian Anderson!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147356 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c25680f728
commit
ed23bdb65f
@ -271,7 +271,8 @@ namespace llvm {
|
||||
|
||||
class MCCFIInstruction {
|
||||
public:
|
||||
enum OpType { SameValue, RememberState, RestoreState, Move, RelMove, Escape };
|
||||
enum OpType { SameValue, RememberState, RestoreState, Move, RelMove, Escape,
|
||||
Restore};
|
||||
private:
|
||||
OpType Operation;
|
||||
MCSymbol *Label;
|
||||
@ -286,7 +287,7 @@ namespace llvm {
|
||||
}
|
||||
MCCFIInstruction(OpType Op, MCSymbol *L, unsigned Register)
|
||||
: Operation(Op), Label(L), Destination(Register) {
|
||||
assert(Op == SameValue);
|
||||
assert(Op == SameValue || Op == Restore);
|
||||
}
|
||||
MCCFIInstruction(MCSymbol *L, const MachineLocation &D,
|
||||
const MachineLocation &S)
|
||||
|
@ -547,6 +547,7 @@ namespace llvm {
|
||||
virtual void EmitCFIRememberState();
|
||||
virtual void EmitCFIRestoreState();
|
||||
virtual void EmitCFISameValue(int64_t Register);
|
||||
virtual void EmitCFIRestore(int64_t Register);
|
||||
virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset);
|
||||
virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment);
|
||||
virtual void EmitCFIEscape(StringRef Values);
|
||||
|
@ -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);
|
||||
|
@ -301,6 +301,8 @@ public:
|
||||
&GenericAsmParser::ParseDirectiveCFIRestoreState>(".cfi_restore_state");
|
||||
AddDirectiveHandler<
|
||||
&GenericAsmParser::ParseDirectiveCFISameValue>(".cfi_same_value");
|
||||
AddDirectiveHandler<
|
||||
&GenericAsmParser::ParseDirectiveCFIRestore>(".cfi_restore");
|
||||
AddDirectiveHandler<
|
||||
&GenericAsmParser::ParseDirectiveCFIEscape>(".cfi_escape");
|
||||
|
||||
@ -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,
|
||||
|
@ -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();
|
||||
|
42
test/MC/ELF/cfi-restore.s
Normal file
42
test/MC/ELF/cfi-restore.s
Normal file
@ -0,0 +1,42 @@
|
||||
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump --dump-section-data | FileCheck %s
|
||||
|
||||
f:
|
||||
.cfi_startproc
|
||||
nop
|
||||
.cfi_restore %rbp
|
||||
nop
|
||||
.cfi_endproc
|
||||
|
||||
// CHECK: # Section 4
|
||||
// CHECK-NEXT: (('sh_name', 0x00000011) # '.eh_frame'
|
||||
// CHECK-NEXT: ('sh_type', 0x00000001)
|
||||
// CHECK-NEXT: ('sh_flags', 0x0000000000000002)
|
||||
// CHECK-NEXT: ('sh_addr', 0x0000000000000000)
|
||||
// CHECK-NEXT: ('sh_offset', 0x0000000000000048)
|
||||
// CHECK-NEXT: ('sh_size', 0x0000000000000030)
|
||||
// CHECK-NEXT: ('sh_link', 0x00000000)
|
||||
// CHECK-NEXT: ('sh_info', 0x00000000)
|
||||
// CHECK-NEXT: ('sh_addralign', 0x0000000000000008)
|
||||
// CHECK-NEXT: ('sh_entsize', 0x0000000000000000)
|
||||
// CHECK-NEXT: ('_section_data', '14000000 00000000 017a5200 01781001 1b0c0708 90010000 14000000 1c000000 00000000 02000000 0041c600 00000000')
|
||||
// CHECK-NEXT: ),
|
||||
// CHECK-NEXT: # Section 5
|
||||
// CHECK-NEXT: (('sh_name', 0x0000000c) # '.rela.eh_frame'
|
||||
// CHECK-NEXT: ('sh_type', 0x00000004)
|
||||
// CHECK-NEXT: ('sh_flags', 0x0000000000000000)
|
||||
// CHECK-NEXT: ('sh_addr', 0x0000000000000000)
|
||||
// CHECK-NEXT: ('sh_offset', 0x0000000000000390)
|
||||
// CHECK-NEXT: ('sh_size', 0x0000000000000018)
|
||||
// CHECK-NEXT: ('sh_link', 0x00000007)
|
||||
// CHECK-NEXT: ('sh_info', 0x00000004)
|
||||
// CHECK-NEXT: ('sh_addralign', 0x0000000000000008)
|
||||
// CHECK-NEXT: ('sh_entsize', 0x0000000000000018)
|
||||
// CHECK-NEXT: ('_relocations', [
|
||||
// CHECK-NEXT: # Relocation 0
|
||||
// CHECK-NEXT: (('r_offset', 0x0000000000000020)
|
||||
// CHECK-NEXT: ('r_sym', 0x00000002)
|
||||
// CHECK-NEXT: ('r_type', 0x00000002)
|
||||
// CHECK-NEXT: ('r_addend', 0x0000000000000000)
|
||||
// CHECK-NEXT: ),
|
||||
// CHECK-NEXT: ])
|
||||
// CHECK-NEXT: ),
|
Loading…
Reference in New Issue
Block a user