[Lldb-commits] [lldb] r245547 - [LLDB] Use llvm::APInt and llvm::APFloat in Scalar and RegisterValue

Sagar Thakur via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 20 02:12:47 PDT 2015


Author: slthakur
Date: Thu Aug 20 04:12:46 2015
New Revision: 245547

URL: http://llvm.org/viewvc/llvm-project?rev=245547&view=rev
Log:
[LLDB] Use llvm::APInt and llvm::APFloat in Scalar and RegisterValue

Eliminated ENABLE_128_BIT_SUPPORT and union ValueData from Scalar.cpp and use llvm::APInt and llvm::APFloat for all integer and floating point types. Also used Scalar in RegisterValue.cpp

Reviewers: tberghammer, ovyalov, clayborg, labath
Subscribers: lldb-commits, nitesh.jain, jaydeep 
Differential: http://reviews.llvm.org/D12100

Modified:
    lldb/trunk/include/lldb/Core/RegisterValue.h
    lldb/trunk/include/lldb/Core/Scalar.h
    lldb/trunk/include/lldb/Core/Value.h
    lldb/trunk/include/lldb/lldb-private-types.h
    lldb/trunk/source/Core/RegisterValue.cpp
    lldb/trunk/source/Core/Scalar.cpp
    lldb/trunk/source/Core/ValueObject.cpp

Modified: lldb/trunk/include/lldb/Core/RegisterValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RegisterValue.h?rev=245547&r1=245546&r2=245547&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/RegisterValue.h (original)
+++ lldb/trunk/include/lldb/Core/RegisterValue.h Thu Aug 20 04:12:46 2015
@@ -19,8 +19,9 @@
 #include "lldb/lldb-public.h"
 #include "lldb/lldb-private.h"
 #include "lldb/Host/Endian.h"
+#include "llvm/ADT/APInt.h"
+#include "lldb/Core/Scalar.h"
 
-//#define ENABLE_128_BIT_SUPPORT 1
 namespace lldb_private {
 
     class RegisterValue
@@ -37,9 +38,7 @@ namespace lldb_private {
             eTypeUInt16,
             eTypeUInt32,
             eTypeUInt64,
-#if defined (ENABLE_128_BIT_SUPPORT)
             eTypeUInt128,
-#endif
             eTypeFloat,
             eTypeDouble,
             eTypeLongDouble,
@@ -47,7 +46,8 @@ namespace lldb_private {
         };
         
         RegisterValue () : 
-            m_type (eTypeInvalid)
+            m_type (eTypeInvalid),
+            m_scalar ((unsigned long)0)
         {
         }
 
@@ -55,57 +55,55 @@ namespace lldb_private {
         RegisterValue (uint8_t inst) : 
             m_type (eTypeUInt8)
         {
-            m_data.uint8 = inst;
+            m_scalar = inst;
         }
 
         explicit 
         RegisterValue (uint16_t inst) : 
             m_type (eTypeUInt16)
         {
-            m_data.uint16 = inst;
+            m_scalar = inst;
         }
 
         explicit 
         RegisterValue (uint32_t inst) : 
             m_type (eTypeUInt32)
         {
-            m_data.uint32 = inst;
+            m_scalar = inst;
         }
 
         explicit 
         RegisterValue (uint64_t inst) : 
             m_type (eTypeUInt64)
         {
-            m_data.uint64 = inst;
+            m_scalar = inst;
         }
 
-#if defined (ENABLE_128_BIT_SUPPORT)
         explicit 
-        RegisterValue (__uint128_t inst) : 
+        RegisterValue (llvm::APInt inst) :
             m_type (eTypeUInt128)
         {
-            m_data.uint128 = inst;
+            m_scalar = llvm::APInt(inst);
         }
-#endif        
         explicit 
         RegisterValue (float value) : 
             m_type (eTypeFloat)
         {
-            m_data.ieee_float = value;
+            m_scalar = value;
         }
 
         explicit 
         RegisterValue (double value) : 
             m_type (eTypeDouble)
         {
-            m_data.ieee_double = value;
+            m_scalar = value;
         }
 
         explicit 
         RegisterValue (long double value) : 
             m_type (eTypeLongDouble)
         {
-            m_data.ieee_long_double = value;
+            m_scalar = value;
         }
 
         explicit 
@@ -167,7 +165,7 @@ namespace lldb_private {
             {
                 if (success_ptr)
                     *success_ptr = true;                
-                return m_data.uint8;
+                return m_scalar.UChar(fail_value);
             }
             if (success_ptr)
                 *success_ptr = true;
@@ -183,10 +181,8 @@ namespace lldb_private {
         uint64_t
         GetAsUInt64 (uint64_t fail_value = UINT64_MAX, bool *success_ptr = NULL) const;
 
-#if defined (ENABLE_128_BIT_SUPPORT)
-        __uint128_t
-        GetAsUInt128 (__uint128_t fail_value = ~((__uint128_t)0), bool *success_ptr = NULL) const;
-#endif
+        llvm::APInt
+        GetAsUInt128 (const llvm::APInt& fail_value, bool *success_ptr = NULL) const;
 
         float
         GetAsFloat (float fail_value = 0.0f, bool *success_ptr = NULL) const;
@@ -219,95 +215,92 @@ namespace lldb_private {
         operator = (uint8_t uint)
         {
             m_type = eTypeUInt8;
-            m_data.uint8 = uint;
+            m_scalar = uint;
         }
 
         void
         operator = (uint16_t uint)
         {
             m_type = eTypeUInt16;
-            m_data.uint16 = uint;
+            m_scalar = uint;
         }
 
         void
         operator = (uint32_t uint)
         {
             m_type = eTypeUInt32;
-            m_data.uint32 = uint;
+            m_scalar = uint;
         }
 
         void
         operator = (uint64_t uint)
         {
             m_type = eTypeUInt64;
-            m_data.uint64 = uint;
+            m_scalar = uint;
         }
 
-#if defined (ENABLE_128_BIT_SUPPORT)
         void
-        operator = (__uint128_t uint)
+        operator = (llvm::APInt uint)
         {
             m_type = eTypeUInt128;
-            m_data.uint128 = uint;
+            m_scalar = llvm::APInt(uint);
         }
-#endif        
+
         void
         operator = (float f)
         {
             m_type = eTypeFloat;
-            m_data.ieee_float = f;
+            m_scalar = f;
         }
 
         void
         operator = (double f)
         {
             m_type = eTypeDouble;
-            m_data.ieee_double = f;
+            m_scalar = f;
         }
 
         void
         operator = (long double f)
         {
             m_type = eTypeLongDouble;
-            m_data.ieee_long_double = f;
+            m_scalar = f;
         }
 
         void
         SetUInt8 (uint8_t uint)
         {
             m_type = eTypeUInt8;
-            m_data.uint8 = uint;
+            m_scalar = uint;
         }
 
         void
         SetUInt16 (uint16_t uint)
         {
             m_type = eTypeUInt16;
-            m_data.uint16 = uint;
+            m_scalar = uint;
         }
 
         void
         SetUInt32 (uint32_t uint, Type t = eTypeUInt32)
         {
             m_type = t;
-            m_data.uint32 = uint;
+            m_scalar = uint;
         }
 
         void
         SetUInt64 (uint64_t uint, Type t = eTypeUInt64)
         {
             m_type = t;
-            m_data.uint64 = uint;
+            m_scalar = uint;
         }
 
-#if defined (ENABLE_128_BIT_SUPPORT)
         void
-        SetUInt128 (__uint128_t uint)
+        SetUInt128 (llvm::APInt uint)
         {
             m_type = eTypeUInt128;
-            m_data.uint128 = uint;
+            m_scalar = llvm::APInt(uint);
         }
-#endif
         bool
         SetUInt (uint64_t uint, uint32_t byte_size);
     
@@ -315,21 +308,21 @@ namespace lldb_private {
         SetFloat (float f)
         {
             m_type = eTypeFloat;
-            m_data.ieee_float = f;
+            m_scalar = f;
         }
 
         void
         SetDouble (double f)
         {
             m_type = eTypeDouble;
-            m_data.ieee_double = f;
+            m_scalar = f;
         }
 
         void
         SetLongDouble (long double f)
         {
             m_type = eTypeLongDouble;
-            m_data.ieee_long_double = f;
+            m_scalar = f;
         }
 
         void
@@ -367,7 +360,7 @@ namespace lldb_private {
         GetByteOrder () const
         {
             if (m_type == eTypeBytes)
-                return m_data.buffer.byte_order;
+                return buffer.byte_order;
             return lldb::endian::InlHostByteOrder();
         }
         
@@ -386,25 +379,13 @@ namespace lldb_private {
     protected:
 
         RegisterValue::Type m_type;
-        union
+        Scalar m_scalar;
+        struct
         {
-            uint8_t  uint8;
-            uint16_t uint16;
-            uint32_t uint32;
-            uint64_t uint64;
-#if defined (ENABLE_128_BIT_SUPPORT)
-            __uint128_t uint128;
-#endif
-            float ieee_float;
-            double ieee_double;
-            long double ieee_long_double;
-            struct 
-            {
-                uint8_t bytes[kMaxRegisterByteSize]; // This must be big enough to hold any register for any supported target.
-                uint8_t length;
-                lldb::ByteOrder byte_order;
-            } buffer;
-        } m_data;
+            uint8_t bytes[kMaxRegisterByteSize]; // This must be big enough to hold any register for any supported target.
+            uint8_t length;
+            lldb::ByteOrder byte_order;
+        } buffer;
     };
 
 } // namespace lldb_private

Modified: lldb/trunk/include/lldb/Core/Scalar.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Scalar.h?rev=245547&r1=245546&r2=245547&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Scalar.h (original)
+++ lldb/trunk/include/lldb/Core/Scalar.h Thu Aug 20 04:12:46 2015
@@ -11,6 +11,11 @@
 #define liblldb_Scalar_h_
 
 #include "lldb/lldb-private.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/APFloat.h"
+
+#define NUM_OF_WORDS_INT128 2
+#define BITWIDTH_INT128 128
 
 namespace lldb_private {
 
@@ -34,22 +39,60 @@ public:
         e_ulonglong,
         e_float,
         e_double,
-        e_long_double
+        e_long_double,
+        e_uint128,
+        e_sint128
     };
 
     //------------------------------------------------------------------
     // Constructors and Destructors
     //------------------------------------------------------------------
     Scalar();
-    Scalar(int v)               : m_type(e_sint),           m_data() { m_data.sint      = v; }
-    Scalar(unsigned int v)      : m_type(e_uint),           m_data() { m_data.uint      = v; }
-    Scalar(long v)              : m_type(e_slong),          m_data() { m_data.slong     = v; }
-    Scalar(unsigned long v)     : m_type(e_ulong),          m_data() { m_data.ulong     = v; }
-    Scalar(long long v)         : m_type(e_slonglong),      m_data() { m_data.slonglong = v; }
-    Scalar(unsigned long long v): m_type(e_ulonglong),      m_data() { m_data.ulonglong = v; }
-    Scalar(float v)             : m_type(e_float),          m_data() { m_data.flt       = v; }
-    Scalar(double v)            : m_type(e_double),         m_data() { m_data.dbl       = v; }
-    Scalar(long double v)       : m_type(e_long_double),    m_data() { m_data.ldbl      = v; }
+    Scalar(int v)               : m_type(e_sint),        m_float((float)0) { m_integer = llvm::APInt(sizeof(int) * 8, v, true);}
+    Scalar(unsigned int v)      : m_type(e_uint),        m_float((float)0) { m_integer = llvm::APInt(sizeof(int) * 8, v);}
+    Scalar(long v)              : m_type(e_slong),       m_float((float)0) { m_integer = llvm::APInt(sizeof(long) * 8, v, true);}
+    Scalar(unsigned long v)     : m_type(e_ulong),       m_float((float)0) { m_integer = llvm::APInt(sizeof(long) * 8, v);}
+    Scalar(long long v)         : m_type(e_slonglong),   m_float((float)0) { m_integer = llvm::APInt(sizeof(long long) * 8, v, true);}
+    Scalar(unsigned long long v): m_type(e_ulonglong),   m_float((float)0) { m_integer = llvm::APInt(sizeof(long long) * 8, v);}
+    Scalar(float v)             : m_type(e_float),       m_float(v) { m_float   = llvm::APFloat(v); }
+    Scalar(double v)            : m_type(e_double),      m_float(v) { m_float   = llvm::APFloat(v); }
+    Scalar(long double v, bool ieee_quad)
+        : m_type(e_long_double), m_float((float)0), m_ieee_quad(ieee_quad)
+        {
+            if(ieee_quad)
+                m_float = llvm::APFloat(llvm::APFloat::IEEEquad, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x));
+            else
+                m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x));
+        }
+    Scalar(llvm::APInt v) :
+        m_type(),
+        m_float((float)0)
+        {
+            m_integer = llvm::APInt(v);
+            switch(m_integer.getBitWidth())
+            {
+            case 8:
+            case 16:
+            case 32:
+                if(m_integer.isSignedIntN(sizeof(sint_t) * 8))
+                    m_type = e_sint;
+                else
+                    m_type = e_uint;
+                break;
+            case 64:
+                if(m_integer.isSignedIntN(sizeof(slonglong_t) * 8))
+                    m_type = e_slonglong;
+                else
+                    m_type = e_ulonglong;
+                break;
+            case 128:
+                if(m_integer.isSignedIntN(BITWIDTH_INT128))
+                    m_type = e_sint128;
+                else
+                    m_type = e_uint128;
+                break;
+            }
+        }
     Scalar(const Scalar& rhs);
     //Scalar(const RegisterValue& reg_value);
     virtual ~Scalar();
@@ -61,15 +104,18 @@ public:
     ExtractBitfield (uint32_t bit_size, 
                      uint32_t bit_offset);
 
+    bool
+    SetBit(uint32_t bit);
+
+    bool
+    ClearBit(uint32_t bit);
+
+    void *
+    GetBytes() const;
+
     size_t
     GetByteSize() const;
 
-    static size_t
-    GetMaxByteSize()
-    {
-        return sizeof(ValueData);
-    }
-
     bool
     GetData (DataExtractor &data, size_t limit_byte_size = UINT32_MAX) const;
 
@@ -83,7 +129,7 @@ public:
     IsZero() const;
 
     void
-    Clear() { m_type = e_void; m_data.ulonglong = 0; }
+    Clear() { m_type = e_void; m_integer.clearAllBits(); }
 
     const char *
     GetTypeAsCString() const;
@@ -133,6 +179,7 @@ public:
     Scalar& operator= (float v);
     Scalar& operator= (double v);
     Scalar& operator= (long double v);
+    Scalar& operator= (llvm::APInt v);
     Scalar& operator= (const Scalar& rhs);      // Assignment operator
     Scalar& operator+= (const Scalar& rhs);
     Scalar& operator<<= (const Scalar& rhs);    // Shift left
@@ -174,6 +221,9 @@ public:
     Scalar::Type
     GetType() const { return m_type; }
 
+    void
+    SetType(const RegisterInfo*);
+
     //----------------------------------------------------------------------
     // Returns a casted value of the current contained data without
     // modifying the current value. FAIL_VALUE will be returned if the type
@@ -194,6 +244,18 @@ public:
     unsigned long long
     RawULongLong () const;
 
+    unsigned char
+    UChar(unsigned char fail_value = 0) const;
+
+    char
+    SChar(char fail_value = 0) const;
+
+    unsigned short
+    UShort(unsigned short fail_value = 0) const;
+
+    short
+    SShort(short fail_value = 0) const;
+
     unsigned int
     UInt(unsigned int fail_value = 0) const;
 
@@ -209,6 +271,12 @@ public:
     unsigned long long
     ULongLong(unsigned long long fail_value = 0) const;
 
+    llvm::APInt
+    SInt128(llvm::APInt& fail_value) const;
+
+    llvm::APInt
+    UInt128(const llvm::APInt& fail_value) const;
+
     float
     Float(float fail_value = 0.0f) const;
 
@@ -255,6 +323,10 @@ public:
     }
 
 protected:
+    typedef char                schar_t;
+    typedef unsigned char       uchar_t;
+    typedef short               sshort_t;
+    typedef unsigned short      ushort_t;
     typedef int                 sint_t;
     typedef unsigned int        uint_t;
     typedef long                slong_t;
@@ -265,24 +337,13 @@ protected:
     typedef double              double_t;
     typedef long double         long_double_t;
     
-    union ValueData
-    {
-        int                 sint;
-        unsigned int        uint;
-        long                slong;
-        unsigned long       ulong;
-        long long           slonglong;
-        unsigned long long  ulonglong;
-        float               flt;
-        double              dbl;
-        long double         ldbl;
-    };
-
     //------------------------------------------------------------------
     // Classes that inherit from Scalar can see and modify these
     //------------------------------------------------------------------
     Scalar::Type m_type;
-    ValueData m_data;
+    llvm::APInt m_integer;
+    llvm::APFloat m_float;
+    bool m_ieee_quad = false;
 
 private:
     friend const Scalar operator+   (const Scalar& lhs, const Scalar& rhs);

Modified: lldb/trunk/include/lldb/Core/Value.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Value.h?rev=245547&r1=245546&r2=245547&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Value.h (original)
+++ lldb/trunk/include/lldb/Core/Value.h Thu Aug 20 04:12:46 2015
@@ -101,6 +101,7 @@ public:
         // Casts a vector, if valid, to an unsigned int of matching or largest supported size.
         // Truncates to the beginning of the vector if required.
         // Returns a default constructed Scalar if the Vector data is internally inconsistent.
+        llvm::APInt rhs = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)bytes)->x);
         Scalar 
 		GetAsScalar() const 
 		{
@@ -111,11 +112,7 @@ public:
                 else if (length == 2) scalar = *(const uint16_t *)bytes;
                 else if (length == 4) scalar = *(const uint32_t *)bytes;
                 else if (length == 8) scalar = *(const uint64_t *)bytes;
-#if defined (ENABLE_128_BIT_SUPPORT)
-                else if (length >= 16) scalar = *(const __uint128_t *)bytes;
-#else
-                else if (length >= 16) scalar = *(const uint64_t *)bytes;
-#endif
+                else if (length >= 16) scalar = rhs;
             }
             return scalar;
         }

Modified: lldb/trunk/include/lldb/lldb-private-types.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-types.h?rev=245547&r1=245546&r2=245547&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private-types.h (original)
+++ lldb/trunk/include/lldb/lldb-private-types.h Thu Aug 20 04:12:46 2015
@@ -102,6 +102,8 @@ namespace lldb_private
                                                  // pass it.
     };
 
+    typedef struct type128 { uint64_t x[2]; } type128;
+
 } // namespace lldb_private
 
 #endif  // #if defined(__cplusplus)

Modified: lldb/trunk/source/Core/RegisterValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/RegisterValue.cpp?rev=245547&r1=245546&r2=245547&view=diff
==============================================================================
--- lldb/trunk/source/Core/RegisterValue.cpp (original)
+++ lldb/trunk/source/Core/RegisterValue.cpp Thu Aug 20 04:12:46 2015
@@ -215,10 +215,10 @@ RegisterValue::SetFromMemoryData (const
     }
     else if (value_type == eTypeBytes)
     {
-        m_data.buffer.byte_order = src_byte_order;
+        buffer.byte_order = src_byte_order;
         // Make sure to set the buffer length of the destination buffer to avoid
-        // problems due to uninitialized variables.
-        m_data.buffer.length = src_len;
+        // problems due to uninitalized variables.
+        buffer.length = src_len;
     }
 
     const uint32_t bytes_copied = src_data.CopyByteOrderedData (0,               // src offset
@@ -240,25 +240,23 @@ RegisterValue::GetScalarValue (Scalar &s
         case eTypeInvalid:      break;
         case eTypeBytes:
         {
-            switch (m_data.buffer.length)
+            switch (buffer.length)
             {
             default:    break;
-            case 1:     scalar = m_data.uint8; return true;
-            case 2:     scalar = m_data.uint16; return true;
-            case 4:     scalar = m_data.uint32; return true;
-            case 8:     scalar = m_data.uint64; return true;
+            case 1:     scalar = *(const uint8_t *)buffer.bytes; return true;
+            case 2:     scalar = *(const uint16_t *)buffer.bytes; return true;
+            case 4:     scalar = *(const uint32_t *)buffer.bytes; return true;
+            case 8:     scalar = *(const uint64_t *)buffer.bytes; return true;
             }
         }
-        case eTypeUInt8:        scalar = m_data.uint8; return true;
-        case eTypeUInt16:       scalar = m_data.uint16; return true;
-        case eTypeUInt32:       scalar = m_data.uint32; return true;
-        case eTypeUInt64:       scalar = m_data.uint64; return true;
-#if defined (ENABLE_128_BIT_SUPPORT)
-        case eTypeUInt128:      break;
-#endif
-        case eTypeFloat:        scalar = m_data.ieee_float; return true;
-        case eTypeDouble:       scalar = m_data.ieee_double; return true;
-        case eTypeLongDouble:   scalar = m_data.ieee_long_double; return true;
+        case eTypeUInt8:
+        case eTypeUInt16:
+        case eTypeUInt32:
+        case eTypeUInt64:
+        case eTypeUInt128:
+        case eTypeFloat:
+        case eTypeDouble:
+        case eTypeLongDouble:   scalar = m_scalar; return true;
     }
     return false;
 }
