1 //===-- RegisterValue.cpp ---------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "RegisterValue.h"
10 #include "llvm/ADT/APFloat.h"
15 static llvm::APFloat
getFloatValue(const llvm::fltSemantics
&FltSemantics
,
16 PredefinedValues Value
) {
18 case PredefinedValues::POS_ZERO
:
19 return llvm::APFloat::getZero(FltSemantics
);
20 case PredefinedValues::NEG_ZERO
:
21 return llvm::APFloat::getZero(FltSemantics
, true);
22 case PredefinedValues::ONE
:
23 return llvm::APFloat(FltSemantics
, "1");
24 case PredefinedValues::TWO
:
25 return llvm::APFloat(FltSemantics
, "2");
26 case PredefinedValues::INF
:
27 return llvm::APFloat::getInf(FltSemantics
);
28 case PredefinedValues::QNAN
:
29 return llvm::APFloat::getQNaN(FltSemantics
);
30 case PredefinedValues::SMALLEST_NORM
:
31 return llvm::APFloat::getSmallestNormalized(FltSemantics
);
32 case PredefinedValues::LARGEST
:
33 return llvm::APFloat::getLargest(FltSemantics
);
34 case PredefinedValues::ULP
:
35 return llvm::APFloat::getSmallest(FltSemantics
);
36 case PredefinedValues::ONE_PLUS_ULP
:
37 auto Output
= getFloatValue(FltSemantics
, PredefinedValues::ONE
);
41 llvm_unreachable("Unhandled exegesis::PredefinedValues");
44 llvm::APInt
bitcastFloatValue(const llvm::fltSemantics
&FltSemantics
,
45 PredefinedValues Value
) {
46 return getFloatValue(FltSemantics
, Value
).bitcastToAPInt();
49 } // namespace exegesis