[LLVMdev] Explanation
John McCall
rjmccall at apple.com
Mon Jun 6 13:48:16 PDT 2011
On Jun 6, 2011, at 10:05 AM, Renato Golin wrote:
> On 6 June 2011 17:08, George Baah <georgebaah at gmail.com> wrote:
>> 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.
More information about the llvm-dev
mailing list