1 //===-- RegisterValue.cpp ---------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "RegisterValue.h"
11 #include "llvm/ADT/APFloat.h"
16 static llvm::APFloat
getFloatValue(const llvm::fltSemantics
&FltSemantics
,
17 PredefinedValues Value
) {
19 case PredefinedValues::POS_ZERO
:
20 return llvm::APFloat::getZero(FltSemantics
);
21 case PredefinedValues::NEG_ZERO
:
22 return llvm::APFloat::getZero(FltSemantics
, true);
23 case PredefinedValues::ONE
:
24 return llvm::APFloat(FltSemantics
, "1");
25 case PredefinedValues::TWO
:
26 return llvm::APFloat(FltSemantics
, "2");
27 case PredefinedValues::INF
:
28 return llvm::APFloat::getInf(FltSemantics
);
29 case PredefinedValues::QNAN
:
30 return llvm::APFloat::getQNaN(FltSemantics
);
31 case PredefinedValues::SMALLEST_NORM
:
32 return llvm::APFloat::getSmallestNormalized(FltSemantics
);
33 case PredefinedValues::LARGEST
:
34 return llvm::APFloat::getLargest(FltSemantics
);
35 case PredefinedValues::ULP
:
36 return llvm::APFloat::getSmallest(FltSemantics
);
37 case PredefinedValues::ONE_PLUS_ULP
:
38 auto Output
= getFloatValue(FltSemantics
, PredefinedValues::ONE
);
42 llvm_unreachable("Unhandled exegesis::PredefinedValues");
45 llvm::APInt
bitcastFloatValue(const llvm::fltSemantics
&FltSemantics
,
46 PredefinedValues Value
) {
47 return getFloatValue(FltSemantics
, Value
).bitcastToAPInt();
50 } // namespace exegesis