mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-29 06:30:30 +00:00
Add all the plumbing needed for MC to expand cfi to the old tables in
the final assembly. It is the same technique used when targeting assemblers that don't support .loc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130587 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a37bd1d02c
commit
f1a5c7ec04
@ -510,6 +510,7 @@ namespace llvm {
|
||||
MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
||||
bool isVerboseAsm,
|
||||
bool useLoc,
|
||||
bool useCFI,
|
||||
MCInstPrinter *InstPrint = 0,
|
||||
MCCodeEmitter *CE = 0,
|
||||
TargetAsmBackend *TAB = 0,
|
||||
|
@ -108,6 +108,7 @@ protected: // Can only create subclasses.
|
||||
unsigned MCNoExecStack : 1;
|
||||
unsigned MCSaveTempLabels : 1;
|
||||
unsigned MCUseLoc : 1;
|
||||
unsigned MCUseCFI : 1;
|
||||
|
||||
public:
|
||||
virtual ~TargetMachine();
|
||||
@ -193,6 +194,12 @@ public:
|
||||
/// setMCUseLoc - Set whether all we should use dwarf's .loc directive.
|
||||
void setMCUseLoc(bool Value) { MCUseLoc = Value; }
|
||||
|
||||
/// hasMCUseCFI - Check whether we should use dwarf's .cfi_* directives.
|
||||
bool hasMCUseCFI() const { return MCUseCFI; }
|
||||
|
||||
/// setMCUseCFI - Set whether all we should use dwarf's .cfi_* directives.
|
||||
void setMCUseCFI(bool Value) { MCUseCFI = Value; }
|
||||
|
||||
/// getRelocationModel - Returns the code generation relocation model. The
|
||||
/// choices are static, PIC, and dynamic-no-pic, and target default.
|
||||
static Reloc::Model getRelocationModel();
|
||||
|
@ -43,7 +43,7 @@ namespace llvm {
|
||||
|
||||
MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
||||
bool isVerboseAsm,
|
||||
bool useLoc,
|
||||
bool useLoc, bool useCFI,
|
||||
MCInstPrinter *InstPrint,
|
||||
MCCodeEmitter *CE,
|
||||
TargetAsmBackend *TAB,
|
||||
@ -96,6 +96,7 @@ namespace llvm {
|
||||
formatted_raw_ostream &OS,
|
||||
bool isVerboseAsm,
|
||||
bool useLoc,
|
||||
bool useCFI,
|
||||
MCInstPrinter *InstPrint,
|
||||
MCCodeEmitter *CE,
|
||||
TargetAsmBackend *TAB,
|
||||
@ -329,12 +330,13 @@ namespace llvm {
|
||||
formatted_raw_ostream &OS,
|
||||
bool isVerboseAsm,
|
||||
bool useLoc,
|
||||
bool useCFI,
|
||||
MCInstPrinter *InstPrint,
|
||||
MCCodeEmitter *CE,
|
||||
TargetAsmBackend *TAB,
|
||||
bool ShowInst) const {
|
||||
// AsmStreamerCtorFn is default to llvm::createAsmStreamer
|
||||
return AsmStreamerCtorFn(Ctx, OS, isVerboseAsm, useLoc,
|
||||
return AsmStreamerCtorFn(Ctx, OS, isVerboseAsm, useLoc, useCFI,
|
||||
InstPrint, CE, TAB, ShowInst);
|
||||
}
|
||||
|
||||
|
@ -149,6 +149,7 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
||||
MCStreamer *S = getTarget().createAsmStreamer(*Context, Out,
|
||||
getVerboseAsm(),
|
||||
hasMCUseLoc(),
|
||||
hasMCUseCFI(),
|
||||
InstPrinter,
|
||||
MCE, TAB,
|
||||
ShowMCInst);
|
||||
|
@ -45,20 +45,20 @@ class MCAsmStreamer : public MCStreamer {
|
||||
unsigned IsVerboseAsm : 1;
|
||||
unsigned ShowInst : 1;
|
||||
unsigned UseLoc : 1;
|
||||
unsigned UseCFI : 1;
|
||||
|
||||
bool needsSet(const MCExpr *Value);
|
||||
|
||||
public:
|
||||
MCAsmStreamer(MCContext &Context, formatted_raw_ostream &os,
|
||||
bool isVerboseAsm,
|
||||
bool useLoc,
|
||||
bool isVerboseAsm, bool useLoc, bool useCFI,
|
||||
MCInstPrinter *printer, MCCodeEmitter *emitter,
|
||||
TargetAsmBackend *asmbackend,
|
||||
bool showInst)
|
||||
: MCStreamer(Context), OS(os), MAI(Context.getAsmInfo()),
|
||||
InstPrinter(printer), Emitter(emitter), AsmBackend(asmbackend),
|
||||
CommentStream(CommentToEmit), IsVerboseAsm(isVerboseAsm),
|
||||
ShowInst(showInst), UseLoc(useLoc) {
|
||||
ShowInst(showInst), UseLoc(useLoc), UseCFI(useCFI) {
|
||||
if (InstPrinter && IsVerboseAsm)
|
||||
InstPrinter->setCommentStream(CommentStream);
|
||||
}
|
||||
@ -740,6 +740,9 @@ void MCAsmStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
|
||||
void MCAsmStreamer::EmitCFIStartProc() {
|
||||
MCStreamer::EmitCFIStartProc();
|
||||
|
||||
if (!UseCFI)
|
||||
return;
|
||||
|
||||
OS << "\t.cfi_startproc";
|
||||
EmitEOL();
|
||||
}
|
||||
@ -747,6 +750,9 @@ void MCAsmStreamer::EmitCFIStartProc() {
|
||||
void MCAsmStreamer::EmitCFIEndProc() {
|
||||
MCStreamer::EmitCFIEndProc();
|
||||
|
||||
if (!UseCFI)
|
||||
return;
|
||||
|
||||
OS << "\t.cfi_endproc";
|
||||
EmitEOL();
|
||||
}
|
||||
@ -754,6 +760,9 @@ void MCAsmStreamer::EmitCFIEndProc() {
|
||||
void MCAsmStreamer::EmitCFIDefCfa(int64_t Register, int64_t Offset) {
|
||||
MCStreamer::EmitCFIDefCfa(Register, Offset);
|
||||
|
||||
if (!UseCFI)
|
||||
return;
|
||||
|
||||
OS << ".cfi_def_cfa " << Register << ", " << Offset;
|
||||
EmitEOL();
|
||||
}
|
||||
@ -761,6 +770,9 @@ void MCAsmStreamer::EmitCFIDefCfa(int64_t Register, int64_t Offset) {
|
||||
void MCAsmStreamer::EmitCFIDefCfaOffset(int64_t Offset) {
|
||||
MCStreamer::EmitCFIDefCfaOffset(Offset);
|
||||
|
||||
if (!UseCFI)
|
||||
return;
|
||||
|
||||
OS << "\t.cfi_def_cfa_offset " << Offset;
|
||||
EmitEOL();
|
||||
}
|
||||
@ -768,6 +780,9 @@ void MCAsmStreamer::EmitCFIDefCfaOffset(int64_t Offset) {
|
||||
void MCAsmStreamer::EmitCFIDefCfaRegister(int64_t Register) {
|
||||
MCStreamer::EmitCFIDefCfaRegister(Register);
|
||||
|
||||
if (!UseCFI)
|
||||
return;
|
||||
|
||||
OS << "\t.cfi_def_cfa_register " << Register;
|
||||
EmitEOL();
|
||||
}
|
||||
@ -775,6 +790,9 @@ void MCAsmStreamer::EmitCFIDefCfaRegister(int64_t Register) {
|
||||
void MCAsmStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) {
|
||||
this->MCStreamer::EmitCFIOffset(Register, Offset);
|
||||
|
||||
if (!UseCFI)
|
||||
return;
|
||||
|
||||
OS << "\t.cfi_offset " << Register << ", " << Offset;
|
||||
EmitEOL();
|
||||
}
|
||||
@ -783,6 +801,9 @@ void MCAsmStreamer::EmitCFIPersonality(const MCSymbol *Sym,
|
||||
unsigned Encoding) {
|
||||
MCStreamer::EmitCFIPersonality(Sym, Encoding);
|
||||
|
||||
if (!UseCFI)
|
||||
return;
|
||||
|
||||
OS << "\t.cfi_personality " << Encoding << ", " << *Sym;
|
||||
EmitEOL();
|
||||
}
|
||||
@ -790,6 +811,9 @@ void MCAsmStreamer::EmitCFIPersonality(const MCSymbol *Sym,
|
||||
void MCAsmStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
|
||||
MCStreamer::EmitCFILsda(Sym, Encoding);
|
||||
|
||||
if (!UseCFI)
|
||||
return;
|
||||
|
||||
OS << "\t.cfi_lsda " << Encoding << ", " << *Sym;
|
||||
EmitEOL();
|
||||
}
|
||||
@ -797,6 +821,9 @@ void MCAsmStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
|
||||
void MCAsmStreamer::EmitCFIRememberState() {
|
||||
MCStreamer::EmitCFIRememberState();
|
||||
|
||||
if (!UseCFI)
|
||||
return;
|
||||
|
||||
OS << "\t.cfi_remember_state";
|
||||
EmitEOL();
|
||||
}
|
||||
@ -804,6 +831,9 @@ void MCAsmStreamer::EmitCFIRememberState() {
|
||||
void MCAsmStreamer::EmitCFIRestoreState() {
|
||||
MCStreamer::EmitCFIRestoreState();
|
||||
|
||||
if (!UseCFI)
|
||||
return;
|
||||
|
||||
OS << "\t.cfi_restore_state";
|
||||
EmitEOL();
|
||||
}
|
||||
@ -811,6 +841,9 @@ void MCAsmStreamer::EmitCFIRestoreState() {
|
||||
void MCAsmStreamer::EmitCFISameValue(int64_t Register) {
|
||||
MCStreamer::EmitCFISameValue(Register);
|
||||
|
||||
if (!UseCFI)
|
||||
return;
|
||||
|
||||
OS << "\t.cfi_same_value " << Register;
|
||||
EmitEOL();
|
||||
}
|
||||
@ -818,6 +851,9 @@ void MCAsmStreamer::EmitCFISameValue(int64_t Register) {
|
||||
void MCAsmStreamer::EmitCFIRelOffset(int64_t Register, int64_t Offset) {
|
||||
MCStreamer::EmitCFIRelOffset(Register, Offset);
|
||||
|
||||
if (!UseCFI)
|
||||
return;
|
||||
|
||||
OS << "\t.cfi_rel_offset " << Register << ", " << Offset;
|
||||
EmitEOL();
|
||||
}
|
||||
@ -825,6 +861,9 @@ void MCAsmStreamer::EmitCFIRelOffset(int64_t Register, int64_t Offset) {
|
||||
void MCAsmStreamer::EmitCFIAdjustCfaOffset(int64_t Adjustment) {
|
||||
MCStreamer::EmitCFIAdjustCfaOffset(Adjustment);
|
||||
|
||||
if (!UseCFI)
|
||||
return;
|
||||
|
||||
OS << "\t.cfi_adjust_cfa_offset " << Adjustment;
|
||||
EmitEOL();
|
||||
}
|
||||
@ -1008,8 +1047,9 @@ void MCAsmStreamer::Finish() {
|
||||
MCStreamer *llvm::createAsmStreamer(MCContext &Context,
|
||||
formatted_raw_ostream &OS,
|
||||
bool isVerboseAsm, bool useLoc,
|
||||
bool useCFI,
|
||||
MCInstPrinter *IP, MCCodeEmitter *CE,
|
||||
TargetAsmBackend *TAB, bool ShowInst) {
|
||||
return new MCAsmStreamer(Context, OS, isVerboseAsm, useLoc,
|
||||
return new MCAsmStreamer(Context, OS, isVerboseAsm, useLoc, useCFI,
|
||||
IP, CE, TAB, ShowInst);
|
||||
}
|
||||
|
@ -531,7 +531,7 @@ void PTXMCAsmStreamer::Finish() {}
|
||||
namespace llvm {
|
||||
MCStreamer *createPTXAsmStreamer(MCContext &Context,
|
||||
formatted_raw_ostream &OS,
|
||||
bool isVerboseAsm, bool useLoc,
|
||||
bool isVerboseAsm, bool useLoc, bool useCFI,
|
||||
MCInstPrinter *IP,
|
||||
MCCodeEmitter *CE, TargetAsmBackend *TAB,
|
||||
bool ShowInst) {
|
||||
|
@ -23,6 +23,7 @@ using namespace llvm;
|
||||
namespace llvm {
|
||||
MCStreamer *createPTXAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
||||
bool isVerboseAsm, bool useLoc,
|
||||
bool useCFI,
|
||||
MCInstPrinter *InstPrint,
|
||||
MCCodeEmitter *CE,
|
||||
TargetAsmBackend *TAB,
|
||||
|
@ -227,7 +227,8 @@ TargetMachine::TargetMachine(const Target &T)
|
||||
MCRelaxAll(false),
|
||||
MCNoExecStack(false),
|
||||
MCSaveTempLabels(false),
|
||||
MCUseLoc(true) {
|
||||
MCUseLoc(true),
|
||||
MCUseCFI(true) {
|
||||
// Typically it will be subtargets that will adjust FloatABIType from Default
|
||||
// to Soft or Hard.
|
||||
if (UseSoftFloat)
|
||||
|
@ -99,6 +99,9 @@ cl::opt<bool> NoVerify("disable-verify", cl::Hidden,
|
||||
cl::opt<bool> DisableDotLoc("disable-dot-loc", cl::Hidden,
|
||||
cl::desc("Do not use .loc entries"));
|
||||
|
||||
cl::opt<bool> DisableCFI("disable-cfi", cl::Hidden,
|
||||
cl::desc("Do not use .cfi_* directives"));
|
||||
|
||||
static cl::opt<bool>
|
||||
DisableRedZone("disable-red-zone",
|
||||
cl::desc("Do not emit code that uses the red zone."),
|
||||
@ -279,6 +282,9 @@ int main(int argc, char **argv) {
|
||||
if (DisableDotLoc)
|
||||
Target.setMCUseLoc(false);
|
||||
|
||||
if (DisableCFI)
|
||||
Target.setMCUseCFI(false);
|
||||
|
||||
// Disable .loc support for older OS X versions.
|
||||
if (TheTriple.isMacOSX() &&
|
||||
TheTriple.isMacOSXVersionLT(10, 6))
|
||||
|
@ -356,7 +356,8 @@ static int AssembleInput(const char *ProgName) {
|
||||
TAB = TheTarget->createAsmBackend(TripleName);
|
||||
}
|
||||
Str.reset(TheTarget->createAsmStreamer(Ctx, FOS, /*asmverbose*/true,
|
||||
/*useLoc*/ true, IP, CE, TAB,
|
||||
/*useLoc*/ true,
|
||||
/*useCFI*/ true, IP, CE, TAB,
|
||||
ShowInst));
|
||||
} else if (FileType == OFT_Null) {
|
||||
Str.reset(createNullStreamer(Ctx));
|
||||
|
Loading…
Reference in New Issue
Block a user