本文整理汇总了C++中Place::getScalar方法的典型用法代码示例。如果您正苦于以下问题:C++ Place::getScalar方法的具体用法?C++ Place::getScalar怎么用?C++ Place::getScalar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Place
的用法示例。
在下文中一共展示了Place::getScalar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visit
void TypeNodeCodeGen::visit(MethodCall* m)
{
Place* self = getSelf(m);
if ( const ScalarType* from = m->expr_->get().type_->cast<ScalarType>() )
{
Value* val = self->getScalar(builder_);
const ScalarType* to = cast<ScalarType>( m->memberFct_->sig_.out_[0]->getType() );
const llvm::Type* llvmTo = to->getLLVMType(ctxt_->module_);
const llvm::Type* llvmFrom = from->getLLVMType(ctxt_->module_);
if ( m->id()->find("bitcast") != std::string::npos )
val = builder_.CreateBitCast(val, llvmTo);
else // -> assumes that r is a normal cast
{
if ( llvmTo == llvmFrom )
{
setResult(m, new Scalar(val));
return;
}
llvm::StringRef name = val->getName();
if ( from->isInteger() && to->isInteger() )
{
if ( from->sizeOf() > to->sizeOf() )
val = builder_.CreateTrunc(val, llvmTo, name);
else
{
// -> sizeof(from) < sizeof(to)
if ( from->isUnsigned() )
val = builder_.CreateZExt(val, llvmTo, name);
else
val = builder_.CreateSExt(val, llvmTo, name);
}
}
else if ( from->isFloat() && to->isSigned() ) // fp -> si
val = builder_.CreateFPToSI(val, llvmTo, name);
else if ( from->isFloat() && to->isUnsigned() ) // fp -> ui
val = builder_.CreateFPToUI(val, llvmTo, name);
else if ( from->isSigned() && to->isFloat() ) // si -> fp
val = builder_.CreateSIToFP(val, llvmTo, name);
else if ( from->isUnsigned() && to->isFloat() ) // ui -> fp
val = builder_.CreateUIToFP(val, llvmTo, name);
else
{
swiftAssert( from->isFloat() && to->isFloat(), "must both be floats" );
if ( from->sizeOf() > to->sizeOf() )
val = builder_.CreateFPTrunc(val, llvmTo, name);
else // -> sizeof(from) < sizeof(to)
val = builder_.CreateFPExt(val, llvmTo, name);
}
}
setResult( m, new Scalar(val) );
}
else
emitCall(m, self);
}