search for: getprimitivesizeinbits

Displaying 20 results from an estimated 48 matches for "getprimitivesizeinbits".

2009 Oct 20
2
[LLVMdev] Dereference PointerType?
Daniel Waterworth <da.waterworth at googlemail.com> writes: [snip] Use the getElementType method of PointerType. >> size_t size; >> if (isa<PointerType>(allocated_type)) { >> size = sizeof(void*) * 8; >> } else { >> size = allocated_type->getPrimitiveSizeInBits(); >> } >> // size now equals the size (in bits) of the type allocated This looks suspicious to me. Maybe you intented if (isa<PointerType>(allocated_type)) { size = sizeof(void*); } else { size = allocated_type->getPrimitiveSizeInBits() * 8; } but take a look at getPrim...
2009 Oct 20
3
[LLVMdev] Dereference PointerType?
..._type = dynamic_cast<PointerType*>(alloca); assert(ptr_type); Type *allocated_type = ptr_type->dereference(); // this is the operation that doesn't seem to exist. size_t size; if (isa<PointerType>(allocated_type)) { size = sizeof(void*) * 8; } else { size = allocated_type->getPrimitiveSizeInBits(); } // size now equals the size (in bits) of the type allocated If it doesn't exist, how do you manage without it? Is there another way to write the above code? Thanks, Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail...
2014 Nov 05
3
[LLVMdev] How to lower the intrinsic function 'llvm.objectsize'?
...= dyn_cast<IntrinsicInst>(&*i); ++i; if(ii) { switch (ii->getIntrinsicID()) { case Intrinsic::objectsize: { IRBuilder<> builder(ii->getParent(), ii); Value *op1 = ii->getArgOperand(0); //i8* uint64_t bit_size = op1->getType()->getPointerElementType()->getPrimitiveSizeInBits(); Value *result = ConstantInt::get(ii->getType(), bit_size); ii->replaceAllUsesWith(result); ii->removeFromParent(); delete ii; break; } } } I'm new to LLVM and not sure whether the implementation is correct. Can anybody tell me whether the implementation is correct...
2009 Oct 20
0
[LLVMdev] Dereference PointerType?
...(alloca); > assert(ptr_type); > Type *allocated_type = ptr_type->dereference(); // this is the operation > that doesn't seem to exist. > size_t size; > if (isa<PointerType>(allocated_type)) { > size = sizeof(void*) * 8; > } else { > size = allocated_type->getPrimitiveSizeInBits(); > } > // size now equals the size (in bits) of the type allocated > > If it doesn't exist, how do you manage without it? Is there another way to > write the above code? > > Thanks, > > Daniel > Spot the deliberate mistake [= PointerType *ptr_type = dynamic_cas...
2010 May 28
4
[LLVMdev] how to get TargetData?
Dear all I am trying to get the size of an LLVM pointer type. getPrimitiveSizeInBits() returns 0 for it and the documentation for isSized() suggest to use TargetData. I figured out from Kaleidoscope example that one can get a pointer to TagetData object through the execution engine but it seems to be an overkill. What is the right way to do it? Best regards, Victor --------------...
2009 Oct 20
4
[LLVMdev] Dereference PointerType?
...: >> >> [snip] >> >> Use the getElementType method of PointerType. >> >> size_t size; >>>> if (isa<PointerType>(allocated_type)) { >>>> size = sizeof(void*) * 8; >>>> } else { >>>> size = allocated_type->getPrimitiveSizeInBits(); >>>> } >>>> // size now equals the size (in bits) of the type allocated >>>> >>> >> This looks suspicious to me. >> > > Probably he wants getTypeAllocSize (available from target data). The > special casing of PointerType is both...
2014 Nov 05
3
[LLVMdev] How to lower the intrinsic function 'llvm.objectsize'?
...p;*i); > ++i; > if(ii) { > switch (ii->getIntrinsicID()) { > case Intrinsic::objectsize: { > IRBuilder<> builder(ii->getParent(), ii); > Value *op1 = ii->getArgOperand(0); //i8* > uint64_t bit_size = op1->getType()->getPointerElementType()->getPrimitiveSizeInBits(); > > First, you can't always determine the size. Just looking at the pointer > element type isn't enough. This requires finding the object definition, > which can fail, and the existing handling uses llvm::getObjectSize to for. > In general when looking at type sizes you...
2007 Jul 27
3
[LLVMdev] Implementing sizeof
...urn load and store instructions into model-checker-specific intrinsics so I can track memory modifications efficiently, but just having the address isn't enough, I really need the size too. Or are reads and writes always guaranteed to be simple types, so the bit width (as given by the Type::getPrimitiveSizeInBits() member function) divided by 8 and rounded up if necessary is enough? (The latter works well for me too, I just don't want to mess myself up by making assumptions). As usual, thank you in advance. Sarah
2014 May 13
4
[LLVMdev] Problems in instrumentation
...w should I create the previous call inst to execute invocation: init((void*)p, sizeof(p)). Because any pointer type is possible, so I let the first parameter of function init as 'void*'. Furthermore, how should I get the size of *p? I check Type.h, and found class Type only provide function getPrimitiveSizeInBits() to return the size of the primitive types. How can I know the size of other types, eg. the size of a structure type. Any Suggestions are welcome. Thank you all in advance. Best Regards! -------------------------------------------- Qiuping Yi Institute Of Software Chinese Academy of Sciences --...
2009 Oct 20
0
[LLVMdev] Dereference PointerType?
...at googlemail.com> writes: > > [snip] > > Use the getElementType method of PointerType. > >>> size_t size; >>> if (isa<PointerType>(allocated_type)) { >>> size = sizeof(void*) * 8; >>> } else { >>> size = allocated_type->getPrimitiveSizeInBits(); >>> } >>> // size now equals the size (in bits) of the type allocated > > This looks suspicious to me. Probably he wants getTypeAllocSize (available from target data). The special casing of PointerType is both useless and bogus. Ciao, Duncan.
2009 Oct 20
0
[LLVMdev] Dereference PointerType?
...ethod for obtaining the size of a Type should work for a PointerType, which is just another kind of Type. >>>>> if (isa<PointerType>(allocated_type)) { >>>>> size = sizeof(void*) * 8; >>>>> } else { >>>>> size = allocated_type->getPrimitiveSizeInBits(); >>>>> } >>>>> // size now equals the size (in bits) of the type allocated -- Óscar
2010 May 28
0
[LLVMdev] how to get TargetData?
Victor Zverovich wrote: > Dear all > > I am trying to get the size of an LLVM pointer type. > getPrimitiveSizeInBits() returns 0 for it and the documentation for > isSized() suggest to use TargetData. > I figured out from Kaleidoscope example that one can get a pointer to > TagetData object through the execution engine but it seems to be an > overkill. > What is the right way to do it? TargetDat...
2011 Jun 06
2
[LLVMdev] Explanation
Hi All, I am trying to check if a Value type is a int32 pointer by using if(T == Type::getInt1PtrTy(Context, AS)) ... I am trying to understand the AS (address space). How do I get it? Thanks. George * * -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110606/775e4f09/attachment.html>
2011 Jun 06
0
[LLVMdev] Explanation
...at gmail.com> wrote: > if(T == Type::getInt1PtrTy(Context, AS)) ... Hi, You don't need to care about address spaces to check for an int32*: if (T->isPointerTy()) { const Type* intT = cast<PointerType>(T)->getElementType(); if (intT->isIntegerTy() && intT->getPrimitiveSizeInBits() == 32) cout << "Yeah!" << endl; } Also, to create a pointer type, if you don't care about address space at all, use the unqualified version: const Type* ptrT = PointerType::getUnqual(intT); cheers, --renato
2010 May 28
0
[LLVMdev] how to get TargetData?
...ing the hand-coded data layout string to the constructor of TargetData. Hope this will be helpful to you. Zonr On Fri, May 28, 2010 at 11:27 PM, Victor Zverovich < victor.zverovich at googlemail.com> wrote: > Dear all > > I am trying to get the size of an LLVM pointer type. > getPrimitiveSizeInBits() returns 0 for it and the documentation for > isSized() suggest to use TargetData. > I figured out from Kaleidoscope example that one can get a pointer to > TagetData object through the execution engine but it seems to be an > overkill. > What is the right way to do it? > > Be...
2012 Feb 15
2
[LLVMdev] Wrong AliasAnalysis::getModRefInfo result
...if ( AllocaInst *allo = dyn_cast<AllocaInst>(vPtr) ) { const Type *t = allo->getAllocatedType(); if ( const ArrayType *at = dyn_cast<ArrayType>(t) ) { int64_t size = at->getNumElements() * at->getElementType()->getPrimitiveSizeInBits() / 8; ImmutableCallSite cs(ci); AliasAnalysis::Location loc(v, size); errs() << AA.getModRefInfo(ci, loc) << "\n"; } } } } } } return false; }...
2009 Jun 29
1
[LLVMdev] Type get size
...if the C source looks like: int a[3]; then printing the description of the type of this global looks like: [3 x i32]* Is there some nice way to get "3 words" or "12 bytes" from the above example? Let's assume I do some "isSized" check. It looks like there is a getPrimitiveSizeInBits, but nothing for composite types. Maybe I am missing something. Thanks, Scott
2011 Jun 06
1
[LLVMdev] Explanation
...t;> if(T == Type::getInt1PtrTy(Context, AS)) ... > > You don't need to care about address spaces to check for an int32*: > > if (T->isPointerTy()) { > const Type* intT = cast<PointerType>(T)->getElementType(); > if (intT->isIntegerTy() && intT->getPrimitiveSizeInBits() == 32) > cout << "Yeah!" << endl; > } The more idiomatic way would be: if (const PointerType *Ptr = dyn_cast<PointerType>(T)) if (Ptr->getElementType()->isIntegerTy(32)) cout << "Yeah!" << endl; John.
2018 Feb 01
0
Get size of memory access with non-primitive type
Hi all, I am trying to get the size of memory access (load) using dyn_cast<LoadInst>(Inst)->getType()->getPrimitiveSizeinBit(), which works for most cases. However, for load instructions like "%18 = load i8*, i8** %11, align 8, !tbaa !10" where we have double star (**) pointer access, such method would only return a value of 0. I am wondering is there any method that
2008 Jun 05
0
[LLVMdev] A question about CBackend.cpp
...ntInt *CI = dyn_cast<ConstantInt>(CPV)) { 939 const Type* Ty = CI->getType(); 940 if (Ty == Type::Int1Ty) 941 Out << (CI->getZExtValue() ? '1' : '0'); 942 else if (Ty == Type::Int32Ty) 943 Out << CI->getZExtValue() << 'u'; 944 else if (Ty->getPrimitiveSizeInBits() > 32) 945 Out << CI->getZExtValue() << "ull"; 946 else { 947 Out << "(("; 948 printSimpleType(Out, Ty, false) << ')'; 949 if (CI->isMinValue(true)) 950 Out << CI->getZExtValue() << 'u'; 951 else 952 Out << C...