forked from OSchip/llvm-project
Make target asm info a property of the target machine.
llvm-svn: 30162
This commit is contained in:
parent
0e83541f8b
commit
261779bb45
|
@ -49,7 +49,7 @@ namespace llvm {
|
|||
|
||||
/// Target Asm Printer information.
|
||||
///
|
||||
TargetAsmInfo *TAI;
|
||||
const TargetAsmInfo *TAI;
|
||||
|
||||
/// Name-mangler for global names.
|
||||
///
|
||||
|
@ -65,7 +65,7 @@ namespace llvm {
|
|||
std::string CurrentSection;
|
||||
|
||||
protected:
|
||||
AsmPrinter(std::ostream &o, TargetMachine &TM, TargetAsmInfo *T);
|
||||
AsmPrinter(std::ostream &o, TargetMachine &TM, const TargetAsmInfo *T);
|
||||
|
||||
public:
|
||||
/// SwitchToTextSection - Switch to the specified section of the executable
|
||||
|
|
|
@ -88,7 +88,7 @@ private:
|
|||
AsmPrinter *Asm;
|
||||
|
||||
/// TAI - Target Asm Printer.
|
||||
TargetAsmInfo *TAI;
|
||||
const TargetAsmInfo *TAI;
|
||||
|
||||
/// TD - Target data.
|
||||
const TargetData *TD;
|
||||
|
@ -387,12 +387,12 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
DwarfWriter(std::ostream &OS, AsmPrinter *A, TargetAsmInfo *T);
|
||||
DwarfWriter(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T);
|
||||
virtual ~DwarfWriter();
|
||||
|
||||
// Accessors.
|
||||
//
|
||||
TargetAsmInfo *getTargetAsmInfo() const { return TAI; }
|
||||
const TargetAsmInfo *getTargetAsmInfo() const { return TAI; }
|
||||
|
||||
/// SetDebugInfo - Set DebugInfo when it's known that pass manager has
|
||||
/// created it. Set by the target AsmPrinter.
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
|
||||
namespace llvm {
|
||||
|
||||
// Forward declaration.
|
||||
class TargetMachine;
|
||||
|
||||
/// TargetAsmInfo - This class is intended to be used as a base class for asm
|
||||
/// properties and features specific to the target.
|
||||
class TargetAsmInfo {
|
||||
|
@ -266,7 +269,7 @@ namespace llvm {
|
|||
unsigned getAddressSize() const {
|
||||
return AddressSize;
|
||||
}
|
||||
bool getNeedsSet() const {
|
||||
bool needsSet() const {
|
||||
return NeedsSet;
|
||||
}
|
||||
const char *getCommentString() const {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace llvm {
|
||||
|
||||
class TargetAsmInfo;
|
||||
class TargetData;
|
||||
class TargetSubtarget;
|
||||
class TargetInstrInfo;
|
||||
|
@ -65,11 +66,16 @@ class TargetMachine {
|
|||
TargetMachine(const TargetMachine &); // DO NOT IMPLEMENT
|
||||
void operator=(const TargetMachine &); // DO NOT IMPLEMENT
|
||||
protected: // Can only create subclasses.
|
||||
TargetMachine() { }
|
||||
TargetMachine() : AsmInfo(NULL) { }
|
||||
|
||||
/// getSubtargetImpl - virtual method implemented by subclasses that returns
|
||||
/// a reference to that target's TargetSubtarget-derived member variable.
|
||||
virtual const TargetSubtarget *getSubtargetImpl() const { return 0; }
|
||||
|
||||
/// AsmInfo - Contains target specific asm information.
|
||||
///
|
||||
mutable const TargetAsmInfo *AsmInfo;
|
||||
|
||||
public:
|
||||
virtual ~TargetMachine();
|
||||
|
||||
|
@ -96,6 +102,18 @@ public:
|
|||
virtual const TargetFrameInfo *getFrameInfo() const { return 0; }
|
||||
virtual TargetLowering *getTargetLowering() const { return 0; }
|
||||
virtual const TargetData *getTargetData() const { return 0; }
|
||||
|
||||
|
||||
/// getTargetAsmInfo - Return target specific asm information.
|
||||
///
|
||||
const TargetAsmInfo *getTargetAsmInfo() const {
|
||||
if (!AsmInfo) AsmInfo = createTargetAsmInfo();
|
||||
return AsmInfo;
|
||||
}
|
||||
|
||||
/// createTargetAsmInfo - Create a new instance of target specific asm
|
||||
/// information.
|
||||
virtual const TargetAsmInfo *createTargetAsmInfo() const { return NULL; }
|
||||
|
||||
/// getSubtarget - This method returns a pointer to the specified type of
|
||||
/// TargetSubtarget. In debug builds, it verifies that the object being
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
#include <cerrno>
|
||||
using namespace llvm;
|
||||
|
||||
AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm, TargetAsmInfo *T)
|
||||
AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm,
|
||||
const TargetAsmInfo *T)
|
||||
: FunctionNumber(0), O(o), TM(tm), TAI(T)
|
||||
{}
|
||||
|
||||
|
|
|
@ -574,24 +574,24 @@ void DIEAbbrev::Emit(const DwarfWriter &DW) const {
|
|||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
void DIEAbbrev::print(std::ostream &O) {
|
||||
O << "Abbreviation @"
|
||||
<< std::hex << (intptr_t)this << std::dec
|
||||
void DIEAbbrev::print(std::ostream &O) {
|
||||
O << "Abbreviation @"
|
||||
<< std::hex << (intptr_t)this << std::dec
|
||||
<< " "
|
||||
<< TagString(Tag)
|
||||
<< " "
|
||||
<< ChildrenString(ChildrenFlag)
|
||||
<< "\n";
|
||||
|
||||
for (unsigned i = 0, N = Data.size(); i < N; ++i) {
|
||||
O << " "
|
||||
<< AttributeString(Data[i].getAttribute())
|
||||
<< " "
|
||||
<< TagString(Tag)
|
||||
<< " "
|
||||
<< ChildrenString(ChildrenFlag)
|
||||
<< FormEncodingString(Data[i].getForm())
|
||||
<< "\n";
|
||||
|
||||
for (unsigned i = 0, N = Data.size(); i < N; ++i) {
|
||||
O << " "
|
||||
<< AttributeString(Data[i].getAttribute())
|
||||
<< " "
|
||||
<< FormEncodingString(Data[i].getForm())
|
||||
<< "\n";
|
||||
}
|
||||
}
|
||||
void DIEAbbrev::dump() { print(std::cerr); }
|
||||
}
|
||||
void DIEAbbrev::dump() { print(std::cerr); }
|
||||
#endif
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -1160,7 +1160,7 @@ void DwarfWriter::EmitReference(const std::string &Name) const {
|
|||
/// is an option (needsSet) to use an intermediary 'set' expression.
|
||||
void DwarfWriter::EmitDifference(const char *TagHi, unsigned NumberHi,
|
||||
const char *TagLo, unsigned NumberLo) const {
|
||||
if (TAI->getNeedsSet()) {
|
||||
if (TAI->needsSet()) {
|
||||
static unsigned SetCounter = 0;
|
||||
|
||||
O << "\t.set\t";
|
||||
|
@ -2467,7 +2467,8 @@ void DwarfWriter::ConstructSubprogramDIEs() {
|
|||
// Main entry points.
|
||||
//
|
||||
|
||||
DwarfWriter::DwarfWriter(std::ostream &OS, AsmPrinter *A, TargetAsmInfo *T)
|
||||
DwarfWriter::DwarfWriter(std::ostream &OS, AsmPrinter *A,
|
||||
const TargetAsmInfo *T)
|
||||
: O(OS)
|
||||
, Asm(A)
|
||||
, TAI(T)
|
||||
|
|
|
@ -38,20 +38,8 @@ using namespace llvm;
|
|||
namespace {
|
||||
Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
|
||||
|
||||
struct VISIBILITY_HIDDEN ARMTargetAsmInfo : public TargetAsmInfo {
|
||||
ARMTargetAsmInfo() {
|
||||
Data16bitsDirective = "\t.half\t";
|
||||
Data32bitsDirective = "\t.word\t";
|
||||
Data64bitsDirective = 0;
|
||||
ZeroDirective = "\t.skip\t";
|
||||
CommentString = "@";
|
||||
ConstantPoolSection = "\t.text\n";
|
||||
AlignmentIsInBytes = false;
|
||||
}
|
||||
};
|
||||
|
||||
struct VISIBILITY_HIDDEN ARMAsmPrinter : public AsmPrinter {
|
||||
ARMAsmPrinter(std::ostream &O, TargetMachine &TM, TargetAsmInfo *T)
|
||||
ARMAsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
|
||||
: AsmPrinter(O, TM, T) {
|
||||
}
|
||||
|
||||
|
@ -113,8 +101,7 @@ namespace {
|
|||
///
|
||||
FunctionPass *llvm::createARMCodePrinterPass(std::ostream &o,
|
||||
TargetMachine &tm) {
|
||||
ARMTargetAsmInfo *TAI = new ARMTargetAsmInfo();
|
||||
return new ARMAsmPrinter(o, tm, TAI);
|
||||
return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
||||
}
|
||||
|
||||
/// runOnMachineFunction - This uses the printMachineInstruction()
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "llvm/Target/TargetFrameInfo.h"
|
||||
#include "ARMInstrInfo.h"
|
||||
#include "ARMFrameInfo.h"
|
||||
#include "ARMTargetAsmInfo.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -40,6 +41,10 @@ public:
|
|||
virtual const TargetData *getTargetData() const { return &DataLayout; }
|
||||
static unsigned getModuleMatchQuality(const Module &M);
|
||||
|
||||
virtual const TargetAsmInfo *createTargetAsmInfo() const {
|
||||
return static_cast<const TargetAsmInfo *>(new ARMTargetAsmInfo(*this));
|
||||
}
|
||||
|
||||
// Pass Pipeline Configuration
|
||||
virtual bool addInstSelector(FunctionPassManager &PM, bool Fast);
|
||||
virtual bool addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
|
||||
|
|
|
@ -29,20 +29,13 @@ using namespace llvm;
|
|||
namespace {
|
||||
Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
|
||||
|
||||
struct VISIBILITY_HIDDEN AlphaTargetAsmInfo : public TargetAsmInfo {
|
||||
AlphaTargetAsmInfo() {
|
||||
AlignmentIsInBytes = false;
|
||||
PrivateGlobalPrefix = "$";
|
||||
}
|
||||
};
|
||||
|
||||
struct VISIBILITY_HIDDEN AlphaAsmPrinter : public AsmPrinter {
|
||||
|
||||
/// Unique incrementer for label values for referencing Global values.
|
||||
///
|
||||
unsigned LabelNumber;
|
||||
|
||||
AlphaAsmPrinter(std::ostream &o, TargetMachine &tm, TargetAsmInfo *T)
|
||||
AlphaAsmPrinter(std::ostream &o, TargetMachine &tm, const TargetAsmInfo *T)
|
||||
: AsmPrinter(o, tm, T), LabelNumber(0) {
|
||||
}
|
||||
|
||||
|
@ -82,8 +75,7 @@ namespace {
|
|||
///
|
||||
FunctionPass *llvm::createAlphaCodePrinterPass (std::ostream &o,
|
||||
TargetMachine &tm) {
|
||||
AlphaTargetAsmInfo *TAI = new AlphaTargetAsmInfo();
|
||||
return new AlphaAsmPrinter(o, tm, TAI);
|
||||
return new AlphaAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
||||
}
|
||||
|
||||
#include "AlphaGenAsmWriter.inc"
|
||||
|
|
|
@ -53,7 +53,8 @@ AlphaTargetMachine::AlphaTargetMachine(const Module &M, const std::string &FS)
|
|||
: DataLayout("e"),
|
||||
FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
|
||||
JITInfo(*this),
|
||||
Subtarget(M, FS) {
|
||||
Subtarget(M, FS),
|
||||
AsmInfo(NULL) {
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "AlphaInstrInfo.h"
|
||||
#include "AlphaJITInfo.h"
|
||||
#include "AlphaSubtarget.h"
|
||||
#include "AlphaTargetAsmInfo.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -31,9 +32,13 @@ class AlphaTargetMachine : public LLVMTargetMachine {
|
|||
TargetFrameInfo FrameInfo;
|
||||
AlphaJITInfo JITInfo;
|
||||
AlphaSubtarget Subtarget;
|
||||
AlphaTargetAsmInfo *AsmInfo;
|
||||
|
||||
public:
|
||||
AlphaTargetMachine(const Module &M, const std::string &FS);
|
||||
~AlphaTargetMachine() {
|
||||
if (AsmInfo) delete AsmInfo;
|
||||
}
|
||||
|
||||
virtual const AlphaInstrInfo *getInstrInfo() const { return &InstrInfo; }
|
||||
virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
|
||||
|
@ -46,6 +51,10 @@ public:
|
|||
return &JITInfo;
|
||||
}
|
||||
|
||||
virtual const TargetAsmInfo *createTargetAsmInfo() const {
|
||||
return static_cast<const TargetAsmInfo *>(new AlphaTargetAsmInfo(*this));
|
||||
}
|
||||
|
||||
static unsigned getJITMatchQuality();
|
||||
static unsigned getModuleMatchQuality(const Module &M);
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
#include "llvm/Assembly/Writer.h"
|
||||
#include "llvm/CodeGen/AsmPrinter.h"
|
||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetAsmInfo.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Support/Mangler.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include <iostream>
|
||||
|
@ -32,31 +32,11 @@ using namespace llvm;
|
|||
|
||||
namespace {
|
||||
Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
|
||||
|
||||
struct VISIBILITY_HIDDEN IA64TargetAsmInfo : public TargetAsmInfo {
|
||||
IA64TargetAsmInfo() {
|
||||
CommentString = "//";
|
||||
Data8bitsDirective = "\tdata1\t"; // FIXME: check that we are
|
||||
Data16bitsDirective = "\tdata2.ua\t"; // disabling auto-alignment
|
||||
Data32bitsDirective = "\tdata4.ua\t"; // properly
|
||||
Data64bitsDirective = "\tdata8.ua\t";
|
||||
ZeroDirective = "\t.skip\t";
|
||||
AsciiDirective = "\tstring\t";
|
||||
|
||||
GlobalVarAddrPrefix="";
|
||||
GlobalVarAddrSuffix="";
|
||||
FunctionAddrPrefix="@fptr(";
|
||||
FunctionAddrSuffix=")";
|
||||
|
||||
// FIXME: would be nice to have rodata (no 'w') when appropriate?
|
||||
ConstantPoolSection = "\n\t.section .data, \"aw\", \"progbits\"\n";
|
||||
}
|
||||
};
|
||||
|
||||
struct IA64AsmPrinter : public AsmPrinter {
|
||||
std::set<std::string> ExternalFunctionNames, ExternalObjectNames;
|
||||
|
||||
IA64AsmPrinter(std::ostream &O, TargetMachine &TM, TargetAsmInfo *T)
|
||||
IA64AsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
|
||||
: AsmPrinter(O, TM, T) {
|
||||
}
|
||||
|
||||
|
@ -366,8 +346,7 @@ bool IA64AsmPrinter::doFinalization(Module &M) {
|
|||
///
|
||||
FunctionPass *llvm::createIA64CodePrinterPass(std::ostream &o,
|
||||
IA64TargetMachine &tm) {
|
||||
IA64TargetAsmInfo *TAI = new IA64TargetAsmInfo();
|
||||
return new IA64AsmPrinter(o, tm, TAI);
|
||||
return new IA64AsmPrinter(o, tm, tm.getTargetAsmInfo());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "llvm/Target/TargetFrameInfo.h"
|
||||
#include "IA64InstrInfo.h"
|
||||
#include "IA64ISelLowering.h"
|
||||
#include "IA64TargetAsmInfo.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -40,6 +41,10 @@ public:
|
|||
return &InstrInfo.getRegisterInfo();
|
||||
}
|
||||
virtual const TargetData *getTargetData() const { return &DataLayout; }
|
||||
|
||||
virtual const TargetAsmInfo *createTargetAsmInfo() const {
|
||||
return static_cast<const TargetAsmInfo *>(new IA64TargetAsmInfo(*this));
|
||||
}
|
||||
|
||||
static unsigned getModuleMatchQuality(const Module &M);
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace {
|
|||
struct VISIBILITY_HIDDEN PPCAsmPrinter : public AsmPrinter {
|
||||
std::set<std::string> FnStubs, GVStubs;
|
||||
|
||||
PPCAsmPrinter(std::ostream &O, TargetMachine &TM, TargetAsmInfo *T)
|
||||
PPCAsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
|
||||
: AsmPrinter(O, TM, T) {}
|
||||
|
||||
virtual const char *getPassName() const {
|
||||
|
@ -239,49 +239,14 @@ namespace {
|
|||
|
||||
};
|
||||
|
||||
struct VISIBILITY_HIDDEN DarwinTargetAsmInfo : public TargetAsmInfo {
|
||||
DarwinTargetAsmInfo(PPCTargetMachine &TM) {
|
||||
bool isPPC64 = TM.getSubtargetImpl()->isPPC64();
|
||||
|
||||
CommentString = ";";
|
||||
GlobalPrefix = "_";
|
||||
PrivateGlobalPrefix = "L";
|
||||
ZeroDirective = "\t.space\t";
|
||||
SetDirective = "\t.set";
|
||||
Data64bitsDirective = isPPC64 ? ".quad\t" : 0;
|
||||
AlignmentIsInBytes = false;
|
||||
ConstantPoolSection = "\t.const\t";
|
||||
JumpTableDataSection = ".const";
|
||||
JumpTableTextSection = "\t.text";
|
||||
LCOMMDirective = "\t.lcomm\t";
|
||||
StaticCtorsSection = ".mod_init_func";
|
||||
StaticDtorsSection = ".mod_term_func";
|
||||
InlineAsmStart = "# InlineAsm Start";
|
||||
InlineAsmEnd = "# InlineAsm End";
|
||||
|
||||
NeedsSet = true;
|
||||
AddressSize = isPPC64 ? 8 : 4;
|
||||
DwarfAbbrevSection = ".section __DWARF,__debug_abbrev";
|
||||
DwarfInfoSection = ".section __DWARF,__debug_info";
|
||||
DwarfLineSection = ".section __DWARF,__debug_line";
|
||||
DwarfFrameSection = ".section __DWARF,__debug_frame";
|
||||
DwarfPubNamesSection = ".section __DWARF,__debug_pubnames";
|
||||
DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes";
|
||||
DwarfStrSection = ".section __DWARF,__debug_str";
|
||||
DwarfLocSection = ".section __DWARF,__debug_loc";
|
||||
DwarfARangesSection = ".section __DWARF,__debug_aranges";
|
||||
DwarfRangesSection = ".section __DWARF,__debug_ranges";
|
||||
DwarfMacInfoSection = ".section __DWARF,__debug_macinfo";
|
||||
}
|
||||
};
|
||||
|
||||
/// DarwinAsmPrinter - PowerPC assembly printer, customized for Darwin/Mac OS
|
||||
/// X
|
||||
struct VISIBILITY_HIDDEN DarwinAsmPrinter : public PPCAsmPrinter {
|
||||
|
||||
DwarfWriter DW;
|
||||
|
||||
DarwinAsmPrinter(std::ostream &O, PPCTargetMachine &TM, TargetAsmInfo *T)
|
||||
DarwinAsmPrinter(std::ostream &O, PPCTargetMachine &TM,
|
||||
const TargetAsmInfo *T)
|
||||
: PPCAsmPrinter(O, TM, T), DW(O, this, T) {
|
||||
bool isPPC64 = TM.getSubtargetImpl()->isPPC64();
|
||||
}
|
||||
|
@ -309,8 +274,7 @@ namespace {
|
|||
///
|
||||
FunctionPass *llvm::createDarwinCodePrinterPass(std::ostream &o,
|
||||
PPCTargetMachine &tm) {
|
||||
TargetAsmInfo *TAI = new DarwinTargetAsmInfo(tm);
|
||||
return new DarwinAsmPrinter(o, tm, TAI);
|
||||
return new DarwinAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
||||
}
|
||||
|
||||
// Include the auto-generated portion of the assembly writer
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "PPCJITInfo.h"
|
||||
#include "PPCInstrInfo.h"
|
||||
#include "PPCISelLowering.h"
|
||||
#include "PPCTargetAsmInfo.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
|
||||
|
@ -55,6 +56,9 @@ public:
|
|||
return InstrItins;
|
||||
}
|
||||
|
||||
virtual const TargetAsmInfo *createTargetAsmInfo() const {
|
||||
return static_cast<const TargetAsmInfo *>(new DarwinTargetAsmInfo(*this));
|
||||
}
|
||||
|
||||
// Pass Pipeline Configuration
|
||||
virtual bool addInstSelector(FunctionPassManager &PM, bool Fast);
|
||||
|
|
|
@ -37,19 +37,8 @@ using namespace llvm;
|
|||
namespace {
|
||||
Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
|
||||
|
||||
struct VISIBILITY_HIDDEN SparcTargetAsmInfo : public TargetAsmInfo {
|
||||
SparcTargetAsmInfo() {
|
||||
Data16bitsDirective = "\t.half\t";
|
||||
Data32bitsDirective = "\t.word\t";
|
||||
Data64bitsDirective = 0; // .xword is only supported by V9.
|
||||
ZeroDirective = "\t.skip\t";
|
||||
CommentString = "!";
|
||||
ConstantPoolSection = "\t.section \".rodata\",#alloc\n";
|
||||
}
|
||||
};
|
||||
|
||||
struct VISIBILITY_HIDDEN SparcAsmPrinter : public AsmPrinter {
|
||||
SparcAsmPrinter(std::ostream &O, TargetMachine &TM, TargetAsmInfo *T)
|
||||
SparcAsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
|
||||
: AsmPrinter(O, TM, T) {
|
||||
}
|
||||
|
||||
|
@ -85,8 +74,7 @@ namespace {
|
|||
///
|
||||
FunctionPass *llvm::createSparcCodePrinterPass(std::ostream &o,
|
||||
TargetMachine &tm) {
|
||||
SparcTargetAsmInfo *TAI = new SparcTargetAsmInfo();
|
||||
return new SparcAsmPrinter(o, tm, TAI);
|
||||
return new SparcAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
||||
}
|
||||
|
||||
/// runOnMachineFunction - This uses the printMachineInstruction()
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "llvm/Target/TargetFrameInfo.h"
|
||||
#include "SparcInstrInfo.h"
|
||||
#include "SparcSubtarget.h"
|
||||
#include "SparcTargetAsmInfo.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -41,6 +42,9 @@ public:
|
|||
virtual const TargetData *getTargetData() const { return &DataLayout; }
|
||||
static unsigned getModuleMatchQuality(const Module &M);
|
||||
|
||||
virtual const TargetAsmInfo *createTargetAsmInfo() const {
|
||||
return static_cast<const TargetAsmInfo *>(new SparcTargetAsmInfo(*this));
|
||||
}
|
||||
|
||||
// Pass Pipeline Configuration
|
||||
virtual bool addInstSelector(FunctionPassManager &PM, bool Fast);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Target/TargetAsmInfo.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetOptions.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
|
@ -95,6 +96,7 @@ namespace {
|
|||
//
|
||||
|
||||
TargetMachine::~TargetMachine() {
|
||||
if (AsmInfo) delete AsmInfo;
|
||||
}
|
||||
|
||||
/// getRelocationModel - Returns the code generation relocation model. The
|
||||
|
|
|
@ -16,8 +16,10 @@
|
|||
#include "X86ATTAsmPrinter.h"
|
||||
#include "X86.h"
|
||||
#include "X86TargetMachine.h"
|
||||
#include "X86TargetAsmInfo.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Support/Mangler.h"
|
||||
#include "llvm/Target/TargetAsmInfo.h"
|
||||
#include "llvm/Target/TargetOptions.h"
|
||||
#include <iostream>
|
||||
using namespace llvm;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
namespace llvm {
|
||||
|
||||
struct X86ATTAsmPrinter : public X86SharedAsmPrinter {
|
||||
X86ATTAsmPrinter(std::ostream &O, X86TargetMachine &TM, TargetAsmInfo *T)
|
||||
X86ATTAsmPrinter(std::ostream &O, X86TargetMachine &TM, const TargetAsmInfo *T)
|
||||
: X86SharedAsmPrinter(O, TM, T) { }
|
||||
|
||||
virtual const char *getPassName() const {
|
||||
|
|
|
@ -23,88 +23,12 @@
|
|||
#include "llvm/Type.h"
|
||||
#include "llvm/Assembly/Writer.h"
|
||||
#include "llvm/Support/Mangler.h"
|
||||
#include "llvm/Target/TargetAsmInfo.h"
|
||||
using namespace llvm;
|
||||
|
||||
Statistic<> llvm::EmittedInsts("asm-printer",
|
||||
"Number of machine instrs printed");
|
||||
|
||||
X86TargetAsmInfo::X86TargetAsmInfo(X86TargetMachine &TM) {
|
||||
const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
|
||||
|
||||
//FIXME - Should to be simplified.
|
||||
|
||||
switch (Subtarget->TargetType) {
|
||||
case X86Subtarget::isDarwin:
|
||||
AlignmentIsInBytes = false;
|
||||
GlobalPrefix = "_";
|
||||
Data64bitsDirective = 0; // we can't emit a 64-bit unit
|
||||
ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
|
||||
PrivateGlobalPrefix = "L"; // Marker for constant pool idxs
|
||||
ConstantPoolSection = "\t.const\n";
|
||||
JumpTableDataSection = "\t.const\n"; // FIXME: depends on PIC mode
|
||||
FourByteConstantSection = "\t.literal4\n";
|
||||
EightByteConstantSection = "\t.literal8\n";
|
||||
LCOMMDirective = "\t.lcomm\t";
|
||||
COMMDirectiveTakesAlignment = false;
|
||||
HasDotTypeDotSizeDirective = false;
|
||||
StaticCtorsSection = ".mod_init_func";
|
||||
StaticDtorsSection = ".mod_term_func";
|
||||
InlineAsmStart = "# InlineAsm Start";
|
||||
InlineAsmEnd = "# InlineAsm End";
|
||||
SetDirective = "\t.set";
|
||||
|
||||
NeedsSet = true;
|
||||
DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
|
||||
DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
|
||||
DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
|
||||
DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
|
||||
DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
|
||||
DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
|
||||
DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
|
||||
DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug";
|
||||
DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug";
|
||||
DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug";
|
||||
DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
|
||||
break;
|
||||
case X86Subtarget::isCygwin:
|
||||
GlobalPrefix = "_";
|
||||
COMMDirectiveTakesAlignment = false;
|
||||
HasDotTypeDotSizeDirective = false;
|
||||
StaticCtorsSection = "\t.section .ctors,\"aw\"";
|
||||
StaticDtorsSection = "\t.section .dtors,\"aw\"";
|
||||
break;
|
||||
case X86Subtarget::isWindows:
|
||||
GlobalPrefix = "_";
|
||||
HasDotTypeDotSizeDirective = false;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (Subtarget->isFlavorIntel()) {
|
||||
GlobalPrefix = "_";
|
||||
CommentString = ";";
|
||||
|
||||
PrivateGlobalPrefix = "$";
|
||||
AlignDirective = "\talign\t";
|
||||
ZeroDirective = "\tdb\t";
|
||||
ZeroDirectiveSuffix = " dup(0)";
|
||||
AsciiDirective = "\tdb\t";
|
||||
AscizDirective = 0;
|
||||
Data8bitsDirective = "\tdb\t";
|
||||
Data16bitsDirective = "\tdw\t";
|
||||
Data32bitsDirective = "\tdd\t";
|
||||
Data64bitsDirective = "\tdq\t";
|
||||
HasDotTypeDotSizeDirective = false;
|
||||
|
||||
TextSection = "_text";
|
||||
DataSection = "_data";
|
||||
SwitchToSectionDirective = "";
|
||||
TextSectionStartSuffix = "\tsegment 'CODE'";
|
||||
DataSectionStartSuffix = "\tsegment 'DATA'";
|
||||
SectionEndDirectiveSuffix = "\tends\n";
|
||||
}
|
||||
}
|
||||
|
||||
/// doInitialization
|
||||
bool X86SharedAsmPrinter::doInitialization(Module &M) {
|
||||
if (Subtarget->isTargetDarwin()) {
|
||||
|
@ -255,11 +179,10 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
|
|||
FunctionPass *llvm::createX86CodePrinterPass(std::ostream &o,
|
||||
X86TargetMachine &tm) {
|
||||
const X86Subtarget *Subtarget = &tm.getSubtarget<X86Subtarget>();
|
||||
TargetAsmInfo *TAI = new X86TargetAsmInfo(tm);
|
||||
|
||||
if (Subtarget->isFlavorIntel()) {
|
||||
return new X86IntelAsmPrinter(o, tm, TAI);
|
||||
return new X86IntelAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
||||
} else {
|
||||
return new X86ATTAsmPrinter(o, tm, TAI);
|
||||
return new X86ATTAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "llvm/CodeGen/DwarfWriter.h"
|
||||
#include "llvm/CodeGen/MachineDebugInfo.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/Target/TargetAsmInfo.h"
|
||||
#include <set>
|
||||
|
||||
|
||||
|
@ -30,15 +29,11 @@ namespace llvm {
|
|||
|
||||
extern Statistic<> EmittedInsts;
|
||||
|
||||
struct VISIBILITY_HIDDEN X86TargetAsmInfo : public TargetAsmInfo {
|
||||
X86TargetAsmInfo(X86TargetMachine &TM);
|
||||
};
|
||||
|
||||
struct VISIBILITY_HIDDEN X86SharedAsmPrinter : public AsmPrinter {
|
||||
DwarfWriter DW;
|
||||
|
||||
X86SharedAsmPrinter(std::ostream &O, X86TargetMachine &TM,
|
||||
TargetAsmInfo *T)
|
||||
const TargetAsmInfo *T)
|
||||
: AsmPrinter(O, TM, T), DW(O, this, T) {
|
||||
Subtarget = &TM.getSubtarget<X86Subtarget>();
|
||||
}
|
||||
|
|
|
@ -14,11 +14,13 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "X86IntelAsmPrinter.h"
|
||||
#include "X86TargetAsmInfo.h"
|
||||
#include "X86.h"
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Assembly/Writer.h"
|
||||
#include "llvm/Support/Mangler.h"
|
||||
#include "llvm/Target/TargetAsmInfo.h"
|
||||
#include "llvm/Target/TargetOptions.h"
|
||||
using namespace llvm;
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
namespace llvm {
|
||||
|
||||
struct X86IntelAsmPrinter : public X86SharedAsmPrinter {
|
||||
X86IntelAsmPrinter(std::ostream &O, X86TargetMachine &TM, TargetAsmInfo *T)
|
||||
X86IntelAsmPrinter(std::ostream &O, X86TargetMachine &TM,
|
||||
const TargetAsmInfo *T)
|
||||
: X86SharedAsmPrinter(O, TM, T) {
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "X86InstrInfo.h"
|
||||
#include "X86JITInfo.h"
|
||||
#include "X86Subtarget.h"
|
||||
#include "X86TargetAsmInfo.h"
|
||||
#include "X86ISelLowering.h"
|
||||
|
||||
namespace llvm {
|
||||
|
@ -50,6 +51,9 @@ public:
|
|||
static unsigned getModuleMatchQuality(const Module &M);
|
||||
static unsigned getJITMatchQuality();
|
||||
|
||||
virtual const TargetAsmInfo *createTargetAsmInfo() const {
|
||||
return static_cast<const TargetAsmInfo *>(new X86TargetAsmInfo(*this));
|
||||
}
|
||||
|
||||
// Set up the pass pipeline.
|
||||
virtual bool addInstSelector(FunctionPassManager &PM, bool Fast);
|
||||
|
|
Loading…
Reference in New Issue