本文整理汇总了C++中OwningPtr::InitSections方法的典型用法代码示例。如果您正苦于以下问题:C++ OwningPtr::InitSections方法的具体用法?C++ OwningPtr::InitSections怎么用?C++ OwningPtr::InitSections使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OwningPtr
的用法示例。
在下文中一共展示了OwningPtr::InitSections方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: jl_dump_function_asm
//.........这里部分代码省略.........
bool ShowEncoding = false;
bool ShowInst = false;
#ifdef LLVM35
std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo());
std::unique_ptr<MCInstrAnalysis>
MCIA(TheTarget->createMCInstrAnalysis(MCII.get()));
#else
OwningPtr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo());
OwningPtr<MCInstrAnalysis>
MCIA(TheTarget->createMCInstrAnalysis(MCII.get()));
#endif
MCInstPrinter* IP =
TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *MCII, *MRI, *STI);
MCCodeEmitter *CE = 0;
MCAsmBackend *MAB = 0;
if (ShowEncoding) {
CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, *STI, Ctx);
#ifdef LLVM34
MAB = TheTarget->createMCAsmBackend(*MRI, TripleName, MCPU);
#else
MAB = TheTarget->createMCAsmBackend(TripleName, MCPU);
#endif
}
Streamer.reset(TheTarget->createAsmStreamer(Ctx, stream, /*asmverbose*/true,
#ifndef LLVM35
/*useLoc*/ true,
/*useCFI*/ true,
#endif
/*useDwarfDirectory*/ true,
IP, CE, MAB, ShowInst));
#ifdef LLVM36
Streamer->InitSections(true);
#else
Streamer->InitSections();
#endif
// Make the MemoryObject wrapper
#ifdef LLVM36
ArrayRef<uint8_t> memoryObject(const_cast<uint8_t*>((const uint8_t*)Fptr),Fsize);
#else
FuncMCView memoryObject(Fptr, Fsize);
#endif
SymbolTable DisInfo(Ctx, memoryObject);
#ifdef USE_MCJIT
if (!objectfile) return;
#ifdef LLVM36
DIContext *di_ctx = DIContext::getDWARFContext(*objectfile);
#else
DIContext *di_ctx = DIContext::getDWARFContext(const_cast<object::ObjectFile*>(objectfile));
#endif
if (di_ctx == NULL) return;
DILineInfoTable lineinfo = di_ctx->getLineInfoForAddressRange((size_t)Fptr, Fsize);
#else
typedef std::vector<JITEvent_EmittedFunctionDetails::LineStart> LInfoVec;
#endif
// Take two passes: In the first pass we record all branch labels,
// in the second we actually perform the output
for (int pass = 0; pass < 2; ++ pass) {
DisInfo.setPass(pass);
if (pass != 0) {
// Switch to symbolic disassembly. We cannot do this
// before the first pass, because this changes branch
示例2: jl_dump_function_asm
void jl_dump_function_asm(void* Fptr, size_t Fsize,
std::vector<JITEvent_EmittedFunctionDetails::LineStart> lineinfo,
formatted_raw_ostream &stream) {
// Initialize targets and assembly printers/parsers.
// Avoids hard-coded targets - will generally be only host CPU anyway.
llvm::InitializeNativeTargetAsmParser();
llvm::InitializeNativeTargetDisassembler();
// Get the host information
std::string TripleName;
if (TripleName.empty())
TripleName = sys::getDefaultTargetTriple();
Triple TheTriple(Triple::normalize(TripleName));
std::string MCPU = sys::getHostCPUName();
SubtargetFeatures Features;
Features.getDefaultSubtargetFeatures(TheTriple);
std::string err;
const Target* TheTarget = TargetRegistry::lookupTarget(TripleName, err);
// Set up required helpers and streamer
OwningPtr<MCStreamer> Streamer;
SourceMgr SrcMgr;
#ifdef LLVM34
llvm::OwningPtr<MCAsmInfo> MAI(TheTarget->createMCAsmInfo(*TheTarget->createMCRegInfo(TripleName),TripleName));
#else
llvm::OwningPtr<MCAsmInfo> MAI(TheTarget->createMCAsmInfo(TripleName));
#endif
assert(MAI && "Unable to create target asm info!");
llvm::OwningPtr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TripleName));
assert(MRI && "Unable to create target register info!");
OwningPtr<MCObjectFileInfo> MOFI(new MCObjectFileInfo());
#ifdef LLVM34
MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &SrcMgr);
#else
MCContext Ctx(*MAI, *MRI, MOFI.get(), &SrcMgr);
#endif
MOFI->InitMCObjectFileInfo(TripleName, Reloc::Default, CodeModel::Default, Ctx);
// Set up Subtarget and Disassembler
OwningPtr<MCSubtargetInfo>
STI(TheTarget->createMCSubtargetInfo(TripleName, MCPU, Features.getString()));
#ifdef LLVM35
OwningPtr<const MCDisassembler> DisAsm(TheTarget->createMCDisassembler(*STI, Ctx));
#else
OwningPtr<const MCDisassembler> DisAsm(TheTarget->createMCDisassembler(*STI));
#endif
if (!DisAsm) {
JL_PRINTF(JL_STDERR, "error: no disassembler for target", TripleName.c_str(), "\n");
return;
}
unsigned OutputAsmVariant = 1;
bool ShowEncoding = false;
bool ShowInst = false;
OwningPtr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo());
MCInstPrinter* IP =
TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *MCII, *MRI, *STI);
MCCodeEmitter *CE = 0;
MCAsmBackend *MAB = 0;
if (ShowEncoding) {
CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, *STI, Ctx);
#ifdef LLVM34
MAB = TheTarget->createMCAsmBackend(*MRI, TripleName, MCPU);
#else
MAB = TheTarget->createMCAsmBackend(TripleName, MCPU);
#endif
}
Streamer.reset(TheTarget->createAsmStreamer(Ctx, stream, /*asmverbose*/true,
#ifndef LLVM35
/*useLoc*/ true,
/*useCFI*/ true,
#endif
/*useDwarfDirectory*/ true,
IP, CE, MAB, ShowInst));
Streamer->InitSections();
// Make the MemoryObject wrapper
FuncMCView memoryObject(Fptr, Fsize);
uint64_t Size;
uint64_t Index;
uint64_t absAddr;
// Set up the line info
typedef std::vector<JITEvent_EmittedFunctionDetails::LineStart> LInfoVec;
LInfoVec::iterator lineIter = lineinfo.begin();
lineIter = lineinfo.begin();
uint64_t nextLineAddr = -1;
DISubprogram debugscope;
if (lineIter != lineinfo.end()) {
nextLineAddr = (*lineIter).Address;
debugscope = DISubprogram((*lineIter).Loc.getScope(jl_LLVMContext));
//.........这里部分代码省略.........