search for: getelementtype

Displaying 20 results from an estimated 175 matches for "getelementtype".

2011 Jul 27
0
[LLVMdev] Proposal for better assertions in LLVM
On Jul 26, 2011, at 9:17 PM, Talin wrote: > Here's an example of how this would be used: In the constructor for ConstantVector, there's an assert: > > assert(C->getType() == T->getElementType() && > "Initializer for vector element doesn't match vector element type!"); > > I would change this to: > > ASSERT_STRM(C->getType() == T->getElementType(), > "Initializer for vector element " << I - V.begin() <<...
2011 Jul 27
5
[LLVMdev] Proposal for better assertions in LLVM
Here's an example of how this would be used: In the constructor for ConstantVector, there's an assert: assert(C->getType() == T->getElementType() && "Initializer for vector element doesn't match vector element type!"); I would change this to: ASSERT_STRM(C->getType() == T->getElementType(), "Initializer for vector element " << I - V.begin() << " with type " <&l...
2010 Mar 15
0
[LLVMdev] [patch] Writing ConstantUnions
...NewOps[0]); } else if (isa<ConstantVector>(UserC)) { NewC = ConstantVector::get(&NewOps[0], NewOps.size()); } else { @@ -1015,6 +1017,11 @@ Elts.push_back(ValueList.getConstantFwdRef(Record[i], STy->getElementType(i))); V = ConstantStruct::get(STy, Elts); + } else if (const UnionType *UnTy = dyn_cast<UnionType>(CurTy)) { + uint64_t Index = Record[0]; + Constant *Val = ValueList.getConstantFwdRef(Record[1], + UnTy->getElementType(Inde...
2010 Mar 15
3
[LLVMdev] [patch] Writing ConstantUnions
Hello, I noticed a bit of a gap in the current code for unions: a ConstantUnion cannot be written out to .ll. Hopefully I'm not stepping on Talin's toes by posting this, it's a fairly straightforward adaptation of the code for structs just above. Tim. -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. --------------
2012 Sep 21
0
[LLVMdev] How To Get The Name of the type the popinter is pointing to
i am using llvm , i did this if ( AllocaInst *allocInst = dyn_cast<AllocaInst>(&*bbit)){ PointerType *p = allocInst->getType(); if ( p->getElementType()->isPointerTy()){ StringRef name = allocInst->getName(); Type *type = allocInst->getOperand(0)->getType();; errs() << type->getName() << " &quot...
2010 Jul 21
1
[LLVMdev] How to recognize pointer variable & ordinary variable
...my stand does not change. I want to differentiate ordinary local variable & pointer variables. Let's have a program, int a,b,c,*ptr; I want to extract only the local variables. That's what my question was. I think it is clear now. cast<PointerType>(A->getType() > > )->getElementType() is not working. I am also getting error with > A->getAllocatedType(). > On 22 July 2010 01:01, Duncan Sands <baldrick at free.fr> wrote: > Hi Soumya_Prasad_Ukil, > > > How to recognize pointer variable & ordinary variable? I have tried with > > "isa&l...
2010 May 28
2
[LLVMdev] Retrieving Underlying Type from AllocaInst
...eate a PointerType pointing to the original type. >> >> I was hoping for a member function of the alloca that would return the >> original type that was passed to CreateAlloca. I can test for a >> PointerTyID and then perform a cast to PointerType and then call the >> getElementType() function on the PointerType but that seems a bit messy. > > There's alloca->getAllocatedType() which merely calls getType()->getElementType() for you. > > http://llvm.org/doxygen/classllvm_1_1AllocaInst.html . > > Nick -------------- next part -------------- An HTM...
2011 Mar 28
2
[LLVMdev] regarding function pointer pass
...clarations in the src program. I could detect function pointer calls using the getCalledFunction(). However,i am stuck in identifying function pointer declaration and use. is there a way one can distinguish between data and function pointers in llvm? I tried the following, I->getType()->getElementType()->getTypeID() but this always returns me 12 i.e pointer type id (for pointers) irrespective if the pointer is a data or a function pointer. Kindly let me know where i am going wrong. Regards, Netra Mtech,CSE,IIT BOMBAY
2004 Dec 03
1
[Fwd: [LLVMdev] GetElementPtr for packed types and VS build]
....53 > +++ lib/Target/TargetData.cpp 26 Nov 2004 09:46:45 -0000 > @@ -175,6 +175,13 @@ > Size = AlignedSize*ATy->getNumElements(); > return; > } > + case Type::PackedTyID: { > + const PackedType *PTy = cast<PackedType>(Ty); > + getTypeInfo(PTy->getElementType(), TD, Size, Alignment); > + unsigned AlignedSize = (Size + Alignment - 1)/Alignment*Alignment; > + Size = AlignedSize*PTy->getNumElements(); > + return; > + } > case Type::StructTyID: { > // Get the layout annotation... which is lazily created on demand. >...
2010 May 28
0
[LLVMdev] Retrieving Underlying Type from AllocaInst
You should be able to use the second alternative that Nick proposed: cast<PointerType*>(pointer_value->getType())->getElementType() Reid On Fri, May 28, 2010 at 9:37 AM, Curtis Faith <curtis at curtisfaith.com> wrote: > Thanks Nick, > Unfortunately, that is indeed what I asked for but not what I really am > looking for. > My naive approach is to store symbol table entries as Value* objects so I > can al...
2019 Oct 21
2
How to create vector pointer type?
...bsp; PointerType *PointerTy = dyn_cast<PointerType&gt;(Ty); &nbsp; &nbsp; assert(PointerTy &amp;&amp; "PointerType expected"); &nbsp; &nbsp; unsigned addSpace = PointerTy-&gt;getAddressSpace(); &nbsp; &nbsp; Type *ScalarType = PointerTy-&gt;getElementType(); &nbsp; &nbsp; VectorType *VectorType = VectorType::get(ScalarType, 16); &nbsp; &nbsp; return PointerType::get(VectorType, addSpace); } There's no isVectorPtr() check, so I add static bool isVectorPtr(Type *Ty) { &nbsp; bool a = false; &nbsp; if(Ty-&gt;isPointe...
2008 Jul 10
0
[LLVMdev] InstructionCombining forgets alignment of globals
I think I found it. In InstCombiner::ComputeMaskedBits we have the following lines: if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) { unsigned Align = GV->getAlignment(); if (Align == 0 && TD && GV->getType()->getElementType()->isSized()) Align = TD->getPrefTypeAlignment(GV->getType()->getElementType()); It assumes that global values are always optimally aligned. I think this is incorrect and the bottom two lines should be removed. However, I do think it's useful to specify the alignment...
2008 Jul 10
2
[LLVMdev] InstructionCombining forgets alignment of globals
Hi Nicolas, > if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) { > > unsigned Align = GV->getAlignment(); > > if (Align == 0 && TD && GV->getType()->getElementType()->isSized()) > > Align = TD->getPrefTypeAlignment(GV->getType()->getElementType()); > > It assumes that global values are always optimally aligned. I think this is > incorrect and the bottom two lines should be removed. I don't understand - if Align is zero...
2012 Sep 20
5
[LLVMdev] How To Get The Name of the type the popinter is pointing to
I want to know the type of pointer . for example if we have int *p, struct node *w char *q then i want int for p,char for q , struct node for w. any help would be appreciated. -- View this message in context: http://llvm.1065342.n5.nabble.com/How-To-Get-The-Name-of-the-type-the-popinter-is-pointing-to-tp49121.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
2010 May 28
2
[LLVMdev] Retrieving Underlying Type from AllocaInst
...ction for AllocaInst::AllocaInst seems to create a PointerType pointing to the original type. I was hoping for a member function of the alloca that would return the original type that was passed to CreateAlloca. I can test for a PointerTyID and then perform a cast to PointerType and then call the getElementType() function on the PointerType but that seems a bit messy. Thanks in advance, Curtis -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100528/1bef64a5/attachment.html>
2008 Nov 07
2
[LLVMdev] non-pointer gcroot
...t it's not a pointer, but I'm not sure how to. Can anyone suggest what should go at "todo; something here"? ... for (AllocaInst **I = Roots, **E = Roots + Count; I != E; ++I) if (!InitedRoots.count(*I)) { const Type* Ty = cast<PointerType>((*I)->getType())->getElementType(); if (Ty->getTypeID() == Type::PointerTyID) { new StoreInst(ConstantPointerNull::get(cast<PointerType>(Ty)), *I, IP); } else { // todo; something here } MadeChange = true; } ... thanks, scott
2017 Oct 13
2
Why does GEP allow src and destination type to have different address spaces?
The GEP constructor does not assert that the source and destination types match. Of course, this is incorrect and causes random failures somewhere down the line. Could I add general sanity checks to the GEP constructor? In general, is an Instruction allowed to be in an inconsistent state? If so, is there some well known method to "verify" whether an instruction is consistent or not?
2010 May 28
0
[LLVMdev] Retrieving Underlying Type from AllocaInst
...Inst seems to > create a PointerType pointing to the original type. > > I was hoping for a member function of the alloca that would return the > original type that was passed to CreateAlloca. I can test for a > PointerTyID and then perform a cast to PointerType and then call the > getElementType() function on the PointerType but that seems a bit messy. There's alloca->getAllocatedType() which merely calls getType()->getElementType() for you. http://llvm.org/doxygen/classllvm_1_1AllocaInst.html . Nick
2007 Jan 19
2
[LLVMdev] Vector comparisons
...: Packed types not supported by fcmp instruction [2] From CmpInst::CmpInst: // Check that the operands are the right type assert(Op0Ty->isInteger() || isa<PointerType>(Op0Ty) || (isa<PackedType>(Op0Ty) && cast<PackedType>(Op0Ty)->getElementType()->isInteger()) && "Invalid operand types for ICmp instruction"); ... // Check that the operands are the right type assert(Op0Ty->isFloatingPoint() || (isa<PackedType>(Op0Ty) && cast<PackedType>(Op0Ty)->getElementType()->...
2008 Jul 10
3
[LLVMdev] InstructionCombining forgets alignment of globals
Hi all, The InstructionCombining pass causes alignment of globals to be ignored. I've attached a replacement of Fibonacci.cpp which reproduces this (I used 2.3 release). Here's the x86 code it produces: 03C20019 movaps xmm0,xmmword ptr ds:[164E799h] 03C20020 mulps xmm0,xmmword ptr ds:[164E79Ah] 03C20027 movaps xmmword ptr ds:[164E799h],xmm0 03C2002E