[UpdateCCTestChecks] Detect function mangled name on separate line
[llvm-core.git] / tools / llvm-exegesis / lib / RegisterValue.cpp
bloba8286c8d856a60109019120027896c88c23af8b1
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"
12 namespace llvm {
13 namespace exegesis {
15 static llvm::APFloat getFloatValue(const llvm::fltSemantics &FltSemantics,
16 PredefinedValues Value) {
17 switch (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);
38 Output.next(false);
39 return Output;
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
50 } // namespace llvm