diff --git a/include/remill/Arch/Runtime/Types.h b/include/remill/Arch/Runtime/Types.h index 0a863465d..28719d9c7 100644 --- a/include/remill/Arch/Runtime/Types.h +++ b/include/remill/Arch/Runtime/Types.h @@ -88,9 +88,10 @@ struct float80_t final { static_assert(12 == sizeof(long double) || 16 == sizeof(long double), "Invalid `float128_t` size."); union union_ld { - uint8_t data[sizeof(float128_t)]; - float128_t ld; + uint8_t data[sizeof(long double)]; + long double ld; } __attribute((packed)); + union_ld f80 = {.ld = ld}; for (unsigned i = 0; i < sizeof(float80_t); i++) { this->data[i] = f80.data[i]; @@ -110,12 +111,46 @@ struct float80_t final { f80.data[i] = this->data[i]; } - return static_cast(f80.ld); + return f80.ld; + } + +#elif defined(__aarch64__) || defined(__arm__) + inline float80_t(long double ld) { + static_assert(8 == sizeof(long double), "Invalid `long double` size."); + + union union_ld { + uint8_t data[sizeof(long double)]; + long double ld; + } __attribute((packed)); + + union_ld f80 = {.ld = ld}; + for (unsigned i = 0; i < sizeof(long double); i++) { + this->data[i] = f80.data[i]; + } + } + + operator long double() { + static_assert(8 == sizeof(long double), "Invalid `long double` size."); + + union union_ld { + uint8_t data[sizeof(long double)]; + long double ld; + } __attribute((packed)); + + union_ld f80 = {{0}}; + for (unsigned i = 0; i < sizeof(long double); i++) { + f80.data[i] = this->data[i]; + } + + return f80.ld; } + +#else +#error "float80_t not supported!"; #endif } __attribute__((packed)); -//static_assert(10 == sizeof(float80_t), "Invalid `float80_t` size."); +static_assert(10 == sizeof(float80_t), "Invalid `float80_t` size."); union nan32_t { float32_t f;