Revert "[HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers ...
[llvm-project.git] / llvm / tools / llvm-exegesis / lib / RegisterValue.cpp
blobf881aa6d5388c3c4d34dc982d144661d08eaca83
1 //===-- RegisterValue.cpp ---------------------------------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "RegisterValue.h"
10 #include "llvm/ADT/APFloat.h"
11 #include "llvm/ADT/StringRef.h"
13 namespace llvm {
14 namespace exegesis {
16 static APFloat getFloatValue(const fltSemantics &FltSemantics,
17 PredefinedValues Value) {
18 switch (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);
39 Output.next(false);
40 return Output;
42 llvm_unreachable("Unhandled exegesis::PredefinedValues");
45 APInt bitcastFloatValue(const fltSemantics &FltSemantics,
46 PredefinedValues Value) {
47 return getFloatValue(FltSemantics, Value).bitcastToAPInt();
50 } // namespace exegesis
51 } // namespace llvm