mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-15 06:29:05 +00:00
Implement .cfi_escape. Patch by Brian Anderson!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147352 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -271,13 +271,14 @@ namespace llvm {
|
|||||||
|
|
||||||
class MCCFIInstruction {
|
class MCCFIInstruction {
|
||||||
public:
|
public:
|
||||||
enum OpType { SameValue, Remember, Restore, Move, RelMove };
|
enum OpType { SameValue, Remember, Restore, Move, RelMove, Escape };
|
||||||
private:
|
private:
|
||||||
OpType Operation;
|
OpType Operation;
|
||||||
MCSymbol *Label;
|
MCSymbol *Label;
|
||||||
// Move to & from location.
|
// Move to & from location.
|
||||||
MachineLocation Destination;
|
MachineLocation Destination;
|
||||||
MachineLocation Source;
|
MachineLocation Source;
|
||||||
|
std::vector<char> Values;
|
||||||
public:
|
public:
|
||||||
MCCFIInstruction(OpType Op, MCSymbol *L)
|
MCCFIInstruction(OpType Op, MCSymbol *L)
|
||||||
: Operation(Op), Label(L) {
|
: Operation(Op), Label(L) {
|
||||||
@@ -296,10 +297,17 @@ namespace llvm {
|
|||||||
: Operation(Op), Label(L), Destination(D), Source(S) {
|
: Operation(Op), Label(L), Destination(D), Source(S) {
|
||||||
assert(Op == RelMove);
|
assert(Op == RelMove);
|
||||||
}
|
}
|
||||||
|
MCCFIInstruction(OpType Op, MCSymbol *L, StringRef Vals)
|
||||||
|
: Operation(Op), Label(L), Values(Vals.begin(), Vals.end()) {
|
||||||
|
assert(Op == Escape);
|
||||||
|
}
|
||||||
OpType getOperation() const { return Operation; }
|
OpType getOperation() const { return Operation; }
|
||||||
MCSymbol *getLabel() const { return Label; }
|
MCSymbol *getLabel() const { return Label; }
|
||||||
const MachineLocation &getDestination() const { return Destination; }
|
const MachineLocation &getDestination() const { return Destination; }
|
||||||
const MachineLocation &getSource() const { return Source; }
|
const MachineLocation &getSource() const { return Source; }
|
||||||
|
const StringRef getValues() const {
|
||||||
|
return StringRef(&Values[0], Values.size());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MCDwarfFrameInfo {
|
struct MCDwarfFrameInfo {
|
||||||
|
@@ -549,6 +549,7 @@ namespace llvm {
|
|||||||
virtual void EmitCFISameValue(int64_t Register);
|
virtual void EmitCFISameValue(int64_t Register);
|
||||||
virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset);
|
virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset);
|
||||||
virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment);
|
virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment);
|
||||||
|
virtual void EmitCFIEscape(StringRef Values);
|
||||||
|
|
||||||
virtual void EmitWin64EHStartProc(const MCSymbol *Symbol);
|
virtual void EmitWin64EHStartProc(const MCSymbol *Symbol);
|
||||||
virtual void EmitWin64EHEndProc();
|
virtual void EmitWin64EHEndProc();
|
||||||
|
@@ -987,6 +987,10 @@ void FrameEmitterImpl::EmitCFIInstruction(MCStreamer &Streamer,
|
|||||||
Streamer.EmitULEB128IntValue(Reg);
|
Streamer.EmitULEB128IntValue(Reg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
case MCCFIInstruction::Escape:
|
||||||
|
if (VerboseAsm) Streamer.AddComment("Escape bytes");
|
||||||
|
Streamer.EmitBytes(Instr.getValues(), 0);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
llvm_unreachable("Unhandled case in switch");
|
llvm_unreachable("Unhandled case in switch");
|
||||||
}
|
}
|
||||||
|
@@ -301,6 +301,8 @@ public:
|
|||||||
&GenericAsmParser::ParseDirectiveCFIRestoreState>(".cfi_restore_state");
|
&GenericAsmParser::ParseDirectiveCFIRestoreState>(".cfi_restore_state");
|
||||||
AddDirectiveHandler<
|
AddDirectiveHandler<
|
||||||
&GenericAsmParser::ParseDirectiveCFISameValue>(".cfi_same_value");
|
&GenericAsmParser::ParseDirectiveCFISameValue>(".cfi_same_value");
|
||||||
|
AddDirectiveHandler<
|
||||||
|
&GenericAsmParser::ParseDirectiveCFIEscape>(".cfi_escape");
|
||||||
|
|
||||||
// Macro directives.
|
// Macro directives.
|
||||||
AddDirectiveHandler<&GenericAsmParser::ParseDirectiveMacrosOnOff>(
|
AddDirectiveHandler<&GenericAsmParser::ParseDirectiveMacrosOnOff>(
|
||||||
@@ -334,6 +336,7 @@ public:
|
|||||||
bool ParseDirectiveCFIRememberState(StringRef, SMLoc DirectiveLoc);
|
bool ParseDirectiveCFIRememberState(StringRef, SMLoc DirectiveLoc);
|
||||||
bool ParseDirectiveCFIRestoreState(StringRef, SMLoc DirectiveLoc);
|
bool ParseDirectiveCFIRestoreState(StringRef, SMLoc DirectiveLoc);
|
||||||
bool ParseDirectiveCFISameValue(StringRef, SMLoc DirectiveLoc);
|
bool ParseDirectiveCFISameValue(StringRef, SMLoc DirectiveLoc);
|
||||||
|
bool ParseDirectiveCFIEscape(StringRef, SMLoc DirectiveLoc);
|
||||||
|
|
||||||
bool ParseDirectiveMacrosOnOff(StringRef, SMLoc DirectiveLoc);
|
bool ParseDirectiveMacrosOnOff(StringRef, SMLoc DirectiveLoc);
|
||||||
bool ParseDirectiveMacro(StringRef, SMLoc DirectiveLoc);
|
bool ParseDirectiveMacro(StringRef, SMLoc DirectiveLoc);
|
||||||
@@ -2812,6 +2815,30 @@ bool GenericAsmParser::ParseDirectiveCFISameValue(StringRef IDVal,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ParseDirectiveCFIEscape
|
||||||
|
/// ::= .cfi_escape expression[,...]
|
||||||
|
bool GenericAsmParser::ParseDirectiveCFIEscape(StringRef IDVal,
|
||||||
|
SMLoc DirectiveLoc) {
|
||||||
|
std::string Values;
|
||||||
|
int64_t CurrValue;
|
||||||
|
if (getParser().ParseAbsoluteExpression(CurrValue))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
Values.push_back((uint8_t)CurrValue);
|
||||||
|
|
||||||
|
while (getLexer().is(AsmToken::Comma)) {
|
||||||
|
Lex();
|
||||||
|
|
||||||
|
if (getParser().ParseAbsoluteExpression(CurrValue))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
Values.push_back((uint8_t)CurrValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
getStreamer().EmitCFIEscape(Values);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// ParseDirectiveMacrosOnOff
|
/// ParseDirectiveMacrosOnOff
|
||||||
/// ::= .macros_on
|
/// ::= .macros_on
|
||||||
/// ::= .macros_off
|
/// ::= .macros_off
|
||||||
|
@@ -408,6 +408,15 @@ void MCStreamer::EmitCFISameValue(int64_t Register) {
|
|||||||
CurFrame->Instructions.push_back(Instruction);
|
CurFrame->Instructions.push_back(Instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MCStreamer::EmitCFIEscape(StringRef Values) {
|
||||||
|
EnsureValidFrame();
|
||||||
|
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
||||||
|
MCSymbol *Label = getContext().CreateTempSymbol();
|
||||||
|
EmitLabel(Label);
|
||||||
|
MCCFIInstruction Instruction(MCCFIInstruction::Escape, Label, Values);
|
||||||
|
CurFrame->Instructions.push_back(Instruction);
|
||||||
|
}
|
||||||
|
|
||||||
void MCStreamer::setCurrentW64UnwindInfo(MCWin64EHUnwindInfo *Frame) {
|
void MCStreamer::setCurrentW64UnwindInfo(MCWin64EHUnwindInfo *Frame) {
|
||||||
W64UnwindInfos.push_back(Frame);
|
W64UnwindInfos.push_back(Frame);
|
||||||
CurrentW64UnwindInfo = W64UnwindInfos.back();
|
CurrentW64UnwindInfo = W64UnwindInfos.back();
|
||||||
|
42
test/MC/ELF/cfi-escape.s
Normal file
42
test/MC/ELF/cfi-escape.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_escape 0x15, 7, 0x7f # DW_CFA_val_offset_sf, %esp, 8/-8
|
||||||
|
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 00411507 7f000000')
|
||||||
|
// 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: ),
|
Reference in New Issue
Block a user