Replace string GNU Triples with llvm::Triple in TargetMachine::getTargetTriple(). NFC.

Summary:
This continues the patch series to eliminate StringRef forms of GNU triples
from the internals of LLVM that began in r239036.

Reviewers: rengolin

Reviewed By: rengolin

Subscribers: llvm-commits, rengolin

Differential Revision: http://reviews.llvm.org/D10381


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239815 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Sanders 2015-06-16 13:15:50 +00:00
parent db8ece3bb7
commit 7f5b833aa3
8 changed files with 29 additions and 29 deletions

View File

@ -105,8 +105,7 @@ public:
const Target &getTarget() const { return TheTarget; } const Target &getTarget() const { return TheTarget; }
// FIXME: Either rename to getTargetName() or make it return a triple. const Triple &getTargetTriple() const { return TargetTriple; }
StringRef getTargetTriple() const { return TargetTriple.str(); }
StringRef getTargetCPU() const { return TargetCPU; } StringRef getTargetCPU() const { return TargetCPU; }
StringRef getTargetFeatureString() const { return TargetFS; } StringRef getTargetFeatureString() const { return TargetFS; }

View File

@ -151,7 +151,7 @@ void AsmPrinter::EmitToStreamer(MCStreamer &S, const MCInst &Inst) {
} }
StringRef AsmPrinter::getTargetTriple() const { StringRef AsmPrinter::getTargetTriple() const {
return TM.getTargetTriple(); return TM.getTargetTriple().str();
} }
/// getCurrentSection() - Return the current section we are emitting to. /// getCurrentSection() - Return the current section we are emitting to.
@ -221,7 +221,8 @@ bool AsmPrinter::doInitialization(Module &M) {
// We're at the module level. Construct MCSubtarget from the default CPU // We're at the module level. Construct MCSubtarget from the default CPU
// and target triple. // and target triple.
std::unique_ptr<MCSubtargetInfo> STI(TM.getTarget().createMCSubtargetInfo( std::unique_ptr<MCSubtargetInfo> STI(TM.getTarget().createMCSubtargetInfo(
TM.getTargetTriple(), TM.getTargetCPU(), TM.getTargetFeatureString())); TM.getTargetTriple().str(), TM.getTargetCPU(),
TM.getTargetFeatureString()));
OutStreamer->AddComment("Start of file scope inline assembly"); OutStreamer->AddComment("Start of file scope inline assembly");
OutStreamer->AddBlankLine(); OutStreamer->AddBlankLine();
EmitInlineAsm(M.getModuleInlineAsm()+"\n", *STI, TM.Options.MCOptions); EmitInlineAsm(M.getModuleInlineAsm()+"\n", *STI, TM.Options.MCOptions);
@ -231,7 +232,7 @@ bool AsmPrinter::doInitialization(Module &M) {
if (MAI->doesSupportDebugInformation()) { if (MAI->doesSupportDebugInformation()) {
bool skip_dwarf = false; bool skip_dwarf = false;
if (Triple(TM.getTargetTriple()).isKnownWindowsMSVCEnvironment()) { if (TM.getTargetTriple().isKnownWindowsMSVCEnvironment()) {
Handlers.push_back(HandlerInfo(new WinCodeViewLineTables(this), Handlers.push_back(HandlerInfo(new WinCodeViewLineTables(this),
DbgTimerName, DbgTimerName,
CodeViewLineTablesGroupName)); CodeViewLineTablesGroupName));
@ -1041,8 +1042,7 @@ bool AsmPrinter::doFinalization(Module &M) {
if (!ModuleFlags.empty()) if (!ModuleFlags.empty())
TLOF.emitModuleFlags(*OutStreamer, ModuleFlags, *Mang, TM); TLOF.emitModuleFlags(*OutStreamer, ModuleFlags, *Mang, TM);
Triple TT(TM.getTargetTriple()); if (TM.getTargetTriple().isOSBinFormatELF()) {
if (TT.isOSBinFormatELF()) {
MachineModuleInfoELF &MMIELF = MMI->getObjFileInfo<MachineModuleInfoELF>(); MachineModuleInfoELF &MMIELF = MMI->getObjFileInfo<MachineModuleInfoELF>();
// Output stubs for external and common global variables. // Output stubs for external and common global variables.

View File

@ -43,16 +43,17 @@ EnableFastISelOption("fast-isel", cl::Hidden,
cl::desc("Enable the \"fast\" instruction selector")); cl::desc("Enable the \"fast\" instruction selector"));
void LLVMTargetMachine::initAsmInfo() { void LLVMTargetMachine::initAsmInfo() {
MRI = TheTarget.createMCRegInfo(getTargetTriple()); MRI = TheTarget.createMCRegInfo(getTargetTriple().str());
MII = TheTarget.createMCInstrInfo(); MII = TheTarget.createMCInstrInfo();
// FIXME: Having an MCSubtargetInfo on the target machine is a hack due // FIXME: Having an MCSubtargetInfo on the target machine is a hack due
// to some backends having subtarget feature dependent module level // to some backends having subtarget feature dependent module level
// code generation. This is similar to the hack in the AsmPrinter for // code generation. This is similar to the hack in the AsmPrinter for
// module level assembly etc. // module level assembly etc.
STI = TheTarget.createMCSubtargetInfo(getTargetTriple(), getTargetCPU(), STI = TheTarget.createMCSubtargetInfo(getTargetTriple().str(), getTargetCPU(),
getTargetFeatureString()); getTargetFeatureString());
MCAsmInfo *TmpAsmInfo = TheTarget.createMCAsmInfo(*MRI, getTargetTriple()); MCAsmInfo *TmpAsmInfo =
TheTarget.createMCAsmInfo(*MRI, getTargetTriple().str());
// TargetSelect.h moved to a different directory between LLVM 2.9 and 3.0, // TargetSelect.h moved to a different directory between LLVM 2.9 and 3.0,
// and if the old one gets included then MCAsmInfo will be NULL and // and if the old one gets included then MCAsmInfo will be NULL and
// we'll crash later. // we'll crash later.
@ -168,15 +169,15 @@ bool LLVMTargetMachine::addPassesToEmitFile(
switch (FileType) { switch (FileType) {
case CGFT_AssemblyFile: { case CGFT_AssemblyFile: {
MCInstPrinter *InstPrinter = getTarget().createMCInstPrinter( MCInstPrinter *InstPrinter = getTarget().createMCInstPrinter(
Triple(getTargetTriple()), MAI.getAssemblerDialect(), MAI, MII, MRI); getTargetTriple(), MAI.getAssemblerDialect(), MAI, MII, MRI);
// Create a code emitter if asked to show the encoding. // Create a code emitter if asked to show the encoding.
MCCodeEmitter *MCE = nullptr; MCCodeEmitter *MCE = nullptr;
if (Options.MCOptions.ShowMCEncoding) if (Options.MCOptions.ShowMCEncoding)
MCE = getTarget().createMCCodeEmitter(MII, MRI, *Context); MCE = getTarget().createMCCodeEmitter(MII, MRI, *Context);
MCAsmBackend *MAB = getTarget().createMCAsmBackend(MRI, getTargetTriple(), MCAsmBackend *MAB =
TargetCPU); getTarget().createMCAsmBackend(MRI, getTargetTriple().str(), TargetCPU);
auto FOut = llvm::make_unique<formatted_raw_ostream>(Out); auto FOut = llvm::make_unique<formatted_raw_ostream>(Out);
MCStreamer *S = getTarget().createAsmStreamer( MCStreamer *S = getTarget().createAsmStreamer(
*Context, std::move(FOut), Options.MCOptions.AsmVerbose, *Context, std::move(FOut), Options.MCOptions.AsmVerbose,
@ -189,15 +190,15 @@ bool LLVMTargetMachine::addPassesToEmitFile(
// Create the code emitter for the target if it exists. If not, .o file // Create the code emitter for the target if it exists. If not, .o file
// emission fails. // emission fails.
MCCodeEmitter *MCE = getTarget().createMCCodeEmitter(MII, MRI, *Context); MCCodeEmitter *MCE = getTarget().createMCCodeEmitter(MII, MRI, *Context);
MCAsmBackend *MAB = getTarget().createMCAsmBackend(MRI, getTargetTriple(), MCAsmBackend *MAB =
TargetCPU); getTarget().createMCAsmBackend(MRI, getTargetTriple().str(), TargetCPU);
if (!MCE || !MAB) if (!MCE || !MAB)
return true; return true;
// Don't waste memory on names of temp labels. // Don't waste memory on names of temp labels.
Context->setUseNamesOnTempLabels(false); Context->setUseNamesOnTempLabels(false);
Triple T(getTargetTriple()); Triple T(getTargetTriple().str());
AsmStreamer.reset(getTarget().createMCObjectStreamer( AsmStreamer.reset(getTarget().createMCObjectStreamer(
T, *Context, *MAB, Out, MCE, STI, Options.MCOptions.MCRelaxAll, T, *Context, *MAB, Out, MCE, STI, Options.MCOptions.MCRelaxAll,
/*DWARFMustBeAtTheEnd*/ true)); /*DWARFMustBeAtTheEnd*/ true));
@ -242,12 +243,12 @@ bool LLVMTargetMachine::addPassesToEmitMC(PassManagerBase &PM, MCContext *&Ctx,
const MCRegisterInfo &MRI = *getMCRegisterInfo(); const MCRegisterInfo &MRI = *getMCRegisterInfo();
MCCodeEmitter *MCE = MCCodeEmitter *MCE =
getTarget().createMCCodeEmitter(*getMCInstrInfo(), MRI, *Ctx); getTarget().createMCCodeEmitter(*getMCInstrInfo(), MRI, *Ctx);
MCAsmBackend *MAB = getTarget().createMCAsmBackend(MRI, getTargetTriple(), MCAsmBackend *MAB =
TargetCPU); getTarget().createMCAsmBackend(MRI, getTargetTriple().str(), TargetCPU);
if (!MCE || !MAB) if (!MCE || !MAB)
return true; return true;
Triple T(getTargetTriple()); const Triple &T = getTargetTriple();
const MCSubtargetInfo &STI = *getMCSubtargetInfo(); const MCSubtargetInfo &STI = *getMCSubtargetInfo();
std::unique_ptr<MCStreamer> AsmStreamer(getTarget().createMCObjectStreamer( std::unique_ptr<MCStreamer> AsmStreamer(getTarget().createMCObjectStreamer(
T, *Ctx, *MAB, Out, MCE, STI, Options.MCOptions.MCRelaxAll, T, *Ctx, *MAB, Out, MCE, STI, Options.MCOptions.MCRelaxAll,

View File

@ -899,7 +899,8 @@ void MipsAsmPrinter::EmitFPCallStub(
// freed) and since we're at the global level we can use the default // freed) and since we're at the global level we can use the default
// constructed subtarget. // constructed subtarget.
std::unique_ptr<MCSubtargetInfo> STI(TM.getTarget().createMCSubtargetInfo( std::unique_ptr<MCSubtargetInfo> STI(TM.getTarget().createMCSubtargetInfo(
TM.getTargetTriple(), TM.getTargetCPU(), TM.getTargetFeatureString())); TM.getTargetTriple().str(), TM.getTargetCPU(),
TM.getTargetFeatureString()));
// //
// .global xxxx // .global xxxx

View File

@ -1276,7 +1276,8 @@ EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) {
// freed) and since we're at the global level we can use the default // freed) and since we're at the global level we can use the default
// constructed subtarget. // constructed subtarget.
std::unique_ptr<MCSubtargetInfo> STI(TM.getTarget().createMCSubtargetInfo( std::unique_ptr<MCSubtargetInfo> STI(TM.getTarget().createMCSubtargetInfo(
TM.getTargetTriple(), TM.getTargetCPU(), TM.getTargetFeatureString())); TM.getTargetTriple().str(), TM.getTargetCPU(),
TM.getTargetFeatureString()));
auto EmitToStreamer = [&STI] (MCStreamer &S, const MCInst &Inst) { auto EmitToStreamer = [&STI] (MCStreamer &S, const MCInst &Inst) {
S.EmitInstruction(Inst, *STI); S.EmitInstruction(Inst, *STI);
}; };

View File

@ -98,13 +98,12 @@ static std::string getDataLayoutString(const Triple &T) {
return Ret; return Ret;
} }
static std::string computeFSAdditions(StringRef FS, CodeGenOpt::Level OL, StringRef TT) { static std::string computeFSAdditions(StringRef FS, CodeGenOpt::Level OL,
const Triple &TT) {
std::string FullFS = FS; std::string FullFS = FS;
Triple TargetTriple(TT);
// Make sure 64-bit features are available when CPUname is generic // Make sure 64-bit features are available when CPUname is generic
if (TargetTriple.getArch() == Triple::ppc64 || if (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le) {
TargetTriple.getArch() == Triple::ppc64le) {
if (!FullFS.empty()) if (!FullFS.empty())
FullFS = "+64bit," + FullFS; FullFS = "+64bit," + FullFS;
else else
@ -171,8 +170,7 @@ PPCTargetMachine::PPCTargetMachine(const Target &T, const Triple &TT,
Reloc::Model RM, CodeModel::Model CM, Reloc::Model RM, CodeModel::Model CM,
CodeGenOpt::Level OL) CodeGenOpt::Level OL)
: LLVMTargetMachine(T, getDataLayoutString(TT), TT, CPU, : LLVMTargetMachine(T, getDataLayoutString(TT), TT, CPU,
computeFSAdditions(FS, OL, TT.str()), Options, RM, CM, computeFSAdditions(FS, OL, TT), Options, RM, CM, OL),
OL),
TLOF(createTLOF(Triple(getTargetTriple()))), TLOF(createTLOF(Triple(getTargetTriple()))),
TargetABI(computeTargetABI(TT, Options)) { TargetABI(computeTargetABI(TT, Options)) {
initAsmInfo(); initAsmInfo();

View File

@ -156,7 +156,7 @@ LLVMTargetRef LLVMGetTargetMachineTarget(LLVMTargetMachineRef T) {
} }
char* LLVMGetTargetMachineTriple(LLVMTargetMachineRef T) { char* LLVMGetTargetMachineTriple(LLVMTargetMachineRef T) {
std::string StringRep = unwrap(T)->getTargetTriple(); std::string StringRep = unwrap(T)->getTargetTriple().str();
return strdup(StringRep.c_str()); return strdup(StringRep.c_str());
} }

View File

@ -131,7 +131,7 @@ int llvm::runOrcLazyJIT(std::unique_ptr<Module> M, int ArgC, char* ArgV[]) {
// manager for this target. Bail out. // manager for this target. Bail out.
if (!CallbackMgrBuilder) { if (!CallbackMgrBuilder) {
errs() << "No callback manager available for target '" errs() << "No callback manager available for target '"
<< TM->getTargetTriple() << "'.\n"; << TM->getTargetTriple().str() << "'.\n";
return 1; return 1;
} }