1 //===-- Scalar.cpp ----------------------------------------------*- 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 #include "lldb/Utility/Scalar.h"
12 #include "lldb/Utility/DataExtractor.h"
13 #include "lldb/Utility/Endian.h"
14 #include "lldb/Utility/Status.h"
15 #include "lldb/Utility/Stream.h"
16 #include "lldb/lldb-types.h"
18 #include "llvm/ADT/SmallString.h"
24 using namespace lldb_private;
26 //----------------------------------------------------------------------
27 // Promote to max type currently follows the ANSI C rule for type promotion in
29 //----------------------------------------------------------------------
30 static Scalar::Type PromoteToMaxType(
31 const Scalar &lhs, // The const left hand side object
32 const Scalar &rhs, // The const right hand side object
33 Scalar &temp_value, // A modifiable temp value than can be used to hold
34 // either the promoted lhs or rhs object
35 const Scalar *&promoted_lhs_ptr, // Pointer to the resulting possibly
36 // promoted value of lhs (at most one of
37 // lhs/rhs will get promoted)
38 const Scalar *&promoted_rhs_ptr // Pointer to the resulting possibly
39 // promoted value of rhs (at most one of
40 // lhs/rhs will get promoted)
43 // Initialize the promoted values for both the right and left hand side
44 // values to be the objects themselves. If no promotion is needed (both right
45 // and left have the same type), then the temp_value will not get used.
46 promoted_lhs_ptr = &lhs;
47 promoted_rhs_ptr = &rhs;
48 // Extract the types of both the right and left hand side values
49 Scalar::Type lhs_type = lhs.GetType();
50 Scalar::Type rhs_type = rhs.GetType();
52 if (lhs_type > rhs_type) {
53 // Right hand side need to be promoted
54 temp_value = rhs; // Copy right hand side into the temp value
55 if (temp_value.Promote(lhs_type)) // Promote it
57 &temp_value; // Update the pointer for the promoted right hand side
58 } else if (lhs_type < rhs_type) {
59 // Left hand side need to be promoted
60 temp_value = lhs; // Copy left hand side value into the temp value
61 if (temp_value.Promote(rhs_type)) // Promote it
63 &temp_value; // Update the pointer for the promoted left hand side
66 // Make sure our type promotion worked as expected
67 if (promoted_lhs_ptr->GetType() == promoted_rhs_ptr->GetType())
68 return promoted_lhs_ptr->GetType(); // Return the resulting max type
70 // Return the void type (zero) if we fail to promote either of the values.
71 return Scalar::e_void;
74 Scalar::Scalar() : m_type(e_void), m_float((float)0) {}
76 Scalar::Scalar(const Scalar &rhs)
77 : m_type(rhs.m_type), m_integer(rhs.m_integer), m_float(rhs.m_float) {}
79 bool Scalar::GetData(DataExtractor &data, size_t limit_byte_size) const {
80 size_t byte_size = GetByteSize();
82 const uint8_t *bytes = reinterpret_cast<const uint8_t *>(GetBytes());
84 if (limit_byte_size < byte_size) {
85 if (endian::InlHostByteOrder() == eByteOrderLittle) {
86 // On little endian systems if we want fewer bytes from the current
87 // type we just specify fewer bytes since the LSByte is first...
88 byte_size = limit_byte_size;
89 } else if (endian::InlHostByteOrder() == eByteOrderBig) {
90 // On big endian systems if we want fewer bytes from the current type
91 // have to advance our initial byte pointer and trim down the number of
92 // bytes since the MSByte is first
93 bytes += byte_size - limit_byte_size;
94 byte_size = limit_byte_size;
98 data.SetData(bytes, byte_size, endian::InlHostByteOrder());
105 const void *Scalar::GetBytes() const {
106 const uint64_t *apint_words;
107 const uint8_t *bytes;
108 static float_t flt_val;
109 static double_t dbl_val;
110 static uint64_t swapped_words[4];
120 bytes = reinterpret_cast<const uint8_t *>(m_integer.getRawData());
121 // getRawData always returns a pointer to an uint64_t. If we have a
122 // smaller type, we need to update the pointer on big-endian systems.
123 if (endian::InlHostByteOrder() == eByteOrderBig) {
124 size_t byte_size = m_integer.getBitWidth() / 8;
126 bytes += 8 - byte_size;
131 apint_words = m_integer.getRawData();
132 // getRawData always returns a pointer to an array of two uint64_t values,
133 // where the least-significant word always comes first. On big-endian
134 // systems we need to swap the two words.
135 if (endian::InlHostByteOrder() == eByteOrderBig) {
136 swapped_words[0] = apint_words[1];
137 swapped_words[1] = apint_words[0];
138 apint_words = swapped_words;
140 return reinterpret_cast<const void *>(apint_words);
143 apint_words = m_integer.getRawData();
144 // getRawData always returns a pointer to an array of four uint64_t values,
145 // where the least-significant word always comes first. On big-endian
146 // systems we need to swap the four words.
147 if (endian::InlHostByteOrder() == eByteOrderBig) {
148 swapped_words[0] = apint_words[3];
149 swapped_words[1] = apint_words[2];
150 swapped_words[2] = apint_words[1];
151 swapped_words[3] = apint_words[0];
152 apint_words = swapped_words;
154 return reinterpret_cast<const void *>(apint_words);
156 flt_val = m_float.convertToFloat();
157 return reinterpret_cast<const void *>(&flt_val);
159 dbl_val = m_float.convertToDouble();
160 return reinterpret_cast<const void *>(&dbl_val);
162 llvm::APInt ldbl_val = m_float.bitcastToAPInt();
163 apint_words = ldbl_val.getRawData();
164 // getRawData always returns a pointer to an array of two uint64_t values,
165 // where the least-significant word always comes first. On big-endian
166 // systems we need to swap the two words.
167 if (endian::InlHostByteOrder() == eByteOrderBig) {
168 swapped_words[0] = apint_words[1];
169 swapped_words[1] = apint_words[0];
170 apint_words = swapped_words;
172 return reinterpret_cast<const void *>(apint_words);
177 size_t Scalar::GetByteSize() const {
191 return (m_integer.getBitWidth() / 8);
193 return sizeof(float_t);
195 return sizeof(double_t);
197 return sizeof(long_double_t);
202 bool Scalar::IsZero() const {
203 llvm::APInt zero_int = llvm::APInt::getNullValue(m_integer.getBitWidth() / 8);
217 return llvm::APInt::isSameValue(zero_int, m_integer);
221 return m_float.isZero();
226 void Scalar::GetValue(Stream *s, bool show_type) const {
228 s->Printf("(%s) ", GetTypeAsCString());
238 s->PutCString(m_integer.toString(10, true));
245 s->PutCString(m_integer.toString(10, false));
250 llvm::SmallString<24> string;
251 m_float.toString(string);
252 s->Printf("%s", string.c_str());
257 const char *Scalar::GetTypeAsCString() const {
264 return "unsigned int";
268 return "unsigned long";
272 return "unsigned long long";
276 return "unsigned int128_t";
280 return "unsigned int256_t";
286 return "long double";
288 return "<invalid Scalar type>";
291 Scalar &Scalar::operator=(const Scalar &rhs) {
294 m_integer = llvm::APInt(rhs.m_integer);
295 m_float = rhs.m_float;
300 Scalar &Scalar::operator=(const int v) {
302 m_integer = llvm::APInt(sizeof(int) * 8, v, true);
306 Scalar &Scalar::operator=(unsigned int v) {
308 m_integer = llvm::APInt(sizeof(int) * 8, v);
312 Scalar &Scalar::operator=(long v) {
314 m_integer = llvm::APInt(sizeof(long) * 8, v, true);
318 Scalar &Scalar::operator=(unsigned long v) {
320 m_integer = llvm::APInt(sizeof(long) * 8, v);
324 Scalar &Scalar::operator=(long long v) {
325 m_type = e_slonglong;
326 m_integer = llvm::APInt(sizeof(long) * 8, v, true);
330 Scalar &Scalar::operator=(unsigned long long v) {
331 m_type = e_ulonglong;
332 m_integer = llvm::APInt(sizeof(long long) * 8, v);
336 Scalar &Scalar::operator=(float v) {
338 m_float = llvm::APFloat(v);
342 Scalar &Scalar::operator=(double v) {
344 m_float = llvm::APFloat(v);
348 Scalar &Scalar::operator=(long double v) {
349 m_type = e_long_double;
351 m_float = llvm::APFloat(
352 llvm::APFloat::IEEEquad(),
353 llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x));
355 m_float = llvm::APFloat(
356 llvm::APFloat::x87DoubleExtended(),
357 llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x));
361 Scalar &Scalar::operator=(llvm::APInt rhs) {
362 m_integer = llvm::APInt(rhs);
363 switch (m_integer.getBitWidth()) {
367 if (m_integer.isSignedIntN(sizeof(sint_t) * 8))
373 if (m_integer.isSignedIntN(sizeof(slonglong_t) * 8))
374 m_type = e_slonglong;
376 m_type = e_ulonglong;
379 if (m_integer.isSignedIntN(BITWIDTH_INT128))
385 if (m_integer.isSignedIntN(BITWIDTH_INT256))
394 Scalar::~Scalar() = default;
396 bool Scalar::Promote(Scalar::Type type) {
397 bool success = false;
410 m_integer = m_integer.sextOrTrunc(sizeof(uint_t) * 8);
415 m_integer = m_integer.sextOrTrunc(sizeof(slong_t) * 8);
420 m_integer = m_integer.sextOrTrunc(sizeof(ulong_t) * 8);
425 m_integer = m_integer.sextOrTrunc(sizeof(slonglong_t) * 8);
430 m_integer = m_integer.sextOrTrunc(sizeof(ulonglong_t) * 8);
436 m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128);
442 m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256);
447 m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
448 m_float.convertFromAPInt(m_integer, true,
449 llvm::APFloat::rmNearestTiesToEven);
454 m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
455 m_float.convertFromAPInt(m_integer, true,
456 llvm::APFloat::rmNearestTiesToEven);
461 m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
462 : llvm::APFloat::x87DoubleExtended());
463 m_float.convertFromAPInt(m_integer, true,
464 llvm::APFloat::rmNearestTiesToEven);
479 m_integer = m_integer.zextOrTrunc(sizeof(slong_t) * 8);
484 m_integer = m_integer.zextOrTrunc(sizeof(ulong_t) * 8);
489 m_integer = m_integer.zextOrTrunc(sizeof(slonglong_t) * 8);
494 m_integer = m_integer.zextOrTrunc(sizeof(ulonglong_t) * 8);
500 m_integer = m_integer.zextOrTrunc(BITWIDTH_INT128);
506 m_integer = m_integer.zextOrTrunc(BITWIDTH_INT256);
511 m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
512 m_float.convertFromAPInt(m_integer, false,
513 llvm::APFloat::rmNearestTiesToEven);
518 m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
519 m_float.convertFromAPInt(m_integer, false,
520 llvm::APFloat::rmNearestTiesToEven);
525 m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
526 : llvm::APFloat::x87DoubleExtended());
527 m_float.convertFromAPInt(m_integer, false,
528 llvm::APFloat::rmNearestTiesToEven);
544 m_integer = m_integer.sextOrTrunc(sizeof(ulong_t) * 8);
549 m_integer = m_integer.sextOrTrunc(sizeof(slonglong_t) * 8);
554 m_integer = m_integer.sextOrTrunc(sizeof(ulonglong_t) * 8);
560 m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128);
566 m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256);
571 m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
572 m_float.convertFromAPInt(m_integer, true,
573 llvm::APFloat::rmNearestTiesToEven);
578 m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
579 m_float.convertFromAPInt(m_integer, true,
580 llvm::APFloat::rmNearestTiesToEven);
585 m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
586 : llvm::APFloat::x87DoubleExtended());
587 m_float.convertFromAPInt(m_integer, true,
588 llvm::APFloat::rmNearestTiesToEven);
605 m_integer = m_integer.zextOrTrunc(sizeof(slonglong_t) * 8);
610 m_integer = m_integer.zextOrTrunc(sizeof(ulonglong_t) * 8);
616 m_integer = m_integer.zextOrTrunc(BITWIDTH_INT128);
622 m_integer = m_integer.zextOrTrunc(BITWIDTH_INT256);
627 m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
628 m_float.convertFromAPInt(m_integer, false,
629 llvm::APFloat::rmNearestTiesToEven);
634 m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
635 m_float.convertFromAPInt(m_integer, false,
636 llvm::APFloat::rmNearestTiesToEven);
641 m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
642 : llvm::APFloat::x87DoubleExtended());
643 m_float.convertFromAPInt(m_integer, false,
644 llvm::APFloat::rmNearestTiesToEven);
662 m_integer = m_integer.sextOrTrunc(sizeof(ulonglong_t) * 8);
668 m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128);
674 m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256);
679 m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
680 m_float.convertFromAPInt(m_integer, true,
681 llvm::APFloat::rmNearestTiesToEven);
686 m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
687 m_float.convertFromAPInt(m_integer, true,
688 llvm::APFloat::rmNearestTiesToEven);
693 m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
694 : llvm::APFloat::x87DoubleExtended());
695 m_float.convertFromAPInt(m_integer, true,
696 llvm::APFloat::rmNearestTiesToEven);
716 m_integer = m_integer.zextOrTrunc(BITWIDTH_INT128);
722 m_integer = m_integer.zextOrTrunc(BITWIDTH_INT256);
727 m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
728 m_float.convertFromAPInt(m_integer, false,
729 llvm::APFloat::rmNearestTiesToEven);
734 m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
735 m_float.convertFromAPInt(m_integer, false,
736 llvm::APFloat::rmNearestTiesToEven);
741 m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
742 : llvm::APFloat::x87DoubleExtended());
743 m_float.convertFromAPInt(m_integer, false,
744 llvm::APFloat::rmNearestTiesToEven);
764 m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128);
770 m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256);
775 m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
776 m_float.convertFromAPInt(m_integer, true,
777 llvm::APFloat::rmNearestTiesToEven);
782 m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
783 m_float.convertFromAPInt(m_integer, true,
784 llvm::APFloat::rmNearestTiesToEven);
789 m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
790 : llvm::APFloat::x87DoubleExtended());
791 m_float.convertFromAPInt(m_integer, true,
792 llvm::APFloat::rmNearestTiesToEven);
814 m_integer = m_integer.zextOrTrunc(BITWIDTH_INT256);
819 m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
820 m_float.convertFromAPInt(m_integer, false,
821 llvm::APFloat::rmNearestTiesToEven);
826 m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
827 m_float.convertFromAPInt(m_integer, false,
828 llvm::APFloat::rmNearestTiesToEven);
833 m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
834 : llvm::APFloat::x87DoubleExtended());
835 m_float.convertFromAPInt(m_integer, false,
836 llvm::APFloat::rmNearestTiesToEven);
858 m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256);
863 m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
864 m_float.convertFromAPInt(m_integer, true,
865 llvm::APFloat::rmNearestTiesToEven);
870 m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
871 m_float.convertFromAPInt(m_integer, true,
872 llvm::APFloat::rmNearestTiesToEven);
877 m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
878 : llvm::APFloat::x87DoubleExtended());
879 m_float.convertFromAPInt(m_integer, true,
880 llvm::APFloat::rmNearestTiesToEven);
903 m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
904 m_float.convertFromAPInt(m_integer, false,
905 llvm::APFloat::rmNearestTiesToEven);
910 m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
911 m_float.convertFromAPInt(m_integer, false,
912 llvm::APFloat::rmNearestTiesToEven);
917 m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
918 : llvm::APFloat::x87DoubleExtended());
919 m_float.convertFromAPInt(m_integer, false,
920 llvm::APFloat::rmNearestTiesToEven);
944 m_float = llvm::APFloat((double_t)m_float.convertToFloat());
948 case e_long_double: {
950 m_float.convert(m_ieee_quad ? llvm::APFloat::IEEEquad()
951 : llvm::APFloat::x87DoubleExtended(),
952 llvm::APFloat::rmNearestTiesToEven, &ignore);
977 case e_long_double: {
979 m_float.convert(m_ieee_quad ? llvm::APFloat::IEEEquad()
980 : llvm::APFloat::x87DoubleExtended(),
981 llvm::APFloat::rmNearestTiesToEven, &ignore);
1016 const char *Scalar::GetValueTypeAsCString(Scalar::Type type) {
1023 return "unsigned int";
1027 return "unsigned long";
1031 return "unsigned long long";
1037 return "long double";
1051 Scalar::GetValueTypeForSignedIntegerWithByteSize(size_t byte_size) {
1052 if (byte_size <= sizeof(sint_t))
1054 if (byte_size <= sizeof(slong_t))
1056 if (byte_size <= sizeof(slonglong_t))
1062 Scalar::GetValueTypeForUnsignedIntegerWithByteSize(size_t byte_size) {
1063 if (byte_size <= sizeof(uint_t))
1065 if (byte_size <= sizeof(ulong_t))
1067 if (byte_size <= sizeof(ulonglong_t))
1072 Scalar::Type Scalar::GetValueTypeForFloatWithByteSize(size_t byte_size) {
1073 if (byte_size == sizeof(float_t))
1075 if (byte_size == sizeof(double_t))
1077 if (byte_size == sizeof(long_double_t))
1078 return e_long_double;
1082 bool Scalar::MakeSigned() {
1083 bool success = false;
1106 m_type = e_slonglong;
1137 bool Scalar::MakeUnsigned() {
1138 bool success = false;
1158 m_type = e_ulonglong;
1192 signed char Scalar::SChar(char fail_value) const {
1206 return (schar_t)(m_integer.sextOrTrunc(sizeof(schar_t) * 8)).getSExtValue();
1208 return (schar_t)m_float.convertToFloat();
1210 return (schar_t)m_float.convertToDouble();
1212 llvm::APInt ldbl_val = m_float.bitcastToAPInt();
1213 return (schar_t)(ldbl_val.sextOrTrunc(sizeof(schar_t) * 8)).getSExtValue();
1218 unsigned char Scalar::UChar(unsigned char fail_value) const {
1232 return (uchar_t)(m_integer.zextOrTrunc(sizeof(uchar_t) * 8)).getZExtValue();
1234 return (uchar_t)m_float.convertToFloat();
1236 return (uchar_t)m_float.convertToDouble();
1238 llvm::APInt ldbl_val = m_float.bitcastToAPInt();
1239 return (uchar_t)(ldbl_val.zextOrTrunc(sizeof(uchar_t) * 8)).getZExtValue();
1244 short Scalar::SShort(short fail_value) const {
1258 return (sshort_t)(m_integer.sextOrTrunc(sizeof(sshort_t) * 8))
1261 return (sshort_t)m_float.convertToFloat();
1263 return (sshort_t)m_float.convertToDouble();
1265 llvm::APInt ldbl_val = m_float.bitcastToAPInt();
1266 return (sshort_t)(ldbl_val.sextOrTrunc(sizeof(sshort_t) * 8))
1272 unsigned short Scalar::UShort(unsigned short fail_value) const {
1286 return (ushort_t)(m_integer.zextOrTrunc(sizeof(ushort_t) * 8))
1289 return (ushort_t)m_float.convertToFloat();
1291 return (ushort_t)m_float.convertToDouble();
1293 llvm::APInt ldbl_val = m_float.bitcastToAPInt();
1294 return (ushort_t)(ldbl_val.zextOrTrunc(sizeof(ushort_t) * 8))
1300 int Scalar::SInt(int fail_value) const {
1314 return (sint_t)(m_integer.sextOrTrunc(sizeof(sint_t) * 8)).getSExtValue();
1316 return (sint_t)m_float.convertToFloat();
1318 return (sint_t)m_float.convertToDouble();
1320 llvm::APInt ldbl_val = m_float.bitcastToAPInt();
1321 return (sint_t)(ldbl_val.sextOrTrunc(sizeof(sint_t) * 8)).getSExtValue();
1326 unsigned int Scalar::UInt(unsigned int fail_value) const {
1340 return (uint_t)(m_integer.zextOrTrunc(sizeof(uint_t) * 8)).getZExtValue();
1342 return (uint_t)m_float.convertToFloat();
1344 return (uint_t)m_float.convertToDouble();
1346 llvm::APInt ldbl_val = m_float.bitcastToAPInt();
1347 return (uint_t)(ldbl_val.zextOrTrunc(sizeof(uint_t) * 8)).getZExtValue();
1352 long Scalar::SLong(long fail_value) const {
1366 return (slong_t)(m_integer.sextOrTrunc(sizeof(slong_t) * 8)).getSExtValue();
1368 return (slong_t)m_float.convertToFloat();
1370 return (slong_t)m_float.convertToDouble();
1372 llvm::APInt ldbl_val = m_float.bitcastToAPInt();
1373 return (slong_t)(ldbl_val.sextOrTrunc(sizeof(slong_t) * 8)).getSExtValue();
1378 unsigned long Scalar::ULong(unsigned long fail_value) const {
1392 return (ulong_t)(m_integer.zextOrTrunc(sizeof(ulong_t) * 8)).getZExtValue();
1394 return (ulong_t)m_float.convertToFloat();
1396 return (ulong_t)m_float.convertToDouble();
1398 llvm::APInt ldbl_val = m_float.bitcastToAPInt();
1399 return (ulong_t)(ldbl_val.zextOrTrunc(sizeof(ulong_t) * 8)).getZExtValue();
1404 long long Scalar::SLongLong(long long fail_value) const {
1418 return (slonglong_t)(m_integer.sextOrTrunc(sizeof(slonglong_t) * 8))
1421 return (slonglong_t)m_float.convertToFloat();
1423 return (slonglong_t)m_float.convertToDouble();
1425 llvm::APInt ldbl_val = m_float.bitcastToAPInt();
1426 return (slonglong_t)(ldbl_val.sextOrTrunc(sizeof(slonglong_t) * 8))
1432 unsigned long long Scalar::ULongLong(unsigned long long fail_value) const {
1446 return (ulonglong_t)(m_integer.zextOrTrunc(sizeof(ulonglong_t) * 8))
1449 return (ulonglong_t)m_float.convertToFloat();
1451 double d_val = m_float.convertToDouble();
1452 llvm::APInt rounded_double =
1453 llvm::APIntOps::RoundDoubleToAPInt(d_val, sizeof(ulonglong_t) * 8);
1454 return (ulonglong_t)(rounded_double.zextOrTrunc(sizeof(ulonglong_t) * 8))
1458 llvm::APInt ldbl_val = m_float.bitcastToAPInt();
1459 return (ulonglong_t)(ldbl_val.zextOrTrunc(sizeof(ulonglong_t) * 8))
1465 llvm::APInt Scalar::SInt128(llvm::APInt &fail_value) const {
1483 return m_float.bitcastToAPInt();
1488 llvm::APInt Scalar::UInt128(const llvm::APInt &fail_value) const {
1506 return m_float.bitcastToAPInt();
1511 llvm::APInt Scalar::SInt256(llvm::APInt &fail_value) const {
1529 return m_float.bitcastToAPInt();
1534 llvm::APInt Scalar::UInt256(const llvm::APInt &fail_value) const {
1552 return m_float.bitcastToAPInt();
1557 float Scalar::Float(float fail_value) const {
1571 return llvm::APIntOps::RoundAPIntToFloat(m_integer);
1573 return m_float.convertToFloat();
1575 return (float_t)m_float.convertToDouble();
1577 llvm::APInt ldbl_val = m_float.bitcastToAPInt();
1578 return ldbl_val.bitsToFloat();
1583 double Scalar::Double(double fail_value) const {
1597 return llvm::APIntOps::RoundAPIntToDouble(m_integer);
1599 return (double_t)m_float.convertToFloat();
1601 return m_float.convertToDouble();
1603 llvm::APInt ldbl_val = m_float.bitcastToAPInt();
1604 return ldbl_val.bitsToFloat();
1609 long double Scalar::LongDouble(long double fail_value) const {
1623 return (long_double_t)llvm::APIntOps::RoundAPIntToDouble(m_integer);
1625 return (long_double_t)m_float.convertToFloat();
1627 return (long_double_t)m_float.convertToDouble();
1629 llvm::APInt ldbl_val = m_float.bitcastToAPInt();
1630 return (long_double_t)ldbl_val.bitsToDouble();
1635 Scalar &Scalar::operator+=(const Scalar &rhs) {
1639 if ((m_type = PromoteToMaxType(*this, rhs, temp_value, a, b)) !=
1654 m_integer = a->m_integer + b->m_integer;
1660 m_float = a->m_float + b->m_float;
1667 Scalar &Scalar::operator<<=(const Scalar &rhs) {
1686 switch (rhs.m_type) {
1703 m_integer = m_integer << rhs.m_integer;
1711 bool Scalar::ShiftRightLogical(const Scalar &rhs) {
1730 switch (rhs.m_type) {
1747 m_integer = m_integer.lshr(rhs.m_integer);
1752 return m_type != e_void;
1755 Scalar &Scalar::operator>>=(const Scalar &rhs) {
1774 switch (rhs.m_type) {
1791 m_integer = m_integer.ashr(rhs.m_integer);
1799 Scalar &Scalar::operator&=(const Scalar &rhs) {
1818 switch (rhs.m_type) {
1835 m_integer &= rhs.m_integer;
1843 bool Scalar::AbsoluteValue() {
1853 if (m_integer.isNegative())
1854 m_integer = -m_integer;
1866 m_float.clearSign();
1872 bool Scalar::UnaryNegate() {
1886 m_integer = -m_integer;
1891 m_float.changeSign();
1897 bool Scalar::OnesComplement() {
1909 m_integer = ~m_integer;
1921 const Scalar lldb_private::operator+(const Scalar &lhs, const Scalar &rhs) {
1926 if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) !=
1928 switch (result.m_type) {
1929 case Scalar::e_void:
1931 case Scalar::e_sint:
1932 case Scalar::e_uint:
1933 case Scalar::e_slong:
1934 case Scalar::e_ulong:
1935 case Scalar::e_slonglong:
1936 case Scalar::e_ulonglong:
1937 case Scalar::e_sint128:
1938 case Scalar::e_uint128:
1939 case Scalar::e_sint256:
1940 case Scalar::e_uint256:
1941 result.m_integer = a->m_integer + b->m_integer;
1943 case Scalar::e_float:
1944 case Scalar::e_double:
1945 case Scalar::e_long_double:
1946 result.m_float = a->m_float + b->m_float;
1953 const Scalar lldb_private::operator-(const Scalar &lhs, const Scalar &rhs) {
1958 if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) !=
1960 switch (result.m_type) {
1961 case Scalar::e_void:
1963 case Scalar::e_sint:
1964 case Scalar::e_uint:
1965 case Scalar::e_slong:
1966 case Scalar::e_ulong:
1967 case Scalar::e_slonglong:
1968 case Scalar::e_ulonglong:
1969 case Scalar::e_sint128:
1970 case Scalar::e_uint128:
1971 case Scalar::e_sint256:
1972 case Scalar::e_uint256:
1973 result.m_integer = a->m_integer - b->m_integer;
1975 case Scalar::e_float:
1976 case Scalar::e_double:
1977 case Scalar::e_long_double:
1978 result.m_float = a->m_float - b->m_float;
1985 const Scalar lldb_private::operator/(const Scalar &lhs, const Scalar &rhs) {
1990 if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) !=
1992 switch (result.m_type) {
1993 case Scalar::e_void:
1995 case Scalar::e_sint:
1996 case Scalar::e_slong:
1997 case Scalar::e_slonglong:
1998 case Scalar::e_sint128:
1999 case Scalar::e_sint256:
2000 if (b->m_integer != 0) {
2001 result.m_integer = a->m_integer.sdiv(b->m_integer);
2005 case Scalar::e_uint:
2006 case Scalar::e_ulong:
2007 case Scalar::e_ulonglong:
2008 case Scalar::e_uint128:
2009 case Scalar::e_uint256:
2010 if (b->m_integer != 0) {
2011 result.m_integer = a->m_integer.udiv(b->m_integer);
2015 case Scalar::e_float:
2016 case Scalar::e_double:
2017 case Scalar::e_long_double:
2018 if (!b->m_float.isZero()) {
2019 result.m_float = a->m_float / b->m_float;
2025 // For division only, the only way it should make it here is if a promotion
2026 // failed, or if we are trying to do a divide by zero.
2027 result.m_type = Scalar::e_void;
2031 const Scalar lldb_private::operator*(const Scalar &lhs, const Scalar &rhs) {
2036 if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) !=
2038 switch (result.m_type) {
2039 case Scalar::e_void:
2041 case Scalar::e_sint:
2042 case Scalar::e_uint:
2043 case Scalar::e_slong:
2044 case Scalar::e_ulong:
2045 case Scalar::e_slonglong:
2046 case Scalar::e_ulonglong:
2047 case Scalar::e_sint128:
2048 case Scalar::e_uint128:
2049 case Scalar::e_sint256:
2050 case Scalar::e_uint256:
2051 result.m_integer = a->m_integer * b->m_integer;
2053 case Scalar::e_float:
2054 case Scalar::e_double:
2055 case Scalar::e_long_double:
2056 result.m_float = a->m_float * b->m_float;
2063 const Scalar lldb_private::operator&(const Scalar &lhs, const Scalar &rhs) {
2068 if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) !=
2070 switch (result.m_type) {
2071 case Scalar::e_sint:
2072 case Scalar::e_uint:
2073 case Scalar::e_slong:
2074 case Scalar::e_ulong:
2075 case Scalar::e_slonglong:
2076 case Scalar::e_ulonglong:
2077 case Scalar::e_sint128:
2078 case Scalar::e_uint128:
2079 case Scalar::e_sint256:
2080 case Scalar::e_uint256:
2081 result.m_integer = a->m_integer & b->m_integer;
2083 case Scalar::e_void:
2084 case Scalar::e_float:
2085 case Scalar::e_double:
2086 case Scalar::e_long_double:
2087 // No bitwise AND on floats, doubles of long doubles
2088 result.m_type = Scalar::e_void;
2095 const Scalar lldb_private::operator|(const Scalar &lhs, const Scalar &rhs) {
2100 if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) !=
2102 switch (result.m_type) {
2103 case Scalar::e_sint:
2104 case Scalar::e_uint:
2105 case Scalar::e_slong:
2106 case Scalar::e_ulong:
2107 case Scalar::e_slonglong:
2108 case Scalar::e_ulonglong:
2109 case Scalar::e_sint128:
2110 case Scalar::e_uint128:
2111 case Scalar::e_sint256:
2112 case Scalar::e_uint256:
2113 result.m_integer = a->m_integer | b->m_integer;
2116 case Scalar::e_void:
2117 case Scalar::e_float:
2118 case Scalar::e_double:
2119 case Scalar::e_long_double:
2120 // No bitwise AND on floats, doubles of long doubles
2121 result.m_type = Scalar::e_void;
2128 const Scalar lldb_private::operator%(const Scalar &lhs, const Scalar &rhs) {
2133 if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) !=
2135 switch (result.m_type) {
2138 case Scalar::e_void:
2140 case Scalar::e_sint:
2141 case Scalar::e_slong:
2142 case Scalar::e_slonglong:
2143 case Scalar::e_sint128:
2144 case Scalar::e_sint256:
2145 if (b->m_integer != 0) {
2146 result.m_integer = a->m_integer.srem(b->m_integer);
2150 case Scalar::e_uint:
2151 case Scalar::e_ulong:
2152 case Scalar::e_ulonglong:
2153 case Scalar::e_uint128:
2154 case Scalar::e_uint256:
2155 if (b->m_integer != 0) {
2156 result.m_integer = a->m_integer.urem(b->m_integer);
2162 result.m_type = Scalar::e_void;
2166 const Scalar lldb_private::operator^(const Scalar &lhs, const Scalar &rhs) {
2171 if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) !=
2173 switch (result.m_type) {
2174 case Scalar::e_sint:
2175 case Scalar::e_uint:
2176 case Scalar::e_slong:
2177 case Scalar::e_ulong:
2178 case Scalar::e_slonglong:
2179 case Scalar::e_ulonglong:
2180 case Scalar::e_sint128:
2181 case Scalar::e_uint128:
2182 case Scalar::e_sint256:
2183 case Scalar::e_uint256:
2184 result.m_integer = a->m_integer ^ b->m_integer;
2187 case Scalar::e_void:
2188 case Scalar::e_float:
2189 case Scalar::e_double:
2190 case Scalar::e_long_double:
2191 // No bitwise AND on floats, doubles of long doubles
2192 result.m_type = Scalar::e_void;
2199 const Scalar lldb_private::operator<<(const Scalar &lhs, const Scalar &rhs) {
2200 Scalar result = lhs;
2205 const Scalar lldb_private::operator>>(const Scalar &lhs, const Scalar &rhs) {
2206 Scalar result = lhs;
2211 Status Scalar::SetValueFromCString(const char *value_str, Encoding encoding,
2214 if (value_str == nullptr || value_str[0] == '\0') {
2215 error.SetErrorString("Invalid c-string value string.");
2219 case eEncodingInvalid:
2220 error.SetErrorString("Invalid encoding.");
2224 if (byte_size <= sizeof(uint64_t)) {
2226 if (!llvm::to_integer(value_str, uval64))
2227 error.SetErrorStringWithFormat(
2228 "'%s' is not a valid unsigned integer string value", value_str);
2229 else if (!UIntValueIsValidForSize(uval64, byte_size))
2230 error.SetErrorStringWithFormat("value 0x%" PRIx64
2231 " is too large to fit in a %" PRIu64
2232 " byte unsigned integer value",
2233 uval64, (uint64_t)byte_size);
2235 m_type = Scalar::GetValueTypeForUnsignedIntegerWithByteSize(byte_size);
2238 m_integer = llvm::APInt(sizeof(uint_t) * 8, uval64, false);
2241 m_integer = llvm::APInt(sizeof(ulong_t) * 8, uval64, false);
2244 m_integer = llvm::APInt(sizeof(ulonglong_t) * 8, uval64, false);
2247 error.SetErrorStringWithFormat(
2248 "unsupported unsigned integer byte size: %" PRIu64 "",
2249 (uint64_t)byte_size);
2254 error.SetErrorStringWithFormat(
2255 "unsupported unsigned integer byte size: %" PRIu64 "",
2256 (uint64_t)byte_size);
2262 if (byte_size <= sizeof(int64_t)) {
2264 if (!llvm::to_integer(value_str, sval64))
2265 error.SetErrorStringWithFormat(
2266 "'%s' is not a valid signed integer string value", value_str);
2267 else if (!SIntValueIsValidForSize(sval64, byte_size))
2268 error.SetErrorStringWithFormat("value 0x%" PRIx64
2269 " is too large to fit in a %" PRIu64
2270 " byte signed integer value",
2271 sval64, (uint64_t)byte_size);
2273 m_type = Scalar::GetValueTypeForSignedIntegerWithByteSize(byte_size);
2276 m_integer = llvm::APInt(sizeof(sint_t) * 8, sval64, true);
2279 m_integer = llvm::APInt(sizeof(slong_t) * 8, sval64, true);
2282 m_integer = llvm::APInt(sizeof(slonglong_t) * 8, sval64, true);
2285 error.SetErrorStringWithFormat(
2286 "unsupported signed integer byte size: %" PRIu64 "",
2287 (uint64_t)byte_size);
2292 error.SetErrorStringWithFormat(
2293 "unsupported signed integer byte size: %" PRIu64 "",
2294 (uint64_t)byte_size);
2299 case eEncodingIEEE754:
2301 static double d_val;
2302 static long double l_val;
2303 if (byte_size == sizeof(float)) {
2304 if (::sscanf(value_str, "%f", &f_val) == 1) {
2305 m_float = llvm::APFloat(f_val);
2308 error.SetErrorStringWithFormat("'%s' is not a valid float string value",
2310 } else if (byte_size == sizeof(double)) {
2311 if (::sscanf(value_str, "%lf", &d_val) == 1) {
2312 m_float = llvm::APFloat(d_val);
2315 error.SetErrorStringWithFormat("'%s' is not a valid float string value",
2317 } else if (byte_size == sizeof(long double)) {
2318 if (::sscanf(value_str, "%Lf", &l_val) == 1) {
2320 llvm::APFloat(llvm::APFloat::x87DoubleExtended(),
2321 llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
2322 ((type128 *)&l_val)->x));
2323 m_type = e_long_double;
2325 error.SetErrorStringWithFormat("'%s' is not a valid float string value",
2328 error.SetErrorStringWithFormat("unsupported float byte size: %" PRIu64 "",
2329 (uint64_t)byte_size);
2334 case eEncodingVector:
2335 error.SetErrorString("vector encoding unsupported.");
2344 Status Scalar::SetValueFromData(DataExtractor &data, lldb::Encoding encoding,
2351 case lldb::eEncodingInvalid:
2352 error.SetErrorString("invalid encoding");
2354 case lldb::eEncodingVector:
2355 error.SetErrorString("vector encoding unsupported");
2357 case lldb::eEncodingUint: {
2358 lldb::offset_t offset = 0;
2360 switch (byte_size) {
2362 operator=((uint8_t)data.GetU8(&offset));
2365 operator=((uint16_t)data.GetU16(&offset));
2368 operator=((uint32_t)data.GetU32(&offset));
2371 operator=((uint64_t)data.GetU64(&offset));
2374 if (data.GetByteOrder() == eByteOrderBig) {
2375 int128.x[1] = (uint64_t)data.GetU64(&offset);
2376 int128.x[0] = (uint64_t)data.GetU64(&offset);
2378 int128.x[0] = (uint64_t)data.GetU64(&offset);
2379 int128.x[1] = (uint64_t)data.GetU64(&offset);
2381 operator=(llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, int128.x));
2384 if (data.GetByteOrder() == eByteOrderBig) {
2385 int256.x[3] = (uint64_t)data.GetU64(&offset);
2386 int256.x[2] = (uint64_t)data.GetU64(&offset);
2387 int256.x[1] = (uint64_t)data.GetU64(&offset);
2388 int256.x[0] = (uint64_t)data.GetU64(&offset);
2390 int256.x[0] = (uint64_t)data.GetU64(&offset);
2391 int256.x[1] = (uint64_t)data.GetU64(&offset);
2392 int256.x[2] = (uint64_t)data.GetU64(&offset);
2393 int256.x[3] = (uint64_t)data.GetU64(&offset);
2395 operator=(llvm::APInt(BITWIDTH_INT256, NUM_OF_WORDS_INT256, int256.x));
2398 error.SetErrorStringWithFormat(
2399 "unsupported unsigned integer byte size: %" PRIu64 "",
2400 (uint64_t)byte_size);
2404 case lldb::eEncodingSint: {
2405 lldb::offset_t offset = 0;
2407 switch (byte_size) {
2409 operator=((int8_t)data.GetU8(&offset));
2412 operator=((int16_t)data.GetU16(&offset));
2415 operator=((int32_t)data.GetU32(&offset));
2418 operator=((int64_t)data.GetU64(&offset));
2421 if (data.GetByteOrder() == eByteOrderBig) {
2422 int128.x[1] = (uint64_t)data.GetU64(&offset);
2423 int128.x[0] = (uint64_t)data.GetU64(&offset);
2425 int128.x[0] = (uint64_t)data.GetU64(&offset);
2426 int128.x[1] = (uint64_t)data.GetU64(&offset);
2428 operator=(llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, int128.x));
2431 if (data.GetByteOrder() == eByteOrderBig) {
2432 int256.x[3] = (uint64_t)data.GetU64(&offset);
2433 int256.x[2] = (uint64_t)data.GetU64(&offset);
2434 int256.x[1] = (uint64_t)data.GetU64(&offset);
2435 int256.x[0] = (uint64_t)data.GetU64(&offset);
2437 int256.x[0] = (uint64_t)data.GetU64(&offset);
2438 int256.x[1] = (uint64_t)data.GetU64(&offset);
2439 int256.x[2] = (uint64_t)data.GetU64(&offset);
2440 int256.x[3] = (uint64_t)data.GetU64(&offset);
2442 operator=(llvm::APInt(BITWIDTH_INT256, NUM_OF_WORDS_INT256, int256.x));
2445 error.SetErrorStringWithFormat(
2446 "unsupported signed integer byte size: %" PRIu64 "",
2447 (uint64_t)byte_size);
2451 case lldb::eEncodingIEEE754: {
2452 lldb::offset_t offset = 0;
2454 if (byte_size == sizeof(float))
2455 operator=((float)data.GetFloat(&offset));
2456 else if (byte_size == sizeof(double))
2457 operator=((double)data.GetDouble(&offset));
2458 else if (byte_size == sizeof(long double))
2459 operator=((long double)data.GetLongDouble(&offset));
2461 error.SetErrorStringWithFormat("unsupported float byte size: %" PRIu64 "",
2462 (uint64_t)byte_size);
2469 bool Scalar::SignExtend(uint32_t sign_bit_pos) {
2470 const uint32_t max_bit_pos = GetByteSize() * 8;
2472 if (sign_bit_pos < max_bit_pos) {
2474 case Scalar::e_void:
2475 case Scalar::e_float:
2476 case Scalar::e_double:
2477 case Scalar::e_long_double:
2480 case Scalar::e_sint:
2481 case Scalar::e_uint:
2482 case Scalar::e_slong:
2483 case Scalar::e_ulong:
2484 case Scalar::e_slonglong:
2485 case Scalar::e_ulonglong:
2486 case Scalar::e_sint128:
2487 case Scalar::e_uint128:
2488 case Scalar::e_sint256:
2489 case Scalar::e_uint256:
2490 if (max_bit_pos == sign_bit_pos)
2492 else if (sign_bit_pos < (max_bit_pos - 1)) {
2493 llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
2494 llvm::APInt bitwize_and = m_integer & sign_bit;
2495 if (bitwize_and.getBoolValue()) {
2496 const llvm::APInt mask =
2497 ~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
2508 size_t Scalar::GetAsMemoryData(void *dst, size_t dst_len,
2509 lldb::ByteOrder dst_byte_order,
2510 Status &error) const {
2511 // Get a data extractor that points to the native scalar data
2513 if (!GetData(data)) {
2514 error.SetErrorString("invalid scalar value");
2518 const size_t src_len = data.GetByteSize();
2520 // Prepare a memory buffer that contains some or all of the register value
2521 const size_t bytes_copied =
2522 data.CopyByteOrderedData(0, // src offset
2523 src_len, // src length
2525 dst_len, // dst length
2526 dst_byte_order); // dst byte order
2527 if (bytes_copied == 0)
2528 error.SetErrorString("failed to copy data");
2530 return bytes_copied;
2533 bool Scalar::ExtractBitfield(uint32_t bit_size, uint32_t bit_offset) {
2538 case Scalar::e_void:
2539 case Scalar::e_float:
2540 case Scalar::e_double:
2541 case Scalar::e_long_double:
2544 case Scalar::e_sint:
2545 case Scalar::e_slong:
2546 case Scalar::e_slonglong:
2547 case Scalar::e_sint128:
2548 case Scalar::e_sint256:
2549 m_integer = m_integer.ashr(bit_offset)
2550 .sextOrTrunc(bit_size)
2551 .sextOrSelf(8 * GetByteSize());
2554 case Scalar::e_uint:
2555 case Scalar::e_ulong:
2556 case Scalar::e_ulonglong:
2557 case Scalar::e_uint128:
2558 case Scalar::e_uint256:
2559 m_integer = m_integer.lshr(bit_offset)
2560 .zextOrTrunc(bit_size)
2561 .zextOrSelf(8 * GetByteSize());
2567 bool lldb_private::operator==(const Scalar &lhs, const Scalar &rhs) {
2568 // If either entry is void then we can just compare the types
2569 if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void)
2570 return lhs.m_type == rhs.m_type;
2575 llvm::APFloat::cmpResult result;
2576 switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) {
2577 case Scalar::e_void:
2579 case Scalar::e_sint:
2580 case Scalar::e_uint:
2581 case Scalar::e_slong:
2582 case Scalar::e_ulong:
2583 case Scalar::e_slonglong:
2584 case Scalar::e_ulonglong:
2585 case Scalar::e_sint128:
2586 case Scalar::e_uint128:
2587 case Scalar::e_sint256:
2588 case Scalar::e_uint256:
2589 return a->m_integer == b->m_integer;
2590 case Scalar::e_float:
2591 case Scalar::e_double:
2592 case Scalar::e_long_double:
2593 result = a->m_float.compare(b->m_float);
2594 if (result == llvm::APFloat::cmpEqual)
2600 bool lldb_private::operator!=(const Scalar &lhs, const Scalar &rhs) {
2601 return !(lhs == rhs);
2604 bool lldb_private::operator<(const Scalar &lhs, const Scalar &rhs) {
2605 if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void)
2611 llvm::APFloat::cmpResult result;
2612 switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) {
2613 case Scalar::e_void:
2615 case Scalar::e_sint:
2616 case Scalar::e_slong:
2617 case Scalar::e_slonglong:
2618 case Scalar::e_sint128:
2619 case Scalar::e_sint256:
2620 return a->m_integer.slt(b->m_integer);
2621 case Scalar::e_uint:
2622 case Scalar::e_ulong:
2623 case Scalar::e_ulonglong:
2624 case Scalar::e_uint128:
2625 case Scalar::e_uint256:
2626 return a->m_integer.ult(b->m_integer);
2627 case Scalar::e_float:
2628 case Scalar::e_double:
2629 case Scalar::e_long_double:
2630 result = a->m_float.compare(b->m_float);
2631 if (result == llvm::APFloat::cmpLessThan)
2637 bool lldb_private::operator<=(const Scalar &lhs, const Scalar &rhs) {
2638 return !(rhs < lhs);
2641 bool lldb_private::operator>(const Scalar &lhs, const Scalar &rhs) {
2645 bool lldb_private::operator>=(const Scalar &lhs, const Scalar &rhs) {
2646 return !(lhs < rhs);
2649 bool Scalar::ClearBit(uint32_t bit) {
2663 m_integer.clearBit(bit);
2673 bool Scalar::SetBit(uint32_t bit) {
2687 m_integer.setBit(bit);