2018-09-17 13:09:32 +02:00
|
|
|
//===-- RegisterValue.cpp ---------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-09-17 13:09:32 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "RegisterValue.h"
|
|
|
|
#include "llvm/ADT/APFloat.h"
|
2019-10-19 02:48:11 +02:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2018-09-17 13:09:32 +02:00
|
|
|
|
2018-10-22 19:10:47 +02:00
|
|
|
namespace llvm {
|
2018-09-17 13:09:32 +02:00
|
|
|
namespace exegesis {
|
|
|
|
|
2019-10-09 13:58:42 +02:00
|
|
|
static APFloat getFloatValue(const fltSemantics &FltSemantics,
|
|
|
|
PredefinedValues Value) {
|
2018-09-17 13:09:32 +02:00
|
|
|
switch (Value) {
|
|
|
|
case PredefinedValues::POS_ZERO:
|
2019-10-09 13:58:42 +02:00
|
|
|
return APFloat::getZero(FltSemantics);
|
2018-09-17 13:09:32 +02:00
|
|
|
case PredefinedValues::NEG_ZERO:
|
2019-10-09 13:58:42 +02:00
|
|
|
return APFloat::getZero(FltSemantics, true);
|
2018-09-17 13:09:32 +02:00
|
|
|
case PredefinedValues::ONE:
|
2019-10-09 13:58:42 +02:00
|
|
|
return APFloat(FltSemantics, "1");
|
2018-09-17 13:09:32 +02:00
|
|
|
case PredefinedValues::TWO:
|
2019-10-09 13:58:42 +02:00
|
|
|
return APFloat(FltSemantics, "2");
|
2018-09-17 13:09:32 +02:00
|
|
|
case PredefinedValues::INF:
|
2019-10-09 13:58:42 +02:00
|
|
|
return APFloat::getInf(FltSemantics);
|
2018-09-17 13:09:32 +02:00
|
|
|
case PredefinedValues::QNAN:
|
2019-10-09 13:58:42 +02:00
|
|
|
return APFloat::getQNaN(FltSemantics);
|
2018-09-17 13:09:32 +02:00
|
|
|
case PredefinedValues::SMALLEST_NORM:
|
2019-10-09 13:58:42 +02:00
|
|
|
return APFloat::getSmallestNormalized(FltSemantics);
|
2018-09-17 13:09:32 +02:00
|
|
|
case PredefinedValues::LARGEST:
|
2019-10-09 13:58:42 +02:00
|
|
|
return APFloat::getLargest(FltSemantics);
|
2018-09-17 13:09:32 +02:00
|
|
|
case PredefinedValues::ULP:
|
2019-10-09 13:58:42 +02:00
|
|
|
return APFloat::getSmallest(FltSemantics);
|
2018-09-17 13:09:32 +02:00
|
|
|
case PredefinedValues::ONE_PLUS_ULP:
|
|
|
|
auto Output = getFloatValue(FltSemantics, PredefinedValues::ONE);
|
|
|
|
Output.next(false);
|
|
|
|
return Output;
|
|
|
|
}
|
2018-09-17 15:56:42 +02:00
|
|
|
llvm_unreachable("Unhandled exegesis::PredefinedValues");
|
2018-09-17 13:09:32 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 13:58:42 +02:00
|
|
|
APInt bitcastFloatValue(const fltSemantics &FltSemantics,
|
|
|
|
PredefinedValues Value) {
|
2018-09-17 13:09:32 +02:00
|
|
|
return getFloatValue(FltSemantics, Value).bitcastToAPInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace exegesis
|
2018-10-22 19:10:47 +02:00
|
|
|
} // namespace llvm
|