search for: constantint

Displaying 20 results from an estimated 569 matches for "constantint".

2004 Jun 17
2
[LLVMdev] ConstantInt::getRawValue
Is there are reason why ConstantInt::getRawValue method can't be moved one step into class hierarchy, into ConstantIntegral::getRawValue The reason I'd like this is that to handle both ConstantInt and ConstantBool, I need the following: if (ConstantInt* CI = dyn_cast<ConstantInt>(V)) { BuildMI(*MBB, IPt, NM::...
2020 Jan 14
2
sizeof implementation: how to get size as a constantInt?
...my implementation: auto *p = builder.CreateGEP(structTy, llvm::ConstantPointerNull::get(pointerTy), constint1); auto *size = builder.CreatePtrToInt(p, llvm::IntegerType::get(context, 64)); and type definitions: auto *constint1 = llvm::ConstantInt::get(context, llvm::APInt(64, 1)); auto *int64Ty = llvm::IntegerType::get(context, 64); auto *doubleTy = llvm::Type::getDoubleTy(context); auto *structTy = llvm::StructType::create(context, "Foo"); structTy->setBody({int64Ty, doubleTy}); auto *pointerTy = llvm::PointerType::get(structT...
2010 Nov 02
2
[LLVMdev] ConstantInt to Value*?
How to convert ConstantInt* to value*? -- regards, soumya prasad ukil -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101102/af73eabb/attachment.html>
2013 Jan 15
2
[LLVMdev] [cfe-dev] no-alias generated as result of restrict function arguments
...ointless, since if both LHS and RHS are constants then we - // already constant folded the compare, and if only one of them is then we - // moved it to RHS already. - Value *LHSPtr = LHS->stripPointerCasts(); - Value *RHSPtr = RHS->stripPointerCasts(); - if (LHSPtr == RHSPtr) - return ConstantInt::get(ITy, CmpInst::isTrueWhenEqual(Pred)); - - // Be more aggressive about stripping pointer adjustments when checking a - // comparison of an alloca address to another object. We can rip off all - // inbounds GEP operations, even if they are variable. - LHSPtr = LHSPtr->stripInBoundsOffset...
2011 Jul 13
2
[LLVMdev] overflow check
...out if B + C wraps around. The way I'll do it is, assuming B and C are both positive, to check if V < B or C. For this I need the values of B, C and V. I tried using APInt as below. *** If (isa<Constant> (B) && isa<Constant> (C) && isa<Constant>(V)) { ConstantInt *CV = dyn_cast<ConstantInt>(V); ConstantInt *CB = dyn_cast<ConstantInt>(B); ConstantInt *CC = dyn_cast<ConstantInt>(C); if (CV && CB && CC) { const APInt &VVal = CV->getValue(); const APInt &BVal = CB->getValue();...
2019 Jul 03
3
optimisation issue in an llvm IR pass
Hi Craig, On 03.07.19 17:33, Craig Topper wrote: > Don't the CreateICmp calls return a Value* with an i1 type? But then > they are added to an i8 type? Not sure that works.  I had that initially: auto cf = IRB.CreateICmpULT(Incr, ConstantInt::get(Int8Ty, 1)); auto carry = IRB.CreateZExt(cf, Int8Ty); Incr = IRB.CreateAdd(Incr, carry); it makes no difference to the generated assembly > Have you tried using the llvm.uadd.with.overflow.i8 intrinsic? we have tried this: CallInst *AddOv = IRB.CreateBinaryIntrinsic(Intrinsic::uadd_w...
2019 Jul 03
2
optimisation issue in an llvm IR pass
...si+rdi*1] mov ecx,edx // <- not needed add cl,0x1 // <- should be done to dl instead adc dl,0x1 mov BYTE PTR [rsi+rdi*1],dl Far below are both variants with the full code around it, however the difference in both variants is this: //variant1 auto cf = IRB.CreateICmpEQ(Incr, ConstantInt::get(Int8Ty, 0)); Incr = IRB.CreateAdd(Incr, cf); //variant2 auto cf = IRB.CreateICmpULT(Incr, ConstantInt::get(Int8Ty, 1)); Incr = IRB.CreateAdd(Incr, cf); //interestingly this totally different approach creates the same instructions as variant2 CallInst *AddOv = IRB.CreateBinaryIntrinsic(Intrin...
2009 Aug 24
1
[LLVMdev] question about LLVMContext
...ut it seems I need to provide an LLVMContext& to do it. I'm not sure what the 'proper' LLVMContext would be in my situation. I'm writing an analysis that is a FunctionPass. At some point in the pass, I am given a Value * representing an N-bit integer. My goal is to contruct two ConstantInt instances, for comparison purposes -- one representing 0 and another representing 2^N (the latter of course needs a wider integer type). I'm trying to use ConstantInt::get (LLVMContext &Context, const APInt &V) which returns static ConstantInt *. (Other APIs exist but ultimately I thin...
2004 Jun 17
0
[LLVMdev] ConstantInt::getRawValue
On Thu, 17 Jun 2004, Vladimir Prus wrote: > Is there are reason why ConstantInt::getRawValue method can't be moved one > step into class hierarchy, into ConstantIntegral::getRawValue > > The reason I'd like this is that to handle both ConstantInt and ConstantBool, > I need the following: > > if (ConstantInt* CI = dyn_cast<ConstantInt>(V)) { &g...
2008 Jul 07
0
[LLVMdev] (GEP) Index validity
...============================== --- lib/VMCore/Type.cpp (revision 53136) +++ lib/VMCore/Type.cpp (working copy) @@ -394,9 +394,8 @@ bool StructType::indexValid(const Value *V) const { // Structure indexes require 32-bit integer constants. - if (V->getType() == Type::Int32Ty) - if (const ConstantInt *CU = dyn_cast<ConstantInt>(V)) - return indexValid(CU->getZExtValue()); + if (const ConstantInt *CU = dyn_cast<ConstantInt>(V)) + return indexValid(CU->getZExtValue()); return false; } @@ -1530,9 +1529,8 @@ } bool SequentialType::indexValid(const Value *V) cons...
2012 Jul 04
2
[LLVMdev] Bogus assert in VMCore/Instructions.cpp CallInst::Create?
...true, GlobalValue::PrivateLinkage, 0, ""); g2->setAlignment(1); vector<Constant*> s1_id; vector<Constant*> s2_id; s1_id.push_back(ConstantInt::get( block->getContext(), APInt(64, StringRef("0"), 10))); s1_id.push_back(ConstantInt::get( block->getContext(), APInt(64, StringRef("0"), 10))); s2_id.push_back(ConstantInt::get...
2008 Jul 07
2
[LLVMdev] (GEP) Index validity
...hat are constant ints of width 32. I can't really see why this limitation is here. SequentialType solves this slightly differently, it allows for both 32 and 64 bits integers. However, AFAICS, any constant integer should do just fine, so I would propose to drop the bitwidth check such that any ConstantInt is valid. This change should also be made to SequentialType, which can be indexed by any integer type as well. I've attached a patch, which makes any integer type valid for indexing an CompositeType. The side effect is now that GEP no longer poses any conditions on it's indices (since it...
2010 Apr 22
2
[LLVMdev] Operand, instruction
Thanks for the quick reply. I am able to get the numerical value. But i also need the numerical value to be in value type, so that it can be used as operand of other instruction. For that i am trying to create a new ConstantInt, but i am unable to find create() function for ConstantInt. Thanks again for the quick and helpful reply. Ben Perry-3 wrote: > > if (ConstantInt *c = (ConstantInt *) dyn_cast<ConstantInt>(index)){ > errs() << "And it's a constant!!!!!!1111oneone!! (" <&l...
2015 Mar 07
2
[LLVMdev] cannot understand global c++API code
...----------- struct stest { int age; float weight; } foo={44,67.2}; int main() { foo.weight=68.2; ... ---------------------------------------- API code // this is clear ConstantFP* const_float_102 = ConstantFP::get(mod->getContext(), APFloat(6.820000e+01f)); ConstantInt* const_int32_98 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("0"), 10)); ConstantInt* const_int32_99 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("1"), 10)); std::vector<Constant*> const_ptr_103_indices; const_ptr_103_indices.push_back(c...
2013 Jan 16
0
[LLVMdev] [cfe-dev] no-alias generated as result of restrict function arguments
...ointless, since if both LHS and RHS are constants then we - // already constant folded the compare, and if only one of them is then we - // moved it to RHS already. - Value *LHSPtr = LHS->stripPointerCasts(); - Value *RHSPtr = RHS->stripPointerCasts(); - if (LHSPtr == RHSPtr) - return ConstantInt::get(ITy, CmpInst::isTrueWhenEqual(Pred)); + // icmp <object*>, <object*/null> + if (LHS->getType()->isPointerTy() && RHS->getType()->isPointerTy()) { + // Ignore pointer casts, they are irrevelant for (in)equality tests. + Value *LHSPtr = LHS->stripPointe...
2008 Jul 10
2
[LLVMdev] (GEP) Index validity
...lib/VMCore/Type.cpp (revision 53136) > +++ lib/VMCore/Type.cpp (working copy) > @@ -394,9 +394,8 @@ > > bool StructType::indexValid(const Value *V) const { > // Structure indexes require 32-bit integer constants. > - if (V->getType() == Type::Int32Ty) > - if (const ConstantInt *CU = dyn_cast<ConstantInt>(V)) > - return indexValid(CU->getZExtValue()); > + if (const ConstantInt *CU = dyn_cast<ConstantInt>(V)) > + return indexValid(CU->getZExtValue()); > return false; > } > > @@ -1530,9 +1529,8 @@ > } > > bo...
2013 Sep 06
2
[LLVMdev] How to get the exact integer from a Value
Hi,all I have a Value* type named indexValue, and the type is i32. I think "indexValue" must hold a number which type is int. Now I want to use the exact number which pointed by indexValue , so I do like this: ConstantInt* CI = llvm::cast<llvm::ConstantInt>(indexValue); //This is wrong, so is dyn_cast. uint64_t index = indexValue->getZExtValue(); uint64_t size = index + 1; I don't know if it is the right way. So, could anybody tell the way to get the integer content from a Value* which type is i32? I...
2013 May 13
3
[LLVMdev] Q: When is a boolean not a boolean?
...ntext & Module life cycles, and this is my first real look at llvm's source. This patch at least makes my problem go away; @@ -2195,11 +2200,11 @@ bool GVN::processInstruction(Instruction *I) { BasicBlock *Parent = BI->getParent(); bool Changed = false; - Value *TrueVal = ConstantInt::getTrue(TrueSucc->getContext()); + Value *TrueVal = ConstantInt::getTrue(BranchCond->getContext()); BasicBlockEdge TrueE(Parent, TrueSucc); Changed |= propagateEquality(BranchCond, TrueVal, TrueE); - Value *FalseVal = ConstantInt::getFalse(FalseSucc->getContext()); + V...
2012 Feb 09
2
[LLVMdev] Your commit 149912 "Remove some dead code and tidy things up"...
...Match.h (revision 149911) > +++ PatternMatch.h (revision 149912) > @@ -98,13 +98,6 @@ > Res = &CI->getValue(); > return true; > } > - // FIXME: Remove this. > - if (ConstantVector *CV = dyn_cast<ConstantVector>(V)) > - if (ConstantInt *CI = > - dyn_cast_or_null<ConstantInt>(CV->getSplatValue())) { > - Res = &CI->getValue(); > - return true; > - } > if (ConstantDataVector *CV = dyn_cast<ConstantDataVector>(V)) > if (ConstantInt *CI = > d...
2009 Jun 18
3
[LLVMdev] Initialising global Array
...r: What i do is, first create the array type. > const ArrayType *ATy = ArrayType::get(Type::Int32Ty, NumEdges); Then create some constant values for the initializer. > std::vector<Constant*> Initializer; Initializer.reserve(NumEdges); > APInt zero(32,0); Constant* zeroc = ConstantInt::get(zero); > APInt minusone(32,-1); Constant* minusonec = ConstantInt::get(minusone); Create the global array, there is no initializer yet. > GlobalVariable *Counters = > new GlobalVariable(ATy, false, GlobalValue::InternalLinkage, > Constant::getNullValue(...