#include "llvm/PassAnalysisSupport.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
return make_error<StringError>("no asm info for target " + TripleName,
inconvertibleErrorCode());
- MOFI.reset(new MCObjectFileInfo);
- MC.reset(new MCContext(MAI.get(), MRI.get(), MOFI.get()));
- MOFI->InitMCObjectFileInfo(TheTriple, /*PIC*/ false, *MC);
-
MSTI.reset(TheTarget->createMCSubtargetInfo(TripleName, "", ""));
if (!MSTI)
return make_error<StringError>("no subtarget info for target " + TripleName,
TripleName,
inconvertibleErrorCode());
+ TM.reset(TheTarget->createTargetMachine(TripleName, "", "", TargetOptions(),
+ None));
+ if (!TM)
+ return make_error<StringError>("no target machine for target " + TripleName,
+ inconvertibleErrorCode());
+
+ TLOF = TM->getObjFileLowering();
+ MC.reset(new MCContext(MAI.get(), MRI.get(), TLOF));
+ TLOF->Initialize(*MC, *TM);
+
MCE = TheTarget->createMCCodeEmitter(*MII, *MRI, *MC);
if (!MCE)
return make_error<StringError>("no code emitter for target " + TripleName,
TripleName,
inconvertibleErrorCode());
- // Finally create the AsmPrinter we'll use to emit the DIEs.
- TM.reset(TheTarget->createTargetMachine(TripleName, "", "", TargetOptions(),
- None));
- if (!TM)
- return make_error<StringError>("no target machine for target " + TripleName,
- inconvertibleErrorCode());
+ // Finally create the AsmPrinter we'll use to emit the DIEs.
Asm.reset(TheTarget->createAsmPrinter(*TM, std::unique_ptr<MCStreamer>(MS)));
if (!Asm)
return make_error<StringError>("no asm printer for target " + TripleName,
SecOffset += CUOffset;
CU->setLength(CUOffset - 4);
}
- Abbreviations.Emit(Asm.get(), MOFI->getDwarfAbbrevSection());
- StringPool->emit(*Asm, MOFI->getDwarfStrSection());
- MS->SwitchSection(MOFI->getDwarfInfoSection());
+ Abbreviations.Emit(Asm.get(), TLOF->getDwarfAbbrevSection());
+ StringPool->emit(*Asm, TLOF->getDwarfStrSection());
+ MS->SwitchSection(TLOF->getDwarfInfoSection());
for (auto &CU : CompileUnits) {
uint16_t Version = CU->getVersion();
auto Length = CU->getLength();
Asm->emitDwarfDIE(*CU->getUnitDIE().Die);
}
- MS->SwitchSection(MOFI->getDwarfLineSection());
+ MS->SwitchSection(TLOF->getDwarfLineSection());
for (auto < : LineTables)
LT->generate(*MC, *Asm);
class MCContext;
struct MCDwarfLineTableParams;
class MCInstrInfo;
-class MCObjectFileInfo;
class MCRegisterInfo;
class MCStreamer;
class MCSubtargetInfo;
class raw_fd_ostream;
+class TargetLoweringObjectFile;
class TargetMachine;
class Triple;
class Generator {
std::unique_ptr<MCRegisterInfo> MRI;
std::unique_ptr<MCAsmInfo> MAI;
- std::unique_ptr<MCObjectFileInfo> MOFI;
std::unique_ptr<MCContext> MC;
MCAsmBackend *MAB; // Owned by MCStreamer
std::unique_ptr<MCInstrInfo> MII;
MCCodeEmitter *MCE; // Owned by MCStreamer
MCStreamer *MS; // Owned by AsmPrinter
std::unique_ptr<TargetMachine> TM;
+ TargetLoweringObjectFile *TLOF; // Owned by TargetMachine;
std::unique_ptr<AsmPrinter> Asm;
BumpPtrAllocator Allocator;
std::unique_ptr<DwarfStringPool> StringPool; // Entries owned by Allocator.