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"
11 #include "llvm/ADT/StringRef.h"
16 static APFloat
getFloatValue(const fltSemantics
&FltSemantics
,
17 PredefinedValues Value
) {
19 case PredefinedValues::POS_ZERO
:
20 return APFloat::getZero(FltSemantics
);
21 case PredefinedValues::NEG_ZERO
:
22 return APFloat::getZero(FltSemantics
, true);
23 case PredefinedValues::ONE
:
24 return APFloat(FltSemantics
, "1");
25 case PredefinedValues::TWO
:
26 return APFloat(FltSemantics
, "2");
27 case PredefinedValues::INF
:
28 return APFloat::getInf(FltSemantics
);
29 case PredefinedValues::QNAN
:
30 return APFloat::getQNaN(FltSemantics
);
31 case PredefinedValues::SMALLEST_NORM
:
32 return APFloat::getSmallestNormalized(FltSemantics
);
33 case PredefinedValues::LARGEST
:
34 return APFloat::getLargest(FltSemantics
);
35 case PredefinedValues::ULP
:
36 return APFloat::getSmallest(FltSemantics
);
37 case PredefinedValues::ONE_PLUS_ULP
:
38 auto Output
= getFloatValue(FltSemantics
, PredefinedValues::ONE
);
42 llvm_unreachable("Unhandled exegesis::PredefinedValues");
45 APInt
bitcastFloatValue(const fltSemantics
&FltSemantics
,
46 PredefinedValues Value
) {
47 return getFloatValue(FltSemantics
, Value
).bitcastToAPInt();
50 } // namespace exegesis