当前位置: 首页>>代码示例>>C++>>正文


C++ Module::setDataLayout方法代码示例

本文整理汇总了C++中llvm::Module::setDataLayout方法的典型用法代码示例。如果您正苦于以下问题:C++ Module::setDataLayout方法的具体用法?C++ Module::setDataLayout怎么用?C++ Module::setDataLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在llvm::Module的用法示例。


在下文中一共展示了Module::setDataLayout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: assert

bool
RenderScriptRuntimeModulePass::runOnModule(llvm::Module &module)
{
    bool changed_module = false;
    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE | LIBLLDB_LOG_EXPRESSIONS));

    std::string err;
    llvm::StringRef real_triple = m_process_ptr->GetTarget().GetArchitecture().GetTriple().getTriple();
    const llvm::Target *target_info = llvm::TargetRegistry::lookupTarget(real_triple, err);
    if (!target_info)
    {
        if (log)
            log->Warning("couldn't determine real target architecture: '%s'", err.c_str());
        return false;
    }

    llvm::Optional<llvm::Reloc::Model> reloc_model = llvm::None;
    assert(m_process_ptr && "no available lldb process");
    switch (m_process_ptr->GetTarget().GetArchitecture().GetMachine())
    {
        case llvm::Triple::ArchType::x86:
            changed_module |= fixupX86FunctionCalls(module);
            // For some reason this triple gets totally missed by the backend, and must be set manually.
            // There a reference in bcc/Main.cpp about auto feature-detection being removed from LLVM3.5, but I can't
            // see that discussion anywhere public.
            real_triple = "i686--linux-android";
            break;
        case llvm::Triple::ArchType::x86_64:
            changed_module |= fixupX86_64FunctionCalls(module);
            break;
        case llvm::Triple::ArchType::mipsel:
        case llvm::Triple::ArchType::mips64el:
            // No actual IR fixup pass is needed on MIPS, but the datalayout
            // and targetmachine do need to be explicitly set.

            // bcc explicitly compiles MIPS code to use the static relocation
            // model due to an issue with relocations in mclinker.
            // see libbcc/support/CompilerConfig.cpp for details
            reloc_model = llvm::Reloc::Static;
            changed_module = true;
            break;
        case llvm::Triple::ArchType::arm:
        case llvm::Triple::ArchType::aarch64:
            // ARM subtargets need no fixup passes as they are the initial target as generated by the
            // slang compiler frontend.
            break;
        default:
            if (log)
                log->Warning("Ignoring unknown renderscript target");
            return false;
    }

    if (changed_module)
    {
        llvm::TargetOptions options;
        llvm::TargetMachine *target_machine =
            target_info->createTargetMachine(real_triple, "", "", options, reloc_model);
        assert(target_machine && "failed to identify RenderScriptRuntime target machine");
        // We've been using a triple and datalayout of some ARM variant all along, so
        // we need to let the backend know that this is no longer the case.
        if (log)
        {
            log->Printf("%s - Changing RS target triple to '%s'", __FUNCTION__, real_triple.str().c_str());
            log->Printf("%s - Changing RS datalayout to '%s'", __FUNCTION__,
                        target_machine->createDataLayout().getStringRepresentation().c_str());
        }
        module.setTargetTriple(real_triple);
        module.setDataLayout(target_machine->createDataLayout());
    }
    return changed_module;
}
开发者ID:Aj0Ay,项目名称:lldb,代码行数:71,代码来源:RenderScriptExpressionOpts.cpp


注:本文中的llvm::Module::setDataLayout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。