numeric limits of llvm Types?

Hi all,

can I access the numeric limits of the llvm types,
e.g. HalfTy, FloatTy, DoubleTy, etc.
in a fashion like the std numeric_limits tool?

std::numeric_limits<half>::min()
std::numeric_limits<half>::max()

In c++API, I want to initialize values and need to know the correct range
for the llvm types....

Thx
Alex

The APFloat class may have what you need, especially if you're looking
to create llvm::Constants.

-- Sanjoy

Yes,
i know the APFloat class, indeed, I initialize as follows:

    if(pType->isFloatTy() || pType->isHalfTy() || pType->isDoubleTy() ||
pType->isX86_FP80Ty() || pType->isFP128Ty() || pType->isPPC_FP128Ty() )
    {
        //--- get rando value in range
        //tbd: replace by type specific range!
        double d=randZeroOne()*(std::numeric_limits<double>::max() -
std::numeric_limits<double>::min());

        ConstantFP* constF_1 = ConstantFP::get(rM.getContext(), APFloat(d));
        pGvar->setInitializer(constF_1);

    }

I want an 'llvm replacement' for td::numeric_limits<double>::max()

I have seen that FLTSemantics defines

  const fltSemantics APFloat::IEEEhalf = { 15, -14, 11 };
  const fltSemantics APFloat::IEEEsingle = { 127, -126, 24 };
  const fltSemantics APFloat::IEEEdouble = { 1023, -1022, 53 };
  const fltSemantics APFloat::IEEEquad = { 16383, -16382, 113 };
  const fltSemantics APFloat::x87DoubleExtended = { 16383, -16382, 64 };
  const fltSemantics APFloat::Bogus = { 0, 0, 0 };

but I'm not sure if I should use these.

I think there should be something like e.g.
FloatType::numeric_limit_min ...

Alex

Sanjoy Das wrote:

Having a llvm float type
Type* pType

i can do
const fltSemantics &fltS=pType->getFltSemantics();

In the debugger, I see taht fltS has maxExponent, minExponent, precision.

However, if I try to access these, I get an error like
'Illegal use of incomplete type....'

Guess this is just a lack of c++ skills....

Alex

Alexander Poddey wrote: