[Lldb-commits] [lldb] r352639 - [Scalar] Implement support for 512-bit values.

Davide Italiano via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 30 10:05:36 PST 2019


Author: davide
Date: Wed Jan 30 10:05:36 2019
New Revision: 352639

URL: http://llvm.org/viewvc/llvm-project?rev=352639&view=rev
Log:
[Scalar] Implement support for 512-bit values.

(useful, e.g. when reading 512-bits registers, a-la AVX-512).

<rdar://problem/46886288>

Modified:
    lldb/trunk/include/lldb/Utility/Scalar.h
    lldb/trunk/source/Utility/RegisterValue.cpp
    lldb/trunk/source/Utility/Scalar.cpp
    lldb/trunk/unittests/Utility/ScalarTest.cpp

Modified: lldb/trunk/include/lldb/Utility/Scalar.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Scalar.h?rev=352639&r1=352638&r2=352639&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/Scalar.h (original)
+++ lldb/trunk/include/lldb/Utility/Scalar.h Wed Jan 30 10:05:36 2019
@@ -27,6 +27,8 @@ class Stream;
 #define BITWIDTH_INT128 128
 #define NUM_OF_WORDS_INT256 4
 #define BITWIDTH_INT256 256
+#define NUM_OF_WORDS_INT512 8
+#define BITWIDTH_INT512 512
 
 namespace lldb_private {
 
@@ -50,6 +52,8 @@ public:
     e_uint128,
     e_sint256,
     e_uint256,
+    e_sint512,
+    e_uint512,
     e_float,
     e_double,
     e_long_double
@@ -109,6 +113,9 @@ public:
     case 256:
       m_type = e_sint256;
       return;
+    case 512:
+      m_type = e_sint512;
+      return;
     }
     lldbassert(false && "unsupported bitwidth");
   }

