From ff7fc9de6955ba3e00898eb703b3da1a15fb417c Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 19 Nov 2018 17:30:06 -0800 Subject: [PATCH] cpu: Stop using unions to store FP registers. These are now accessed only as integer values. Change-Id: I21ae6537ebbcbaa02890384194ee1ce001c092bb Reviewed-on: https://gem5-review.googlesource.com/c/14458 Reviewed-by: Giacomo Travaglini Maintainer: Gabe Black --- src/cpu/o3/regfile.hh | 11 +++-------- src/cpu/simple_thread.hh | 19 ++++++++----------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/cpu/o3/regfile.hh b/src/cpu/o3/regfile.hh index 2f874213f..354fe2bc5 100644 --- a/src/cpu/o3/regfile.hh +++ b/src/cpu/o3/regfile.hh @@ -79,17 +79,12 @@ class PhysRegFile private: static constexpr auto NumVecElemPerVecReg = TheISA::NumVecElemPerVecReg; - typedef union { - FloatReg d; - FloatRegBits q; - } PhysFloatReg; - /** Integer register file. */ std::vector intRegFile; std::vector intRegIds; /** Floating point register file. */ - std::vector floatRegFile; + std::vector floatRegFile; std::vector floatRegIds; /** Vector register file. */ @@ -191,7 +186,7 @@ class PhysRegFile { assert(phys_reg->isFloatPhysReg()); - FloatRegBits floatRegBits = floatRegFile[phys_reg->index()].q; + FloatRegBits floatRegBits = floatRegFile[phys_reg->index()]; DPRINTF(IEW, "RegFile: Access to float register %i as int, " "has data %#x\n", phys_reg->index(), @@ -294,7 +289,7 @@ class PhysRegFile phys_reg->index(), (uint64_t)val); if (!phys_reg->isZeroReg()) - floatRegFile[phys_reg->index()].q = val; + floatRegFile[phys_reg->index()] = val; } /** Sets a vector register to the given value. */ diff --git a/src/cpu/simple_thread.hh b/src/cpu/simple_thread.hh index 601aa7c07..65491f27a 100644 --- a/src/cpu/simple_thread.hh +++ b/src/cpu/simple_thread.hh @@ -109,10 +109,7 @@ class SimpleThread : public ThreadState typedef ThreadContext::Status Status; protected: - union { - FloatReg f[TheISA::NumFloatRegs]; - FloatRegBits i[TheISA::NumFloatRegs]; - } floatRegs; + FloatRegBits floatRegs[TheISA::NumFloatRegs]; TheISA::IntReg intRegs[TheISA::NumIntRegs]; VecRegContainer vecRegs[TheISA::NumVecRegs]; #ifdef ISA_HAS_CC_REGS @@ -230,7 +227,7 @@ class SimpleThread : public ThreadState { _pcState = 0; memset(intRegs, 0, sizeof(intRegs)); - memset(floatRegs.i, 0, sizeof(floatRegs.i)); + memset(floatRegs, 0, sizeof(floatRegs)); for (int i = 0; i < TheISA::NumVecRegs; i++) { vecRegs[i].zero(); } @@ -258,8 +255,8 @@ class SimpleThread : public ThreadState int flatIndex = isa->flattenFloatIndex(reg_idx); assert(flatIndex < TheISA::NumFloatRegs); FloatRegBits regVal(readFloatRegBitsFlat(flatIndex)); - DPRINTF(FloatRegs, "Reading float reg %d (%d) bits as %#x, %f.\n", - reg_idx, flatIndex, regVal, floatRegs.f[flatIndex]); + DPRINTF(FloatRegs, "Reading float reg %d (%d) bits as %#x.\n", + reg_idx, flatIndex, regVal); return regVal; } @@ -388,8 +385,8 @@ class SimpleThread : public ThreadState // when checkercpu enabled if (flatIndex < TheISA::NumFloatRegs) setFloatRegBitsFlat(flatIndex, val); - DPRINTF(FloatRegs, "Setting float reg %d (%d) bits to %#x, %#f.\n", - reg_idx, flatIndex, val, floatRegs.f[flatIndex]); + DPRINTF(FloatRegs, "Setting float reg %d (%d) bits to %#x.\n", + reg_idx, flatIndex, val); } void setVecReg(const RegId& reg, const VecRegContainer& val) @@ -518,9 +515,9 @@ class SimpleThread : public ThreadState uint64_t readIntRegFlat(int idx) { return intRegs[idx]; } void setIntRegFlat(int idx, uint64_t val) { intRegs[idx] = val; } - FloatRegBits readFloatRegBitsFlat(int idx) { return floatRegs.i[idx]; } + FloatRegBits readFloatRegBitsFlat(int idx) { return floatRegs[idx]; } void setFloatRegBitsFlat(int idx, FloatRegBits val) { - floatRegs.i[idx] = val; + floatRegs[idx] = val; } const VecRegContainer& readVecRegFlat(const RegIndex& reg) const -- 2.30.2