[LLVMdev] access IntegerType::getSignBit from Type *

Alexander Poddey alexander.poddey at gmx.net
Thu Jan 22 02:07:44 PST 2015


Hi,

I have a Type * which may come from an IntegerType as shown below:

Type.getIntegerBitWidth() tells me numBits.
But how to extract the IntegerType.getSignBit?

If pType isIntegerType, I need to know if it is signed or unsigned...

How to achieve this?

Thx
Alex


 
llvm::Type * getRandomValid_IntegerType(llvm::LLVMContext &C)
{
    using namespace llvm;

    //--- determine num of bits between allowed bits
    int rI=randInt(IntegerType::MIN_INT_BITS,IntegerType::MAX_INT_BITS);

    return IntegerType::get(C, rI);


}


llvm::Type * pType=getRandomValid_IntegerType(llvm::LLVMContext &C);

if(pType.isIntegerTy)
{
  pType->getIntegerBitWidth();  // ok
  pType->HOWTOGET_SIGN_INFO;    //?
}




More information about the llvm-dev mailing list