Modified: lldb/trunk/source/Utility/RegisterValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/RegisterValue.cpp?rev=352639&r1=352638&r2=352639&view=diff
==============================================================================
--- lldb/trunk/source/Utility/RegisterValue.cpp (original)
+++ lldb/trunk/source/Utility/RegisterValue.cpp Wed Jan 30 10:05:36 2019
@@ -156,6 +156,7 @@ bool RegisterValue::GetScalarValue(Scala
       return true;
     case 16:
     case 32:
+    case 64:
       if (buffer.length % sizeof(uint64_t) == 0) {
         const auto length_in_bits = buffer.length * 8;
         const auto length_in_uint64 = buffer.length / sizeof(uint64_t);

Modified: lldb/trunk/source/Utility/Scalar.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Scalar.cpp?rev=352639&r1=352638&r2=352639&view=diff
==============================================================================
--- lldb/trunk/source/Utility/Scalar.cpp (original)
+++ lldb/trunk/source/Utility/Scalar.cpp Wed Jan 30 10:05:36 2019
@@ -106,7 +106,7 @@ const void *Scalar::GetBytes() const {
   const uint8_t *bytes;
   static float_t flt_val;
   static double_t dbl_val;
-  static uint64_t swapped_words[4];
+  static uint64_t swapped_words[8];
   switch (m_type) {
   case e_void:
     break;
@@ -151,6 +151,24 @@ const void *Scalar::GetBytes() const {
       apint_words = swapped_words;
     }
     return reinterpret_cast<const void *>(apint_words);
+  case e_sint512:
+  case e_uint512:
+    apint_words = m_integer.getRawData();
+    // getRawData always returns a pointer to an array of four uint64_t values,
+    // where the least-significant word always comes first.  On big-endian
+    // systems we need to swap the four words.
+    if (endian::InlHostByteOrder() == eByteOrderBig) {
+      swapped_words[0] = apint_words[7];
+      swapped_words[1] = apint_words[6];
+      swapped_words[2] = apint_words[5];
+      swapped_words[3] = apint_words[4];
+      swapped_words[4] = apint_words[3];
+      swapped_words[5] = apint_words[2];
+      swapped_words[6] = apint_words[1];
+      swapped_words[7] = apint_words[0];
+      apint_words = swapped_words;
+    }
+    return reinterpret_cast<const void *>(apint_words);
   case e_float:
     flt_val = m_float.convertToFloat();
     return reinterpret_cast<const void *>(&flt_val);
@@ -187,6 +205,8 @@ size_t Scalar::GetByteSize() const {
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     return (m_integer.getBitWidth() / 8);
   case e_float:
     return sizeof(float_t);
@@ -213,6 +233,8 @@ bool Scalar::IsZero() const {
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_uint512:
+  case e_sint512:
     return llvm::APInt::isSameValue(zero_int, m_integer);
   case e_float:
   case e_double:
@@ -234,6 +256,7 @@ void Scalar::GetValue(Stream *s, bool sh
   case e_slonglong:
   case e_sint128:
   case e_sint256:
+  case e_sint512:
     s->PutCString(m_integer.toString(10, true));
     break;
   case e_uint:
@@ -241,6 +264,7 @@ void Scalar::GetValue(Stream *s, bool sh
   case e_ulonglong:
   case e_uint128:
   case e_uint256:
+  case e_uint512:
     s->PutCString(m_integer.toString(10, false));
     break;
   case e_float:
@@ -277,6 +301,10 @@ const char *Scalar::GetTypeAsCString() c
     return "int256_t";
   case e_uint256:
     return "unsigned int256_t";
+  case e_sint512:
+    return "int512_t";
+  case e_uint512:
+    return "unsigned int512_t";
   case e_float:
     return "float";
   case e_double:
@@ -386,6 +414,12 @@ Scalar &Scalar::operator=(llvm::APInt rh
     else
       m_type = e_uint256;
     break;
+  case 512:
+    if (m_integer.isSignedIntN(BITWIDTH_INT512))
+      m_type = e_sint512;
+    else
+      m_type = e_uint512;
+    break;
   }
   return *this;
 }
@@ -442,6 +476,12 @@ bool Scalar::Promote(Scalar::Type type)
       success = true;
       break;
 
+    case e_sint512:
+    case e_uint512:
+      m_integer = m_integer.sextOrTrunc(BITWIDTH_INT512);
+      success = true;
+      break;
+
     case e_float:
       m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
       m_float.convertFromAPInt(m_integer, true,
@@ -506,6 +546,12 @@ bool Scalar::Promote(Scalar::Type type)
       success = true;
       break;
 
+    case e_sint512:
+    case e_uint512:
+      m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512);
+      success = true;
+      break;
+
     case e_float:
       m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
       m_float.convertFromAPInt(m_integer, false,
@@ -566,6 +612,12 @@ bool Scalar::Promote(Scalar::Type type)
       success = true;
       break;
 
+    case e_sint512:
+    case e_uint512:
+      m_integer = m_integer.sextOrTrunc(BITWIDTH_INT512);
+      success = true;
+      break;
+
     case e_float:
       m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
       m_float.convertFromAPInt(m_integer, true,
@@ -622,6 +674,12 @@ bool Scalar::Promote(Scalar::Type type)
       success = true;
       break;
 
+    case e_sint512:
+    case e_uint512:
+      m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512);
+      success = true;
+      break;
+
     case e_float:
       m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
       m_float.convertFromAPInt(m_integer, false,
@@ -674,6 +732,12 @@ bool Scalar::Promote(Scalar::Type type)
       success = true;
       break;
 
+    case e_sint512:
+    case e_uint512:
+      m_integer = m_integer.sextOrTrunc(BITWIDTH_INT512);
+      success = true;
+      break;
+
     case e_float:
       m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
       m_float.convertFromAPInt(m_integer, true,
@@ -722,6 +786,12 @@ bool Scalar::Promote(Scalar::Type type)
       success = true;
       break;
 
+    case e_sint512:
+    case e_uint512:
+      m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512);
+      success = true;
+      break;
+
     case e_float:
       m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
       m_float.convertFromAPInt(m_integer, false,
@@ -770,6 +840,12 @@ bool Scalar::Promote(Scalar::Type type)
       success = true;
       break;
 
+    case e_sint512:
+    case e_uint512:
+      m_integer = m_integer.sextOrTrunc(BITWIDTH_INT512);
+      success = true;
+      break;
+
     case e_float:
       m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
       m_float.convertFromAPInt(m_integer, true,
@@ -814,6 +890,12 @@ bool Scalar::Promote(Scalar::Type type)
       success = true;
       break;
 
+    case e_sint512:
+    case e_uint512:
+      m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512);
+      success = true;
+      break;
+
     case e_float:
       m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
       m_float.convertFromAPInt(m_integer, false,
@@ -858,6 +940,12 @@ bool Scalar::Promote(Scalar::Type type)
       success = true;
       break;
 
+    case e_sint512:
+    case e_uint512:
+      m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512);
+      success = true;
+      break;
+
     case e_float:
       m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
       m_float.convertFromAPInt(m_integer, true,
@@ -898,6 +986,13 @@ bool Scalar::Promote(Scalar::Type type)
     case e_uint256:
       success = true;
       break;
+
+    case e_sint512:
+    case e_uint512:
+      m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512);
+      success = true;
+      break;
+
     case e_float:
       m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
       m_float.convertFromAPInt(m_integer, false,
@@ -922,6 +1017,11 @@ bool Scalar::Promote(Scalar::Type type)
     }
     break;
 
+  case e_sint512:
+  case e_uint512:
+    lldbassert(false && "unimplemented");
+    break;
+
   case e_float:
     switch (type) {
     case e_void:
@@ -935,6 +1035,8 @@ bool Scalar::Promote(Scalar::Type type)
     case e_uint128:
     case e_sint256:
     case e_uint256:
+    case e_uint512:
+    case e_sint512:
       break;
     case e_float:
       success = true;
@@ -968,6 +1070,8 @@ bool Scalar::Promote(Scalar::Type type)
     case e_uint128:
     case e_sint256:
     case e_uint256:
+    case e_sint512:
+    case e_uint512:
     case e_float:
       break;
     case e_double:
@@ -997,6 +1101,8 @@ bool Scalar::Promote(Scalar::Type type)
     case e_uint128:
     case e_sint256:
     case e_uint256:
+    case e_sint512:
+    case e_uint512:
     case e_float:
     case e_double:
       break;
@@ -1042,6 +1148,10 @@ const char *Scalar::GetValueTypeAsCStrin
     return "int256_t";
   case e_uint256:
     return "uint256_t";
+  case e_sint512:
+    return "int512_t";
+  case e_uint512:
+    return "uint512_t";
   }
   return "???";
 }
@@ -1119,6 +1229,13 @@ bool Scalar::MakeSigned() {
     m_type = e_sint256;
     success = true;
     break;
+  case e_sint512:
+    success = true;
+    break;
+  case e_uint512:
+    m_type = e_sint512;
+    success = true;
+    break;
   case e_float:
     success = true;
     break;
@@ -1174,6 +1291,13 @@ bool Scalar::MakeUnsigned() {
   case e_uint256:
     success = true;
     break;
+  case e_sint512:
+    m_type = e_uint512;
+    success = true;
+    break;
+  case e_uint512:
+    success = true;
+    break;
   case e_float:
     success = true;
     break;
@@ -1202,6 +1326,8 @@ signed char Scalar::SChar(char fail_valu
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     return (schar_t)(m_integer.sextOrTrunc(sizeof(schar_t) * 8)).getSExtValue();
   case e_float:
     return (schar_t)m_float.convertToFloat();
@@ -1228,6 +1354,8 @@ unsigned char Scalar::UChar(unsigned cha
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     return (uchar_t)(m_integer.zextOrTrunc(sizeof(uchar_t) * 8)).getZExtValue();
   case e_float:
     return (uchar_t)m_float.convertToFloat();
@@ -1254,6 +1382,8 @@ short Scalar::SShort(short fail_value) c
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     return (sshort_t)(m_integer.sextOrTrunc(sizeof(sshort_t) * 8))
         .getSExtValue();
   case e_float:
@@ -1282,6 +1412,8 @@ unsigned short Scalar::UShort(unsigned s
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     return (ushort_t)(m_integer.zextOrTrunc(sizeof(ushort_t) * 8))
         .getZExtValue();
   case e_float:
@@ -1310,6 +1442,8 @@ int Scalar::SInt(int fail_value) const {
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     return (sint_t)(m_integer.sextOrTrunc(sizeof(sint_t) * 8)).getSExtValue();
   case e_float:
     return (sint_t)m_float.convertToFloat();
@@ -1336,6 +1470,8 @@ unsigned int Scalar::UInt(unsigned int f
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     return (uint_t)(m_integer.zextOrTrunc(sizeof(uint_t) * 8)).getZExtValue();
   case e_float:
     return (uint_t)m_float.convertToFloat();
@@ -1362,6 +1498,8 @@ long Scalar::SLong(long fail_value) cons
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     return (slong_t)(m_integer.sextOrTrunc(sizeof(slong_t) * 8)).getSExtValue();
   case e_float:
     return (slong_t)m_float.convertToFloat();
@@ -1388,6 +1526,8 @@ unsigned long Scalar::ULong(unsigned lon
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     return (ulong_t)(m_integer.zextOrTrunc(sizeof(ulong_t) * 8)).getZExtValue();
   case e_float:
     return (ulong_t)m_float.convertToFloat();
@@ -1414,6 +1554,8 @@ long long Scalar::SLongLong(long long fa
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     return (slonglong_t)(m_integer.sextOrTrunc(sizeof(slonglong_t) * 8))
         .getSExtValue();
   case e_float:
@@ -1442,6 +1584,8 @@ unsigned long long Scalar::ULongLong(uns
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     return (ulonglong_t)(m_integer.zextOrTrunc(sizeof(ulonglong_t) * 8))
         .getZExtValue();
   case e_float:
@@ -1475,6 +1619,8 @@ llvm::APInt Scalar::SInt128(llvm::APInt
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     return m_integer;
   case e_float:
   case e_double:
@@ -1498,6 +1644,8 @@ llvm::APInt Scalar::UInt128(const llvm::
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     return m_integer;
   case e_float:
   case e_double:
@@ -1521,6 +1669,8 @@ llvm::APInt Scalar::SInt256(llvm::APInt
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_uint512:
+  case e_sint512:
     return m_integer;
   case e_float:
   case e_double:
@@ -1544,6 +1694,8 @@ llvm::APInt Scalar::UInt256(const llvm::
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     return m_integer;
   case e_float:
   case e_double:
@@ -1567,6 +1719,8 @@ float Scalar::Float(float fail_value) co
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     return llvm::APIntOps::RoundAPIntToFloat(m_integer);
   case e_float:
     return m_float.convertToFloat();
@@ -1593,6 +1747,8 @@ double Scalar::Double(double fail_value)
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     return llvm::APIntOps::RoundAPIntToDouble(m_integer);
   case e_float:
     return (double_t)m_float.convertToFloat();
@@ -1619,6 +1775,8 @@ long double Scalar::LongDouble(long doub
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     return (long_double_t)llvm::APIntOps::RoundAPIntToDouble(m_integer);
   case e_float:
     return (long_double_t)m_float.convertToFloat();
@@ -1650,6 +1808,8 @@ Scalar &Scalar::operator+=(const Scalar
     case e_uint128:
     case e_sint256:
     case e_uint256:
+    case e_sint512:
+    case e_uint512:
       m_integer = a->m_integer + b->m_integer;
       break;
 
@@ -1682,6 +1842,8 @@ Scalar &Scalar::operator<<=(const Scalar
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     switch (rhs.m_type) {
     case e_void:
     case e_float:
@@ -1699,6 +1861,8 @@ Scalar &Scalar::operator<<=(const Scalar
     case e_uint128:
     case e_sint256:
     case e_uint256:
+    case e_sint512:
+    case e_uint512:
       m_integer = m_integer << rhs.m_integer;
       break;
     }
@@ -1726,6 +1890,8 @@ bool Scalar::ShiftRightLogical(const Sca
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     switch (rhs.m_type) {
     case e_void:
     case e_float:
@@ -1743,6 +1909,8 @@ bool Scalar::ShiftRightLogical(const Sca
     case e_uint128:
     case e_sint256:
     case e_uint256:
+    case e_sint512:
+    case e_uint512:
       m_integer = m_integer.lshr(rhs.m_integer);
       break;
     }
@@ -1770,6 +1938,8 @@ Scalar &Scalar::operator>>=(const Scalar
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     switch (rhs.m_type) {
     case e_void:
     case e_float:
@@ -1787,6 +1957,8 @@ Scalar &Scalar::operator>>=(const Scalar
     case e_uint128:
     case e_sint256:
     case e_uint256:
+    case e_sint512:
+    case e_uint512:
       m_integer = m_integer.ashr(rhs.m_integer);
       break;
     }
@@ -1814,6 +1986,8 @@ Scalar &Scalar::operator&=(const Scalar
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     switch (rhs.m_type) {
     case e_void:
     case e_float:
@@ -1831,6 +2005,8 @@ Scalar &Scalar::operator&=(const Scalar
     case e_uint128:
     case e_sint256:
     case e_uint256:
+    case e_sint512:
+    case e_uint512:
       m_integer &= rhs.m_integer;
       break;
     }
@@ -1849,6 +2025,7 @@ bool Scalar::AbsoluteValue() {
   case e_slonglong:
   case e_sint128:
   case e_sint256:
+  case e_sint512:
     if (m_integer.isNegative())
       m_integer = -m_integer;
     return true;
@@ -1859,6 +2036,7 @@ bool Scalar::AbsoluteValue() {
     return true;
   case e_uint128:
   case e_uint256:
+  case e_uint512:
   case e_float:
   case e_double:
   case e_long_double:
@@ -1882,6 +2060,8 @@ bool Scalar::UnaryNegate() {
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     m_integer = -m_integer;
     return true;
   case e_float:
@@ -1905,6 +2085,8 @@ bool Scalar::OnesComplement() {
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     m_integer = ~m_integer;
     return true;
 
@@ -1937,6 +2119,8 @@ const Scalar lldb_private::operator+(con
     case Scalar::e_uint128:
     case Scalar::e_sint256:
     case Scalar::e_uint256:
+    case Scalar::e_sint512:
+    case Scalar::e_uint512:
       result.m_integer = a->m_integer + b->m_integer;
       break;
     case Scalar::e_float:
@@ -1969,6 +2153,8 @@ const Scalar lldb_private::operator-(con
     case Scalar::e_uint128:
     case Scalar::e_sint256:
     case Scalar::e_uint256:
+    case Scalar::e_sint512:
+    case Scalar::e_uint512:
       result.m_integer = a->m_integer - b->m_integer;
       break;
     case Scalar::e_float:
@@ -1996,6 +2182,7 @@ const Scalar lldb_private::operator/(con
     case Scalar::e_slonglong:
     case Scalar::e_sint128:
     case Scalar::e_sint256:
+    case Scalar::e_sint512:
       if (b->m_integer != 0) {
         result.m_integer = a->m_integer.sdiv(b->m_integer);
         return result;
@@ -2006,6 +2193,7 @@ const Scalar lldb_private::operator/(con
     case Scalar::e_ulonglong:
     case Scalar::e_uint128:
     case Scalar::e_uint256:
+    case Scalar::e_uint512:
       if (b->m_integer != 0) {
         result.m_integer = a->m_integer.udiv(b->m_integer);
         return result;
@@ -2047,6 +2235,8 @@ const Scalar lldb_private::operator*(con
     case Scalar::e_uint128:
     case Scalar::e_sint256:
     case Scalar::e_uint256:
+    case Scalar::e_sint512:
+    case Scalar::e_uint512:
       result.m_integer = a->m_integer * b->m_integer;
       break;
     case Scalar::e_float:
@@ -2077,6 +2267,8 @@ const Scalar lldb_private::operator&(con
     case Scalar::e_uint128:
     case Scalar::e_sint256:
     case Scalar::e_uint256:
+    case Scalar::e_sint512:
+    case Scalar::e_uint512:
       result.m_integer = a->m_integer & b->m_integer;
       break;
     case Scalar::e_void:
@@ -2109,6 +2301,8 @@ const Scalar lldb_private::operator|(con
     case Scalar::e_uint128:
     case Scalar::e_sint256:
     case Scalar::e_uint256:
+    case Scalar::e_sint512:
+    case Scalar::e_uint512:
       result.m_integer = a->m_integer | b->m_integer;
       break;
 
@@ -2141,6 +2335,7 @@ const Scalar lldb_private::operator%(con
     case Scalar::e_slonglong:
     case Scalar::e_sint128:
     case Scalar::e_sint256:
+    case Scalar::e_sint512:
       if (b->m_integer != 0) {
         result.m_integer = a->m_integer.srem(b->m_integer);
         return result;
@@ -2151,6 +2346,7 @@ const Scalar lldb_private::operator%(con
     case Scalar::e_ulonglong:
     case Scalar::e_uint128:
     case Scalar::e_uint256:
+    case Scalar::e_uint512:
       if (b->m_integer != 0) {
         result.m_integer = a->m_integer.urem(b->m_integer);
         return result;
@@ -2180,6 +2376,8 @@ const Scalar lldb_private::operator^(con
     case Scalar::e_uint128:
     case Scalar::e_sint256:
     case Scalar::e_uint256:
+    case Scalar::e_sint512:
+    case Scalar::e_uint512:
       result.m_integer = a->m_integer ^ b->m_integer;
       break;
 
@@ -2486,6 +2684,8 @@ bool Scalar::SignExtend(uint32_t sign_bi
     case Scalar::e_uint128:
     case Scalar::e_sint256:
     case Scalar::e_uint256:
+    case Scalar::e_sint512:
+    case Scalar::e_uint512:
       if (max_bit_pos == sign_bit_pos)
         return true;
       else if (sign_bit_pos < (max_bit_pos - 1)) {
@@ -2545,6 +2745,7 @@ bool Scalar::ExtractBitfield(uint32_t bi
   case Scalar::e_slonglong:
   case Scalar::e_sint128:
   case Scalar::e_sint256:
+  case Scalar::e_sint512:
     m_integer = m_integer.ashr(bit_offset)
                     .sextOrTrunc(bit_size)
                     .sextOrSelf(8 * GetByteSize());
@@ -2555,6 +2756,7 @@ bool Scalar::ExtractBitfield(uint32_t bi
   case Scalar::e_ulonglong:
   case Scalar::e_uint128:
   case Scalar::e_uint256:
+  case Scalar::e_uint512:
     m_integer = m_integer.lshr(bit_offset)
                     .zextOrTrunc(bit_size)
                     .zextOrSelf(8 * GetByteSize());
@@ -2585,6 +2787,8 @@ bool lldb_private::operator==(const Scal
   case Scalar::e_uint128:
   case Scalar::e_sint256:
   case Scalar::e_uint256:
+  case Scalar::e_sint512:
+  case Scalar::e_uint512:
     return a->m_integer == b->m_integer;
   case Scalar::e_float:
   case Scalar::e_double:
@@ -2616,6 +2820,8 @@ bool lldb_private::operator<(const Scala
   case Scalar::e_slonglong:
   case Scalar::e_sint128:
   case Scalar::e_sint256:
+  case Scalar::e_sint512:
+  case Scalar::e_uint512:
     return a->m_integer.slt(b->m_integer);
   case Scalar::e_uint:
   case Scalar::e_ulong:
@@ -2659,6 +2865,8 @@ bool Scalar::ClearBit(uint32_t bit) {
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     m_integer.clearBit(bit);
     return true;
   case e_float:
@@ -2683,6 +2891,8 @@ bool Scalar::SetBit(uint32_t bit) {
   case e_uint128:
   case e_sint256:
   case e_uint256:
+  case e_sint512:
+  case e_uint512:
     m_integer.setBit(bit);
     return true;
   case e_float:

Modified: lldb/trunk/unittests/Utility/ScalarTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/ScalarTest.cpp?rev=352639&r1=352638&r2=352639&view=diff
==============================================================================
--- lldb/trunk/unittests/Utility/ScalarTest.cpp (original)
+++ lldb/trunk/unittests/Utility/ScalarTest.cpp Wed Jan 30 10:05:36 2019
@@ -277,4 +277,27 @@ TEST(ScalarTest, APIntConstructor) {
   EXPECT_EQ(C.GetType(), Scalar::e_sint128);
   Scalar D(APInt(256, 156));
   EXPECT_EQ(D.GetType(), Scalar::e_sint256);
+  Scalar E(APInt(512, 456));
+  EXPECT_EQ(E.GetType(), Scalar::e_sint512);
+}
+
+TEST(ScalarTest, Scalar_512) {
+  Scalar Z(APInt(512, 0));
+  ASSERT_TRUE(Z.IsZero());
+  Z.MakeUnsigned();
+  ASSERT_TRUE(Z.IsZero());
+
+  Scalar S(APInt(512, 2000));
+  EXPECT_EQ(S.GetTypeAsCString(), "int512_t");
+  EXPECT_EQ(S.GetValueTypeAsCString(Scalar::e_sint512), "int512_t");
+
+  ASSERT_TRUE(S.MakeUnsigned());
+  EXPECT_EQ(S.GetType(), Scalar::e_uint512);
+  EXPECT_EQ(S.GetTypeAsCString(), "unsigned int512_t");
+  EXPECT_EQ(S.GetValueTypeAsCString(Scalar::e_uint512), "uint512_t");
+  EXPECT_EQ(S.GetByteSize(), 64U);
+
+  ASSERT_TRUE(S.MakeSigned());
+  EXPECT_EQ(S.GetType(), Scalar::e_sint512);
+  EXPECT_EQ(S.GetByteSize(), 64U);
 }




More information about the lldb-commits mailing list