@@ -289,10 +287,8 @@ RegisterValue::SetType (const RegisterIn
                 m_type = eTypeUInt32;
             else if (byte_size <= 8)
                 m_type = eTypeUInt64;
-#if defined (ENABLE_128_BIT_SUPPORT)
             else if (byte_size <= 16)
                 m_type = eTypeUInt128;
-#endif
             break;
 
         case eEncodingIEEE754:
@@ -308,6 +304,7 @@ RegisterValue::SetType (const RegisterIn
             m_type = eTypeBytes;
             break;
     }
+    m_scalar.SetType(reg_info);
     return m_type;
 }
 
@@ -342,8 +339,9 @@ RegisterValue::SetValueFromData (const R
         src_len = reg_info->byte_size;
 
     // Zero out the value in case we get partial data...
-    memset (m_data.buffer.bytes, 0, sizeof (m_data.buffer.bytes));
-    
+    memset (buffer.bytes, 0, sizeof (buffer.bytes));
+
+    type128 int128;
     switch (SetType (reg_info))
     {
         case eTypeInvalid:
@@ -353,33 +351,38 @@ RegisterValue::SetValueFromData (const R
         case eTypeUInt16:   SetUInt16 (src.GetMaxU32 (&src_offset, src_len)); break;
         case eTypeUInt32:   SetUInt32 (src.GetMaxU32 (&src_offset, src_len)); break;
         case eTypeUInt64:   SetUInt64 (src.GetMaxU64 (&src_offset, src_len)); break;
-#if defined (ENABLE_128_BIT_SUPPORT)
         case eTypeUInt128:
             {
-                __uint128_t data1 = src.GetU64 (&src_offset);
-                __uint128_t data2 = src.GetU64 (&src_offset);
+                uint64_t data1 = src.GetU64 (&src_offset);
+                uint64_t data2 = src.GetU64 (&src_offset);
                 if (src.GetByteSize() == eByteOrderBig)
-                    SetUInt128 (data1 << 64 + data2);
+                {
+                    int128.x[0] = data1;
+                    int128.x[1] = data2;
+                }
                 else
-                    SetUInt128 (data2 << 64 + data1);
+                {
+                    int128.x[0] = data2;
+                    int128.x[1] = data1;
+                }
+                SetUInt128 (llvm::APInt(128, 2, int128.x));
             }
             break;
-#endif
         case eTypeFloat:        SetFloat (src.GetFloat (&src_offset));      break;
         case eTypeDouble:       SetDouble(src.GetDouble (&src_offset));     break;
         case eTypeLongDouble:   SetFloat (src.GetLongDouble (&src_offset)); break;
         case eTypeBytes:
         {
-            m_data.buffer.length = reg_info->byte_size;
-            m_data.buffer.byte_order = src.GetByteOrder();
-            assert (m_data.buffer.length <= kMaxRegisterByteSize);
-            if (m_data.buffer.length > kMaxRegisterByteSize)
-                m_data.buffer.length = kMaxRegisterByteSize;
+            buffer.length = reg_info->byte_size;
+            buffer.byte_order = src.GetByteOrder();
+            assert (buffer.length <= kMaxRegisterByteSize);
+            if (buffer.length > kMaxRegisterByteSize)
+                buffer.length = kMaxRegisterByteSize;
             if (src.CopyByteOrderedData (src_offset,                    // offset within "src" to start extracting data
                                          src_len,                       // src length
-                                         m_data.buffer.bytes,           // dst buffer
-                                         m_data.buffer.length,          // dst length
-                                         m_data.buffer.byte_order) == 0)// dst byte order
+                                         buffer.bytes,           // dst buffer
+                                         buffer.length,          // dst length
+                                         buffer.byte_order) == 0)// dst byte order
             {
                 error.SetErrorString ("data copy failed data.");
                 return error;
@@ -459,6 +462,9 @@ RegisterValue::SetValueFromCString (cons
     }
     bool success = false;
     const uint32_t byte_size = reg_info->byte_size;
+    static float flt_val;
+    static double dbl_val;
+    static long double ldbl_val;
     switch (reg_info->encoding)
     {
         case eEncodingInvalid:
@@ -510,22 +516,31 @@ RegisterValue::SetValueFromCString (cons
         case eEncodingIEEE754:
             if (byte_size == sizeof (float))
             {
-                if (::sscanf (value_str, "%f", &m_data.ieee_float) == 1)
+                if (::sscanf (value_str, "%f", &flt_val) == 1)
+                {
+                    m_scalar = flt_val;
                     m_type = eTypeFloat;
+                }
                 else
                     error.SetErrorStringWithFormat ("'%s' is not a valid float string value", value_str);
             }
             else if (byte_size == sizeof (double))
             {
-                if (::sscanf (value_str, "%lf", &m_data.ieee_double) == 1)
+                if (::sscanf (value_str, "%lf", &dbl_val) == 1)
+                {
+                    m_scalar = dbl_val;
                     m_type = eTypeDouble;
+                }
                 else
                     error.SetErrorStringWithFormat ("'%s' is not a valid float string value", value_str);
             }
             else if (byte_size == sizeof (long double))
             {
-                if (::sscanf (value_str, "%Lf", &m_data.ieee_long_double) == 1)
+                if (::sscanf (value_str, "%Lf", &ldbl_val) == 1)
+                {
+                    m_scalar = ldbl_val;
                     m_type = eTypeLongDouble;
+                }
                 else
                     error.SetErrorStringWithFormat ("'%s' is not a valid float string value", value_str);
             }
@@ -557,81 +572,11 @@ RegisterValue::SignExtend (uint32_t sign
             break;
 
         case eTypeUInt8:        
-            if (sign_bitpos == (8-1))
-                return true;
-            else if (sign_bitpos < (8-1))
-            {
-                uint8_t sign_bit = 1u << sign_bitpos;
-                if (m_data.uint8 & sign_bit)
-                {
-                    const uint8_t mask = ~(sign_bit) + 1u;
-                    m_data.uint8 |= mask;
-                }
-                return true;
-            }
-            break;
-
         case eTypeUInt16:
-            if (sign_bitpos == (16-1))
-                return true;
-            else if (sign_bitpos < (16-1))
-            {
-                uint16_t sign_bit = 1u << sign_bitpos;
-                if (m_data.uint16 & sign_bit)
-                {
-                    const uint16_t mask = ~(sign_bit) + 1u;
-                    m_data.uint16 |= mask;
-                }
-                return true;
-            }
-            break;
-        
         case eTypeUInt32:
-            if (sign_bitpos == (32-1))
-                return true;
-            else if (sign_bitpos < (32-1))
-            {
-                uint32_t sign_bit = 1u << sign_bitpos;
-                if (m_data.uint32 & sign_bit)
-                {
-                    const uint32_t mask = ~(sign_bit) + 1u;
-                    m_data.uint32 |= mask;
-                }
-                return true;
-            }
-            break;
-
         case eTypeUInt64:
-            if (sign_bitpos == (64-1))
-                return true;
-            else if (sign_bitpos < (64-1))
-            {
-                uint64_t sign_bit = 1ull << sign_bitpos;
-                if (m_data.uint64 & sign_bit)
-                {
-                    const uint64_t mask = ~(sign_bit) + 1ull;
-                    m_data.uint64 |= mask;
-                }
-                return true;
-            }
-            break;
-
-#if defined (ENABLE_128_BIT_SUPPORT)
         case eTypeUInt128:
-            if (sign_bitpos == (128-1))
-                return true;
-            else if (sign_bitpos < (128-1))
-            {
-                __uint128_t sign_bit = (__uint128_t)1u << sign_bitpos;
-                if (m_data.uint128 & sign_bit)
-                {
-                    const uint128_t mask = ~(sign_bit) + 1u;
-                    m_data.uint128 |= mask;
-                }
-                return true;
-            }
-            break;
-#endif
+            return m_scalar.SignExtend(sign_bitpos);
         case eTypeFloat:
         case eTypeDouble:
         case eTypeLongDouble:
@@ -649,21 +594,19 @@ RegisterValue::CopyValue (const Register
     {
         case eTypeInvalid: 
             return false;
-        case eTypeUInt8:        m_data.uint8 = rhs.m_data.uint8; break;
-        case eTypeUInt16:       m_data.uint16 = rhs.m_data.uint16; break;
-        case eTypeUInt32:       m_data.uint32 = rhs.m_data.uint32; break;
-        case eTypeUInt64:       m_data.uint64 = rhs.m_data.uint64; break;
-#if defined (ENABLE_128_BIT_SUPPORT)
-        case eTypeUInt128:      m_data.uint128 = rhs.m_data.uint128; break;
-#endif
-        case eTypeFloat:        m_data.ieee_float = rhs.m_data.ieee_float; break;
-        case eTypeDouble:       m_data.ieee_double = rhs.m_data.ieee_double; break;
-        case eTypeLongDouble:   m_data.ieee_long_double = rhs.m_data.ieee_long_double; break;
+        case eTypeUInt8:
+        case eTypeUInt16:
+        case eTypeUInt32:
+        case eTypeUInt64:
+        case eTypeUInt128:
+        case eTypeFloat:
+        case eTypeDouble:
+        case eTypeLongDouble:   m_scalar = rhs.m_scalar; break;
         case eTypeBytes:        
-            assert (rhs.m_data.buffer.length <= kMaxRegisterByteSize);
-            ::memcpy (m_data.buffer.bytes, rhs.m_data.buffer.bytes, kMaxRegisterByteSize);
-            m_data.buffer.length = rhs.m_data.buffer.length;
-            m_data.buffer.byte_order = rhs.m_data.buffer.byte_order;
+            assert (rhs.buffer.length <= kMaxRegisterByteSize);
+            ::memcpy (buffer.bytes, rhs.buffer.bytes, kMaxRegisterByteSize);
+            buffer.length = rhs.buffer.length;
+            buffer.byte_order = rhs.buffer.byte_order;
             break;
     }
     return true;
@@ -678,15 +621,15 @@ RegisterValue::GetAsUInt16 (uint16_t fai
     switch (m_type)
     {
         default:            break;
-        case eTypeUInt8:    return m_data.uint8;
-        case eTypeUInt16:   return m_data.uint16;
+        case eTypeUInt8:
+        case eTypeUInt16:   return m_scalar.UShort(fail_value);
         case eTypeBytes:
         {
-            switch (m_data.buffer.length)
+            switch (buffer.length)
             {
             default:    break;
-            case 1:     return m_data.uint8;
-            case 2:     return m_data.uint16;
+            case 1:
+            case 2:     return *(const uint16_t *)buffer.bytes;
             }
         }
         break;
@@ -704,29 +647,20 @@ RegisterValue::GetAsUInt32 (uint32_t fai
     switch (m_type)
     {
         default:            break;
-        case eTypeUInt8:    return m_data.uint8;
-        case eTypeUInt16:   return m_data.uint16;
-        case eTypeUInt32:   return m_data.uint32;
+        case eTypeUInt8:
+        case eTypeUInt16:
+        case eTypeUInt32:
         case eTypeFloat:
-            if (sizeof(float) == sizeof(uint32_t))
-                return m_data.uint32;
-            break;
         case eTypeDouble:
-            if (sizeof(double) == sizeof(uint32_t))
-                return m_data.uint32;
-            break;
-        case eTypeLongDouble:
-            if (sizeof(long double) == sizeof(uint32_t))
-                return m_data.uint32;
-            break;
+        case eTypeLongDouble:   return m_scalar.UInt(fail_value);
         case eTypeBytes:
         {
-            switch (m_data.buffer.length)
+            switch (buffer.length)
             {
             default:    break;
-            case 1:     return m_data.uint8;
-            case 2:     return m_data.uint16;
-            case 4:     return m_data.uint32;
+            case 1:
+            case 2:
+            case 4:     return *(const uint32_t *)buffer.bytes;
             }
         }
         break;
@@ -744,31 +678,22 @@ RegisterValue::GetAsUInt64 (uint64_t fai
     switch (m_type)
     {
         default:            break;
-        case eTypeUInt8:    return m_data.uint8;
-        case eTypeUInt16:   return m_data.uint16;
-        case eTypeUInt32:   return m_data.uint32;
-        case eTypeUInt64:   return m_data.uint64;
+        case eTypeUInt8:
+        case eTypeUInt16:
+        case eTypeUInt32:
+        case eTypeUInt64:
         case eTypeFloat:
-            if (sizeof(float) == sizeof(uint64_t))
-                return m_data.uint64;
-            break;
         case eTypeDouble:
-            if (sizeof(double) == sizeof(uint64_t))
-                return m_data.uint64;
-            break;
-        case eTypeLongDouble:
-            if (sizeof(long double) == sizeof(uint64_t))
-                return m_data.uint64;
-            break;
+        case eTypeLongDouble: return m_scalar.ULongLong(fail_value);
         case eTypeBytes:
         {
-            switch (m_data.buffer.length)
+            switch (buffer.length)
             {
             default:    break;
-            case 1:     return m_data.uint8;
-            case 2:     return m_data.uint16;
-            case 4:     return m_data.uint32;
-            case 8:     return m_data.uint64;
+            case 1:
+            case 2:
+            case 4:
+            case 8:     return *(const uint64_t *)buffer.bytes;
             }
         }
         break;
@@ -778,43 +703,36 @@ RegisterValue::GetAsUInt64 (uint64_t fai
     return fail_value;
 }
 
-#if defined (ENABLE_128_BIT_SUPPORT)
-__uint128_t
-RegisterValue::GetAsUInt128 (__uint128_t fail_value, bool *success_ptr) const
+llvm::APInt
+RegisterValue::GetAsUInt128 (const llvm::APInt& fail_value, bool *success_ptr) const
 {
     if (success_ptr)
         *success_ptr = true;
     switch (m_type)
     {
         default:            break;
-        case eTypeUInt8:    return m_data.uint8;
-        case eTypeUInt16:   return m_data.uint16;
-        case eTypeUInt32:   return m_data.uint32;
-        case eTypeUInt64:   return m_data.uint64;
-        case eTypeUInt128:  return m_data.uint128;
+        case eTypeUInt8:
+        case eTypeUInt16:
+        case eTypeUInt32:
+        case eTypeUInt64:
+        case eTypeUInt128:
         case eTypeFloat:
-            if (sizeof(float) == sizeof(__uint128_t))
-                return m_data.uint128;
-            break;
         case eTypeDouble:
-            if (sizeof(double) == sizeof(__uint128_t))
-                return m_data.uint128;
-            break;
-        case eTypeLongDouble:
-            if (sizeof(long double) == sizeof(__uint128_t))
-                return m_data.uint128;
-            break;
+        case eTypeLongDouble:  return m_scalar.UInt128(fail_value);
         case eTypeBytes:
         {
-            switch (m_data.buffer.length)
+            switch (buffer.length)
             {
-            default:
-                break;
-            case 1:     return m_data.uint8;
-            case 2:     return m_data.uint16;
-            case 4:     return m_data.uint32;
-            case 8:     return m_data.uint64;
-            case 16:    return m_data.uint128;
+                default:
+                    break;
+                case 1:
+                case 2:
+                case 4:
+                case 8:
+                case 16:
+                {
+                    return llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)buffer.bytes)->x);
+                }
             }
         }
         break;
@@ -823,7 +741,7 @@ RegisterValue::GetAsUInt128 (__uint128_t
         *success_ptr = false;
     return fail_value;
 }
-#endif
+
 float
 RegisterValue::GetAsFloat (float fail_value, bool *success_ptr) const
 {
@@ -833,28 +751,12 @@ RegisterValue::GetAsFloat (float fail_va
     {
         default:            break;
         case eTypeUInt32:
-            if (sizeof(float) == sizeof(m_data.uint32))
-                return m_data.ieee_float;
-            break;
         case eTypeUInt64:
-            if (sizeof(float) == sizeof(m_data.uint64))
-                return m_data.ieee_float;
-            break;
-#if defined (ENABLE_128_BIT_SUPPORT)
         case eTypeUInt128:
-            if (sizeof(float) == sizeof(m_data.uint128))
-                return m_data.ieee_float;
-            break;
-#endif
-        case eTypeFloat:    return m_data.ieee_float;
+        case eTypeFloat:
         case eTypeDouble:
-            if (sizeof(float) == sizeof(double))
-                return m_data.ieee_float;
-            break;
         case eTypeLongDouble:
-            if (sizeof(float) == sizeof(long double))
-                return m_data.ieee_float;
-            break;
+            return m_scalar.Float(fail_value);
     }
     if (success_ptr)
         *success_ptr = false;
@@ -872,27 +774,12 @@ RegisterValue::GetAsDouble (double fail_
             break;
             
         case eTypeUInt32:
-            if (sizeof(double) == sizeof(m_data.uint32))
-                return m_data.ieee_double;
-            break;
-            
         case eTypeUInt64:
-            if (sizeof(double) == sizeof(m_data.uint64))
-                return m_data.ieee_double;
-            break;
-            
-#if defined (ENABLE_128_BIT_SUPPORT)
         case eTypeUInt128:
-            if (sizeof(double) == sizeof(m_data.uint128))
-                return m_data.ieee_double;
-#endif
-        case eTypeFloat:    return m_data.ieee_float;
-        case eTypeDouble:   return m_data.ieee_double;
-            
+        case eTypeFloat:
+        case eTypeDouble:
         case eTypeLongDouble:
-            if (sizeof(double) == sizeof(long double))
-                return m_data.ieee_double;
-            break;
+            return m_scalar.Double(fail_value);
     }
     if (success_ptr)
         *success_ptr = false;
@@ -910,24 +797,12 @@ RegisterValue::GetAsLongDouble (long dou
             break;
             
         case eTypeUInt32:
-            if (sizeof(long double) == sizeof(m_data.uint32))
-                return m_data.ieee_long_double;
-            break;
-            
         case eTypeUInt64:
-            if (sizeof(long double) == sizeof(m_data.uint64))
-                return m_data.ieee_long_double;
-            break;
-            
-#if defined (ENABLE_128_BIT_SUPPORT)
         case eTypeUInt128:
-            if (sizeof(long double) == sizeof(m_data.uint128))
-                return m_data.ieee_long_double;
-#endif
-        case eTypeFloat:        return m_data.ieee_float;
-        case eTypeDouble:       return m_data.ieee_double;
-        case eTypeLongDouble:   return m_data.ieee_long_double;
-            break;
+        case eTypeFloat:
+        case eTypeDouble:
+        case eTypeLongDouble:
+            return m_scalar.LongDouble();
     }
     if (success_ptr)
         *success_ptr = false;
@@ -940,17 +815,15 @@ RegisterValue::GetBytes () const
     switch (m_type)
     {
         case eTypeInvalid:      break;
-        case eTypeUInt8:        return &m_data.uint8;
-        case eTypeUInt16:       return &m_data.uint16;
-        case eTypeUInt32:       return &m_data.uint32;
-        case eTypeUInt64:       return &m_data.uint64;
-#if defined (ENABLE_128_BIT_SUPPORT)
-        case eTypeUInt128:      return &m_data.uint128;
-#endif
-        case eTypeFloat:        return &m_data.ieee_float;
-        case eTypeDouble:       return &m_data.ieee_double;
-        case eTypeLongDouble:   return &m_data.ieee_long_double;
-        case eTypeBytes:        return m_data.buffer.bytes;
+        case eTypeUInt8:
+        case eTypeUInt16:
+        case eTypeUInt32:
+        case eTypeUInt64:
+        case eTypeUInt128:
+        case eTypeFloat:
+        case eTypeDouble:
+        case eTypeLongDouble:   return m_scalar.GetBytes();
+        case eTypeBytes:        return buffer.bytes;
     }
     return NULL;
 }
@@ -961,17 +834,15 @@ RegisterValue::GetBytes ()
     switch (m_type)
     {
         case eTypeInvalid:      break;
-        case eTypeUInt8:        return &m_data.uint8;
-        case eTypeUInt16:       return &m_data.uint16;
-        case eTypeUInt32:       return &m_data.uint32;
-        case eTypeUInt64:       return &m_data.uint64;
-#if defined (ENABLE_128_BIT_SUPPORT)
-        case eTypeUInt128:      return &m_data.uint128;
-#endif
-        case eTypeFloat:        return &m_data.ieee_float;
-        case eTypeDouble:       return &m_data.ieee_double;
-        case eTypeLongDouble:   return &m_data.ieee_long_double;
-        case eTypeBytes:        return m_data.buffer.bytes;
+        case eTypeUInt8:
+        case eTypeUInt16:
+        case eTypeUInt32:
+        case eTypeUInt64:
+        case eTypeUInt128:
+        case eTypeFloat:
+        case eTypeDouble:
+        case eTypeLongDouble:   return m_scalar.GetBytes();
+        case eTypeBytes:        return buffer.bytes;
     }
     return NULL;
 }
@@ -982,17 +853,15 @@ RegisterValue::GetByteSize () const
     switch (m_type)
     {
         case eTypeInvalid: break;
-        case eTypeUInt8:        return sizeof(m_data.uint8);
-        case eTypeUInt16:       return sizeof(m_data.uint16);
-        case eTypeUInt32:       return sizeof(m_data.uint32);
-        case eTypeUInt64:       return sizeof(m_data.uint64);
-#if defined (ENABLE_128_BIT_SUPPORT)
-        case eTypeUInt128:      return sizeof(m_data.uint128);
-#endif
-        case eTypeFloat:        return sizeof(m_data.ieee_float);
-        case eTypeDouble:       return sizeof(m_data.ieee_double);
-        case eTypeLongDouble:   return sizeof(m_data.ieee_long_double);
-        case eTypeBytes: return m_data.buffer.length;
+        case eTypeUInt8:   return 1;
+        case eTypeUInt16:  return 2;
+        case eTypeUInt32:
+        case eTypeUInt64:
+        case eTypeUInt128:
+        case eTypeFloat:
+        case eTypeDouble:
+        case eTypeLongDouble: return m_scalar.GetByteSize();
+        case eTypeBytes: return buffer.length;
     }
     return 0;
 }
@@ -1021,12 +890,10 @@ RegisterValue::SetUInt (uint64_t uint, u
     {
         SetUInt64 (uint);
     }
-#if defined (ENABLE_128_BIT_SUPPORT)
     else if (byte_size <= 16)
     {
-        SetUInt128 (uint);
+        SetUInt128 (llvm::APInt(64, uint));
     }
-#endif
     else
         return false;
     return true;
@@ -1036,21 +903,21 @@ void
 RegisterValue::SetBytes (const void *bytes, size_t length, lldb::ByteOrder byte_order)
 {
     // If this assertion fires off we need to increase the size of
-    // m_data.buffer.bytes, or make it something that is allocated on
+    // buffer.bytes, or make it something that is allocated on
     // the heap. Since the data buffer is in a union, we can't make it
     // a collection class like SmallVector...
     if (bytes && length > 0)
     {
-        assert (length <= sizeof (m_data.buffer.bytes) && "Storing too many bytes in a RegisterValue.");
+        assert (length <= sizeof (buffer.bytes) && "Storing too many bytes in a RegisterValue.");
         m_type = eTypeBytes;
-        m_data.buffer.length = length;
-        memcpy (m_data.buffer.bytes, bytes, length);
-        m_data.buffer.byte_order = byte_order;
+        buffer.length = length;
+        memcpy (buffer.bytes, bytes, length);
+        buffer.byte_order = byte_order;
     }
     else
     {
         m_type = eTypeInvalid;
-        m_data.buffer.length = 0;
+        buffer.length = 0;
     }
 }
 
@@ -1063,25 +930,23 @@ RegisterValue::operator == (const Regist
         switch (m_type)
         {
             case eTypeInvalid:      return true;
-            case eTypeUInt8:        return m_data.uint8 == rhs.m_data.uint8;
-            case eTypeUInt16:       return m_data.uint16 == rhs.m_data.uint16;
-            case eTypeUInt32:       return m_data.uint32 == rhs.m_data.uint32;
-            case eTypeUInt64:       return m_data.uint64 == rhs.m_data.uint64;
-#if defined (ENABLE_128_BIT_SUPPORT)
-            case eTypeUInt128:      return m_data.uint128 == rhs.m_data.uint128;
-#endif
-            case eTypeFloat:        return m_data.ieee_float == rhs.m_data.ieee_float;
-            case eTypeDouble:       return m_data.ieee_double == rhs.m_data.ieee_double;
-            case eTypeLongDouble:   return m_data.ieee_long_double == rhs.m_data.ieee_long_double;
+            case eTypeUInt8:
+            case eTypeUInt16:
+            case eTypeUInt32:
+            case eTypeUInt64:
+            case eTypeUInt128:
+            case eTypeFloat:
+            case eTypeDouble:
+            case eTypeLongDouble:   return m_scalar == rhs.m_scalar;
             case eTypeBytes:        
-                if (m_data.buffer.length != rhs.m_data.buffer.length)
+                if (buffer.length != rhs.buffer.length)
                     return false;
                 else
                 {
-                    uint8_t length = m_data.buffer.length;
+                    uint8_t length = buffer.length;
                     if (length > kMaxRegisterByteSize)
                         length = kMaxRegisterByteSize;
-                    return memcmp (m_data.buffer.bytes, rhs.m_data.buffer.bytes, length) == 0;
+                    return memcmp (buffer.bytes, rhs.buffer.bytes, length) == 0;
                 }
                 break;
         }
@@ -1097,27 +962,25 @@ RegisterValue::operator != (const Regist
     switch (m_type)
     {
         case eTypeInvalid:      return false;
-        case eTypeUInt8:        return m_data.uint8 != rhs.m_data.uint8;
-        case eTypeUInt16:       return m_data.uint16 != rhs.m_data.uint16;
-        case eTypeUInt32:       return m_data.uint32 != rhs.m_data.uint32;
-        case eTypeUInt64:       return m_data.uint64 != rhs.m_data.uint64;
-#if defined (ENABLE_128_BIT_SUPPORT)
-        case eTypeUInt128:      return m_data.uint128 != rhs.m_data.uint128;
-#endif
-        case eTypeFloat:        return m_data.ieee_float != rhs.m_data.ieee_float;
-        case eTypeDouble:       return m_data.ieee_double != rhs.m_data.ieee_double;
-        case eTypeLongDouble:   return m_data.ieee_long_double != rhs.m_data.ieee_long_double;
+        case eTypeUInt8:
+        case eTypeUInt16:
+        case eTypeUInt32:
+        case eTypeUInt64:
+        case eTypeUInt128:
+        case eTypeFloat:
+        case eTypeDouble:
+        case eTypeLongDouble:   return m_scalar != rhs.m_scalar;
         case eTypeBytes:        
-            if (m_data.buffer.length != rhs.m_data.buffer.length)
+            if (buffer.length != rhs.buffer.length)
             {
                 return true;
             }
             else
             {
-                uint8_t length = m_data.buffer.length;
+                uint8_t length = buffer.length;
                 if (length > kMaxRegisterByteSize)
                     length = kMaxRegisterByteSize;
-                return memcmp (m_data.buffer.bytes, rhs.m_data.buffer.bytes, length) != 0;
+                return memcmp (buffer.bytes, rhs.buffer.bytes, length) != 0;
             }
             break;
     }
@@ -1132,63 +995,35 @@ RegisterValue::ClearBit (uint32_t bit)
         case eTypeInvalid:
             break;
 
-        case eTypeUInt8:        
-            if (bit < 8)
-            {
-                m_data.uint8 &= ~(1u << bit);
-                return true;
-            }
-            break;
-            
+        case eTypeUInt8:
         case eTypeUInt16:
-            if (bit < 16)
-            {
-                m_data.uint16 &= ~(1u << bit);
-                return true;
-            }
-            break;
-
         case eTypeUInt32:
-            if (bit < 32)
-            {
-                m_data.uint32 &= ~(1u << bit);
-                return true;
-            }
-            break;
-            
         case eTypeUInt64:
-            if (bit < 64)
-            {
-                m_data.uint64 &= ~(1ull << (uint64_t)bit);
-                return true;
-            }
-            break;
-#if defined (ENABLE_128_BIT_SUPPORT)
         case eTypeUInt128:
-            if (bit < 64)
+            if (bit < (GetByteSize() * 8))
             {
-                m_data.uint128 &= ~((__uint128_t)1ull << (__uint128_t)bit);
-                return true;
+                return m_scalar.ClearBit(bit);
             }
-#endif
+            break;
+
         case eTypeFloat:
         case eTypeDouble:
         case eTypeLongDouble:
             break;
 
         case eTypeBytes:
-            if (m_data.buffer.byte_order == eByteOrderBig || m_data.buffer.byte_order == eByteOrderLittle)
+            if (buffer.byte_order == eByteOrderBig || buffer.byte_order == eByteOrderLittle)
             {
                 uint32_t byte_idx;
-                if (m_data.buffer.byte_order == eByteOrderBig)
-                    byte_idx = m_data.buffer.length - (bit / 8) - 1;
+                if (buffer.byte_order == eByteOrderBig)
+                    byte_idx = buffer.length - (bit / 8) - 1;
                 else
                     byte_idx = bit / 8;
 
                 const uint32_t byte_bit = bit % 8;
-                if (byte_idx < m_data.buffer.length)
+                if (byte_idx < buffer.length)
                 {
-                    m_data.buffer.bytes[byte_idx] &= ~(1u << byte_bit);
+                    buffer.bytes[byte_idx] &= ~(1u << byte_bit);
                     return true;
                 }
             }
@@ -1207,62 +1042,34 @@ RegisterValue::SetBit (uint32_t bit)
             break;
             
         case eTypeUInt8:        
-            if (bit < 8)
-            {
-                m_data.uint8 |= (1u << bit);
-                return true;
-            }
-            break;
-            
         case eTypeUInt16:
-            if (bit < 16)
-            {
-                m_data.uint16 |= (1u << bit);
-                return true;
-            }
-            break;
-            
         case eTypeUInt32:
-            if (bit < 32)
-            {
-                m_data.uint32 |= (1u << bit);
-                return true;
-            }
-            break;
-            
         case eTypeUInt64:
-            if (bit < 64)
-            {
-                m_data.uint64 |= (1ull << (uint64_t)bit);
-                return true;
-            }
-            break;
-#if defined (ENABLE_128_BIT_SUPPORT)
         case eTypeUInt128:
-            if (bit < 64)
+            if (bit < (GetByteSize() * 8))
             {
-                m_data.uint128 |= ((__uint128_t)1ull << (__uint128_t)bit);
-                return true;
+                return m_scalar.SetBit(bit);
             }
-#endif
+            break;
+
         case eTypeFloat:
         case eTypeDouble:
         case eTypeLongDouble:
             break;
             
         case eTypeBytes:
-            if (m_data.buffer.byte_order == eByteOrderBig || m_data.buffer.byte_order == eByteOrderLittle)
+            if (buffer.byte_order == eByteOrderBig || buffer.byte_order == eByteOrderLittle)
             {
                 uint32_t byte_idx;
-                if (m_data.buffer.byte_order == eByteOrderBig)
-                    byte_idx = m_data.buffer.length - (bit / 8) - 1;
+                if (buffer.byte_order == eByteOrderBig)
+                    byte_idx = buffer.length - (bit / 8) - 1;
                 else
                     byte_idx = bit / 8;
                 
                 const uint32_t byte_bit = bit % 8;
-                if (byte_idx < m_data.buffer.length)
+                if (byte_idx < buffer.length)
                 {
-                    m_data.buffer.bytes[byte_idx] |= (1u << byte_bit);
+                    buffer.bytes[byte_idx] |= (1u << byte_bit);
                     return true;
                 }
             }

Modified: lldb/trunk/source/Core/Scalar.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Scalar.cpp?rev=245547&r1=245546&r2=245547&view=diff
==============================================================================
--- lldb/trunk/source/Core/Scalar.cpp (original)
+++ lldb/trunk/source/Core/Scalar.cpp Thu Aug 20 04:12:46 2015
@@ -11,6 +11,7 @@
 
 #include <math.h>
 #include <inttypes.h>
+#include <stdio.h>
 
 #include "lldb/Interpreter/Args.h"
 #include "lldb/Core/Error.h"
@@ -77,7 +78,7 @@ PromoteToMaxType
 //----------------------------------------------------------------------
 Scalar::Scalar() :
     m_type(e_void),
-    m_data()
+    m_float((float)0)
 {
 }
 
@@ -86,7 +87,8 @@ Scalar::Scalar() :
 //----------------------------------------------------------------------
 Scalar::Scalar(const Scalar& rhs) :
     m_type(rhs.m_type),
-    m_data(rhs.m_data)  // TODO: verify that for C++ this will correctly copy the union??
+    m_integer(rhs.m_integer),
+    m_float(rhs.m_float)
 {
 }
 
@@ -135,6 +137,8 @@ bool
 Scalar::GetData (DataExtractor &data, size_t limit_byte_size) const
 {
     size_t byte_size = GetByteSize();
+    static float f_val;
+    static double d_val;
     if (byte_size > 0)
     {
         if (limit_byte_size < byte_size)
@@ -144,20 +148,98 @@ Scalar::GetData (DataExtractor &data, si
                 // On little endian systems if we want fewer bytes from the
                 // current type we just specify fewer bytes since the LSByte
                 // is first...
-                data.SetData((uint8_t*)&m_data, limit_byte_size, lldb::endian::InlHostByteOrder());
+                switch(m_type)
+                {
+                case e_void:
+                    break;
+                case e_sint:
+                case e_uint:
+                case e_slong:
+                case e_ulong:
+                case e_slonglong:
+                case e_ulonglong:
+                case e_sint128:
+                case e_uint128:
+                    data.SetData((const uint8_t *)m_integer.getRawData(), limit_byte_size, lldb::endian::InlHostByteOrder());
+                    return true;
+                case e_float:
+                    f_val = m_float.convertToFloat();
+                    data.SetData((uint8_t *)&f_val, limit_byte_size, lldb::endian::InlHostByteOrder());
+                    return true;
+                case e_double:
+                    d_val = m_float.convertToDouble();
+                    data.SetData((uint8_t *)&d_val, limit_byte_size, lldb::endian::InlHostByteOrder());
+                    return true;
+                case e_long_double:
+                    static llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+                    data.SetData((const uint8_t *)ldbl_val.getRawData(), limit_byte_size, lldb::endian::InlHostByteOrder());
+                    return true;
+                }
             }
             else if (lldb::endian::InlHostByteOrder() == eByteOrderBig)
             {
                 // On big endian systems if we want fewer bytes from the
                 // current type have to advance our initial byte pointer and
                 // trim down the number of bytes since the MSByte is first
-                data.SetData(((uint8_t*)&m_data) + byte_size - limit_byte_size, limit_byte_size, lldb::endian::InlHostByteOrder());
+                switch(m_type)
+                {
+                case e_void:
+                    break;
+                case e_sint:
+                case e_uint:
+                case e_slong:
+                case e_ulong:
+                case e_slonglong:
+                case e_ulonglong:
+                case e_sint128:
+                case e_uint128:
+                    data.SetData((const uint8_t *)m_integer.getRawData() + byte_size - limit_byte_size, limit_byte_size, lldb::endian::InlHostByteOrder());
+                    return true;
+                case e_float:
+                    f_val = m_float.convertToFloat();
+                    data.SetData((uint8_t *)&f_val + byte_size - limit_byte_size, limit_byte_size, lldb::endian::InlHostByteOrder());
+                    return true;
+                case e_double:
+                    d_val = m_float.convertToDouble();
+                    data.SetData((uint8_t *)&d_val + byte_size - limit_byte_size, limit_byte_size, lldb::endian::InlHostByteOrder());
+                    return true;
+                case e_long_double:
+                    static llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+                    data.SetData((const uint8_t *)ldbl_val.getRawData() + byte_size - limit_byte_size, limit_byte_size, lldb::endian::InlHostByteOrder());
+                    return true;
+                }
             }
         }
         else
         {
             // We want all of the data
-            data.SetData((uint8_t*)&m_data, byte_size, lldb::endian::InlHostByteOrder());
+            switch(m_type)
+            {
+            case e_void:
+                break;
+            case e_sint:
+            case e_uint:
+            case e_slong:
+            case e_ulong:
+            case e_slonglong:
+            case e_ulonglong:
+            case e_sint128:
+            case e_uint128:
+                data.SetData((const uint8_t *)m_integer.getRawData(), byte_size, lldb::endian::InlHostByteOrder());
+                return true;
+            case e_float:
+                f_val = m_float.convertToFloat();
+                data.SetData((uint8_t *)&f_val, byte_size, lldb::endian::InlHostByteOrder());
+                return true;
+            case e_double:
+                d_val = m_float.convertToDouble();
+                data.SetData((uint8_t *)&d_val, byte_size, lldb::endian::InlHostByteOrder());
+                return true;
+            case e_long_double:
+                static llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+                data.SetData((const uint8_t *)ldbl_val.getRawData(), byte_size, lldb::endian::InlHostByteOrder());
+                return true;
+            }
         }
         return true;
     }
@@ -165,6 +247,37 @@ Scalar::GetData (DataExtractor &data, si
     return false;
 }
 
+void *
+Scalar::GetBytes() const
+{
+    static float_t flt_val;
+    static double_t dbl_val;
+    switch (m_type)
+    {
+    case e_void:
+        break;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        return (void *)m_integer.getRawData();
+    case e_float:
+        flt_val = m_float.convertToFloat();
+        return (void *)&flt_val;
+    case e_double:
+        dbl_val = m_float.convertToDouble();
+        return (void *)&dbl_val;
+    case e_long_double:
+        llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+        return (void *)ldbl_val.getRawData();
+    }
+    return NULL;
+}
+
 size_t
 Scalar::GetByteSize() const
 {
@@ -172,15 +285,17 @@ Scalar::GetByteSize() const
     {
     case e_void:
         break;
-    case e_sint:        return sizeof(m_data.sint);
-    case e_uint:        return sizeof(m_data.uint);
-    case e_slong:       return sizeof(m_data.slong);
-    case e_ulong:       return sizeof(m_data.ulong);
-    case e_slonglong:   return sizeof(m_data.slonglong);
-    case e_ulonglong:   return sizeof(m_data.ulonglong);
-    case e_float:       return sizeof(m_data.flt);
-    case e_double:      return sizeof(m_data.dbl);
-    case e_long_double: return sizeof(m_data.ldbl);
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:      return (m_integer.getBitWidth() / 8);
+    case e_float:       return sizeof(float_t);
+    case e_double:      return sizeof(double_t);
+    case e_long_double: return sizeof(long_double_t);
     }
     return 0;
 }
@@ -188,19 +303,24 @@ Scalar::GetByteSize() const
 bool
 Scalar::IsZero() const
 {
+    llvm::APInt zero_int = llvm::APInt::getNullValue(m_integer.getBitWidth() / 8);
     switch (m_type)
     {
     case e_void:
         break;
-    case e_sint:        return m_data.sint == 0;
-    case e_uint:        return m_data.uint == 0;
-    case e_slong:       return m_data.slong == 0;
-    case e_ulong:       return m_data.ulong == 0;
-    case e_slonglong:   return m_data.slonglong == 0;
-    case e_ulonglong:   return m_data.ulonglong == 0;
-    case e_float:       return m_data.flt == 0.0f;
-    case e_double:      return m_data.dbl == 0.0;
-    case e_long_double: return m_data.ldbl == 0.0;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        return llvm::APInt::isSameValue(zero_int, m_integer);
+    case e_float:
+    case e_double:
+    case e_long_double:
+        return m_float.isZero();
     }
     return false;
 }
@@ -208,6 +328,7 @@ Scalar::IsZero() const
 void
 Scalar::GetValue (Stream *s, bool show_type) const
 {
+    const uint64_t *src;
     if (show_type)
         s->Printf("(%s) ", GetTypeAsCString());
 
@@ -215,15 +336,26 @@ Scalar::GetValue (Stream *s, bool show_t
     {
     case e_void:
         break;
-    case e_sint:        s->Printf("%i", m_data.sint);               break;
-    case e_uint:        s->Printf("0x%8.8x", m_data.uint);          break;
-    case e_slong:       s->Printf("%li", m_data.slong);             break;
-    case e_ulong:       s->Printf("0x%8.8lx", m_data.ulong);        break;
-    case e_slonglong:   s->Printf("%lli", m_data.slonglong);        break;
-    case e_ulonglong:   s->Printf("0x%16.16llx", m_data.ulonglong); break;
-    case e_float:       s->Printf("%f", m_data.flt);                break;
-    case e_double:      s->Printf("%g", m_data.dbl);                break;
-    case e_long_double: s->Printf("%Lg", m_data.ldbl);              break;
+    case e_sint:        s->Printf("%i", *(const sint_t *) m_integer.getRawData());                        break;
+    case e_uint:        s->Printf("0x%8.8x", *(const uint_t *) m_integer.getRawData());           break;
+    case e_slong:       s->Printf("%li", *(const slong_t *) m_integer.getRawData());                       break;
+    case e_ulong:       s->Printf("0x%8.8lx", *(const ulong_t *) m_integer.getRawData());         break;
+    case e_slonglong:   s->Printf("%lli", *(const slonglong_t *) m_integer.getRawData());                  break;
+    case e_ulonglong:   s->Printf("0x%16.16llx", *(const ulonglong_t *) m_integer.getRawData()); break;
+    case e_sint128:
+        src = m_integer.getRawData();
+        s->Printf("%lli%lli", *(const slonglong_t *)src, *(const slonglong_t *)(src + 1));
+        break;
+    case e_uint128:
+        src = m_integer.getRawData();
+        s->Printf("0x%16.16llx%16.16llx", *(const ulonglong_t *)src, *(const ulonglong_t *)(src + 1));
+        break;
+    case e_float:       s->Printf("%f", m_float.convertToFloat());                break;
+    case e_double:      s->Printf("%g", m_float.convertToDouble());                break;
+    case e_long_double:
+        llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+        s->Printf("%Lg", *(const long_double_t *)ldbl_val.getRawData());
+        break;
     }
 }
 
@@ -239,6 +371,8 @@ Scalar::GetTypeAsCString() const
     case e_ulong:       return "unsigned long";
     case e_slonglong:   return "long long";
     case e_ulonglong:   return "unsigned long long";
+    case e_sint128:     return "int128_t";
+    case e_uint128:     return "unsigned int128_t";
     case e_float:       return "float";
     case e_double:      return "double";
     case e_long_double: return "long double";
@@ -257,7 +391,8 @@ Scalar::operator=(const Scalar& rhs)
     if (this != &rhs)
     {
         m_type = rhs.m_type;
-        ::memcpy (&m_data, &rhs.m_data, sizeof(m_data));
+        m_integer = llvm::APInt(rhs.m_integer);
+        m_float = rhs.m_float;
     }
     return *this;
 }
@@ -266,7 +401,7 @@ Scalar&
 Scalar::operator= (const int v)
 {
     m_type = e_sint;
-    m_data.sint = v;
+    m_integer = llvm::APInt(sizeof(int) * 8, v, true);
     return *this;
 }
 
@@ -275,7 +410,7 @@ Scalar&
 Scalar::operator= (unsigned int v)
 {
     m_type = e_uint;
-    m_data.uint = v;
+    m_integer = llvm::APInt(sizeof(int) * 8, v);
     return *this;
 }
 
@@ -283,7 +418,7 @@ Scalar&
 Scalar::operator= (long v)
 {
     m_type = e_slong;
-    m_data.slong = v;
+    m_integer = llvm::APInt(sizeof(long) * 8, v, true);
     return *this;
 }
 
@@ -291,7 +426,7 @@ Scalar&
 Scalar::operator= (unsigned long v)
 {
     m_type = e_ulong;
-    m_data.ulong = v;
+    m_integer = llvm::APInt(sizeof(long) * 8, v);
     return *this;
 }
 
@@ -299,7 +434,7 @@ Scalar&
 Scalar::operator= (long long v)
 {
     m_type = e_slonglong;
-    m_data.slonglong = v;
+    m_integer = llvm::APInt(sizeof(long) * 8, v, true);
     return *this;
 }
 
@@ -307,7 +442,7 @@ Scalar&
 Scalar::operator= (unsigned long long v)
 {
     m_type = e_ulonglong;
-    m_data.ulonglong = v;
+    m_integer = llvm::APInt(sizeof(long long) * 8, v);
     return *this;
 }
 
@@ -315,7 +450,7 @@ Scalar&
 Scalar::operator= (float v)
 {
     m_type = e_float;
-    m_data.flt = v;
+    m_float = llvm::APFloat(v);
     return *this;
 }
 
@@ -323,7 +458,7 @@ Scalar&
 Scalar::operator= (double v)
 {
     m_type = e_double;
-    m_data.dbl = v;
+    m_float = llvm::APFloat(v);
     return *this;
 }
 
@@ -331,7 +466,40 @@ Scalar&
 Scalar::operator= (long double v)
 {
     m_type = e_long_double;
-    m_data.ldbl = v;
+    if(m_ieee_quad)
+        m_float = llvm::APFloat(llvm::APFloat::IEEEquad, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x));
+    else
+        m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x));
+    return *this;
+}
+
+Scalar&
+Scalar::operator= (llvm::APInt rhs)
+{
+    m_integer = llvm::APInt(rhs);
+    switch(m_integer.getBitWidth())
+    {
+        case 8:
+        case 16:
+        case 32:
+            if(m_integer.isSignedIntN(sizeof(sint_t) * 8))
+                m_type = e_sint;
+            else
+                m_type = e_uint;
+            break;
+        case 64:
+            if(m_integer.isSignedIntN(sizeof(slonglong_t) * 8))
+                m_type = e_slonglong;
+            else
+                m_type = e_ulonglong;
+            break;
+        case 128:
+            if(m_integer.isSignedIntN(BITWIDTH_INT128))
+                m_type = e_sint128;
+            else
+                m_type = e_uint128;
+            break;
+    }
     return *this;
 }
 
@@ -354,128 +522,455 @@ Scalar::Promote(Scalar::Type type)
     case e_sint:
         switch (type)
         {
-        case e_void:        break;
-        case e_sint:        success = true; break;
-        case e_uint:        m_data.uint         = m_data.sint;      success = true; break;
-        case e_slong:       m_data.slong        = m_data.sint;      success = true; break;
-        case e_ulong:       m_data.ulong        = m_data.sint;      success = true; break;
-        case e_slonglong:   m_data.slonglong    = m_data.sint;      success = true; break;
-        case e_ulonglong:   m_data.ulonglong    = m_data.sint;      success = true; break;
-        case e_float:       m_data.flt          = m_data.sint;      success = true; break;
-        case e_double:      m_data.dbl          = m_data.sint;      success = true; break;
-        case e_long_double: m_data.ldbl         = m_data.sint;      success = true; break;
+            case e_void: break;
+            case e_sint: success = true; break;
+            case e_uint:
+            {
+                m_integer = llvm::APInt(sizeof(uint_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+                success = true;
+                break;
+            }
+            case e_slong:
+            {
+                m_integer = llvm::APInt(sizeof(slong_t) * 8, *(const uint64_t *)m_integer.getRawData(), true);
+                success = true;
+                break;
+            }
+            case e_ulong:
+            {
+                m_integer = llvm::APInt(sizeof(ulong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+                success = true;
+                break;
+            }
+            case e_slonglong:
+            {
+                m_integer = llvm::APInt(sizeof(slonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), true);
+                success = true;
+                break;
+            }
+            case e_ulonglong:
+            {
+                m_integer = llvm::APInt(sizeof(ulonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+                success = true;
+                break;
+            }
+            case e_sint128:
+            case e_uint128:
+            {
+                m_integer = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)m_integer.getRawData()));
+                success = true;
+                break;
+            }
+            case e_float:
+            {
+                m_float = llvm::APFloat(m_integer.bitsToFloat());
+                success = true;
+                break;
+            }
+            case e_double:
+            {
+                m_float = llvm::APFloat(m_integer.bitsToDouble());
+                success = true;
+                break;
+            }
+            case e_long_double:
+            {
+                if(m_ieee_quad)
+                    m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_integer);
+                else
+                    m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_integer);
+                success = true;
+                break;
+            }
         }
         break;
 
     case e_uint:
         switch (type)
         {
-        case e_void:
-        case e_sint:        break;
-        case e_uint:        success = true; break;
-        case e_slong:       m_data.slong        = m_data.uint;      success = true; break;
-        case e_ulong:       m_data.ulong        = m_data.uint;      success = true; break;
-        case e_slonglong:   m_data.slonglong    = m_data.uint;      success = true; break;
-        case e_ulonglong:   m_data.ulonglong    = m_data.uint;      success = true; break;
-        case e_float:       m_data.flt          = m_data.uint;      success = true; break;
-        case e_double:      m_data.dbl          = m_data.uint;      success = true; break;
-        case e_long_double: m_data.ldbl         = m_data.uint;      success = true; break;
+             case e_void:
+             case e_sint:     break;
+             case e_uint:     success = true; break;
+             case e_slong:
+             {
+                 m_integer = llvm::APInt(sizeof(slong_t) * 8, *(const uint64_t *)m_integer.getRawData(), true);
+                 success = true;
+                 break;
+             }
+             case e_ulong:
+             {
+                 m_integer = llvm::APInt(sizeof(ulong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+                 success = true;
+                 break;
+             }
+             case e_slonglong:
+             {
+                 m_integer = llvm::APInt(sizeof(slonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), true);
+                 success = true;
+                 break;
+             }
+             case e_ulonglong:
+             {
+                 m_integer = llvm::APInt(sizeof(ulonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+                 success = true;
+                 break;
+             }
+             case e_sint128:
+             case e_uint128:
+             {
+                 m_integer = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)m_integer.getRawData()));
+                 success = true;
+                 break;
+             }
+             case e_float:
+             {
+                 m_float = llvm::APFloat(m_integer.bitsToFloat());
+                 success = true;
+                 break;
+             }
+             case e_double:
+             {
+                 m_float = llvm::APFloat(m_integer.bitsToDouble());
+                 success = true;
+                 break;
+             }
+             case e_long_double:
+             {
+                 if(m_ieee_quad)
+                     m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_integer);
+                 else
+                     m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_integer);
+                 success = true;
+                 break;
+             }
         }
         break;
 
     case e_slong:
         switch (type)
         {
-        case e_void:
-        case e_sint:
-        case e_uint:        break;
-        case e_slong:       success = true; break;
-        case e_ulong:       m_data.ulong        = m_data.slong;     success = true; break;
-        case e_slonglong:   m_data.slonglong    = m_data.slong;     success = true; break;
-        case e_ulonglong:   m_data.ulonglong    = m_data.slong;     success = true; break;
-        case e_float:       m_data.flt          = m_data.slong;     success = true; break;
-        case e_double:      m_data.dbl          = m_data.slong;     success = true; break;
-        case e_long_double: m_data.ldbl         = m_data.slong;     success = true; break;
+             case e_void:
+             case e_sint:
+             case e_uint:    break;
+             case e_slong:   success = true; break;
+             case e_ulong:
+             {
+                 m_integer = llvm::APInt(sizeof(ulong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+                 success = true;
+                 break;
+             }
+             case e_slonglong:
+             {
+                 m_integer = llvm::APInt(sizeof(slonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), true);
+                 success = true;
+                 break;
+             }
+             case e_ulonglong:
+             {
+                 m_integer = llvm::APInt(sizeof(ulonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+                 success = true;
+                 break;
+             }
+             case e_sint128:
+             case e_uint128:
+             {
+                 m_integer = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)m_integer.getRawData()));
+                 success = true;
+                 break;
+             }
+             case e_float:
+             {
+                 m_float = llvm::APFloat(m_integer.bitsToFloat());
+                 success = true;
+                 break;
+             }
+             case e_double:
+             {
+                 m_float = llvm::APFloat(m_integer.bitsToDouble());
+                 success = true;
+                 break;
+             }
+             case e_long_double:
+             {
+                 if(m_ieee_quad)
+                     m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_integer);
+                 else
+                     m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_integer);
+                 success = true;
+                 break;
+             }
         }
         break;
 
     case e_ulong:
         switch (type)
         {
-        case e_void:
-        case e_sint:
-        case e_uint:
-        case e_slong:       break;
-        case e_ulong:       success = true; break;
-        case e_slonglong:   m_data.slonglong    = m_data.ulong;     success = true; break;
-        case e_ulonglong:   m_data.ulonglong    = m_data.ulong;     success = true; break;
-        case e_float:       m_data.flt          = m_data.ulong;     success = true; break;
-        case e_double:      m_data.dbl          = m_data.ulong;     success = true; break;
-        case e_long_double: m_data.ldbl         = m_data.ulong;     success = true; break;
+             case e_void:
+             case e_sint:
+             case e_uint:
+             case e_slong:    break;
+             case e_ulong:    success = true; break;
+             case e_slonglong:
+             {
+                 m_integer = llvm::APInt(sizeof(slonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), true);
+                 success = true;
+                 break;
+             }
+             case e_ulonglong:
+             {
+                 m_integer = llvm::APInt(sizeof(ulonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+                 success = true;
+                 break;
+             }
+             case e_sint128:
+             case e_uint128:
+             {
+                 m_integer = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)m_integer.getRawData()));
+                 success = true;
+                 break;
+             }
+             case e_float:
+             {
+                 m_float = llvm::APFloat(m_integer.bitsToFloat());
+                 success = true;
+                 break;
+             }
+             case e_double:
+             {
+                 m_float = llvm::APFloat(m_integer.bitsToDouble());
+                 success = true;
+                 break;
+             }
+             case e_long_double:
+             {
+                 if(m_ieee_quad)
+                     m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_integer);
+                 else
+                     m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_integer);
+                 success = true;
+                 break;
+             }
         }
         break;
 
     case e_slonglong:
         switch (type)
         {
-        case e_void:
-        case e_sint:
-        case e_uint:
-        case e_slong:
-        case e_ulong:       break;
-        case e_slonglong:   success = true; break;
-        case e_ulonglong:   m_data.ulonglong    = m_data.slonglong;     success = true; break;
-        case e_float:       m_data.flt          = m_data.slonglong;     success = true; break;
-        case e_double:      m_data.dbl          = m_data.slonglong;     success = true; break;
-        case e_long_double: m_data.ldbl         = m_data.slonglong;     success = true; break;
+             case e_void:
+             case e_sint:
+             case e_uint:
+             case e_slong:
+             case e_ulong:        break;
+             case e_slonglong:    success = true; break;
+             case e_ulonglong:
+             {
+                 m_integer = llvm::APInt(sizeof(ulonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+                 success = true;
+                 break;
+             }
+             case e_sint128:
+             case e_uint128:
+             {
+                 m_integer = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)m_integer.getRawData()));
+                 success = true;
+                 break;
+             }
+             case e_float:
+             {
+                 m_float = llvm::APFloat(m_integer.bitsToFloat());
+                 success = true;
+                 break;
+             }
+             case e_double:
+             {
+                 m_float = llvm::APFloat(m_integer.bitsToDouble());
+                 success = true;
+                 break;
+             }
+             case e_long_double:
+             {
+                 if(m_ieee_quad)
+                     m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_integer);
+                 else
+                     m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_integer);
+                 success = true;
+                 break;
+             }
         }
         break;
 
     case e_ulonglong:
         switch (type)
         {
-        case e_void:
-        case e_sint:
-        case e_uint:
-        case e_slong:
-        case e_ulong:
-        case e_slonglong:   break;
-        case e_ulonglong:   success = true; break;
-        case e_float:       m_data.flt          = m_data.ulonglong;     success = true; break;
-        case e_double:      m_data.dbl          = m_data.ulonglong;     success = true; break;
-        case e_long_double: m_data.ldbl         = m_data.ulonglong;     success = true; break;
+             case e_void:
+             case e_sint:
+             case e_uint:
+             case e_slong:
+             case e_ulong:
+             case e_slonglong:    break;
+             case e_ulonglong:    success = true; break;
+             case e_sint128:
+             case e_uint128:
+             {
+                 m_integer = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)m_integer.getRawData()));
+                 success = true;
+                 break;
+             }
+             case e_float:
+             {
+                 m_float = llvm::APFloat(m_integer.bitsToFloat());
+                 success = true;
+                 break;
+             }
+             case e_double:
+             {
+                 m_float = llvm::APFloat(m_integer.bitsToDouble());
+                 success = true;
+                 break;
+             }
+             case e_long_double:
+             {
+                 if(m_ieee_quad)
+                     m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_integer);
+                 else
+                     m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_integer);
+                 success = true;
+                 break;
+             }
+        }
+        break;
+
+    case e_sint128:
+        switch (type)
+        {
+             case e_void:
+             case e_sint:
+             case e_uint:
+             case e_slong:
+             case e_ulong:
+             case e_slonglong:
+             case e_ulonglong:   break;
+             case e_sint128:     success = true; break;
+             case e_uint128:
+             {
+                 m_integer = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)m_integer.getRawData()));
+                 success = true;
+                 break;
+             }
+             case e_float:
+             {
+                 m_float = llvm::APFloat(m_integer.bitsToFloat());
+                 success = true;
+                 break;
+             }
+             case e_double:
+             {
+                 m_float = llvm::APFloat(m_integer.bitsToDouble());
+                 success = true;
+                 break;
+             }
+             case e_long_double:
+             {
+                 if(m_ieee_quad)
+                     m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_integer);
+                 else
+                     m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_integer);
+                 success = true;
+                 break;
+             }
+        }
+        break;
+
+    case e_uint128:
+        switch (type)
+        {
+             case e_void:
+             case e_sint:
+             case e_uint:
+             case e_slong:
+             case e_ulong:
+             case e_slonglong:
+             case e_ulonglong:
+             case e_sint128:    break;
+             case e_uint128:    success = true; break;
+             case e_float:
+             {
+                 m_float = llvm::APFloat(m_integer.bitsToFloat());
+                 success = true;
+                 break;
+             }
+             case e_double:
+             {
+                 m_float = llvm::APFloat(m_integer.bitsToDouble());
+                 success = true;
+                 break;
+             }
+             case e_long_double:
+             {
+                 if(m_ieee_quad)
+                     m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_integer);
+                 else
+                     m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_integer);
+                 success = true;
+                 break;
+             }
         }
         break;
 
     case e_float:
         switch (type)
         {
-        case e_void:
-        case e_sint:
-        case e_uint:
-        case e_slong:
-        case e_ulong:
-        case e_slonglong:
-        case e_ulonglong:   break;
-        case e_float:       success = true; break;
-        case e_double:      m_data.dbl          = m_data.flt;           success = true; break;
-        case e_long_double: m_data.ldbl         = m_data.ulonglong;     success = true; break;
+             case e_void:
+             case e_sint:
+             case e_uint:
+             case e_slong:
+             case e_ulong:
+             case e_slonglong:
+             case e_ulonglong:
+             case e_sint128:
+             case e_uint128:    break;
+             case e_float:      success = true; break;
+             case e_double:
+             {
+                 m_float = llvm::APFloat((float_t)m_float.convertToFloat());
+                 success = true;
+                 break;
+             }
+             case e_long_double:
+             {
+                 if(m_ieee_quad)
+                     m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_float.bitcastToAPInt());
+                 else
+                     m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_float.bitcastToAPInt());
+                 success = true;
+                 break;
+             }
         }
         break;
 
     case e_double:
         switch (type)
         {
-        case e_void:
-        case e_sint:
-        case e_uint:
-        case e_slong:
-        case e_ulong:
-        case e_slonglong:
-        case e_ulonglong:
-        case e_float:       break;
-        case e_double:      success = true; break;
-        case e_long_double: m_data.ldbl         = m_data.dbl;       success = true; break;
+             case e_void:
+             case e_sint:
+             case e_uint:
+             case e_slong:
+             case e_ulong:
+             case e_slonglong:
+             case e_ulonglong:
+             case e_sint128:
+             case e_uint128:
+             case e_float:      break;
+             case e_double:     success = true; break;
+             case e_long_double:
+             {
+                 if(m_ieee_quad)
+                     m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_float.bitcastToAPInt());
+                 else
+                     m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_float.bitcastToAPInt());
+                 success = true;
+                 break;
+             }
         }
         break;
 
