// automagically by the compiler, so no temporary objects will need to be
// created. As a result, we currently don't need a variety of overloaded set
// value accessors.
- Scalar &operator=(const int i);
- Scalar &operator=(unsigned int v);
- Scalar &operator=(long v);
- Scalar &operator=(unsigned long v);
- Scalar &operator=(long long v);
- Scalar &operator=(unsigned long long v);
- Scalar &operator=(float v);
- Scalar &operator=(double v);
- Scalar &operator=(long double v);
- Scalar &operator=(llvm::APInt v);
Scalar &operator+=(const Scalar &rhs);
Scalar &operator<<=(const Scalar &rhs); // Shift left
Scalar &operator>>=(const Scalar &rhs); // Shift right (arithmetic)
return "<invalid Scalar type>";
}
-Scalar &Scalar::operator=(const int v) {
- m_type = e_sint;
- m_integer = llvm::APInt(sizeof(int) * 8, v, true);
- return *this;
-}
-
-Scalar &Scalar::operator=(unsigned int v) {
- m_type = e_uint;
- m_integer = llvm::APInt(sizeof(int) * 8, v);
- return *this;
-}
-
-Scalar &Scalar::operator=(long v) {
- m_type = e_slong;
- m_integer = llvm::APInt(sizeof(long) * 8, v, true);
- return *this;
-}
-
-Scalar &Scalar::operator=(unsigned long v) {
- m_type = e_ulong;
- m_integer = llvm::APInt(sizeof(long) * 8, v);
- return *this;
-}
-
-Scalar &Scalar::operator=(long long v) {
- m_type = e_slonglong;
- m_integer = llvm::APInt(sizeof(long long) * 8, v, true);
- return *this;
-}
-
-Scalar &Scalar::operator=(unsigned long long v) {
- m_type = e_ulonglong;
- m_integer = llvm::APInt(sizeof(long long) * 8, v);
- return *this;
-}
-
-Scalar &Scalar::operator=(float v) {
- m_type = e_float;
- m_float = llvm::APFloat(v);
- return *this;
-}
-
-Scalar &Scalar::operator=(double v) {
- m_type = e_double;
- m_float = llvm::APFloat(v);
- return *this;
-}
-
-Scalar &Scalar::operator=(long double v) {
- m_type = e_long_double;
- m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended(),
- llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
- (reinterpret_cast<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;
- case 256:
- if (m_integer.isSignedIntN(BITWIDTH_INT256))
- m_type = e_sint256;
- else
- m_type = e_uint256;
- break;
- case 512:
- if (m_integer.isSignedIntN(BITWIDTH_INT512))
- m_type = e_sint512;
- else
- m_type = e_uint512;
- break;
- }
- return *this;
-}
-
Scalar::~Scalar() = default;
Scalar::Type Scalar::GetBestTypeForBitSize(size_t bit_size, bool sign) {