[LLVMdev] Explanation

Renato Golin rengolin at systemcall.org
Mon Jun 6 10:05:30 PDT 2011


On 6 June 2011 17:08, George Baah <georgebaah 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



More information about the llvm-dev mailing list