@@ -489,6 +984,8 @@ Scalar::Promote(Scalar::Type type)
         case e_ulong:
         case e_slonglong:
         case e_ulonglong:
+        case e_sint128:
+        case e_uint128:
         case e_float:
         case e_double:      break;
         case e_long_double: success = true; break;
@@ -516,6 +1013,8 @@ Scalar::GetValueTypeAsCString (Scalar::T
     case e_float:       return "float";
     case e_double:      return "double";
     case e_long_double: return "long double";
+    case e_sint128:     return "int128_t";
+    case e_uint128:     return "uint128_t";
     }
     return "???";
 }
@@ -567,145 +1066,198 @@ Scalar::Cast(Scalar::Type type)
         break;
 
     case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
         switch (type)
         {
-        case e_void:        break;
-        case e_sint:        success = true; break;
-        case e_uint:        m_data.uint         = m_data.sint;      success = true; break;
-        case e_slong:       m_data.slong        = m_data.sint;      success = true; break;
-        case e_ulong:       m_data.ulong        = m_data.sint;      success = true; break;
-        case e_slonglong:   m_data.slonglong    = m_data.sint;      success = true; break;
-        case e_ulonglong:   m_data.ulonglong    = m_data.sint;      success = true; break;
-        case e_float:       m_data.flt          = m_data.sint;      success = true; break;
-        case e_double:      m_data.dbl          = m_data.sint;      success = true; break;
-        case e_long_double: m_data.ldbl         = m_data.sint;      success = true; break;
+             case e_void:        break;
+             case e_sint:
+             {
+                 m_integer = m_integer.sextOrTrunc(sizeof(sint_t) * 8);
+                 success = true;
+                 break;
+             }
+             case e_uint:
+             {
+                 m_integer = m_integer.zextOrTrunc(sizeof(sint_t) * 8);
+                 success = true;
+                 break;
+             }
+             case e_slong:
+             {
+                 m_integer = m_integer.sextOrTrunc(sizeof(slong_t) * 8);
+                 success = true;
+                 break;
+             }
+             case e_ulong:
+             {
+                 m_integer = m_integer.zextOrTrunc(sizeof(slong_t) * 8);
+                 success = true;
+                 break;
+             }
+             case e_slonglong:
+             {
+                 m_integer = m_integer.sextOrTrunc(sizeof(slonglong_t) * 8);
+                 success = true;
+                 break;
+             }
+             case e_ulonglong:
+             {
+                 m_integer = m_integer.zextOrTrunc(sizeof(slonglong_t) * 8);
+                 success = true;
+                 break;
+             }
+             case e_sint128:
+             {
+                 m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128);
+                 success = true;
+                 break;
+             }
+             case e_uint128:
+             {
+                 m_integer = m_integer.zextOrTrunc(BITWIDTH_INT128);
+                 success = true;
+                 break;
+             }
+             case e_float:
+             {
+                 m_float = llvm::APFloat(m_integer.bitsToFloat());
+                 success = true;
+                 break;
+             }
+             case e_double:
+             {
+                 m_float = llvm::APFloat(m_integer.bitsToDouble());
+                 success = true;
+                 break;
+             }
+             case e_long_double:
+             {
+                 if(m_ieee_quad)
+                     m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_integer);
+                 else
+                     m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_integer);
+                 success = true;
+                 break;
+             }
         }
         break;
 
-    case e_uint:
+    case e_float:
         switch (type)
         {
-        case e_void:
-        case e_sint:        m_data.sint         = m_data.uint;      success = true; break;
-        case e_uint:        success = true; break;
-        case e_slong:       m_data.slong        = m_data.uint;      success = true; break;
-        case e_ulong:       m_data.ulong        = m_data.uint;      success = true; break;
-        case e_slonglong:   m_data.slonglong    = m_data.uint;      success = true; break;
-        case e_ulonglong:   m_data.ulonglong    = m_data.uint;      success = true; break;
-        case e_float:       m_data.flt          = m_data.uint;      success = true; break;
-        case e_double:      m_data.dbl          = m_data.uint;      success = true; break;
-        case e_long_double: m_data.ldbl         = m_data.uint;      success = true; break;
+        case e_void: break;
+        case e_sint:
+        case e_uint:
+        case e_slong:
+        case e_ulong:
+        case e_slonglong:
+        case e_ulonglong:
+        case e_sint128:
+        case e_uint128:     m_integer = m_float.bitcastToAPInt();         success = true; break;
+        case e_float:       m_float = llvm::APFloat(m_float.convertToFloat());         success = true; break;
+        case e_double:      m_float = llvm::APFloat(m_float.convertToFloat());         success = true; break;
+        case e_long_double:
+            if(m_ieee_quad)
+                m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_float.bitcastToAPInt());
+            else
+                m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_float.bitcastToAPInt());
+            success = true;
+            break;
         }
         break;
 
-    case e_slong:
+    case e_double:
         switch (type)
         {
-        case e_void:
-        case e_sint:        m_data.sint         = (sint_t)m_data.slong;     success = true; break;
-        case e_uint:        m_data.uint         = (uint_t)m_data.slong;     success = true; break;
-        case e_slong:       success = true; break;
-        case e_ulong:       m_data.ulong        = m_data.slong;     success = true; break;
-        case e_slonglong:   m_data.slonglong    = m_data.slong;     success = true; break;
-        case e_ulonglong:   m_data.ulonglong    = m_data.slong;     success = true; break;
-        case e_float:       m_data.flt          = m_data.slong;     success = true; break;
-        case e_double:      m_data.dbl          = m_data.slong;     success = true; break;
-        case e_long_double: m_data.ldbl         = m_data.slong;     success = true; break;
+        case e_void: break;
+        case e_sint:
+        case e_uint:
+        case e_slong:
+        case e_ulong:
+        case e_slonglong:
+        case e_ulonglong:
+        case e_sint128:
+        case e_uint128:     m_integer = m_float.bitcastToAPInt();                      success = true; break;
+        case e_float:       m_float = llvm::APFloat(m_float.convertToDouble());        success = true; break;
+        case e_double:      m_float = llvm::APFloat(m_float.convertToDouble());        success = true; break;
+        case e_long_double:
+            if(m_ieee_quad)
+                m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_float.bitcastToAPInt());
+            else
+                m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_float.bitcastToAPInt());
+            success = true;
+            break;
         }
         break;
 
-    case e_ulong:
+    case e_long_double:
         switch (type)
         {
-        case e_void:
-        case e_sint:        m_data.sint         = (sint_t)m_data.ulong;     success = true; break;
-        case e_uint:        m_data.uint         = (uint_t)m_data.ulong;     success = true; break;
-        case e_slong:       m_data.slong        = m_data.ulong;     success = true; break;
-        case e_ulong:       success = true; break;
-        case e_slonglong:   m_data.slonglong    = m_data.ulong;     success = true; break;
-        case e_ulonglong:   m_data.ulonglong    = m_data.ulong;     success = true; break;
-        case e_float:       m_data.flt          = m_data.ulong;     success = true; break;
-        case e_double:      m_data.dbl          = m_data.ulong;     success = true; break;
-        case e_long_double: m_data.ldbl         = m_data.ulong;     success = true; break;
+        case e_void: break;
+        case e_sint:
+        {
+            m_integer = m_float.bitcastToAPInt();
+            m_integer = m_integer.sextOrTrunc(sizeof(sint_t) * 8);
+            success = true;
+            break;
         }
-        break;
-
-    case e_slonglong:
-        switch (type)
+        case e_uint:
         {
-        case e_void:
-        case e_sint:        m_data.sint         = (sint_t)m_data.slonglong;     success = true; break;
-        case e_uint:        m_data.uint         = (uint_t)m_data.slonglong;     success = true; break;
-        case e_slong:       m_data.slong        = m_data.slonglong;     success = true; break;
-        case e_ulong:       m_data.ulong        = m_data.slonglong;     success = true; break;
-        case e_slonglong:   success = true; break;
-        case e_ulonglong:   m_data.ulonglong    = m_data.slonglong;     success = true; break;
-        case e_float:       m_data.flt          = m_data.slonglong;     success = true; break;
-        case e_double:      m_data.dbl          = m_data.slonglong;     success = true; break;
-        case e_long_double: m_data.ldbl         = m_data.slonglong;     success = true; break;
+            m_integer = m_float.bitcastToAPInt();
+            m_integer = m_integer.zextOrTrunc(sizeof(sint_t) * 8);
+            success = true;
+            break;
         }
-        break;
-
-    case e_ulonglong:
-        switch (type)
+        case e_slong:
         {
-        case e_void:
-        case e_sint:        m_data.sint         = (sint_t)m_data.ulonglong;     success = true; break;
-        case e_uint:        m_data.uint         = (uint_t)m_data.ulonglong;     success = true; break;
-        case e_slong:       m_data.slong        = m_data.ulonglong;     success = true; break;
-        case e_ulong:       m_data.ulong        = m_data.ulonglong;     success = true; break;
-        case e_slonglong:   m_data.slonglong    = m_data.ulonglong;     success = true; break;
-        case e_ulonglong:   success = true; break;
-        case e_float:       m_data.flt          = m_data.ulonglong;     success = true; break;
-        case e_double:      m_data.dbl          = m_data.ulonglong;     success = true; break;
-        case e_long_double: m_data.ldbl         = m_data.ulonglong;     success = true; break;
+            m_integer = m_float.bitcastToAPInt();
+            m_integer = m_integer.sextOrTrunc(sizeof(slong_t) * 8);
+            success = true;
+            break;
         }
-        break;
-
-    case e_float:
-        switch (type)
+        case e_ulong:
         {
-        case e_void:
-        case e_sint:        m_data.sint         = (sint_t)m_data.flt;       success = true; break;
-        case e_uint:        m_data.uint         = (uint_t)m_data.flt;       success = true; break;
-        case e_slong:       m_data.slong        = (slong_t)m_data.flt;      success = true; break;
-        case e_ulong:       m_data.ulong        = (ulong_t)m_data.flt;      success = true; break;
-        case e_slonglong:   m_data.slonglong    = (slonglong_t)m_data.flt;  success = true; break;
-        case e_ulonglong:   m_data.ulonglong    = (ulonglong_t)m_data.flt;  success = true; break;
-        case e_float:       success = true; break;
-        case e_double:      m_data.dbl          = m_data.flt;               success = true; break;
-        case e_long_double: m_data.ldbl         = m_data.flt;               success = true; break;
+            m_integer = m_float.bitcastToAPInt();
+            m_integer = m_integer.zextOrTrunc(sizeof(slong_t) * 8);
+            success = true;
+            break;
         }
-        break;
-
-    case e_double:
-        switch (type)
+        case e_slonglong:
         {
-        case e_void:
-        case e_sint:        m_data.sint         = (sint_t)m_data.dbl;       success = true; break;
-        case e_uint:        m_data.uint         = (uint_t)m_data.dbl;       success = true; break;
-        case e_slong:       m_data.slong        = (slong_t)m_data.dbl;      success = true; break;
-        case e_ulong:       m_data.ulong        = (ulong_t)m_data.dbl;      success = true; break;
-        case e_slonglong:   m_data.slonglong    = (slonglong_t)m_data.dbl;  success = true; break;
-        case e_ulonglong:   m_data.ulonglong    = (ulonglong_t)m_data.dbl;  success = true; break;
-        case e_float:       m_data.flt          = (float_t)m_data.dbl;      success = true; break;
-        case e_double:      success = true; break;
-        case e_long_double: m_data.ldbl         = m_data.dbl;               success = true; break;
+            m_integer = m_float.bitcastToAPInt();
+            m_integer = m_integer.sextOrTrunc(sizeof(slonglong_t) * 8);
+            success = true;
+            break;
         }
-        break;
-
-    case e_long_double:
-        switch (type)
+        case e_ulonglong:
         {
-        case e_void:
-        case e_sint:        m_data.sint         = (sint_t)m_data.ldbl;      success = true; break;
-        case e_uint:        m_data.uint         = (uint_t)m_data.ldbl;      success = true; break;
-        case e_slong:       m_data.slong        = (slong_t)m_data.ldbl;     success = true; break;
-        case e_ulong:       m_data.ulong        = (ulong_t)m_data.ldbl;     success = true; break;
-        case e_slonglong:   m_data.slonglong    = (slonglong_t)m_data.ldbl; success = true; break;
-        case e_ulonglong:   m_data.ulonglong    = (ulonglong_t)m_data.ldbl; success = true; break;
-        case e_float:       m_data.flt          = (float_t)m_data.ldbl;     success = true; break;
-        case e_double:      m_data.dbl          = (double_t)m_data.ldbl;    success = true; break;
+            m_integer = m_float.bitcastToAPInt();
+            m_integer = m_integer.zextOrTrunc(sizeof(slonglong_t) * 8);
+            success = true;
+            break;
+        }
+        case e_sint128:
+        {
+            m_integer = m_float.bitcastToAPInt();
+            m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128);
+            success = true;
+            break;
+        }
+        case e_uint128:
+        {
+            m_integer = m_float.bitcastToAPInt();
+            m_integer = m_integer.zextOrTrunc(BITWIDTH_INT128);
+            success = true;
+            break;
+        }
+        case e_float:       m_float = llvm::APFloat(m_float.convertToFloat());     success = true; break;
+        case e_double:      m_float = llvm::APFloat(m_float.convertToFloat());    success = true; break;
         case e_long_double: success = true; break;
         }
         break;
@@ -730,6 +1282,8 @@ Scalar::MakeSigned ()
     case e_ulong:       m_type = e_slong;       success = true; break;
     case e_slonglong:                           success = true; break;
     case e_ulonglong:   m_type = e_slonglong;   success = true; break;
+    case e_sint128:                             success = true; break;
+    case e_uint128:     m_type = e_sint;        success = true; break;
     case e_float:                               success = true; break;
     case e_double:                              success = true; break;
     case e_long_double:                         success = true; break;
@@ -738,131 +1292,241 @@ Scalar::MakeSigned ()
     return success;
 }
 
-int
-Scalar::SInt(int fail_value) const
+char
+Scalar::SChar(char fail_value) const
 {
     switch (m_type)
     {
     case e_void:        break;
-    case e_sint:        return m_data.sint;
-    case e_uint:        return (int)m_data.uint;
-    case e_slong:       return (int)m_data.slong;
-    case e_ulong:       return (int)m_data.ulong;
-    case e_slonglong:   return (int)m_data.slonglong;
-    case e_ulonglong:   return (int)m_data.ulonglong;
-    case e_float:       return (int)m_data.flt;
-    case e_double:      return (int)m_data.dbl;
-    case e_long_double: return (int)m_data.ldbl;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        return *(const schar_t *)(m_integer.sextOrTrunc(sizeof(schar_t) * 8)).getRawData();
+    case e_float:
+        return (schar_t)m_float.convertToFloat();
+    case e_double:
+        return (schar_t)m_float.convertToDouble();
+    case e_long_double:
+        llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+        return (schar_t)*ldbl_val.getRawData();
     }
     return fail_value;
 }
 
-unsigned int
-Scalar::UInt(unsigned int fail_value) const
+unsigned char
+Scalar::UChar(unsigned char fail_value) const
 {
     switch (m_type)
     {
     case e_void:        break;
-    case e_sint:        return (unsigned int)m_data.sint;
-    case e_uint:        return (unsigned int)m_data.uint;
-    case e_slong:       return (unsigned int)m_data.slong;
-    case e_ulong:       return (unsigned int)m_data.ulong;
-    case e_slonglong:   return (unsigned int)m_data.slonglong;
-    case e_ulonglong:   return (unsigned int)m_data.ulonglong;
-    case e_float:       return (unsigned int)m_data.flt;
-    case e_double:      return (unsigned int)m_data.dbl;
-    case e_long_double: return (unsigned int)m_data.ldbl;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        return *(const uchar_t *)m_integer.getRawData();
+    case e_float:
+        return (uchar_t)m_float.convertToFloat();
+    case e_double:
+        return (uchar_t)m_float.convertToDouble();
+    case e_long_double:
+        llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+        return (uchar_t)*ldbl_val.getRawData();
     }
     return fail_value;
 }
 
-
-long
-Scalar::SLong(long fail_value) const
+short
+Scalar::SShort(short fail_value) const
 {
     switch (m_type)
     {
     case e_void:        break;
-    case e_sint:        return (long)m_data.sint;
-    case e_uint:        return (long)m_data.uint;
-    case e_slong:       return (long)m_data.slong;
-    case e_ulong:       return (long)m_data.ulong;
-    case e_slonglong:   return (long)m_data.slonglong;
-    case e_ulonglong:   return (long)m_data.ulonglong;
-    case e_float:       return (long)m_data.flt;
-    case e_double:      return (long)m_data.dbl;
-    case e_long_double: return (long)m_data.ldbl;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        return *(const sshort_t *)(m_integer.sextOrTrunc(sizeof(sshort_t) * 8)).getRawData();
+    case e_float:
+        return (sshort_t)m_float.convertToFloat();
+    case e_double:
+        return (sshort_t)m_float.convertToDouble();
+    case e_long_double:
+        llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+        return *(const sshort_t *)ldbl_val.getRawData();
     }
     return fail_value;
 }
 
-
-
-unsigned long
-Scalar::ULong(unsigned long fail_value) const
+unsigned short
+Scalar::UShort(unsigned short fail_value) const
 {
     switch (m_type)
     {
     case e_void:        break;
-    case e_sint:        return (unsigned long)m_data.sint;
-    case e_uint:        return (unsigned long)m_data.uint;
-    case e_slong:       return (unsigned long)m_data.slong;
-    case e_ulong:       return (unsigned long)m_data.ulong;
-    case e_slonglong:   return (unsigned long)m_data.slonglong;
-    case e_ulonglong:   return (unsigned long)m_data.ulonglong;
-    case e_float:       return (unsigned long)m_data.flt;
-    case e_double:      return (unsigned long)m_data.dbl;
-    case e_long_double: return (unsigned long)m_data.ldbl;
-    }
-    return fail_value;
-}
-
-uint64_t
-Scalar::GetRawBits64(uint64_t fail_value) const
-{
-    switch (m_type)
-    {
-    case e_void:
-        break;
-
     case e_sint:
     case e_uint:
-        return m_data.uint;
-
     case e_slong:
     case e_ulong:
-        return m_data.ulong;
-
     case e_slonglong:
     case e_ulonglong:
-        return m_data.ulonglong;
-
+    case e_sint128:
+    case e_uint128:
+        return *(const ushort_t *)m_integer.getRawData();
     case e_float:
-        if (sizeof(m_data.flt) == sizeof(m_data.uint))
-            return m_data.uint;
-        else if (sizeof(m_data.flt) == sizeof(m_data.ulong))
-            return m_data.ulong;
-        else if (sizeof(m_data.flt) == sizeof(m_data.ulonglong))
-            return m_data.ulonglong;
-        break;
+        return (ushort_t)m_float.convertToFloat();
+    case e_double:
+        return (ushort_t)m_float.convertToDouble();
+    case e_long_double:
+        llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+        return *(const ushort_t *)ldbl_val.getRawData();;
+    }
+    return fail_value;
+}
 
+int
+Scalar::SInt(int fail_value) const
+{
+    switch (m_type)
+    {
+    case e_void:        break;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        return *(const sint_t *)(m_integer.sextOrTrunc(sizeof(sint_t) * 8)).getRawData();
+    case e_float:
+        return (sint_t)m_float.convertToFloat();
     case e_double:
-        if (sizeof(m_data.dbl) == sizeof(m_data.uint))
-            return m_data.uint;
-        else if (sizeof(m_data.dbl) == sizeof(m_data.ulong))
-            return m_data.ulong;
-        else if (sizeof(m_data.dbl) == sizeof(m_data.ulonglong))
-            return m_data.ulonglong;
-        break;
+        return (sint_t)m_float.convertToDouble();
+    case e_long_double:
+        llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+        return *(const sint_t *)ldbl_val.getRawData();
+    }
+    return fail_value;
+}
+
+unsigned int
+Scalar::UInt(unsigned int fail_value) const
+{
+    switch (m_type)
+    {
+    case e_void:        break;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        return *(const uint_t *)m_integer.getRawData();
+    case e_float:
+        return (uint_t)m_float.convertToFloat();
+    case e_double:
+        return (uint_t)m_float.convertToDouble();
+    case e_long_double:
+        llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+        return *(const uint_t *)ldbl_val.getRawData();
+    }
+    return fail_value;
+}
+
+
+long
+Scalar::SLong(long fail_value) const
+{
+    switch (m_type)
+    {
+    case e_void:        break;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        return *(const slong_t *)(m_integer.sextOrTrunc(sizeof(slong_t) * 8)).getRawData();
+    case e_float:
+        return (slong_t)m_float.convertToFloat();
+    case e_double:
+        return (slong_t)m_float.convertToDouble();
+    case e_long_double:
+        llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+        return *(const slong_t *)ldbl_val.getRawData();
+    }
+    return fail_value;
+}
+
+
 
+unsigned long
+Scalar::ULong(unsigned long fail_value) const
+{
+    switch (m_type)
+    {
+    case e_void:        break;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        return *(const ulong_t *)m_integer.getRawData();
+    case e_float:
+        return (ulong_t)m_float.convertToFloat();
+    case e_double:
+        return (ulong_t)m_float.convertToDouble();
     case e_long_double:
-        if (sizeof(m_data.ldbl) == sizeof(m_data.uint))
-            return m_data.uint;
-        else if (sizeof(m_data.ldbl) == sizeof(m_data.ulong))
-            return m_data.ulong;
-        else if (sizeof(m_data.ldbl) == sizeof(m_data.ulonglong))
-            return m_data.ulonglong;
+        llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+        return *(const ulong_t *)ldbl_val.getRawData();
+    }
+    return fail_value;
+}
+
+uint64_t
+Scalar::GetRawBits64(uint64_t fail_value) const
+{
+    switch (m_type)
+    {
+    case e_void:
         break;
+
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        return *m_integer.getRawData();
+    case e_float:
+        return (uint64_t)m_float.convertToFloat();
+    case e_double:
+        return (uint64_t)m_float.convertToDouble();
+    case e_long_double:
+        llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+        return *ldbl_val.getRawData();
     }
     return fail_value;
 }
@@ -875,15 +1539,22 @@ Scalar::SLongLong(long long fail_value)
     switch (m_type)
     {
     case e_void:        break;
-    case e_sint:        return (long long)m_data.sint;
-    case e_uint:        return (long long)m_data.uint;
-    case e_slong:       return (long long)m_data.slong;
-    case e_ulong:       return (long long)m_data.ulong;
-    case e_slonglong:   return (long long)m_data.slonglong;
-    case e_ulonglong:   return (long long)m_data.ulonglong;
-    case e_float:       return (long long)m_data.flt;
-    case e_double:      return (long long)m_data.dbl;
-    case e_long_double: return (long long)m_data.ldbl;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        return *(const slonglong_t *)(m_integer.sextOrTrunc(sizeof(slonglong_t) * 8)).getRawData();
+    case e_float:
+        return (slonglong_t)m_float.convertToFloat();
+    case e_double:
+        return (slonglong_t)m_float.convertToDouble();
+    case e_long_double:
+        llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+        return *(const slonglong_t *)ldbl_val.getRawData();
     }
     return fail_value;
 }
@@ -895,19 +1566,73 @@ Scalar::ULongLong(unsigned long long fai
     switch (m_type)
     {
     case e_void:        break;
-    case e_sint:        return (unsigned long long)m_data.sint;
-    case e_uint:        return (unsigned long long)m_data.uint;
-    case e_slong:       return (unsigned long long)m_data.slong;
-    case e_ulong:       return (unsigned long long)m_data.ulong;
-    case e_slonglong:   return (unsigned long long)m_data.slonglong;
-    case e_ulonglong:   return (unsigned long long)m_data.ulonglong;
-    case e_float:       return (unsigned long long)m_data.flt;
-    case e_double:      return (unsigned long long)m_data.dbl;
-    case e_long_double: return (unsigned long long)m_data.ldbl;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        if(m_integer.isAllOnesValue())
+            return *(const ulonglong_t *)(llvm::APInt::getAllOnesValue(128)).getRawData();
+        return *(const ulonglong_t *)m_integer.getRawData();
+    case e_float:
+        return (ulonglong_t)m_float.convertToFloat();
+    case e_double:
+        return (ulonglong_t)m_float.convertToDouble();
+    case e_long_double:
+        llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+        return *(const ulonglong_t *)ldbl_val.getRawData();
     }
     return fail_value;
 }
 
+llvm::APInt
+Scalar::UInt128(const llvm::APInt& fail_value) const
+{
+    switch (m_type)
+    {
+    case e_void:        break;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        return m_integer;
+    case e_float:
+    case e_double:
+    case e_long_double:
+        return m_float.bitcastToAPInt();
+    }
+    return fail_value;
+}
+
+llvm::APInt
+Scalar::SInt128(llvm::APInt& fail_value) const
+{
+    switch (m_type)
+    {
+    case e_void:        break;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        return m_integer;
+    case e_float:
+    case e_double:
+    case e_long_double:
+        return m_float.bitcastToAPInt();
+    }
+    return fail_value;
+}
 
 float
 Scalar::Float(float fail_value) const
@@ -915,15 +1640,22 @@ Scalar::Float(float fail_value) const
     switch (m_type)
     {
     case e_void:        break;
-    case e_sint:        return (float)m_data.sint;
-    case e_uint:        return (float)m_data.uint;
-    case e_slong:       return (float)m_data.slong;
-    case e_ulong:       return (float)m_data.ulong;
-    case e_slonglong:   return (float)m_data.slonglong;
-    case e_ulonglong:   return (float)m_data.ulonglong;
-    case e_float:       return (float)m_data.flt;
-    case e_double:      return (float)m_data.dbl;
-    case e_long_double: return (float)m_data.ldbl;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        return m_integer.bitsToFloat();
+    case e_float:
+        return m_float.convertToFloat();
+    case e_double:
+        return (float_t)m_float.convertToDouble();
+    case e_long_double:
+        llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+        return ldbl_val.bitsToFloat();
     }
     return fail_value;
 }
