arch,cpu: Enforce using accessors to get at src/destRegIdx.

There were accessors for reading these indexes, but they were not
consistently used. This change makes them private to StaticInst, and
changes places that were accessing them directly to instead use the
accessors. New accessors are added for code generated by the ISA parser
and some ARM code to set the indexes without accessing them directly.

By forcing these values to be behind accessors, it will be much simpler
to change how those values are stored and retrieved.

Change-Id: Icca80023d7f89e29504fac6b194881f88aedeec2
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/36875
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2020-11-01 01:53:03 -07:00
parent a82ea84244
commit 2cfc24b8dc
43 changed files with 220 additions and 209 deletions

View File

@@ -93,6 +93,12 @@ class StaticInst : public RefCounted, public StaticInstFlags
MaxInstDestRegs = TheISA::MaxInstDestRegs //< Max dest regs
};
private:
/// See destRegIdx().
RegId _destRegIdx[MaxInstDestRegs];
/// See srcRegIdx().
RegId _srcRegIdx[MaxInstSrcRegs];
protected:
/// Flag values for this instruction.
@@ -232,10 +238,14 @@ class StaticInst : public RefCounted, public StaticInstFlags
/// Only the entries from 0 through numDestRegs()-1 are valid.
const RegId& destRegIdx(int i) const { return _destRegIdx[i]; }
void setDestRegIdx(int i, const RegId &val) { _destRegIdx[i] = val; }
/// Return logical index (architectural reg num) of i'th source reg.
/// Only the entries from 0 through numSrcRegs()-1 are valid.
const RegId& srcRegIdx(int i) const { return _srcRegIdx[i]; }
void setSrcRegIdx(int i, const RegId &val) { _srcRegIdx[i] = val; }
/// Pointer to a statically allocated "null" instruction object.
static StaticInstPtr nullStaticInstPtr;
@@ -247,11 +257,6 @@ class StaticInst : public RefCounted, public StaticInstFlags
protected:
/// See destRegIdx().
RegId _destRegIdx[MaxInstDestRegs];
/// See srcRegIdx().
RegId _srcRegIdx[MaxInstSrcRegs];
/**
* Base mnemonic (e.g., "add"). Used by generateDisassembly()
* methods. Also useful to readily identify instructions from