本文整理汇总了C++中rc::ConstHandle::llvmCallConcat方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstHandle::llvmCallConcat方法的具体用法?C++ ConstHandle::llvmCallConcat怎么用?C++ ConstHandle::llvmCallConcat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rc::ConstHandle
的用法示例。
在下文中一共展示了ConstHandle::llvmCallConcat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: llvmThrowOutOfRangeException
void ArrayAdapter::llvmThrowOutOfRangeException(
BasicBlockBuilder &basicBlockBuilder,
llvm::Value *itemDescRValue,
llvm::Value *indexRValue,
llvm::Value *sizeRValue,
llvm::Value *errorDescRValue
) const
{
RC::Handle<Context> context = basicBlockBuilder.getContext();
RC::ConstHandle<SizeAdapter> sizeAdapter = basicBlockBuilder.getManager()->getSizeAdapter();
RC::ConstHandle<StringAdapter> stringAdapter = basicBlockBuilder.getManager()->getStringAdapter();
RC::ConstHandle<ConstStringAdapter> constStringAdapter = basicBlockBuilder.getManager()->getConstStringAdapter();
std::vector<llvm::Type const *> argTypes;
argTypes.push_back( constStringAdapter->llvmRType( context ) );
argTypes.push_back( sizeAdapter->llvmRType( context ) );
argTypes.push_back( sizeAdapter->llvmRType( context ) );
argTypes.push_back( constStringAdapter->llvmRType( context ) );
llvm::FunctionType const *funcType = llvm::FunctionType::get( basicBlockBuilder->getVoidTy(), argTypes, false );
llvm::AttributeWithIndex AWI[1];
AWI[0] = llvm::AttributeWithIndex::get( ~0u, 0 /*llvm::Attribute::InlineHint | llvm::Attribute::NoUnwind*/ );
llvm::AttrListPtr attrListPtr = llvm::AttrListPtr::get( AWI, 1 );
std::string name = "__ThrowOutOfRangeException";
llvm::Function *func = llvm::cast<llvm::Function>( basicBlockBuilder.getModuleBuilder()->getFunction( name ) );
if ( !func )
{
ModuleBuilder &mb = basicBlockBuilder.getModuleBuilder();
func = llvm::cast<llvm::Function>( mb->getOrInsertFunction( name, funcType, attrListPtr ) );
func->setLinkage( llvm::GlobalValue::PrivateLinkage );
FunctionBuilder fb( mb, funcType, func );
llvm::Argument *itemRValue = fb[0];
itemRValue->setName( "itemRValue" );
itemRValue->addAttr( llvm::Attribute::NoCapture );
llvm::Argument *indexRValue = fb[1];
indexRValue->setName( "indexRValue" );
llvm::Argument *sizeRValue = fb[2];
sizeRValue->setName( "sizeRValue" );
llvm::Argument *errorDescRValue = fb[3];
errorDescRValue->setName( "errorDescRValue" );
errorDescRValue->addAttr( llvm::Attribute::NoCapture );
BasicBlockBuilder bbb( fb );
llvm::BasicBlock *entryBB = fb.createBasicBlock( "entry" );
bbb->SetInsertPoint( entryBB );
llvm::Value *errorMsg1PlusIndexPlusErrorMsg2PlusSizePlusErrorMsg3LValue;
{
Scope subScope( bbb.getScope() );
BasicBlockBuilder subBasicBlockBuilder( bbb, subScope );
llvm::BasicBlock *haveErrorDescBB = fb.createBasicBlock( "haveErrorDescBB" );
llvm::BasicBlock *noErrorDescBB = fb.createBasicBlock( "noErrorDescBB" );
llvm::BasicBlock *goBB = fb.createBasicBlock( "goBB" );
subBasicBlockBuilder->CreateCondBr(
subBasicBlockBuilder->CreateIsNotNull( errorDescRValue ),
haveErrorDescBB,
noErrorDescBB
);
subBasicBlockBuilder->SetInsertPoint( haveErrorDescBB );
llvm::Value *haveErrorDescConstStringRValue = errorDescRValue;
subBasicBlockBuilder->CreateBr( goBB );
subBasicBlockBuilder->SetInsertPoint( noErrorDescBB );
llvm::Value *noErrorDescConstStringRValue = constStringAdapter->llvmConst( subBasicBlockBuilder, "KL" );
subBasicBlockBuilder->CreateBr( goBB );
subBasicBlockBuilder->SetInsertPoint( goBB );
llvm::PHINode *errorDescConstStringRValue = subBasicBlockBuilder->CreatePHI( haveErrorDescConstStringRValue->getType(), "errorDescConstStringRValue" );
errorDescConstStringRValue->addIncoming( haveErrorDescConstStringRValue, haveErrorDescBB );
errorDescConstStringRValue->addIncoming( noErrorDescConstStringRValue, noErrorDescBB );
llvm::Value *errorMsg0RValue = stringAdapter->llvmCast(
subBasicBlockBuilder,
ExprValue( constStringAdapter, USAGE_RVALUE, context, errorDescConstStringRValue )
);
llvm::Value *errorMsgARValue = stringAdapter->llvmCast( subBasicBlockBuilder,
ExprValue( constStringAdapter, USAGE_RVALUE, context, constStringAdapter->llvmConst( subBasicBlockBuilder, ": " ) )
);
llvm::Value *errorMsgALValue = stringAdapter->llvmAlloca( subBasicBlockBuilder, "errorMsgA" );
stringAdapter->llvmInit( subBasicBlockBuilder, errorMsgALValue );
stringAdapter->llvmCallConcat(
subBasicBlockBuilder,
errorMsg0RValue,
errorMsgARValue,
errorMsgALValue
);
llvm::Value *errorMsgBRValue = stringAdapter->llvmCast( subBasicBlockBuilder,
ExprValue( constStringAdapter, USAGE_RVALUE, context, itemRValue )
);
llvm::Value *errorMsgBLValue = stringAdapter->llvmAlloca( subBasicBlockBuilder, "errorMsgB" );
//.........这里部分代码省略.........