本文整理汇总了C++中llvm::Module::getDataLayout方法的典型用法代码示例。如果您正苦于以下问题:C++ Module::getDataLayout方法的具体用法?C++ Module::getDataLayout怎么用?C++ Module::getDataLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::Module
的用法示例。
在下文中一共展示了Module::getDataLayout方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: emit_file
void emit_file(llvm::Module &module, Internal::LLVMOStream& out, llvm::TargetMachine::CodeGenFileType file_type) {
Internal::debug(1) << "emit_file.Compiling to native code...\n";
Internal::debug(2) << "Target triple: " << module.getTargetTriple() << "\n";
// Get the target specific parser.
auto target_machine = Internal::make_target_machine(module);
internal_assert(target_machine.get()) << "Could not allocate target machine!\n";
#if LLVM_VERSION == 37
llvm::DataLayout target_data_layout(*(target_machine->getDataLayout()));
#else
llvm::DataLayout target_data_layout(target_machine->createDataLayout());
#endif
if (!(target_data_layout == module.getDataLayout())) {
internal_error << "Warning: module's data layout does not match target machine's\n"
<< target_data_layout.getStringRepresentation() << "\n"
<< module.getDataLayout().getStringRepresentation() << "\n";
}
// Build up all of the passes that we want to do to the module.
llvm::legacy::PassManager pass_manager;
pass_manager.add(new llvm::TargetLibraryInfoWrapperPass(llvm::Triple(module.getTargetTriple())));
// Make sure things marked as always-inline get inlined
#if LLVM_VERSION < 40
pass_manager.add(llvm::createAlwaysInlinerPass());
#else
pass_manager.add(llvm::createAlwaysInlinerLegacyPass());
#endif
// Enable symbol rewriting. This allows code outside libHalide to
// use symbol rewriting when compiling Halide code (for example, by
// using cl::ParseCommandLineOption and then passing the appropriate
// rewrite options via -mllvm flags).
pass_manager.add(llvm::createRewriteSymbolsPass());
// Override default to generate verbose assembly.
target_machine->Options.MCOptions.AsmVerbose = true;
// Ask the target to add backend passes as necessary.
target_machine->addPassesToEmitFile(pass_manager, out, file_type);
pass_manager.run(module);
}
示例2: runOnModule
bool ContractManager::runOnModule(llvm::Module& M) {
const llvm::DataLayout* DL = M.getDataLayout();
FN = FactoryNest(DL, nullptr);
VariableInfoTracker* VI = &GetAnalysis<VariableInfoTracker>::doit(this);
FN.Type->initialize(*VI);
if (not contracts) {
contracts = ContractContainer::Ptr{new ContractContainer()};
}
return false;
}
示例3: emit_file
void emit_file(llvm::Module &module, Internal::LLVMOStream& out, llvm::TargetMachine::CodeGenFileType file_type) {
#if LLVM_VERSION < 37
emit_file_legacy(module, out, file_type);
#else
Internal::debug(1) << "emit_file.Compiling to native code...\n";
Internal::debug(2) << "Target triple: " << module.getTargetTriple() << "\n";
// Get the target specific parser.
auto target_machine = Internal::make_target_machine(module);
internal_assert(target_machine.get()) << "Could not allocate target machine!\n";
#if LLVM_VERSION == 37
llvm::DataLayout target_data_layout(*(target_machine->getDataLayout()));
#else
llvm::DataLayout target_data_layout(target_machine->createDataLayout());
#endif
if (!(target_data_layout == module.getDataLayout())) {
internal_error << "Warning: module's data layout does not match target machine's\n"
<< target_data_layout.getStringRepresentation() << "\n"
<< module.getDataLayout().getStringRepresentation() << "\n";
}
// Build up all of the passes that we want to do to the module.
llvm::legacy::PassManager pass_manager;
pass_manager.add(new llvm::TargetLibraryInfoWrapperPass(llvm::Triple(module.getTargetTriple())));
// Make sure things marked as always-inline get inlined
pass_manager.add(llvm::createAlwaysInlinerPass());
// Override default to generate verbose assembly.
target_machine->Options.MCOptions.AsmVerbose = true;
// Ask the target to add backend passes as necessary.
target_machine->addPassesToEmitFile(pass_manager, out, file_type);
pass_manager.run(module);
#endif
}
示例4: logic_error
Runtime::Runtime(llvm::LLVMContext& context,
llvm::Module& target,
llvm::IRBuilder<>& builder)
: target_(target)
, builder_(builder)
, layout_(target.getDataLayout())
{
llvm::SMDiagnostic diag;
auto mem_buf = llvm::MemoryBuffer::getMemBuffer(runtime_definitions);
runtime_ = llvm::parseIR(*mem_buf.get(), diag, context);
if (runtime_ == nullptr)
throw std::logic_error("runtime could not be loaded");
}
示例5: doInitialization
bool TargetInfo::doInitialization(llvm::Module &m)
{
dl = &m.getDataLayout();
return ImmutablePass::doInitialization(m);
}
示例6: generateProgram
void SmackModuleGenerator::generateProgram(llvm::Module& M) {
Naming naming;
SmackRep rep(M.getDataLayout(), naming, program, getAnalysis<Regions>());
std::list<Decl*>& decls = program.getDeclarations();
DEBUG(errs() << "Analyzing globals...\n");
for (auto& G : M.globals()) {
auto ds = rep.globalDecl(&G);
decls.insert(decls.end(), ds.begin(), ds.end());
}
DEBUG(errs() << "Analyzing functions...\n");
for (auto& F : M) {
// Reset the counters for per-function names
naming.reset();
DEBUG(errs() << "Analyzing function: " << naming.get(F) << "\n");
auto ds = rep.globalDecl(&F);
decls.insert(decls.end(), ds.begin(), ds.end());
auto procs = rep.procedure(&F);
assert(procs.size() > 0);
if (naming.get(F) != Naming::DECLARATIONS_PROC)
decls.insert(decls.end(), procs.begin(), procs.end());
if (F.isDeclaration())
continue;
if (!F.empty() && !F.getEntryBlock().empty()) {
DEBUG(errs() << "Analyzing function body: " << naming.get(F) << "\n");
for (auto P : procs) {
SmackInstGenerator igen(getAnalysis<LoopInfo>(F), rep, *P, naming);
DEBUG(errs() << "Generating body for " << naming.get(F) << "\n");
igen.visit(F);
DEBUG(errs() << "\n");
// First execute static initializers, in the main procedure.
if (F.hasName() && SmackOptions::isEntryPoint(F.getName())) {
P->insert(Stmt::call(Naming::INITIALIZE_PROC));
} else if (naming.get(F).find(Naming::INIT_FUNC_PREFIX) == 0)
rep.addInitFunc(&F);
}
DEBUG(errs() << "Finished analyzing function: " << naming.get(F) << "\n\n");
}
// MODIFIES
// ... to do below, after memory splitting is determined.
}
auto ds = rep.auxiliaryDeclarations();
decls.insert(decls.end(), ds.begin(), ds.end());
decls.insert(decls.end(), rep.getInitFuncs());
// NOTE we must do this after instruction generation, since we would not
// otherwise know how many regions to declare.
program.appendPrelude(rep.getPrelude());
std::list<Decl*> kill_list;
for (auto D : program) {
if (auto P = dyn_cast<ProcDecl>(D)) {
if (D->getName().find(Naming::CONTRACT_EXPR) != std::string::npos) {
decls.insert(decls.end(), Decl::code(P));
kill_list.push_back(P);
}
}
}
for (auto D : kill_list)
decls.erase(std::remove(decls.begin(), decls.end(), D), decls.end());
}