1 //===-- RegisterValue.h ------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef lldb_RegisterValue_h
11 #define lldb_RegisterValue_h
17 // Other libraries and framework includes
19 #include "lldb/lldb-public.h"
20 #include "lldb/lldb-private.h"
21 #include "lldb/Host/Endian.h"
23 //#define ENABLE_128_BIT_SUPPORT 1
24 namespace lldb_private {
31 kMaxRegisterByteSize = 32u
40 #if defined (ENABLE_128_BIT_SUPPORT)
55 RegisterValue (uint8_t inst) :
62 RegisterValue (uint16_t inst) :
69 RegisterValue (uint32_t inst) :
76 RegisterValue (uint64_t inst) :
82 #if defined (ENABLE_128_BIT_SUPPORT)
84 RegisterValue (__uint128_t inst) :
87 m_data.uint128 = inst;
91 RegisterValue (float value) :
94 m_data.ieee_float = value;
98 RegisterValue (double value) :
101 m_data.ieee_double = value;
105 RegisterValue (long double value) :
106 m_type (eTypeLongDouble)
108 m_data.ieee_long_double = value;
112 RegisterValue (uint8_t *bytes, size_t length, lldb::ByteOrder byte_order)
114 SetBytes (bytes, length, byte_order);
124 CopyValue (const RegisterValue &rhs);
127 SetType (RegisterValue::Type type)
133 SetType (const RegisterInfo *reg_info);
136 GetData (DataExtractor &data) const;
138 // Copy the register value from this object into a buffer in "dst"
139 // and obey the "dst_byte_order" when copying the data. Also watch out
140 // in case "dst_len" is longer or shorter than the register value
141 // described by "reg_info" and only copy the least significant bytes
142 // of the register value, or pad the destination with zeroes if the
143 // register byte size is shorter that "dst_len" (all while correctly
144 // abiding the "dst_byte_order"). Returns the number of bytes copied
147 GetAsMemoryData (const RegisterInfo *reg_info,
150 lldb::ByteOrder dst_byte_order,
154 SetFromMemoryData (const RegisterInfo *reg_info,
157 lldb::ByteOrder src_byte_order,
161 GetScalarValue (Scalar &scalar) const;
164 GetAsUInt8 (uint8_t fail_value = UINT8_MAX, bool *success_ptr = NULL) const
166 if (m_type == eTypeUInt8)
178 GetAsUInt16 (uint16_t fail_value = UINT16_MAX, bool *success_ptr = NULL) const;
181 GetAsUInt32 (uint32_t fail_value = UINT32_MAX, bool *success_ptr = NULL) const;
184 GetAsUInt64 (uint64_t fail_value = UINT64_MAX, bool *success_ptr = NULL) const;
186 #if defined (ENABLE_128_BIT_SUPPORT)
188 GetAsUInt128 (__uint128_t fail_value = ~((__uint128_t)0), bool *success_ptr = NULL) const;
192 GetAsFloat (float fail_value = 0.0f, bool *success_ptr = NULL) const;
195 GetAsDouble (double fail_value = 0.0, bool *success_ptr = NULL) const;
198 GetAsLongDouble (long double fail_value = 0.0, bool *success_ptr = NULL) const;
203 m_type = eTypeInvalid;
207 ClearBit (uint32_t bit);
210 SetBit (uint32_t bit);
213 operator == (const RegisterValue &rhs) const;
216 operator != (const RegisterValue &rhs) const;
219 operator = (uint8_t uint)
226 operator = (uint16_t uint)
228 m_type = eTypeUInt16;
229 m_data.uint16 = uint;
233 operator = (uint32_t uint)
235 m_type = eTypeUInt32;
236 m_data.uint32 = uint;
240 operator = (uint64_t uint)
242 m_type = eTypeUInt64;
243 m_data.uint64 = uint;
246 #if defined (ENABLE_128_BIT_SUPPORT)
248 operator = (__uint128_t uint)
250 m_type = eTypeUInt128;
251 m_data.uint128 = uint;
258 m_data.ieee_float = f;
262 operator = (double f)
264 m_type = eTypeDouble;
265 m_data.ieee_double = f;
269 operator = (long double f)
271 m_type = eTypeLongDouble;
272 m_data.ieee_long_double = f;
276 SetUInt8 (uint8_t uint)
283 SetUInt16 (uint16_t uint)
285 m_type = eTypeUInt16;
286 m_data.uint16 = uint;
290 SetUInt32 (uint32_t uint, Type t = eTypeUInt32)
293 m_data.uint32 = uint;
297 SetUInt64 (uint64_t uint, Type t = eTypeUInt64)
300 m_data.uint64 = uint;
303 #if defined (ENABLE_128_BIT_SUPPORT)
305 SetUInt128 (__uint128_t uint)
307 m_type = eTypeUInt128;
308 m_data.uint128 = uint;
312 SetUInt (uint64_t uint, uint32_t byte_size);
318 m_data.ieee_float = f;
324 m_type = eTypeDouble;
325 m_data.ieee_double = f;
329 SetLongDouble (long double f)
331 m_type = eTypeLongDouble;
332 m_data.ieee_long_double = f;
336 SetBytes (const void *bytes, size_t length, lldb::ByteOrder byte_order);
339 SignExtend (uint32_t sign_bitpos);
342 SetValueFromCString (const RegisterInfo *reg_info,
343 const char *value_str);
346 SetValueFromData (const RegisterInfo *reg_info,
348 lldb::offset_t offset,
349 bool partial_data_ok);
351 // The default value of 0 for reg_name_right_align_at means no alignment at all.
354 const RegisterInfo *reg_info,
355 bool prefix_with_name,
356 bool prefix_with_alt_name,
358 uint32_t reg_name_right_align_at = 0) const;
367 GetByteOrder () const
369 if (m_type == eTypeBytes)
370 return m_data.buffer.byte_order;
371 return lldb::endian::InlHostByteOrder();
375 GetByteSize () const;
382 RegisterValue::Type m_type;
389 #if defined (ENABLE_128_BIT_SUPPORT)
394 long double ieee_long_double;
397 uint8_t bytes[kMaxRegisterByteSize]; // This must be big enough to hold any register for any supported target.
399 lldb::ByteOrder byte_order;
404 } // namespace lldb_private
406 #endif // lldb_RegisterValue_h