本文整理汇总了C++中APInt::isNonNegative方法的典型用法代码示例。如果您正苦于以下问题:C++ APInt::isNonNegative方法的具体用法?C++ APInt::isNonNegative怎么用?C++ APInt::isNonNegative使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类APInt
的用法示例。
在下文中一共展示了APInt::isNonNegative方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getIntImmCodeSizeCost
// Constants smaller than 256 fit in the immediate field of
// Thumb1 instructions so we return a zero cost and 1 otherwise.
int ARMTTIImpl::getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx,
const APInt &Imm, Type *Ty) {
if (Imm.isNonNegative() && Imm.getLimitedValue() < 256)
return 0;
return 1;
}
示例2: getIntegerIndex
/// We do not support symbolic projections yet, only 32-bit unsigned integers.
bool swift::getIntegerIndex(SILValue IndexVal, unsigned &IndexConst) {
if (auto *IndexLiteral = dyn_cast<IntegerLiteralInst>(IndexVal)) {
APInt ConstInt = IndexLiteral->getValue();
// IntegerLiterals are signed.
if (ConstInt.isIntN(32) && ConstInt.isNonNegative()) {
IndexConst = (unsigned)ConstInt.getSExtValue();
return true;
}
}
return false;
}
示例3: isDereferenceableFromAttribute
static bool isDereferenceableFromAttribute(const Value *BV, APInt Offset,
Type *Ty, const DataLayout &DL,
const Instruction *CtxI,
const DominatorTree *DT,
const TargetLibraryInfo *TLI) {
assert(Offset.isNonNegative() && "offset can't be negative");
assert(Ty->isSized() && "must be sized");
APInt DerefBytes(Offset.getBitWidth(), 0);
bool CheckForNonNull = false;
if (const Argument *A = dyn_cast<Argument>(BV)) {
DerefBytes = A->getDereferenceableBytes();
if (!DerefBytes.getBoolValue()) {
DerefBytes = A->getDereferenceableOrNullBytes();
CheckForNonNull = true;
}
} else if (auto CS = ImmutableCallSite(BV)) {
DerefBytes = CS.getDereferenceableBytes(0);
if (!DerefBytes.getBoolValue()) {
DerefBytes = CS.getDereferenceableOrNullBytes(0);
CheckForNonNull = true;
}
} else if (const LoadInst *LI = dyn_cast<LoadInst>(BV)) {
if (MDNode *MD = LI->getMetadata(LLVMContext::MD_dereferenceable)) {
ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
DerefBytes = CI->getLimitedValue();
}
if (!DerefBytes.getBoolValue()) {
if (MDNode *MD =
LI->getMetadata(LLVMContext::MD_dereferenceable_or_null)) {
ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
DerefBytes = CI->getLimitedValue();
}
CheckForNonNull = true;
}
}
if (DerefBytes.getBoolValue())
if (DerefBytes.uge(Offset + DL.getTypeStoreSize(Ty)))
if (!CheckForNonNull || isKnownNonNullAt(BV, CtxI, DT, TLI))
return true;
return false;
}
示例4: mathb
//.........这里部分代码省略.........
}
case and_int: return ctx.builder.CreateAnd(x, y);
case or_int: return ctx.builder.CreateOr(x, y);
case xor_int: return ctx.builder.CreateXor(x, y);
case shl_int:
return ctx.builder.CreateSelect(
ctx.builder.CreateICmpUGE(y, ConstantInt::get(y->getType(),
t->getPrimitiveSizeInBits())),
ConstantInt::get(t, 0),
ctx.builder.CreateShl(x, uint_cnvt(ctx, t, y)));
case lshr_int:
return ctx.builder.CreateSelect(
ctx.builder.CreateICmpUGE(y, ConstantInt::get(y->getType(),
t->getPrimitiveSizeInBits())),
ConstantInt::get(t, 0),
ctx.builder.CreateLShr(x, uint_cnvt(ctx, t, y)));
case ashr_int:
return ctx.builder.CreateSelect(
ctx.builder.CreateICmpUGE(y, ConstantInt::get(y->getType(),
t->getPrimitiveSizeInBits())),
ctx.builder.CreateAShr(x, ConstantInt::get(t, t->getPrimitiveSizeInBits() - 1)),
ctx.builder.CreateAShr(x, uint_cnvt(ctx, t, y)));
case bswap_int: {
Value *bswapintr = Intrinsic::getDeclaration(jl_Module, Intrinsic::bswap, makeArrayRef(t));
return ctx.builder.CreateCall(bswapintr, x);
}
case ctpop_int: {
Value *ctpopintr = Intrinsic::getDeclaration(jl_Module, Intrinsic::ctpop, makeArrayRef(t));
return ctx.builder.CreateCall(ctpopintr, x);
}
case ctlz_int: {
Value *ctlz = Intrinsic::getDeclaration(jl_Module, Intrinsic::ctlz, makeArrayRef(t));
y = ConstantInt::get(T_int1, 0);
return ctx.builder.CreateCall(ctlz, {x, y});
}
case cttz_int: {
Value *cttz = Intrinsic::getDeclaration(jl_Module, Intrinsic::cttz, makeArrayRef(t));
y = ConstantInt::get(T_int1, 0);
return ctx.builder.CreateCall(cttz, {x, y});
}
case abs_float: {
Value *absintr = Intrinsic::getDeclaration(jl_Module, Intrinsic::fabs, makeArrayRef(t));
return ctx.builder.CreateCall(absintr, x);
}
case copysign_float: {
Value *bits = ctx.builder.CreateBitCast(x, t);
Value *sbits = ctx.builder.CreateBitCast(y, t);
unsigned nb = cast<IntegerType>(t)->getBitWidth();
APInt notsignbit = APInt::getSignedMaxValue(nb);
APInt signbit0(nb, 0); signbit0.setBit(nb - 1);
return ctx.builder.CreateOr(
ctx.builder.CreateAnd(bits, ConstantInt::get(t, notsignbit)),
ctx.builder.CreateAnd(sbits, ConstantInt::get(t, signbit0)));
}
case flipsign_int: {
ConstantInt *cx = dyn_cast<ConstantInt>(x);
ConstantInt *cy = dyn_cast<ConstantInt>(y);
if (cx && cy) {
APInt ix = cx->getValue();
APInt iy = cy->getValue();
return ConstantInt::get(t, iy.isNonNegative() ? ix : -ix);
}
if (cy) {
APInt iy = cy->getValue();
return iy.isNonNegative() ? x : ctx.builder.CreateSub(ConstantInt::get(t, 0), x);
}
Value *tmp = ctx.builder.CreateAShr(y, ConstantInt::get(t, cast<IntegerType>(t)->getBitWidth() - 1));
return ctx.builder.CreateXor(ctx.builder.CreateAdd(x, tmp), tmp);
}
case ceil_llvm: {
Value *ceilintr = Intrinsic::getDeclaration(jl_Module, Intrinsic::ceil, makeArrayRef(t));
return ctx.builder.CreateCall(ceilintr, x);
}
case floor_llvm: {
Value *floorintr = Intrinsic::getDeclaration(jl_Module, Intrinsic::floor, makeArrayRef(t));
return ctx.builder.CreateCall(floorintr, x);
}
case trunc_llvm: {
Value *truncintr = Intrinsic::getDeclaration(jl_Module, Intrinsic::trunc, makeArrayRef(t));
return ctx.builder.CreateCall(truncintr, x);
}
case rint_llvm: {
Value *rintintr = Intrinsic::getDeclaration(jl_Module, Intrinsic::rint, makeArrayRef(t));
return ctx.builder.CreateCall(rintintr, x);
}
case sqrt_llvm: {
Value *sqrtintr = Intrinsic::getDeclaration(jl_Module, Intrinsic::sqrt, makeArrayRef(t));
return ctx.builder.CreateCall(sqrtintr, x);
}
default:
assert(0 && "invalid intrinsic");
abort();
}
assert(0 && "unreachable");
}