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


C++ BasicBlockBuilder::CreateCall2方法代码示例

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


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

示例1: buildExprValue

    CG::ExprValue CreateValueCache::buildExprValue( CG::BasicBlockBuilder &basicBlockBuilder, CG::Usage usage, std::string const &lValueErrorDesc ) const
    {
      if ( usage == CG::USAGE_LVALUE )
        throw Exception( "cannot be used as l-values" );

      RC::Handle<CG::Context> context = basicBlockBuilder.getContext();
      llvm::LLVMContext &llvmContext = context->getLLVMContext();
      
      CG::ExprType inputExprType = m_input->getExprType( basicBlockBuilder );
      if ( !RT::isValueProducer( inputExprType.getAdapter()->getType() ) )
        throw CG::Error( getLocation(), "input must be a value producer" );
      RC::ConstHandle<CG::ValueProducerAdapter> valueProducerAdapter = RC::ConstHandle<CG::ValueProducerAdapter>::StaticCast( inputExprType.getAdapter() );
      RC::ConstHandle<CG::Adapter> valueAdapter = valueProducerAdapter->getValueAdapter();
     
      CG::ExprValue inputExprRValue = m_input->buildExprValue( basicBlockBuilder, CG::USAGE_RVALUE, lValueErrorDesc );
      llvm::Value *resultLValue = valueProducerAdapter->llvmAlloca( basicBlockBuilder, "result" );

      valueProducerAdapter->llvmInit( basicBlockBuilder, resultLValue );
      basicBlockBuilder.getScope().put(
        CG::VariableSymbol::Create(
          CG::ExprValue(
            valueProducerAdapter,
            CG::USAGE_LVALUE,
            context,
            resultLValue
            )
          )
        );

      std::vector<llvm::Type const *> argTypes;
      argTypes.push_back( valueProducerAdapter->llvmLType( context ) );
      argTypes.push_back( valueProducerAdapter->llvmLType( context ) );
      llvm::FunctionType const *funcType = llvm::FunctionType::get( llvm::Type::getVoidTy( llvmContext ), argTypes, false );
      llvm::Constant *func = basicBlockBuilder.getModuleBuilder()->getOrInsertFunction( "__MR_CreateValueCache", funcType );
      
      basicBlockBuilder->CreateCall2(
        func,
        inputExprRValue.getValue(),
        resultLValue
        );
      
      return CG::ExprValue(
        valueProducerAdapter,
        CG::USAGE_RVALUE,
        context,
        valueProducerAdapter->llvmLValueToRValue( basicBlockBuilder, resultLValue )
        );
    }
开发者ID:nikelin,项目名称:PublicStable,代码行数:48,代码来源:CreateValueCache.cpp


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