Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/36876 )
Change subject: cpu: Access src and dest reg indexes using a pointer to
member.
......................................................................
cpu: Access src and dest reg indexes using a pointer to member.
This will eventually let subclasses provide their own appropriately
sized storage for these indexes. By using a pointer to member instead of
a regular pointer, we ensure that even if the StaticInst is copied/moved
somewhere, it will still find its indexes correctly, without any
additional performance overhead or maintenance.
Change-Id: Id747b0cf68d1a0b4809ebb66a32472187110d7d8
---
M src/cpu/static_inst.hh
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/src/cpu/static_inst.hh b/src/cpu/static_inst.hh
index 0e105aa..cf4ba3f 100644
--- a/src/cpu/static_inst.hh
+++ b/src/cpu/static_inst.hh
@@ -94,10 +94,14 @@
};
private:
- /// See destRegIdx().
- RegId _destRegIdx[MaxInstDestRegs];
+
/// See srcRegIdx().
RegId _srcRegIdx[MaxInstSrcRegs];
+ RegId (StaticInst:: *_srcRegIdxPtr)[] = nullptr;
+
+ /// See destRegIdx().
+ RegId _destRegIdx[MaxInstDestRegs];
+ RegId (StaticInst:: *_destRegIdxPtr)[] = nullptr;
protected:
@@ -236,15 +240,23 @@
/// Return logical index (architectural reg num) of i'th destination
reg.
/// Only the entries from 0 through numDestRegs()-1 are valid.
- const RegId& destRegIdx(int i) const { return _destRegIdx[i]; }
+ const RegId &destRegIdx(int i) const { return
(this->*_destRegIdxPtr)[i]; }
- void destRegIdx(int i, const RegId &val) { _destRegIdx[i] = val; }
+ void
+ destRegIdx(int i, const RegId &val)
+ {
+ (this->*_destRegIdxPtr)[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]; }
+ const RegId &srcRegIdx(int i) const { return
(this->*_srcRegIdxPtr)[i]; }
- void srcRegIdx(int i, const RegId &val) { _srcRegIdx[i] = val; }
+ void
+ srcRegIdx(int i, const RegId &val)
+ {
+ (this->*_srcRegIdxPtr)[i] = val;
+ }
/// Pointer to a statically allocated "null" instruction object.
static StaticInstPtr nullStaticInstPtr;
@@ -283,10 +295,12 @@
/// the fields that are meaningful for the particular
/// instruction.
StaticInst(const char *_mnemonic, ExtMachInst _machInst, OpClass
__opClass)
- : _opClass(__opClass), _numSrcRegs(0), _numDestRegs(0),
- _numFPDestRegs(0), _numIntDestRegs(0), _numCCDestRegs(0),
- _numVecDestRegs(0), _numVecElemDestRegs(0),
_numVecPredDestRegs(0),
- machInst(_machInst), mnemonic(_mnemonic), cachedDisassembly(0)
+ : _srcRegIdxPtr(&StaticInst::_srcRegIdx),
+ _destRegIdxPtr(&StaticInst::_destRegIdx), _opClass(__opClass),
+ _numSrcRegs(0), _numDestRegs(0), _numFPDestRegs(0),
+ _numIntDestRegs(0), _numCCDestRegs(0), _numVecDestRegs(0),
+ _numVecElemDestRegs(0), _numVecPredDestRegs(0),
machInst(_machInst),
+ mnemonic(_mnemonic), cachedDisassembly(0)
{ }
public:
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/36876
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Id747b0cf68d1a0b4809ebb66a32472187110d7d8
Gerrit-Change-Number: 36876
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s