diff --git a/src/arch/x86/utility.cc b/src/arch/x86/utility.cc --- a/src/arch/x86/utility.cc +++ b/src/arch/x86/utility.cc @@ -354,17 +354,17 @@ double loadFloat80(const void *_mem) { - const fp80_t *fp80((const fp80_t *)_mem); + fp80_t fp80; + memcpy(fp80.bits, _mem, 10); - return fp80_cvtd(*fp80); + return fp80_cvtd(fp80); } void storeFloat80(void *_mem, double value) { - fp80_t *fp80((fp80_t *)_mem); - - *fp80 = fp80_cvfd(value); + fp80_t fp80 = fp80_cvfd(value); + memcpy(_mem, fp80.bits, 10); } } // namespace X86_ISA # Node ID c211fc37d7a16c53baa4b77995ec73eaaa718c48 # Parent c638b7be766b0f73c9a4daf7b11973eaad1e698d diff --git a/ext/fputils/fpbits.h b/ext/fputils/fpbits.h --- a/ext/fputils/fpbits.h +++ b/ext/fputils/fpbits.h @@ -84,6 +84,7 @@ #define BUILD_FP80(sign, frac, exp) \ { \ + .repr.pad = { 0 }, \ .repr.se = BUILD_FP80_SE(sign, exp), \ .repr.fi = BUILD_FP80_FI(frac, exp) \ } diff --git a/ext/fputils/include/fputils/fptypes.h b/ext/fputils/include/fputils/fptypes.h --- a/ext/fputils/include/fputils/fptypes.h +++ b/ext/fputils/include/fputils/fptypes.h @@ -69,12 +69,16 @@ uint64_t fi; /** Raw representation of sign bit and exponent */ uint16_t se; + /** Add explicit padding to ensure this data structure + * is properly aligned. + */ + uint16_t pad[3]; } repr; /** * Represented as a char array, mainly intended for debug dumping * and serialization. */ - char bits[10]; + char bits[16]; } fp80_t; /** @} */ diff --git a/src/arch/x86/isa/microops/fpop.isa b/src/arch/x86/isa/microops/fpop.isa --- a/src/arch/x86/isa/microops/fpop.isa +++ b/src/arch/x86/isa/microops/fpop.isa @@ -342,7 +342,7 @@ # extract the highest 64 bits. class cvtfp80h_int(ConvOp): code = ''' - char bits[10]; + uint8_t bits[10]; storeFloat80(bits, FpSrcReg1); SDestReg = *(uint64_t *)(bits + 0); ''' @@ -351,7 +351,7 @@ # extract the lowest 16 bits. class cvtfp80l_int(ConvOp): code = ''' - char bits[10]; + uint8_t bits[10]; storeFloat80(bits, FpSrcReg1); SDestReg = *(uint16_t *)(bits + 8); '''