9#ifndef LLDB_UTILITY_SCALAR_H
10#define LLDB_UTILITY_SCALAR_H
16#include "llvm/ADT/APFloat.h"
17#include "llvm/ADT/APSInt.h"
27#define NUM_OF_WORDS_INT128 2
28#define BITWIDTH_INT128 128
37 static_assert(std::is_integral<T>::value);
38 static_assert(
sizeof(T) <=
sizeof(uint64_t),
"Conversion loses precision!");
40 llvm::APInt(
sizeof(T) * 8, uint64_t(v), std::is_signed<T>::value),
41 std::is_unsigned<T>::value);
67 m_float.convert(llvm::APFloat::x87DoubleExtended(),
68 llvm::APFloat::rmNearestTiesToEven, &ignore);
87 void GetBytes(llvm::MutableArrayRef<uint8_t> storage)
const;
154 int SInt(
int fail_value = 0)
const;
156 unsigned char UChar(
unsigned char fail_value = 0)
const;
158 signed char SChar(
signed char fail_value = 0)
const;
160 unsigned short UShort(
unsigned short fail_value = 0)
const;
162 short SShort(
short fail_value = 0)
const;
164 unsigned int UInt(
unsigned int fail_value = 0)
const;
166 long SLong(
long fail_value = 0)
const;
168 unsigned long ULong(
unsigned long fail_value = 0)
const;
170 long long SLongLong(
long long fail_value = 0)
const;
172 unsigned long long ULongLong(
unsigned long long fail_value = 0)
const;
174 llvm::APInt
SInt128(
const llvm::APInt &fail_value)
const;
176 llvm::APInt
UInt128(
const llvm::APInt &fail_value)
const;
178 float Float(
float fail_value = 0.0f)
const;
180 double Double(
double fail_value = 0.0)
const;
182 long double LongDouble(
long double fail_value = 0.0)
const;
203 template <
typename T> T
GetAs(T fail_value)
const;
static llvm::raw_ostream & error(Stream &strm)
llvm::APFloat CreateAPFloatFromAPFloat(lldb::BasicType basic_type)
void GetValue(Stream &s, bool show_type) const
friend bool operator<(Scalar lhs, Scalar rhs)
static llvm::APSInt MakeAPSInt(T v)
llvm::APFloat CreateAPFloatFromAPSInt(lldb::BasicType basic_type)
const char * GetTypeAsCString() const
bool IntegralPromote(uint16_t bits, bool sign)
bool SetBit(uint32_t bit)
friend bool operator==(Scalar lhs, Scalar rhs)
long SLong(long fail_value=0) const
size_t GetByteSize() const
unsigned char UChar(unsigned char fail_value=0) const
Status SetValueFromData(const DataExtractor &data, lldb::Encoding encoding, size_t byte_size)
friend const Scalar operator^(Scalar lhs, Scalar rhs)
bool SignExtend(uint32_t bit_pos)
short SShort(short fail_value=0) const
Scalar(unsigned long long v)
T GetAs(T fail_value) const
void TruncOrExtendTo(uint16_t bits, bool sign)
Convert to an integer with bits and the given signedness.
friend const Scalar operator/(Scalar lhs, Scalar rhs)
unsigned long long ULongLong(unsigned long long fail_value=0) const
Scalar::Type GetType() const
llvm::APFloat GetAPFloat() const
unsigned long ULong(unsigned long fail_value=0) const
friend const Scalar operator|(Scalar lhs, Scalar rhs)
friend bool operator>(const Scalar &lhs, const Scalar &rhs)
size_t GetAsMemoryData(void *dst, size_t dst_len, lldb::ByteOrder dst_byte_order, Status &error) const
void GetBytes(llvm::MutableArrayRef< uint8_t > storage) const
Store the binary representation of this value into the given storage.
friend bool operator<=(const Scalar &lhs, const Scalar &rhs)
friend const Scalar operator<<(const Scalar &lhs, const Scalar &rhs)
bool GetData(DataExtractor &data, size_t limit_byte_size=UINT32_MAX) const
friend bool operator!=(const Scalar &lhs, const Scalar &rhs)
signed char SChar(signed char fail_value=0) const
friend const Scalar operator>>(const Scalar &lhs, const Scalar &rhs)
bool FloatPromote(const llvm::fltSemantics &semantics)
bool ClearBit(uint32_t bit)
static PromotionKey GetFloatPromoKey(const llvm::fltSemantics &semantics)
float Float(float fail_value=0.0f) const
friend bool operator>=(const Scalar &lhs, const Scalar &rhs)
Scalar & operator&=(const Scalar &rhs)
friend const Scalar operator*(Scalar lhs, Scalar rhs)
friend const Scalar operator+(const Scalar &lhs, const Scalar &rhs)
friend const Scalar operator%(Scalar lhs, Scalar rhs)
long long SLongLong(long long fail_value=0) const
static const char * GetValueTypeAsCString(Scalar::Type value_type)
bool ExtractBitfield(uint32_t bit_size, uint32_t bit_offset)
std::tuple< Type, unsigned, bool > PromotionKey
friend const Scalar operator&(Scalar lhs, Scalar rhs)
double Double(double fail_value=0.0) const
Scalar & operator<<=(const Scalar &rhs)
Status SetValueFromCString(const char *s, lldb::Encoding encoding, size_t byte_size)
static Type PromoteToMaxType(Scalar &lhs, Scalar &rhs)
llvm::APInt SInt128(const llvm::APInt &fail_value) const
unsigned short UShort(unsigned short fail_value=0) const
Scalar & operator+=(Scalar rhs)
bool ShiftRightLogical(const Scalar &rhs)
PromotionKey GetPromoKey() const
friend const Scalar operator-(Scalar lhs, Scalar rhs)
long double LongDouble(long double fail_value=0.0) const
Scalar & operator>>=(const Scalar &rhs)
llvm::APSInt GetAPSInt() const
llvm::APInt UInt128(const llvm::APInt &fail_value) const
A stream class that can stream formatted output to a file.
A class that represents a running process on the host machine.
const Scalar operator&(Scalar lhs, Scalar rhs)
const Scalar operator*(Scalar lhs, Scalar rhs)
bool operator<=(const Scalar &lhs, const Scalar &rhs)
const Scalar operator/(Scalar lhs, Scalar rhs)
bool operator!=(const Address &lhs, const Address &rhs)
bool operator>(const Address &lhs, const Address &rhs)
const Scalar operator>>(const Scalar &lhs, const Scalar &rhs)
const Scalar operator%(Scalar lhs, Scalar rhs)
Stream & operator<<(Stream &s, const Mangled &obj)
AdaptedConstIterator< C, E, A > operator+(typename AdaptedConstIterator< C, E, A >::BackingIterator::difference_type offset, AdaptedConstIterator< C, E, A > &rhs)
const Scalar operator^(Scalar lhs, Scalar rhs)
bool operator==(const Address &lhs, const Address &rhs)
const Scalar operator|(Scalar lhs, Scalar rhs)
bool operator<(const Address &lhs, const Address &rhs)
static uint32_t bits(const uint32_t val, const uint32_t msbit, const uint32_t lsbit)
bool operator>=(const Scalar &lhs, const Scalar &rhs)
AdaptedConstIterator< C, E, A >::BackingIterator::difference_type operator-(AdaptedConstIterator< C, E, A > &lhs, AdaptedConstIterator< C, E, A > &rhs)
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
Encoding
Register encoding definitions.
ByteOrder
Byte ordering definitions.