Go to the documentation of this file.
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);
86 void GetBytes(llvm::MutableArrayRef<uint8_t> storage)
const;
153 int SInt(
int fail_value = 0)
const;
155 unsigned char UChar(
unsigned char fail_value = 0)
const;
157 signed char SChar(
signed char fail_value = 0)
const;
159 unsigned short UShort(
unsigned short fail_value = 0)
const;
161 short SShort(
short fail_value = 0)
const;
163 unsigned int UInt(
unsigned int fail_value = 0)
const;
165 long SLong(
long fail_value = 0)
const;
167 unsigned long ULong(
unsigned long fail_value = 0)
const;
169 long long SLongLong(
long long fail_value = 0)
const;
171 unsigned long long ULongLong(
unsigned long long fail_value = 0)
const;
173 llvm::APInt
SInt128(
const llvm::APInt &fail_value)
const;
175 llvm::APInt
UInt128(
const llvm::APInt &fail_value)
const;
177 float Float(
float fail_value = 0.0f)
const;
179 double Double(
double fail_value = 0.0)
const;
181 long double LongDouble(
long double fail_value = 0.0)
const;
194 template <
typename T> T
GetAs(T fail_value)
const;
256 #endif // LLDB_UTILITY_SCALAR_H
unsigned long ULong(unsigned long fail_value=0) const
const Scalar operator%(Scalar lhs, Scalar rhs)
signed char SChar(signed char fail_value=0) const
const Scalar operator|(Scalar lhs, Scalar rhs)
bool GetData(DataExtractor &data, size_t limit_byte_size=UINT32_MAX) const
bool SignExtend(uint32_t bit_pos)
friend bool operator>(const Scalar &lhs, const Scalar &rhs)
unsigned char UChar(unsigned char fail_value=0) const
bool FloatPromote(const llvm::fltSemantics &semantics)
friend bool operator!=(const Scalar &lhs, const Scalar &rhs)
Status SetValueFromCString(const char *s, lldb::Encoding encoding, size_t byte_size)
size_t GetAsMemoryData(void *dst, size_t dst_len, lldb::ByteOrder dst_byte_order, Status &error) const
const friend Scalar operator>>(const Scalar &lhs, const Scalar &rhs)
Scalar & operator>>=(const Scalar &rhs)
const char * GetTypeAsCString() const
llvm::APInt UInt128(const llvm::APInt &fail_value) const
T GetAs(T fail_value) const
const friend Scalar operator&(Scalar lhs, Scalar rhs)
Status SetValueFromData(const DataExtractor &data, lldb::Encoding encoding, size_t byte_size)
bool operator==(const Address &lhs, const Address &rhs)
static Type PromoteToMaxType(Scalar &lhs, Scalar &rhs)
static llvm::raw_ostream & error(Stream &strm)
Scalar(unsigned long long v)
const friend Scalar operator|(Scalar lhs, Scalar rhs)
friend bool operator>=(const Scalar &lhs, const Scalar &rhs)
unsigned long long ULongLong(unsigned long long fail_value=0) const
friend bool operator<=(const Scalar &lhs, const Scalar &rhs)
long long SLongLong(long long fail_value=0) const
std::tuple< Type, unsigned, bool > PromotionKey
friend bool operator==(Scalar lhs, Scalar rhs)
static llvm::APSInt MakeAPSInt(T v)
short SShort(short fail_value=0) const
unsigned int UInt(unsigned int fail_value=0) const
AdaptedConstIterator< C, E, A >::BackingIterator::difference_type operator-(AdaptedConstIterator< C, E, A > &lhs, AdaptedConstIterator< C, E, A > &rhs)
bool SetBit(uint32_t bit)
const Scalar operator>>(const Scalar &lhs, const Scalar &rhs)
Scalar & operator+=(Scalar rhs)
void GetBytes(llvm::MutableArrayRef< uint8_t > storage) const
Store the binary representation of this value into the given storage.
size_t GetByteSize() const
bool ExtractBitfield(uint32_t bit_size, uint32_t bit_offset)
bool operator>(const Address &lhs, const Address &rhs)
Scalar & operator<<=(const Scalar &rhs)
static PromotionKey GetFloatPromoKey(const llvm::fltSemantics &semantics)
unsigned short UShort(unsigned short fail_value=0) const
float Float(float fail_value=0.0f) const
static uint32_t bit(const uint32_t val, const uint32_t msbit)
bool operator!=(const Address &lhs, const Address &rhs)
friend bool operator<(Scalar lhs, Scalar rhs)
Scalar::Type GetType() const
double Double(double fail_value=0.0) const
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)
Stream & operator<<(Stream &s, const SourceLocationSpec &loc)
Dump a SourceLocationSpec object to a stream.
const Scalar operator/(Scalar lhs, Scalar rhs)
const friend Scalar operator<<(const Scalar &lhs, const Scalar &rhs)
long SLong(long fail_value=0) const
bool ShiftRightLogical(const Scalar &rhs)
const friend Scalar operator*(Scalar lhs, Scalar rhs)
const friend Scalar operator+(const Scalar &lhs, const Scalar &rhs)
bool IntegralPromote(uint16_t bits, bool sign)
Scalar & operator&=(const Scalar &rhs)
bool operator<(const Address &lhs, const Address &rhs)
const friend Scalar operator%(Scalar lhs, Scalar rhs)
Encoding
Register encoding definitions.
static const char * GetValueTypeAsCString(Scalar::Type value_type)
llvm::APInt SInt128(const llvm::APInt &fail_value) const
bool operator>=(const Scalar &lhs, const Scalar &rhs)
A class that represents a running process on the host machine.
long double LongDouble(long double fail_value=0.0) const
const friend Scalar operator/(Scalar lhs, Scalar rhs)
bool ClearBit(uint32_t bit)
void TruncOrExtendTo(uint16_t bits, bool sign)
Convert to an integer with bits and the given signedness.
PromotionKey GetPromoKey() const
const Scalar operator^(Scalar lhs, Scalar rhs)
const friend Scalar operator^(Scalar lhs, Scalar rhs)
const friend Scalar operator-(Scalar lhs, Scalar rhs)
static uint32_t bits(const uint32_t val, const uint32_t msbit, const uint32_t lsbit)
const Scalar operator*(Scalar lhs, Scalar rhs)
bool operator<=(const Scalar &lhs, const Scalar &rhs)
int SInt(int fail_value=0) const
void GetValue(Stream *s, bool show_type) const
ByteOrder
Byte ordering definitions.