本文整理汇总了C++中cg::BasicBlockBuilder::CreatePointerCast方法的典型用法代码示例。如果您正苦于以下问题:C++ BasicBlockBuilder::CreatePointerCast方法的具体用法?C++ BasicBlockBuilder::CreatePointerCast怎么用?C++ BasicBlockBuilder::CreatePointerCast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cg::BasicBlockBuilder
的用法示例。
在下文中一共展示了BasicBlockBuilder::CreatePointerCast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildExprValue
CG::ExprValue CreateConstValue::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" );
CG::ExprType childExprType = m_child->getExprType( basicBlockBuilder );
RC::ConstHandle<CG::ValueProducerAdapter> valueProducerAdapter = basicBlockBuilder.getManager()->getValueProducerOf( childExprType.getAdapter() );
RC::Handle<CG::Context> context = basicBlockBuilder.getContext();
llvm::LLVMContext &llvmContext = context->getLLVMContext();
std::vector<llvm::Type const *> argTypes;
argTypes.push_back( llvm::Type::getInt8PtrTy( llvmContext ) );
argTypes.push_back( llvm::Type::getInt8PtrTy( llvmContext ) );
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_CreateConstValue", funcType );
CG::ExprValue childExprRValue = m_child->buildExprValue( basicBlockBuilder, CG::USAGE_RVALUE, lValueErrorDesc );
llvm::Value *childExprLValue = childExprType.getAdapter()->llvmRValueToLValue( basicBlockBuilder, childExprRValue.getValue() );
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
)
)
);
basicBlockBuilder->CreateCall3(
func,
valueProducerAdapter->llvmAdapterPtr( basicBlockBuilder ),
basicBlockBuilder->CreatePointerCast(
childExprLValue,
llvm::Type::getInt8PtrTy( llvmContext )
),
resultLValue
);
return CG::ExprValue(
valueProducerAdapter,
CG::USAGE_RVALUE,
context,
valueProducerAdapter->llvmLValueToRValue( basicBlockBuilder, resultLValue )
);
}