[LLVMdev] numeric limits of llvm Types?

Alexander Poddey alexander.poddey at gmx.net
Thu Jan 22 01:33:12 PST 2015


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:

> The APFloat class may have what you need, especially if you're looking
> to create llvm::Constants.
> 
> -- Sanjoy
> 
> On Thu, Jan 22, 2015 at 12:54 AM, Alexander Poddey
> <alexander.poddey at gmx.net> wrote:
>> 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
>>
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev





More information about the llvm-dev mailing list