Fail* CPUState: set/getRegisterContent() uses "const Register*" as 1st param

The first parameter (Register* reg) is only used as input (const-correctness).

Change-Id: I5a75a9f7378913e491a8a22872f51a385e910af6
This commit is contained in:
Adrian Böckenkamp
2013-04-29 16:09:28 +02:00
committed by Gerrit Code Review
parent 72c9ba6363
commit 515eb9973b
7 changed files with 14 additions and 14 deletions

View File

@ -20,13 +20,13 @@ public:
* Gets the content of the passed Register. * Gets the content of the passed Register.
* @param reg the register to get the content from * @param reg the register to get the content from
*/ */
virtual regdata_t getRegisterContent(Register* reg) const = 0; virtual regdata_t getRegisterContent(const Register* reg) const = 0;
/** /**
* Writes the passed value into the given register. * Writes the passed value into the given register.
* @param reg the register that should be written to * @param reg the register that should be written to
* @param value the value that should be written into the register * @param value the value that should be written into the register
*/ */
virtual void setRegisterContent(Register* reg, regdata_t value) = 0; virtual void setRegisterContent(const Register* reg, regdata_t value) = 0;
/** /**
* Returns the current instruction pointer. * Returns the current instruction pointer.
* @return the current eip * @return the current eip

View File

@ -5,7 +5,7 @@
namespace fail { namespace fail {
regdata_t BochsCPU::getRegisterContent(Register* reg) const regdata_t BochsCPU::getRegisterContent(const Register* reg) const
{ {
assert(reg != NULL && "FATAL ERROR: reg-ptr cannot be NULL!"); assert(reg != NULL && "FATAL ERROR: reg-ptr cannot be NULL!");
// TODO: BX_CPU(0) *always* correct? // TODO: BX_CPU(0) *always* correct?
@ -26,7 +26,7 @@ regdata_t BochsCPU::getRegisterContent(Register* reg) const
#endif // SIM_SUPPORT_64 #endif // SIM_SUPPORT_64
} }
void BochsCPU::setRegisterContent(Register* reg, regdata_t value) void BochsCPU::setRegisterContent(const Register* reg, regdata_t value)
{ {
assert(reg != NULL && "FATAL ERROR: reg-ptr cannot be NULL!"); assert(reg != NULL && "FATAL ERROR: reg-ptr cannot be NULL!");
// TODO: BX_CPU(0) *always* correct? // TODO: BX_CPU(0) *always* correct?

View File

@ -36,13 +36,13 @@ public:
* @param reg the register pointer of interest (cannot be \c NULL) * @param reg the register pointer of interest (cannot be \c NULL)
* @return the content of the register \c reg * @return the content of the register \c reg
*/ */
regdata_t getRegisterContent(Register* reg) const; regdata_t getRegisterContent(const Register* reg) const;
/** /**
* Sets the content of the register \c reg to \c value. * Sets the content of the register \c reg to \c value.
* @param reg the destination register object pointer (cannot be \c NULL) * @param reg the destination register object pointer (cannot be \c NULL)
* @param value the new value to assign * @param value the new value to assign
*/ */
void setRegisterContent(Register* reg, regdata_t value); void setRegisterContent(const Register* reg, regdata_t value);
/** /**
* Returns the current instruction pointer (aka program counter). * Returns the current instruction pointer (aka program counter).
* @return the current (e)ip register content * @return the current (e)ip register content

View File

@ -4,12 +4,12 @@
namespace fail { namespace fail {
regdata_t Gem5ArmCPU::getRegisterContent(Register* reg) const regdata_t Gem5ArmCPU::getRegisterContent(const Register* reg) const
{ {
return GetRegisterContent(m_System, m_Id, reg->getType(), reg->getIndex()); return GetRegisterContent(m_System, m_Id, reg->getType(), reg->getIndex());
} }
void Gem5ArmCPU::setRegisterContent(Register* reg, regdata_t value) void Gem5ArmCPU::setRegisterContent(const Register* reg, regdata_t value)
{ {
SetRegisterContent(m_System, m_Id, reg->getType(), reg->getIndex(), value); SetRegisterContent(m_System, m_Id, reg->getType(), reg->getIndex(), value);
} }

View File

@ -33,13 +33,13 @@ public:
* @param reg the destination register whose content should be retrieved * @param reg the destination register whose content should be retrieved
* @return the content of register \c reg * @return the content of register \c reg
*/ */
regdata_t getRegisterContent(Register* reg) const; regdata_t getRegisterContent(const Register* reg) const;
/** /**
* Sets the register content for the \a current gem5 CPU. * Sets the register content for the \a current gem5 CPU.
* @param reg the (initialized) register object whose content should be set * @param reg the (initialized) register object whose content should be set
* @param value the new content of the register \c reg * @param value the new content of the register \c reg
*/ */
void setRegisterContent(Register* reg, regdata_t value); void setRegisterContent(const Register* reg, regdata_t value);
/** /**
* Retrieves the current instruction pointer (IP aka program counter, PC for short) * Retrieves the current instruction pointer (IP aka program counter, PC for short)
* for the current CPU \c this. * for the current CPU \c this.

View File

@ -6,7 +6,7 @@ namespace fail {
static const uint64_t lower = 0x00000000ffffffff; static const uint64_t lower = 0x00000000ffffffff;
regdata_t T32ArmCPU::getRegisterContent(Register* reg) const regdata_t T32ArmCPU::getRegisterContent(const Register* reg) const
{ {
// T32_ReadRegister wants a mask of bits representig the registers to read: // T32_ReadRegister wants a mask of bits representig the registers to read:
// e.g., reading R1 and R4 and R63 // e.g., reading R1 and R4 and R63
@ -28,7 +28,7 @@ regdata_t T32ArmCPU::getRegisterContent(Register* reg) const
return 0; // we should not come here. return 0; // we should not come here.
} }
void T32ArmCPU::setRegisterContent(Register* reg, regdata_t value) void T32ArmCPU::setRegisterContent(const Register* reg, regdata_t value)
{ {
uint64_t mask = (1 << reg->getIndex()); uint64_t mask = (1 << reg->getIndex());

View File

@ -29,13 +29,13 @@ public:
* @param reg the destination register whose content should be retrieved * @param reg the destination register whose content should be retrieved
* @return the content of register \c reg * @return the content of register \c reg
*/ */
regdata_t getRegisterContent(Register* reg) const; regdata_t getRegisterContent(const Register* reg) const;
/** /**
* Sets the register content for the \a current CPU. * Sets the register content for the \a current CPU.
* @param reg the (initialized) register object whose content should be set * @param reg the (initialized) register object whose content should be set
* @param value the new content of the register \c reg * @param value the new content of the register \c reg
*/ */
void setRegisterContent(Register* reg, regdata_t value); void setRegisterContent(const Register* reg, regdata_t value);
/** /**
* Retrieves the current instruction pointer (IP aka program counter, PC for short) * Retrieves the current instruction pointer (IP aka program counter, PC for short)
* for the current CPU \c this. * for the current CPU \c this.