@@ -935,15 +1667,22 @@ Scalar::Double(double fail_value) const
     switch (m_type)
     {
     case e_void:        break;
-    case e_sint:        return (double)m_data.sint;
-    case e_uint:        return (double)m_data.uint;
-    case e_slong:       return (double)m_data.slong;
-    case e_ulong:       return (double)m_data.ulong;
-    case e_slonglong:   return (double)m_data.slonglong;
-    case e_ulonglong:   return (double)m_data.ulonglong;
-    case e_float:       return (double)m_data.flt;
-    case e_double:      return (double)m_data.dbl;
-    case e_long_double: return (double)m_data.ldbl;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        return m_integer.bitsToDouble();
+    case e_float:
+        return (double_t)m_float.convertToFloat();
+    case e_double:
+        return m_float.convertToDouble();
+    case e_long_double:
+        llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+        return ldbl_val.bitsToFloat();
     }
     return fail_value;
 }
@@ -955,15 +1694,22 @@ Scalar::LongDouble(long double fail_valu
     switch (m_type)
     {
     case e_void:        break;
-    case e_sint:        return (long double)m_data.sint;
-    case e_uint:        return (long double)m_data.uint;
-    case e_slong:       return (long double)m_data.slong;
-    case e_ulong:       return (long double)m_data.ulong;
-    case e_slonglong:   return (long double)m_data.slonglong;
-    case e_ulonglong:   return (long double)m_data.ulonglong;
-    case e_float:       return (long double)m_data.flt;
-    case e_double:      return (long double)m_data.dbl;
-    case e_long_double: return (long double)m_data.ldbl;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        return (long_double_t)m_integer.bitsToDouble();
+    case e_float:
+        return (long_double_t)m_float.convertToFloat();
+    case e_double:
+        return (long_double_t)m_float.convertToDouble();
+    case e_long_double:
+        llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+        return (long_double_t)ldbl_val.bitsToDouble();
     }
     return fail_value;
 }
@@ -978,17 +1724,27 @@ Scalar::operator+= (const Scalar& rhs)
     if ((m_type = PromoteToMaxType(*this, rhs, temp_value, a, b)) != Scalar::e_void)
     {
         switch (m_type)
-        {
-        case e_void:        break;
-        case e_sint:        m_data.sint         = a->m_data.sint        + b->m_data.sint;       break;
-        case e_uint:        m_data.uint         = a->m_data.uint        + b->m_data.uint;       break;
-        case e_slong:       m_data.slong        = a->m_data.slong       + b->m_data.slong;      break;
-        case e_ulong:       m_data.ulong        = a->m_data.ulong       + b->m_data.ulong;      break;
-        case e_slonglong:   m_data.slonglong    = a->m_data.slonglong   + b->m_data.slonglong;  break;
-        case e_ulonglong:   m_data.ulonglong    = a->m_data.ulonglong   + b->m_data.ulonglong;  break;
-        case e_float:       m_data.flt          = a->m_data.flt         + b->m_data.flt;        break;
-        case e_double:      m_data.dbl          = a->m_data.dbl         + b->m_data.dbl;        break;
-        case e_long_double: m_data.ldbl         = a->m_data.ldbl        + b->m_data.ldbl;       break;
+            {
+             case e_void:        break;
+             case e_sint:
+             case e_uint:
+             case e_slong:
+             case e_ulong:
+             case e_slonglong:
+             case e_ulonglong:
+             case e_sint128:
+             case e_uint128:
+             {
+                 m_integer = a->m_integer + b->m_integer;
+                 break;
+             }
+             case e_float:
+             case e_double:
+             case e_long_double:
+             {
+                 m_float = a->m_float + b->m_float;
+                 break;
+             }
         }
     }
     return *this;
@@ -1007,109 +1763,33 @@ Scalar::operator<<= (const Scalar& rhs)
         break;
 
     case e_sint:
-        switch (rhs.m_type)
-        {
-        case e_void:
-        case e_float:
-        case e_double:
-        case e_long_double:
-            m_type = e_void;
-            break;
-        case e_sint:            m_data.sint <<= rhs.m_data.sint;        break;
-        case e_uint:            m_data.sint <<= rhs.m_data.uint;        break;
-        case e_slong:           m_data.sint <<= rhs.m_data.slong;       break;
-        case e_ulong:           m_data.sint <<= rhs.m_data.ulong;       break;
-        case e_slonglong:       m_data.sint <<= rhs.m_data.slonglong;   break;
-        case e_ulonglong:       m_data.sint <<= rhs.m_data.ulonglong;   break;
-        }
-        break;
-
     case e_uint:
-        switch (rhs.m_type)
-        {
-        case e_void:
-        case e_float:
-        case e_double:
-        case e_long_double:
-            m_type = e_void;
-            break;
-        case e_sint:            m_data.uint <<= rhs.m_data.sint;        break;
-        case e_uint:            m_data.uint <<= rhs.m_data.uint;        break;
-        case e_slong:           m_data.uint <<= rhs.m_data.slong;       break;
-        case e_ulong:           m_data.uint <<= rhs.m_data.ulong;       break;
-        case e_slonglong:       m_data.uint <<= rhs.m_data.slonglong;   break;
-        case e_ulonglong:       m_data.uint <<= rhs.m_data.ulonglong;   break;
-        }
-        break;
-
     case e_slong:
-        switch (rhs.m_type)
-        {
-        case e_void:
-        case e_float:
-        case e_double:
-        case e_long_double:
-            m_type = e_void;
-            break;
-        case e_sint:            m_data.slong <<= rhs.m_data.sint;       break;
-        case e_uint:            m_data.slong <<= rhs.m_data.uint;       break;
-        case e_slong:           m_data.slong <<= rhs.m_data.slong;      break;
-        case e_ulong:           m_data.slong <<= rhs.m_data.ulong;      break;
-        case e_slonglong:       m_data.slong <<= rhs.m_data.slonglong;  break;
-        case e_ulonglong:       m_data.slong <<= rhs.m_data.ulonglong;  break;
-        }
-        break;
-
     case e_ulong:
-        switch (rhs.m_type)
-        {
-        case e_void:
-        case e_float:
-        case e_double:
-        case e_long_double:
-            m_type = e_void;
-            break;
-        case e_sint:            m_data.ulong <<= rhs.m_data.sint;       break;
-        case e_uint:            m_data.ulong <<= rhs.m_data.uint;       break;
-        case e_slong:           m_data.ulong <<= rhs.m_data.slong;      break;
-        case e_ulong:           m_data.ulong <<= rhs.m_data.ulong;      break;
-        case e_slonglong:       m_data.ulong <<= rhs.m_data.slonglong;  break;
-        case e_ulonglong:       m_data.ulong <<= rhs.m_data.ulonglong;  break;
-        }
-        break;
     case e_slonglong:
-        switch (rhs.m_type)
-        {
-        case e_void:
-        case e_float:
-        case e_double:
-        case e_long_double:
-            m_type = e_void;
-            break;
-        case e_sint:            m_data.slonglong <<= rhs.m_data.sint;       break;
-        case e_uint:            m_data.slonglong <<= rhs.m_data.uint;       break;
-        case e_slong:           m_data.slonglong <<= rhs.m_data.slong;      break;
-        case e_ulong:           m_data.slonglong <<= rhs.m_data.ulong;      break;
-        case e_slonglong:       m_data.slonglong <<= rhs.m_data.slonglong;  break;
-        case e_ulonglong:       m_data.slonglong <<= rhs.m_data.ulonglong;  break;
-        }
-        break;
-
     case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
         switch (rhs.m_type)
         {
-        case e_void:
-        case e_float:
-        case e_double:
-        case e_long_double:
-            m_type = e_void;
-            break;
-        case e_sint:            m_data.ulonglong <<= rhs.m_data.sint;       break;
-        case e_uint:            m_data.ulonglong <<= rhs.m_data.uint;       break;
-        case e_slong:           m_data.ulonglong <<= rhs.m_data.slong;      break;
-        case e_ulong:           m_data.ulonglong <<= rhs.m_data.ulong;      break;
-        case e_slonglong:       m_data.ulonglong <<= rhs.m_data.slonglong;  break;
-        case e_ulonglong:       m_data.ulonglong <<= rhs.m_data.ulonglong;  break;
+             case e_void:
+             case e_float:
+             case e_double:
+             case e_long_double:
+                 m_type = e_void;
+                 break;
+             case e_sint:
+             case e_uint:
+             case e_slong:
+             case e_ulong:
+             case e_slonglong:
+             case e_ulonglong:
+             case e_sint128:
+             case e_uint128:
+             {
+                 m_integer <<= *rhs.m_integer.getRawData();
+                 break;
+             }
         }
         break;
     }
@@ -1130,44 +1810,12 @@ Scalar::ShiftRightLogical(const Scalar&
 
     case e_sint:
     case e_uint:
-        switch (rhs.m_type)
-        {
-        case e_void:
-        case e_float:
-        case e_double:
-        case e_long_double:
-            m_type = e_void;
-            break;
-        case e_sint:            m_data.uint >>= rhs.m_data.sint;        break;
-        case e_uint:            m_data.uint >>= rhs.m_data.uint;        break;
-        case e_slong:           m_data.uint >>= rhs.m_data.slong;       break;
-        case e_ulong:           m_data.uint >>= rhs.m_data.ulong;       break;
-        case e_slonglong:       m_data.uint >>= rhs.m_data.slonglong;   break;
-        case e_ulonglong:       m_data.uint >>= rhs.m_data.ulonglong;   break;
-        }
-        break;
-
     case e_slong:
     case e_ulong:
-        switch (rhs.m_type)
-        {
-        case e_void:
-        case e_float:
-        case e_double:
-        case e_long_double:
-            m_type = e_void;
-            break;
-        case e_sint:            m_data.ulong >>= rhs.m_data.sint;       break;
-        case e_uint:            m_data.ulong >>= rhs.m_data.uint;       break;
-        case e_slong:           m_data.ulong >>= rhs.m_data.slong;      break;
-        case e_ulong:           m_data.ulong >>= rhs.m_data.ulong;      break;
-        case e_slonglong:       m_data.ulong >>= rhs.m_data.slonglong;  break;
-        case e_ulonglong:       m_data.ulong >>= rhs.m_data.ulonglong;  break;
-        }
-        break;
-
     case e_slonglong:
     case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
         switch (rhs.m_type)
         {
         case e_void:
@@ -1176,12 +1824,15 @@ Scalar::ShiftRightLogical(const Scalar&
         case e_long_double:
             m_type = e_void;
             break;
-        case e_sint:            m_data.ulonglong >>= rhs.m_data.sint;       break;
-        case e_uint:            m_data.ulonglong >>= rhs.m_data.uint;       break;
-        case e_slong:           m_data.ulonglong >>= rhs.m_data.slong;      break;
-        case e_ulong:           m_data.ulonglong >>= rhs.m_data.ulong;      break;
-        case e_slonglong:       m_data.ulonglong >>= rhs.m_data.slonglong;  break;
-        case e_ulonglong:       m_data.ulonglong >>= rhs.m_data.ulonglong;  break;
+        case e_sint:
+        case e_uint:
+        case e_slong:
+        case e_ulong:
+        case e_slonglong:
+        case e_ulonglong:
+        case e_sint128:
+        case e_uint128:
+            m_integer = m_integer.lshr(*(const uint_t *) rhs.m_integer.getRawData());   break;
         }
         break;
     }
@@ -1202,95 +1853,13 @@ Scalar::operator>>= (const Scalar& rhs)
         break;
 
     case e_sint:
-        switch (rhs.m_type)
-        {
-        case e_void:
-        case e_float:
-        case e_double:
-        case e_long_double:
-            m_type = e_void;
-            break;
-        case e_sint:            m_data.sint >>= rhs.m_data.sint;        break;
-        case e_uint:            m_data.sint >>= rhs.m_data.uint;        break;
-        case e_slong:           m_data.sint >>= rhs.m_data.slong;       break;
-        case e_ulong:           m_data.sint >>= rhs.m_data.ulong;       break;
-        case e_slonglong:       m_data.sint >>= rhs.m_data.slonglong;   break;
-        case e_ulonglong:       m_data.sint >>= rhs.m_data.ulonglong;   break;
-        }
-        break;
-
     case e_uint:
-        switch (rhs.m_type)
-        {
-        case e_void:
-        case e_float:
-        case e_double:
-        case e_long_double:
-            m_type = e_void;
-            break;
-        case e_sint:            m_data.uint >>= rhs.m_data.sint;        break;
-        case e_uint:            m_data.uint >>= rhs.m_data.uint;        break;
-        case e_slong:           m_data.uint >>= rhs.m_data.slong;       break;
-        case e_ulong:           m_data.uint >>= rhs.m_data.ulong;       break;
-        case e_slonglong:       m_data.uint >>= rhs.m_data.slonglong;   break;
-        case e_ulonglong:       m_data.uint >>= rhs.m_data.ulonglong;   break;
-        }
-        break;
-
     case e_slong:
-        switch (rhs.m_type)
-        {
-        case e_void:
-        case e_float:
-        case e_double:
-        case e_long_double:
-            m_type = e_void;
-            break;
-        case e_sint:            m_data.slong >>= rhs.m_data.sint;       break;
-        case e_uint:            m_data.slong >>= rhs.m_data.uint;       break;
-        case e_slong:           m_data.slong >>= rhs.m_data.slong;      break;
-        case e_ulong:           m_data.slong >>= rhs.m_data.ulong;      break;
-        case e_slonglong:       m_data.slong >>= rhs.m_data.slonglong;  break;
-        case e_ulonglong:       m_data.slong >>= rhs.m_data.ulonglong;  break;
-        }
-        break;
-
     case e_ulong:
-        switch (rhs.m_type)
-        {
-        case e_void:
-        case e_float:
-        case e_double:
-        case e_long_double:
-            m_type = e_void;
-            break;
-        case e_sint:            m_data.ulong >>= rhs.m_data.sint;       break;
-        case e_uint:            m_data.ulong >>= rhs.m_data.uint;       break;
-        case e_slong:           m_data.ulong >>= rhs.m_data.slong;      break;
-        case e_ulong:           m_data.ulong >>= rhs.m_data.ulong;      break;
-        case e_slonglong:       m_data.ulong >>= rhs.m_data.slonglong;  break;
-        case e_ulonglong:       m_data.ulong >>= rhs.m_data.ulonglong;  break;
-        }
-        break;
     case e_slonglong:
-        switch (rhs.m_type)
-        {
-        case e_void:
-        case e_float:
-        case e_double:
-        case e_long_double:
-            m_type = e_void;
-            break;
-        case e_sint:            m_data.slonglong >>= rhs.m_data.sint;       break;
-        case e_uint:            m_data.slonglong >>= rhs.m_data.uint;       break;
-        case e_slong:           m_data.slonglong >>= rhs.m_data.slong;      break;
-        case e_ulong:           m_data.slonglong >>= rhs.m_data.ulong;      break;
-        case e_slonglong:       m_data.slonglong >>= rhs.m_data.slonglong;  break;
-        case e_ulonglong:       m_data.slonglong >>= rhs.m_data.ulonglong;  break;
-        }
-        break;
-
     case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
         switch (rhs.m_type)
         {
         case e_void:
@@ -1299,12 +1868,18 @@ Scalar::operator>>= (const Scalar& rhs)
         case e_long_double:
             m_type = e_void;
             break;
-        case e_sint:            m_data.ulonglong >>= rhs.m_data.sint;       break;
-        case e_uint:            m_data.ulonglong >>= rhs.m_data.uint;       break;
-        case e_slong:           m_data.ulonglong >>= rhs.m_data.slong;      break;
-        case e_ulong:           m_data.ulonglong >>= rhs.m_data.ulong;      break;
-        case e_slonglong:       m_data.ulonglong >>= rhs.m_data.slonglong;  break;
-        case e_ulonglong:       m_data.ulonglong >>= rhs.m_data.ulonglong;  break;
+        case e_sint:
+        case e_uint:
+        case e_slong:
+        case e_ulong:
+        case e_slonglong:
+        case e_ulonglong:
+             case e_sint128:
+             case e_uint128:
+             {
+                 m_integer >> *rhs.m_integer.getRawData();
+                 break;
+             }
         }
         break;
     }
@@ -1316,104 +1891,22 @@ Scalar&
 Scalar::operator&= (const Scalar& rhs)
 {
     switch (m_type)
-    {
-    case e_void:
-    case e_float:
-    case e_double:
-    case e_long_double:
-        m_type = e_void;
-        break;
-
-    case e_sint:
-        switch (rhs.m_type)
-        {
-        case e_void:
-        case e_float:
-        case e_double:
-        case e_long_double:
-            m_type = e_void;
-            break;
-        case e_sint:            m_data.sint &= rhs.m_data.sint;         break;
-        case e_uint:            m_data.sint &= rhs.m_data.uint;         break;
-        case e_slong:           m_data.sint &= rhs.m_data.slong;        break;
-        case e_ulong:           m_data.sint &= rhs.m_data.ulong;        break;
-        case e_slonglong:       m_data.sint &= rhs.m_data.slonglong;    break;
-        case e_ulonglong:       m_data.sint &= rhs.m_data.ulonglong;    break;
-        }
-        break;
-
-    case e_uint:
-        switch (rhs.m_type)
-        {
-        case e_void:
-        case e_float:
-        case e_double:
-        case e_long_double:
-            m_type = e_void;
-            break;
-        case e_sint:            m_data.uint &= rhs.m_data.sint;         break;
-        case e_uint:            m_data.uint &= rhs.m_data.uint;         break;
-        case e_slong:           m_data.uint &= rhs.m_data.slong;        break;
-        case e_ulong:           m_data.uint &= rhs.m_data.ulong;        break;
-        case e_slonglong:       m_data.uint &= rhs.m_data.slonglong;    break;
-        case e_ulonglong:       m_data.uint &= rhs.m_data.ulonglong;    break;
-        }
-        break;
-
-    case e_slong:
-        switch (rhs.m_type)
-        {
-        case e_void:
-        case e_float:
-        case e_double:
-        case e_long_double:
-            m_type = e_void;
-            break;
-        case e_sint:            m_data.slong &= rhs.m_data.sint;        break;
-        case e_uint:            m_data.slong &= rhs.m_data.uint;        break;
-        case e_slong:           m_data.slong &= rhs.m_data.slong;       break;
-        case e_ulong:           m_data.slong &= rhs.m_data.ulong;       break;
-        case e_slonglong:       m_data.slong &= rhs.m_data.slonglong;   break;
-        case e_ulonglong:       m_data.slong &= rhs.m_data.ulonglong;   break;
-        }
-        break;
-
-    case e_ulong:
-        switch (rhs.m_type)
-        {
-        case e_void:
-        case e_float:
-        case e_double:
-        case e_long_double:
-            m_type = e_void;
-            break;
-        case e_sint:            m_data.ulong &= rhs.m_data.sint;        break;
-        case e_uint:            m_data.ulong &= rhs.m_data.uint;        break;
-        case e_slong:           m_data.ulong &= rhs.m_data.slong;       break;
-        case e_ulong:           m_data.ulong &= rhs.m_data.ulong;       break;
-        case e_slonglong:       m_data.ulong &= rhs.m_data.slonglong;   break;
-        case e_ulonglong:       m_data.ulong &= rhs.m_data.ulonglong;   break;
-        }
-        break;
-    case e_slonglong:
-        switch (rhs.m_type)
-        {
-        case e_void:
-        case e_float:
-        case e_double:
-        case e_long_double:
-            m_type = e_void;
-            break;
-        case e_sint:            m_data.slonglong &= rhs.m_data.sint;        break;
-        case e_uint:            m_data.slonglong &= rhs.m_data.uint;        break;
-        case e_slong:           m_data.slonglong &= rhs.m_data.slong;       break;
-        case e_ulong:           m_data.slonglong &= rhs.m_data.ulong;       break;
-        case e_slonglong:       m_data.slonglong &= rhs.m_data.slonglong;   break;
-        case e_ulonglong:       m_data.slonglong &= rhs.m_data.ulonglong;   break;
-        }
+    {
+    case e_void:
+    case e_float:
+    case e_double:
+    case e_long_double:
+        m_type = e_void;
         break;
 
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
     case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
         switch (rhs.m_type)
         {
         case e_void:
@@ -1422,12 +1915,18 @@ Scalar::operator&= (const Scalar& rhs)
         case e_long_double:
             m_type = e_void;
             break;
-        case e_sint:            m_data.ulonglong &= rhs.m_data.sint;        break;
-        case e_uint:            m_data.ulonglong &= rhs.m_data.uint;        break;
-        case e_slong:           m_data.ulonglong &= rhs.m_data.slong;       break;
-        case e_ulong:           m_data.ulonglong &= rhs.m_data.ulong;       break;
-        case e_slonglong:       m_data.ulonglong &= rhs.m_data.slonglong;   break;
-        case e_ulonglong:       m_data.ulonglong &= rhs.m_data.ulonglong;   break;
+        case e_sint:
+        case e_uint:
+        case e_slong:
+        case e_ulong:
+        case e_slonglong:
+        case e_ulonglong:
+             case e_sint128:
+             case e_uint128:
+             {
+                 m_integer &= rhs.m_integer;
+                 break;
+             }
         }
         break;
     }
@@ -1445,26 +1944,22 @@ Scalar::AbsoluteValue()
         break;
 
     case e_sint:
-        if (m_data.sint < 0)
-            m_data.sint = -m_data.sint;
-        return true;
-
     case e_slong:
-        if (m_data.slong < 0)
-            m_data.slong = -m_data.slong;
-        return true;
-
     case e_slonglong:
-        if (m_data.slonglong < 0)
-            m_data.slonglong = -m_data.slonglong;
+    case e_sint128:
+        if (m_integer.isNegative())
+            m_integer = -m_integer;
         return true;
 
     case e_uint:
     case e_ulong:
     case e_ulonglong:   return true;
-    case e_float:       m_data.flt = fabsf(m_data.flt);     return true;
-    case e_double:      m_data.dbl = fabs(m_data.dbl);      return true;
-    case e_long_double: m_data.ldbl = fabsl(m_data.ldbl);   return true;
+    case e_uint128:
+    case e_float:
+    case e_double:
+    case e_long_double:
+        m_float.clearSign();
+        return true;
     }
     return false;
 }
@@ -1476,15 +1971,19 @@ Scalar::UnaryNegate()
     switch (m_type)
     {
     case e_void:        break;
-    case e_sint:        m_data.sint = -m_data.sint;             return true;
-    case e_uint:        m_data.uint = -m_data.uint;             return true;
-    case e_slong:       m_data.slong = -m_data.slong;           return true;
-    case e_ulong:       m_data.ulong = -m_data.ulong;           return true;
-    case e_slonglong:   m_data.slonglong = -m_data.slonglong;   return true;
-    case e_ulonglong:   m_data.ulonglong = -m_data.ulonglong;   return true;
-    case e_float:       m_data.flt = -m_data.flt;               return true;
-    case e_double:      m_data.dbl = -m_data.dbl;               return true;
-    case e_long_double: m_data.ldbl = -m_data.ldbl;             return true;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        m_integer = -m_integer; return true;
+    case e_float:
+    case e_double:
+    case e_long_double:
+        m_float.changeSign(); return true;
     }
     return false;
 }
@@ -1494,12 +1993,15 @@ Scalar::OnesComplement()
 {
     switch (m_type)
     {
-    case e_sint:        m_data.sint = ~m_data.sint; return true;
-    case e_uint:        m_data.uint = ~m_data.uint; return true;
-    case e_slong:       m_data.slong = ~m_data.slong; return true;
-    case e_ulong:       m_data.ulong = ~m_data.ulong; return true;
-    case e_slonglong:   m_data.slonglong = ~m_data.slonglong; return true;
-    case e_ulonglong:   m_data.ulonglong = ~m_data.ulonglong; return true;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128:
+        m_integer = ~m_integer; return true;
 
     case e_void:
     case e_float:
@@ -1523,15 +2025,19 @@ lldb_private::operator+ (const Scalar& l
         switch (result.m_type)
         {
         case Scalar::e_void:            break;
-        case Scalar::e_sint:            result.m_data.sint      = a->m_data.sint        + b->m_data.sint;       break;
-        case Scalar::e_uint:            result.m_data.uint      = a->m_data.uint        + b->m_data.uint;       break;
-        case Scalar::e_slong:           result.m_data.slong     = a->m_data.slong       + b->m_data.slong;      break;
-        case Scalar::e_ulong:           result.m_data.ulong     = a->m_data.ulong       + b->m_data.ulong;      break;
-        case Scalar::e_slonglong:       result.m_data.slonglong = a->m_data.slonglong   + b->m_data.slonglong;  break;
-        case Scalar::e_ulonglong:       result.m_data.ulonglong = a->m_data.ulonglong   + b->m_data.ulonglong;  break;
-        case Scalar::e_float:           result.m_data.flt       = a->m_data.flt         + b->m_data.flt;        break;
-        case Scalar::e_double:      result.m_data.dbl       = a->m_data.dbl         + b->m_data.dbl;        break;
-        case Scalar::e_long_double: result.m_data.ldbl      = a->m_data.ldbl        + b->m_data.ldbl;       break;
+        case Scalar::e_sint:
+        case Scalar::e_uint:
+        case Scalar::e_slong:
+        case Scalar::e_ulong:
+        case Scalar::e_slonglong:
+        case Scalar::e_ulonglong:
+        case Scalar::e_sint128:
+        case Scalar::e_uint128:
+            result.m_integer = a->m_integer + b->m_integer;  break;
+        case Scalar::e_float:
+        case Scalar::e_double:
+        case Scalar::e_long_double:
+            result.m_float = a->m_float + b->m_float; break;
         }
     }
     return result;
@@ -1550,15 +2056,19 @@ lldb_private::operator- (const Scalar& l
         switch (result.m_type)
         {
         case Scalar::e_void:            break;
-        case Scalar::e_sint:            result.m_data.sint      = a->m_data.sint        - b->m_data.sint;       break;
-        case Scalar::e_uint:            result.m_data.uint      = a->m_data.uint        - b->m_data.uint;       break;
-        case Scalar::e_slong:           result.m_data.slong     = a->m_data.slong       - b->m_data.slong;      break;
-        case Scalar::e_ulong:           result.m_data.ulong     = a->m_data.ulong       - b->m_data.ulong;      break;
-        case Scalar::e_slonglong:       result.m_data.slonglong = a->m_data.slonglong   - b->m_data.slonglong;  break;
-        case Scalar::e_ulonglong:       result.m_data.ulonglong = a->m_data.ulonglong   - b->m_data.ulonglong;  break;
-        case Scalar::e_float:           result.m_data.flt       = a->m_data.flt         - b->m_data.flt;        break;
-        case Scalar::e_double:      result.m_data.dbl       = a->m_data.dbl         - b->m_data.dbl;        break;
-        case Scalar::e_long_double: result.m_data.ldbl      = a->m_data.ldbl        - b->m_data.ldbl;       break;
+        case Scalar::e_sint:
+        case Scalar::e_uint:
+        case Scalar::e_slong:
+        case Scalar::e_ulong:
+        case Scalar::e_slonglong:
+        case Scalar::e_ulonglong:
+        case Scalar::e_sint128:
+        case Scalar::e_uint128:
+            result.m_integer = a->m_integer - b->m_integer;  break;
+        case Scalar::e_float:
+        case Scalar::e_double:
+        case Scalar::e_long_double:
+            result.m_float = a->m_float - b->m_float; break;
         }
     }
     return result;
@@ -1576,16 +2086,31 @@ lldb_private::operator/ (const Scalar& l
         switch (result.m_type)
         {
         case Scalar::e_void:            break;
-
-        case Scalar::e_sint:            if (b->m_data.sint != 0)        { result.m_data.sint = a->m_data.sint/ b->m_data.sint; return result; } break;
-        case Scalar::e_uint:            if (b->m_data.uint != 0)        { result.m_data.uint = a->m_data.uint / b->m_data.uint; return result; } break;
-        case Scalar::e_slong:           if (b->m_data.slong != 0)       { result.m_data.slong = a->m_data.slong / b->m_data.slong; return result; } break;
-        case Scalar::e_ulong:           if (b->m_data.ulong != 0)       { result.m_data.ulong = a->m_data.ulong / b->m_data.ulong; return result; } break;
-        case Scalar::e_slonglong:       if (b->m_data.slonglong != 0)   { result.m_data.slonglong = a->m_data.slonglong / b->m_data.slonglong; return result; } break;
-        case Scalar::e_ulonglong:       if (b->m_data.ulonglong != 0)   { result.m_data.ulonglong = a->m_data.ulonglong / b->m_data.ulonglong; return result; } break;
-        case Scalar::e_float:           if (b->m_data.flt != 0.0f)      { result.m_data.flt = a->m_data.flt / b->m_data.flt; return result; } break;
-        case Scalar::e_double:      if (b->m_data.dbl != 0.0)       { result.m_data.dbl = a->m_data.dbl / b->m_data.dbl; return result; } break;
-        case Scalar::e_long_double: if (b->m_data.ldbl != 0.0)      { result.m_data.ldbl = a->m_data.ldbl / b->m_data.ldbl; return result; } break;
+        case Scalar::e_sint:
+        case Scalar::e_uint:
+        case Scalar::e_slong:
+        case Scalar::e_ulong:
+        case Scalar::e_slonglong:
+        case Scalar::e_ulonglong:
+        case Scalar::e_sint128:
+        case Scalar::e_uint128:
+        {
+            if (b->m_integer != 0)
+            {
+                result.m_integer = *a->m_integer.getRawData() / *b->m_integer.getRawData();
+                return result;
+            }
+            break;
+        }
+        case Scalar::e_float:
+        case Scalar::e_double:
+        case Scalar::e_long_double:
+            if (b->m_float.isZero())
+            {
+                result.m_float = a->m_float / b->m_float;
+                return result;
+            }
+            break;
         }
     }
     // For division only, the only way it should make it here is if a promotion failed,
@@ -1606,15 +2131,19 @@ lldb_private::operator* (const Scalar& l
         switch (result.m_type)
         {
         case Scalar::e_void:            break;
-        case Scalar::e_sint:            result.m_data.sint      = a->m_data.sint        * b->m_data.sint;       break;
-        case Scalar::e_uint:            result.m_data.uint      = a->m_data.uint        * b->m_data.uint;       break;
-        case Scalar::e_slong:           result.m_data.slong     = a->m_data.slong       * b->m_data.slong;      break;
-        case Scalar::e_ulong:           result.m_data.ulong     = a->m_data.ulong       * b->m_data.ulong;      break;
-        case Scalar::e_slonglong:       result.m_data.slonglong = a->m_data.slonglong   * b->m_data.slonglong;  break;
-        case Scalar::e_ulonglong:       result.m_data.ulonglong = a->m_data.ulonglong   * b->m_data.ulonglong;  break;
-        case Scalar::e_float:           result.m_data.flt       = a->m_data.flt         * b->m_data.flt;        break;
-        case Scalar::e_double:      result.m_data.dbl       = a->m_data.dbl         * b->m_data.dbl;        break;
-        case Scalar::e_long_double: result.m_data.ldbl      = a->m_data.ldbl        * b->m_data.ldbl;       break;
+        case Scalar::e_sint:
+        case Scalar::e_uint:
+        case Scalar::e_slong:
+        case Scalar::e_ulong:
+        case Scalar::e_slonglong:
+        case Scalar::e_ulonglong:
+        case Scalar::e_sint128:
+        case Scalar::e_uint128:
+            result.m_integer = a->m_integer * b->m_integer;  break;
+        case Scalar::e_float:
+        case Scalar::e_double:
+        case Scalar::e_long_double:
+            result.m_float = a->m_float * b->m_float; break;
         }
     }
     return result;
@@ -1631,13 +2160,15 @@ lldb_private::operator& (const Scalar& l
     {
         switch (result.m_type)
         {
-        case Scalar::e_sint:        result.m_data.sint      = a->m_data.sint        & b->m_data.sint;       break;
-        case Scalar::e_uint:        result.m_data.uint      = a->m_data.uint        & b->m_data.uint;       break;
-        case Scalar::e_slong:       result.m_data.slong     = a->m_data.slong       & b->m_data.slong;      break;
-        case Scalar::e_ulong:       result.m_data.ulong     = a->m_data.ulong       & b->m_data.ulong;      break;
-        case Scalar::e_slonglong:   result.m_data.slonglong = a->m_data.slonglong   & b->m_data.slonglong;  break;
-        case Scalar::e_ulonglong:   result.m_data.ulonglong = a->m_data.ulonglong   & b->m_data.ulonglong;  break;
-
+        case Scalar::e_sint:
+        case Scalar::e_uint:
+        case Scalar::e_slong:
+        case Scalar::e_ulong:
+        case Scalar::e_slonglong:
+        case Scalar::e_ulonglong:
+        case Scalar::e_sint128:
+        case Scalar::e_uint128:
+            result.m_integer = a->m_integer & b->m_integer;  break;
         case Scalar::e_void:
         case Scalar::e_float:
         case Scalar::e_double:
@@ -1661,12 +2192,15 @@ lldb_private::operator| (const Scalar& l
     {
         switch (result.m_type)
         {
-        case Scalar::e_sint:        result.m_data.sint      = a->m_data.sint        | b->m_data.sint;       break;
-        case Scalar::e_uint:        result.m_data.uint      = a->m_data.uint        | b->m_data.uint;       break;
-        case Scalar::e_slong:       result.m_data.slong     = a->m_data.slong       | b->m_data.slong;      break;
-        case Scalar::e_ulong:       result.m_data.ulong     = a->m_data.ulong       | b->m_data.ulong;      break;
-        case Scalar::e_slonglong:   result.m_data.slonglong = a->m_data.slonglong   | b->m_data.slonglong;  break;
-        case Scalar::e_ulonglong:   result.m_data.ulonglong = a->m_data.ulonglong   | b->m_data.ulonglong;  break;
+        case Scalar::e_sint:
+        case Scalar::e_uint:
+        case Scalar::e_slong:
+        case Scalar::e_ulong:
+        case Scalar::e_slonglong:
+        case Scalar::e_ulonglong:
+        case Scalar::e_sint128:
+        case Scalar::e_uint128:
+            result.m_integer = a->m_integer | b->m_integer;  break;
 
         case Scalar::e_void:
         case Scalar::e_float:
@@ -1692,12 +2226,23 @@ lldb_private::operator% (const Scalar& l
         switch (result.m_type)
         {
         default:                    break;
-        case Scalar::e_sint:        if (b->m_data.sint != 0)        {   result.m_data.sint      = a->m_data.sint        % b->m_data.sint;       return result;  }   break;
-        case Scalar::e_uint:        if (b->m_data.uint != 0)        {   result.m_data.uint      = a->m_data.uint        % b->m_data.uint;       return result;  }   break;
-        case Scalar::e_slong:       if (b->m_data.slong != 0)       {   result.m_data.slong     = a->m_data.slong       % b->m_data.slong;      return result;  }   break;
-        case Scalar::e_ulong:       if (b->m_data.ulong != 0)       {   result.m_data.ulong     = a->m_data.ulong       % b->m_data.ulong;      return result;  }   break;
-        case Scalar::e_slonglong:   if (b->m_data.slonglong != 0)   {   result.m_data.slonglong = a->m_data.slonglong   % b->m_data.slonglong;  return result;  }   break;
-        case Scalar::e_ulonglong:   if (b->m_data.ulonglong != 0)   {   result.m_data.ulonglong = a->m_data.ulonglong   % b->m_data.ulonglong;  return result;  }   break;
+             case Scalar::e_void:            break;
+             case Scalar::e_sint:
+             case Scalar::e_uint:
+             case Scalar::e_slong:
+             case Scalar::e_ulong:
+             case Scalar::e_slonglong:
+             case Scalar::e_ulonglong:
+             case Scalar::e_sint128:
+             case Scalar::e_uint128:
+             {
+                 if (b->m_integer != 0)
+                 {
+                     result.m_integer = *a->m_integer.getRawData() % *b->m_integer.getRawData();
+                     return result;
+                 }
+                 break;
+             }
         }
     }
     result.m_type = Scalar::e_void;
@@ -1715,12 +2260,15 @@ lldb_private::operator^ (const Scalar& l
     {
         switch (result.m_type)
         {
-        case Scalar::e_sint:        result.m_data.sint      = a->m_data.sint        ^ b->m_data.sint;       break;
-        case Scalar::e_uint:        result.m_data.uint      = a->m_data.uint        ^ b->m_data.uint;       break;
-        case Scalar::e_slong:       result.m_data.slong     = a->m_data.slong       ^ b->m_data.slong;      break;
-        case Scalar::e_ulong:       result.m_data.ulong     = a->m_data.ulong       ^ b->m_data.ulong;      break;
-        case Scalar::e_slonglong:   result.m_data.slonglong = a->m_data.slonglong   ^ b->m_data.slonglong;  break;
-        case Scalar::e_ulonglong:   result.m_data.ulonglong = a->m_data.ulonglong   ^ b->m_data.ulonglong;  break;
+        case Scalar::e_sint:
+        case Scalar::e_uint:
+        case Scalar::e_slong:
+        case Scalar::e_ulong:
+        case Scalar::e_slonglong:
+        case Scalar::e_ulonglong:
+        case Scalar::e_sint128:
+        case Scalar::e_uint128:
+            result.m_integer = a->m_integer ^ b->m_integer;  break;
 
         case Scalar::e_void:
         case Scalar::e_float:
@@ -1754,21 +2302,21 @@ lldb_private::operator>> (const Scalar&
 unsigned int
 Scalar::RawUInt () const
 {
-    return m_data.uint;
+    return *(const uint_t *) m_integer.getRawData();
 }
 
 // Return the raw unsigned long without any casting or conversion
 unsigned long
 Scalar::RawULong () const
 {
-    return m_data.ulong;
+    return *(const ulong_t *) m_integer.getRawData();
 }
 
 // Return the raw unsigned long long without any casting or conversion
 unsigned long long
 Scalar::RawULongLong () const
 {
-    return m_data.ulonglong;
+    return *(const ulonglong_t *) m_integer.getRawData();
 }
 
 
@@ -1801,9 +2349,9 @@ Scalar::SetValueFromCString (const char
                 m_type = Scalar::GetValueTypeForUnsignedIntegerWithByteSize (byte_size);
                 switch (m_type)
                 {
-                case e_uint:        m_data.uint = (uint_t)uval64;           break;
-                case e_ulong:       m_data.ulong = (ulong_t)uval64;         break;
-                case e_ulonglong:   m_data.ulonglong = (ulonglong_t)uval64; break;
+                case e_uint:        m_integer = llvm::APInt(sizeof(uint_t) * 8, uval64, false);           break;
+                case e_ulong:       m_integer = llvm::APInt(sizeof(ulong_t) * 8, uval64, false);         break;
+                case e_ulonglong:   m_integer = llvm::APInt(sizeof(ulonglong_t) * 8, uval64, false); break;
                 default:
                     error.SetErrorStringWithFormat("unsupported unsigned integer byte size: %" PRIu64 "", (uint64_t)byte_size);
                     break;
@@ -1830,9 +2378,9 @@ Scalar::SetValueFromCString (const char
                 m_type = Scalar::GetValueTypeForSignedIntegerWithByteSize (byte_size);
                 switch (m_type)
                 {
-                case e_sint:        m_data.sint = (sint_t)sval64;           break;
-                case e_slong:       m_data.slong = (slong_t)sval64;         break;
-                case e_slonglong:   m_data.slonglong = (slonglong_t)sval64; break;
+                case e_sint:        m_integer = llvm::APInt(sizeof(sint_t) * 8, sval64, true);           break;
+                case e_slong:       m_integer = llvm::APInt(sizeof(slong_t) * 8, sval64, true);         break;
+                case e_slonglong:   m_integer = llvm::APInt(sizeof(slonglong_t) * 8, sval64, true); break;
                 default:
                     error.SetErrorStringWithFormat("unsupported signed integer byte size: %" PRIu64 "", (uint64_t)byte_size);
                     break;
@@ -1847,24 +2395,36 @@ Scalar::SetValueFromCString (const char
         break;
 
     case eEncodingIEEE754:
+        static float f_val;
+        static double d_val;
+        static long double l_val;
         if (byte_size == sizeof (float))
         {
-            if (::sscanf (value_str, "%f", &m_data.flt) == 1)
+            if (::sscanf (value_str, "%f", &f_val) == 1)
+            {
+                m_float = llvm::APFloat(f_val);
                 m_type = e_float;
+            }
             else
                 error.SetErrorStringWithFormat ("'%s' is not a valid float string value", value_str);
         }
         else if (byte_size == sizeof (double))
         {
-            if (::sscanf (value_str, "%lf", &m_data.dbl) == 1)
+            if (::sscanf (value_str, "%lf", &d_val) == 1)
+            {
+                m_float = llvm::APFloat(d_val);
                 m_type = e_double;
+            }
             else
                 error.SetErrorStringWithFormat ("'%s' is not a valid float string value", value_str);
         }
         else if (byte_size == sizeof (long double))
         {
-            if (::sscanf (value_str, "%Lf", &m_data.ldbl) == 1)
+            if (::sscanf (value_str, "%Lf", &l_val) == 1)
+            {
+                m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&l_val)->x));
                 m_type = e_long_double;
+            }
             else
                 error.SetErrorStringWithFormat ("'%s' is not a valid float string value", value_str);
         }
@@ -1890,6 +2450,7 @@ Scalar::SetValueFromData (DataExtractor
 {
     Error error;
     
+    type128 int128;
     switch (encoding)
     {
     case lldb::eEncodingInvalid:
@@ -1904,10 +2465,25 @@ Scalar::SetValueFromData (DataExtractor
             
             switch (byte_size)
             {
-            case 1: operator=((uint8_t)data.GetU8(&offset)); break;
-            case 2: operator=((uint16_t)data.GetU16(&offset)); break;
-            case 4: operator=((uint32_t)data.GetU32(&offset)); break;
-            case 8: operator=((uint64_t)data.GetU64(&offset)); break;
+            case 1:  operator=((uint8_t)data.GetU8(&offset)); break;
+            case 2:  operator=((uint16_t)data.GetU16(&offset)); break;
+            case 4:  operator=((uint32_t)data.GetU32(&offset)); break;
+            case 8:  operator=((uint64_t)data.GetU64(&offset)); break;
+            case 16:
+            {
+                if (data.GetByteOrder() == eByteOrderBig)
+                {
+                    int128.x[1] = (uint64_t)data.GetU64 (&offset);
+                    int128.x[0] = (uint64_t)data.GetU64 (&offset + 1);
+                }
+                else
+                {
+                    int128.x[0] = (uint64_t)data.GetU64 (&offset);
+                    int128.x[1] = (uint64_t)data.GetU64 (&offset + 1);
+                }
+                operator=(llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, int128.x));
+                break;
+            }
             default:
                 error.SetErrorStringWithFormat("unsupported unsigned integer byte size: %" PRIu64 "", (uint64_t)byte_size);
                 break;
@@ -1924,6 +2500,21 @@ Scalar::SetValueFromData (DataExtractor
             case 2: operator=((int16_t)data.GetU16(&offset)); break;
             case 4: operator=((int32_t)data.GetU32(&offset)); break;
             case 8: operator=((int64_t)data.GetU64(&offset)); break;
+            case 16:
+            {
+                if (data.GetByteOrder() == eByteOrderBig)
+                {
+                    int128.x[1] = (uint64_t)data.GetU64 (&offset);
+                    int128.x[0] = (uint64_t)data.GetU64 (&offset + 1);
+                }
+                else
+                {
+                    int128.x[0] = (uint64_t)data.GetU64 (&offset);
+                    int128.x[1] = (uint64_t)data.GetU64 (&offset + 1);
+                }
+                operator=(llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, int128.x));
+                break;
+            }
             default:
                 error.SetErrorStringWithFormat("unsupported signed integer byte size: %" PRIu64 "", (uint64_t)byte_size);
                 break;
@@ -1966,47 +2557,22 @@ Scalar::SignExtend (uint32_t sign_bit_po
             
         case Scalar::e_sint:            
         case Scalar::e_uint:
-            if (max_bit_pos == sign_bit_pos)
-                return true;
-            else if (sign_bit_pos < (max_bit_pos-1))
-            {
-                unsigned int sign_bit = 1u << sign_bit_pos;
-                if (m_data.uint & sign_bit)
-                {
-                    const unsigned int mask = ~(sign_bit) + 1u;
-                    m_data.uint |= mask;
-                }
-                return true;
-            }
-            break;
-            
         case Scalar::e_slong:
         case Scalar::e_ulong:
-            if (max_bit_pos == sign_bit_pos)
-                return true;
-            else if (sign_bit_pos < (max_bit_pos-1))
-            {
-                unsigned long sign_bit = 1ul << sign_bit_pos;
-                if (m_data.ulong & sign_bit)
-                {
-                    const unsigned long mask = ~(sign_bit) + 1ul;
-                    m_data.ulong |= mask;
-                }
-                return true;
-            }
-            break;
-            
         case Scalar::e_slonglong:
         case Scalar::e_ulonglong:
+        case Scalar::e_sint128:
+        case Scalar::e_uint128:
             if (max_bit_pos == sign_bit_pos)
                 return true;
             else if (sign_bit_pos < (max_bit_pos-1))
             {
-                unsigned long long sign_bit = 1ull << sign_bit_pos;
-                if (m_data.ulonglong & sign_bit)
+                llvm::APInt sign_bit = llvm::APInt::getSignBit(sign_bit_pos + 1);
+                llvm::APInt bitwize_and = m_integer & sign_bit;
+                if (bitwize_and.getBoolValue())
                 {
-                    const unsigned long long mask = ~(sign_bit) + 1ull;
-                    m_data.ulonglong |= mask;
+                    const llvm::APInt mask = ~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
+                    m_integer |= mask;
                 }
                 return true;
             }
@@ -2053,66 +2619,40 @@ Scalar::ExtractBitfield (uint32_t bit_si
 
     uint32_t msbit = bit_offset + bit_size - 1;
     uint32_t lsbit = bit_offset;
+    uint64_t result;
     switch (m_type)
     {
         case Scalar::e_void:
             break;
             
         case e_float:
-            if (sizeof(m_data.flt) == sizeof(sint_t))
-                m_data.sint = (sint_t)SignedBits (m_data.sint, msbit, lsbit);
-            else if (sizeof(m_data.flt) == sizeof(ulong_t))
-                m_data.slong = (slong_t)SignedBits (m_data.slong, msbit, lsbit);
-            else if (sizeof(m_data.flt) == sizeof(ulonglong_t))
-                m_data.slonglong = (slonglong_t)SignedBits (m_data.slonglong, msbit, lsbit);
-            else
-                return false;
+            result = SignedBits ((uint64_t )m_float.convertToFloat(), msbit, lsbit);
+            m_float = llvm::APFloat((float_t)result);
             return true;
-            
         case e_double:
-            if (sizeof(m_data.dbl) == sizeof(sint_t))
-                m_data.sint = SignedBits (m_data.sint, msbit, lsbit);
-            else if (sizeof(m_data.dbl) == sizeof(ulong_t))
-                m_data.slong = SignedBits (m_data.slong, msbit, lsbit);
-            else if (sizeof(m_data.dbl) == sizeof(ulonglong_t))
-                m_data.slonglong = SignedBits (m_data.slonglong, msbit, lsbit);
-            else
-                return false;
-            return true;
-            
+            result = SignedBits ((uint64_t )m_float.convertToDouble(), msbit, lsbit);
+            m_float = llvm::APFloat((double_t)result);
         case e_long_double:
-            if (sizeof(m_data.ldbl) == sizeof(sint_t))
-                m_data.sint = SignedBits (m_data.sint, msbit, lsbit);
-            else if (sizeof(m_data.ldbl) == sizeof(ulong_t))
-                m_data.slong = SignedBits (m_data.slong, msbit, lsbit);
-            else if (sizeof(m_data.ldbl) == sizeof(ulonglong_t))
-                m_data.slonglong = SignedBits (m_data.slonglong, msbit, lsbit);
+            m_integer = m_float.bitcastToAPInt();
+            result = SignedBits (*m_integer.getRawData(), msbit, lsbit);
+            if(m_ieee_quad)
+                m_float = llvm::APFloat(llvm::APFloat::IEEEquad, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&result)->x));
             else
-                return false;
+                m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&result)->x));
             return true;
             
         case Scalar::e_sint:
-            m_data.sint = (sint_t)SignedBits (m_data.sint, msbit, lsbit);
-            return true;
-
-        case Scalar::e_uint:
-            m_data.uint = (uint_t)UnsignedBits (m_data.uint, msbit, lsbit);
-            return true;
-            
         case Scalar::e_slong:
-            m_data.slong = (slong_t)SignedBits (m_data.slong, msbit, lsbit);
-            return true;
-
-        case Scalar::e_ulong:
-            m_data.ulong = (ulong_t)UnsignedBits (m_data.ulong, msbit, lsbit);
-            return true;
-            
         case Scalar::e_slonglong:
-            m_data.slonglong = (slonglong_t)SignedBits (m_data.slonglong, msbit, lsbit);
+        case Scalar::e_sint128:
+            m_integer = SignedBits (*m_integer.getRawData(), msbit, lsbit);
             return true;
 
+        case Scalar::e_uint:
+        case Scalar::e_ulong:
         case Scalar::e_ulonglong:
-            m_data.ulonglong = (ulonglong_t)UnsignedBits (m_data.ulonglong, msbit, lsbit);
+        case Scalar::e_uint128:
+            m_integer = UnsignedBits (*m_integer.getRawData(), msbit, lsbit);
             return true;
     }
     return false;
@@ -2132,18 +2672,25 @@ lldb_private::operator== (const Scalar&
     Scalar temp_value;
     const Scalar* a;
     const Scalar* b;
+    llvm::APFloat::cmpResult result;
     switch (PromoteToMaxType(lhs, rhs, temp_value, a, b))
     {
     case Scalar::e_void:            break;
-    case Scalar::e_sint:            return a->m_data.sint       == b->m_data.sint;
-    case Scalar::e_uint:            return a->m_data.uint       == b->m_data.uint;
-    case Scalar::e_slong:           return a->m_data.slong      == b->m_data.slong;
-    case Scalar::e_ulong:           return a->m_data.ulong      == b->m_data.ulong;
-    case Scalar::e_slonglong:       return a->m_data.slonglong  == b->m_data.slonglong;
-    case Scalar::e_ulonglong:       return a->m_data.ulonglong  == b->m_data.ulonglong;
-    case Scalar::e_float:           return a->m_data.flt        == b->m_data.flt;
-    case Scalar::e_double:      return a->m_data.dbl        == b->m_data.dbl;
-    case Scalar::e_long_double: return a->m_data.ldbl       == b->m_data.ldbl;
+    case Scalar::e_sint:
+    case Scalar::e_uint:
+    case Scalar::e_slong:
+    case Scalar::e_ulong:
+    case Scalar::e_slonglong:
+    case Scalar::e_ulonglong:
+    case Scalar::e_sint128:
+    case Scalar::e_uint128:
+        return a->m_integer == b->m_integer;
+    case Scalar::e_float:
+    case Scalar::e_double:
+    case Scalar::e_long_double:
+        result = a->m_float.compare(b->m_float);
+        if(result == llvm::APFloat::cmpEqual)
+            return true;
     }
     return false;
 }
@@ -2158,18 +2705,25 @@ lldb_private::operator!= (const Scalar&
     Scalar temp_value;  // A temp value that might get a copy of either promoted value
     const Scalar* a;
     const Scalar* b;
+    llvm::APFloat::cmpResult result;
     switch (PromoteToMaxType(lhs, rhs, temp_value, a, b))
     {
     case Scalar::e_void:            break;
-    case Scalar::e_sint:            return a->m_data.sint       != b->m_data.sint;
-    case Scalar::e_uint:            return a->m_data.uint       != b->m_data.uint;
-    case Scalar::e_slong:           return a->m_data.slong      != b->m_data.slong;
-    case Scalar::e_ulong:           return a->m_data.ulong      != b->m_data.ulong;
-    case Scalar::e_slonglong:       return a->m_data.slonglong  != b->m_data.slonglong;
-    case Scalar::e_ulonglong:       return a->m_data.ulonglong  != b->m_data.ulonglong;
-    case Scalar::e_float:           return a->m_data.flt        != b->m_data.flt;
-    case Scalar::e_double:      return a->m_data.dbl        != b->m_data.dbl;
-    case Scalar::e_long_double: return a->m_data.ldbl       != b->m_data.ldbl;
+    case Scalar::e_sint:
+    case Scalar::e_uint:
+    case Scalar::e_slong:
+    case Scalar::e_ulong:
+    case Scalar::e_slonglong:
+    case Scalar::e_ulonglong:
+    case Scalar::e_sint128:
+    case Scalar::e_uint128:
+        return a->m_integer != b->m_integer;
+    case Scalar::e_float:
+    case Scalar::e_double:
+    case Scalar::e_long_double:
+        result = a->m_float.compare(b->m_float);
+        if(result != llvm::APFloat::cmpEqual)
+            return true;
     }
     return true;
 }
@@ -2183,18 +2737,26 @@ lldb_private::operator< (const Scalar& l
     Scalar temp_value;
     const Scalar* a;
     const Scalar* b;
+    llvm::APFloat::cmpResult result;
     switch (PromoteToMaxType(lhs, rhs, temp_value, a, b))
     {
     case Scalar::e_void:            break;
-    case Scalar::e_sint:            return a->m_data.sint       < b->m_data.sint;
-    case Scalar::e_uint:            return a->m_data.uint       < b->m_data.uint;
-    case Scalar::e_slong:           return a->m_data.slong      < b->m_data.slong;
-    case Scalar::e_ulong:           return a->m_data.ulong      < b->m_data.ulong;
-    case Scalar::e_slonglong:       return a->m_data.slonglong  < b->m_data.slonglong;
-    case Scalar::e_ulonglong:       return a->m_data.ulonglong  < b->m_data.ulonglong;
-    case Scalar::e_float:           return a->m_data.flt        < b->m_data.flt;
-    case Scalar::e_double:      return a->m_data.dbl        < b->m_data.dbl;
-    case Scalar::e_long_double: return a->m_data.ldbl       < b->m_data.ldbl;
+    case Scalar::e_sint:
+    case Scalar::e_slong:
+    case Scalar::e_slonglong:
+    case Scalar::e_sint128:
+        return a->m_integer.slt(b->m_integer);
+    case Scalar::e_uint:
+    case Scalar::e_ulong:
+    case Scalar::e_ulonglong:
+    case Scalar::e_uint128:
+        return a->m_integer.ult(b->m_integer);
+    case Scalar::e_float:
+    case Scalar::e_double:
+    case Scalar::e_long_double:
+        result = a->m_float.compare(b->m_float);
+        if(result == llvm::APFloat::cmpLessThan)
+            return true;
     }
     return false;
 }
@@ -2208,18 +2770,26 @@ lldb_private::operator<= (const Scalar&
     Scalar temp_value;
     const Scalar* a;
     const Scalar* b;
+    llvm::APFloat::cmpResult result;
     switch (PromoteToMaxType(lhs, rhs, temp_value, a, b))
     {
     case Scalar::e_void:            break;
-    case Scalar::e_sint:            return a->m_data.sint       <= b->m_data.sint;
-    case Scalar::e_uint:            return a->m_data.uint       <= b->m_data.uint;
-    case Scalar::e_slong:           return a->m_data.slong      <= b->m_data.slong;
-    case Scalar::e_ulong:           return a->m_data.ulong      <= b->m_data.ulong;
-    case Scalar::e_slonglong:       return a->m_data.slonglong  <= b->m_data.slonglong;
-    case Scalar::e_ulonglong:       return a->m_data.ulonglong  <= b->m_data.ulonglong;
-    case Scalar::e_float:           return a->m_data.flt        <= b->m_data.flt;
-    case Scalar::e_double:      return a->m_data.dbl        <= b->m_data.dbl;
-    case Scalar::e_long_double: return a->m_data.ldbl       <= b->m_data.ldbl;
+    case Scalar::e_sint:
+    case Scalar::e_slong:
+    case Scalar::e_slonglong:
+    case Scalar::e_sint128:
+        return a->m_integer.sle(b->m_integer);
+    case Scalar::e_uint:
+    case Scalar::e_ulong:
+    case Scalar::e_ulonglong:
+    case Scalar::e_uint128:
+        return a->m_integer.ule(b->m_integer);
+    case Scalar::e_float:
+    case Scalar::e_double:
+    case Scalar::e_long_double:
+        result = a->m_float.compare(b->m_float);
+        if(result == llvm::APFloat::cmpLessThan || result == llvm::APFloat::cmpEqual)
+            return true;
     }
     return false;
 }
@@ -2234,18 +2804,26 @@ lldb_private::operator> (const Scalar& l
     Scalar temp_value;
     const Scalar* a;
     const Scalar* b;
+    llvm::APFloat::cmpResult result;
     switch (PromoteToMaxType(lhs, rhs, temp_value, a, b))
     {
-    case Scalar::e_void:            break;
-    case Scalar::e_sint:            return a->m_data.sint       > b->m_data.sint;
-    case Scalar::e_uint:            return a->m_data.uint       > b->m_data.uint;
-    case Scalar::e_slong:           return a->m_data.slong      > b->m_data.slong;
-    case Scalar::e_ulong:           return a->m_data.ulong      > b->m_data.ulong;
-    case Scalar::e_slonglong:       return a->m_data.slonglong  > b->m_data.slonglong;
-    case Scalar::e_ulonglong:       return a->m_data.ulonglong  > b->m_data.ulonglong;
-    case Scalar::e_float:           return a->m_data.flt        > b->m_data.flt;
-    case Scalar::e_double:      return a->m_data.dbl        > b->m_data.dbl;
-    case Scalar::e_long_double: return a->m_data.ldbl       > b->m_data.ldbl;
+        case Scalar::e_void:            break;
+        case Scalar::e_sint:
+        case Scalar::e_slong:
+        case Scalar::e_slonglong:
+        case Scalar::e_sint128:
+            return a->m_integer.sgt(b->m_integer);
+        case Scalar::e_uint:
+        case Scalar::e_ulong:
+        case Scalar::e_ulonglong:
+        case Scalar::e_uint128:
+            return a->m_integer.ugt(b->m_integer);
+        case Scalar::e_float:
+        case Scalar::e_double:
+        case Scalar::e_long_double:
+        result = a->m_float.compare(b->m_float);
+        if(result == llvm::APFloat::cmpGreaterThan)
+            return true;
     }
     return false;
 }
@@ -2259,22 +2837,138 @@ lldb_private::operator>= (const Scalar&
     Scalar temp_value;
     const Scalar* a;
     const Scalar* b;
+    llvm::APFloat::cmpResult result;
     switch (PromoteToMaxType(lhs, rhs, temp_value, a, b))
     {
-    case Scalar::e_void:            break;
-    case Scalar::e_sint:            return a->m_data.sint       >= b->m_data.sint;
-    case Scalar::e_uint:            return a->m_data.uint       >= b->m_data.uint;
-    case Scalar::e_slong:           return a->m_data.slong      >= b->m_data.slong;
-    case Scalar::e_ulong:           return a->m_data.ulong      >= b->m_data.ulong;
-    case Scalar::e_slonglong:       return a->m_data.slonglong  >= b->m_data.slonglong;
-    case Scalar::e_ulonglong:       return a->m_data.ulonglong  >= b->m_data.ulonglong;
-    case Scalar::e_float:           return a->m_data.flt        >= b->m_data.flt;
-    case Scalar::e_double:      return a->m_data.dbl        >= b->m_data.dbl;
-    case Scalar::e_long_double: return a->m_data.ldbl       >= b->m_data.ldbl;
+        case Scalar::e_void:            break;
+        case Scalar::e_sint:
+        case Scalar::e_slong:
+        case Scalar::e_slonglong:
+        case Scalar::e_sint128:
+            return a->m_integer.sge(b->m_integer);
+        case Scalar::e_uint:
+        case Scalar::e_ulong:
+        case Scalar::e_ulonglong:
+        case Scalar::e_uint128:
+            return a->m_integer.uge(b->m_integer);
+        case Scalar::e_float:
+        case Scalar::e_double:
+        case Scalar::e_long_double:
+        result = a->m_float.compare(b->m_float);
+        if(result == llvm::APFloat::cmpGreaterThan || result == llvm::APFloat::cmpEqual)
+            return true;
     }
     return false;
 }
 
+bool
+Scalar::ClearBit (uint32_t bit)
+{
+    switch (m_type)
+    {
+    case e_void:
+        break;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128: m_integer.clearBit(bit); return true;
+    case e_float:
+    case e_double:
+    case e_long_double: break;
+    }
+    return false;
+}
 
+bool
+Scalar::SetBit (uint32_t bit)
+{
+    switch (m_type)
+    {
+    case e_void:
+        break;
+    case e_sint:
+    case e_uint:
+    case e_slong:
+    case e_ulong:
+    case e_slonglong:
+    case e_ulonglong:
+    case e_sint128:
+    case e_uint128: m_integer.setBit(bit); return true;
+    case e_float:
+    case e_double:
+    case e_long_double: break;
+    }
+    return false;
+}
 
-
+void
+Scalar::SetType (const RegisterInfo *reg_info)
+{
+    const uint32_t byte_size = reg_info->byte_size;
+    switch (reg_info->encoding)
+    {
+        case eEncodingInvalid:
+            break;
+        case eEncodingUint:
+            if (byte_size == 1 || byte_size == 2 || byte_size == 4)
+            {
+                m_integer = llvm::APInt(sizeof(uint_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+                m_type = e_uint;
+            }
+            if (byte_size == 8)
+            {
+                m_integer = llvm::APInt(sizeof(ulonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+                m_type = e_ulonglong;
+            }
+            if (byte_size == 16)
+            {
+                m_integer = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)m_integer.getRawData())->x);
+                m_type = e_uint128;
+            }
+            break;
+        case eEncodingSint:
+            if (byte_size == 1 || byte_size == 2 || byte_size == 4)
+            {
+                m_integer = llvm::APInt(sizeof(sint_t) * 8, *(const uint64_t *)m_integer.getRawData(), true);
+                m_type = e_sint;
+            }
+            if (byte_size == 8)
+            {
+                m_integer = llvm::APInt(sizeof(slonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), true);
+                m_type = e_slonglong;
+            }
+            if (byte_size == 16)
+            {
+                m_integer = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)m_integer.getRawData())->x);
+                m_type = e_sint128;
+            }
+            break;
+        case eEncodingIEEE754:
+            if (byte_size == sizeof(float))
+            {
+                m_float = llvm::APFloat(m_float.convertToFloat());
+                m_type = e_float;
+            }
+            else if (byte_size == sizeof(double))
+            {
+                m_float = llvm::APFloat(m_float.convertToDouble());
+                m_type = e_double;
+            }
+            else if (byte_size == sizeof(long double))
+            {
+                if(m_ieee_quad)
+                     m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_float.bitcastToAPInt());
+                 else
+                     m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_float.bitcastToAPInt());
+                m_type = e_long_double;
+            }
+            break;
+        case eEncodingVector:
+            m_type = e_void;
+            break;
+    }
+}

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=245547&r1=245546&r2=245547&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Thu Aug 20 04:12:46 2015
@@ -1897,7 +1897,7 @@ ValueObject::SetValueFromCString (const
         // If the value is already a scalar, then let the scalar change itself:
         m_value.GetScalar().SetValueFromCString (value_str, encoding, byte_size);
     }
-    else if (byte_size <= Scalar::GetMaxByteSize())
+    else if (byte_size <= 16)
     {
         // If the value fits in a scalar, then make a new scalar and again let the
         // scalar code do the conversion, then figure out where to put the new value.




More information about the lldb-commits mailing list