Gabe Black has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/40176 )
Change subject: arch: Template the generic PC types on the instruction
width.
......................................................................
arch: Template the generic PC types on the instruction width.
These had been templated on a type, and then the width of that type was
considered the amount the PC should advance when executing straight line
code. That type was MachInst, which was loosely the size of an
instruction, but was practically whatever sized data type was fed into
the decoder at a time.
Instead of tying this to a type, this change moves it over to be a
simple number. This avoids a level of indirection, and also further
decouples the type the decoder might use as input from the instruction
size.
Change-Id: I797876a33d27e759c7a6e23a658179201fabfa47
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40176
Tested-by: kokoro <[email protected]>
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Bobby R. Bruce <[email protected]>
---
M src/arch/arm/types.hh
M src/arch/generic/types.hh
M src/arch/mips/types.hh
M src/arch/null/types.hh
M src/arch/power/types.hh
M src/arch/riscv/types.hh
M src/arch/sparc/types.hh
M src/arch/x86/types.hh
8 files changed, 42 insertions(+), 48 deletions(-)
Approvals:
Gabe Black: Looks good to me, approved
Bobby R. Bruce: Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/arch/arm/types.hh b/src/arch/arm/types.hh
index 2ec5255..6d5bc2a 100644
--- a/src/arch/arm/types.hh
+++ b/src/arch/arm/types.hh
@@ -213,11 +213,11 @@
Bitfield<11, 8> ltcoproc;
EndBitUnion(ExtMachInst)
- class PCState : public GenericISA::UPCState<MachInst>
+ class PCState : public GenericISA::UPCState<4>
{
protected:
- typedef GenericISA::UPCState<MachInst> Base;
+ typedef GenericISA::UPCState<4> Base;
enum FlagBits
{
diff --git a/src/arch/generic/types.hh b/src/arch/generic/types.hh
index 0f1e837..2e3b847 100644
--- a/src/arch/generic/types.hh
+++ b/src/arch/generic/types.hh
@@ -137,7 +137,7 @@
*/
// The most basic type of PC.
-template <class MachInst>
+template <int InstWidth>
class SimplePCState : public PCStateBase
{
protected:
@@ -155,7 +155,7 @@
set(Addr val)
{
pc(val);
- npc(val + sizeof(MachInst));
+ npc(val + InstWidth);
};
void
@@ -170,7 +170,7 @@
bool
branching() const
{
- return this->npc() != this->pc() + sizeof(MachInst);
+ return this->npc() != this->pc() + InstWidth;
}
// Advance the PC.
@@ -178,24 +178,24 @@
advance()
{
_pc = _npc;
- _npc += sizeof(MachInst);
+ _npc += InstWidth;
}
};
-template <class MachInst>
+template <int InstWidth>
std::ostream &
-operator<<(std::ostream & os, const SimplePCState<MachInst> &pc)
+operator<<(std::ostream & os, const SimplePCState<InstWidth> &pc)
{
ccprintf(os, "(%#x=>%#x)", pc.pc(), pc.npc());
return os;
}
// A PC and microcode PC.
-template <class MachInst>
-class UPCState : public SimplePCState<MachInst>
+template <int InstWidth>
+class UPCState : public SimplePCState<InstWidth>
{
protected:
- typedef SimplePCState<MachInst> Base;
+ typedef SimplePCState<InstWidth> Base;
MicroPC _upc;
MicroPC _nupc;
@@ -228,7 +228,7 @@
bool
branching() const
{
- return this->npc() != this->pc() + sizeof(MachInst) ||
+ return this->npc() != this->pc() + InstWidth ||
this->nupc() != this->upc() + 1;
}
@@ -258,7 +258,7 @@
}
bool
- operator == (const UPCState<MachInst> &opc) const
+ operator == (const UPCState<InstWidth> &opc) const
{
return Base::_pc == opc._pc &&
Base::_npc == opc._npc &&
@@ -266,7 +266,7 @@
}
bool
- operator != (const UPCState<MachInst> &opc) const
+ operator != (const UPCState<InstWidth> &opc) const
{
return !(*this == opc);
}
@@ -288,9 +288,9 @@
}
};
-template <class MachInst>
+template <int InstWidth>
std::ostream &
-operator<<(std::ostream & os, const UPCState<MachInst> &pc)
+operator<<(std::ostream & os, const UPCState<InstWidth> &pc)
{
ccprintf(os, "(%#x=>%#x).(%d=>%d)",
pc.pc(), pc.npc(), pc.upc(), pc.nupc());
@@ -298,11 +298,11 @@
}
// A PC with a delay slot.
-template <class MachInst>
-class DelaySlotPCState : public SimplePCState<MachInst>
+template <int InstWidth>
+class DelaySlotPCState : public SimplePCState<InstWidth>
{
protected:
- typedef SimplePCState<MachInst> Base;
+ typedef SimplePCState<InstWidth> Base;
Addr _nnpc;
@@ -315,7 +315,7 @@
set(Addr val)
{
Base::set(val);
- nnpc(val + 2 * sizeof(MachInst));
+ nnpc(val + 2 * InstWidth);
}
DelaySlotPCState() {}
@@ -324,9 +324,9 @@
bool
branching() const
{
- return !(this->nnpc() == this->npc() + sizeof(MachInst) &&
- (this->npc() == this->pc() + sizeof(MachInst) ||
- this->npc() == this->pc() + 2 * sizeof(MachInst)));
+ return !(this->nnpc() == this->npc() + InstWidth &&
+ (this->npc() == this->pc() + InstWidth ||
+ this->npc() == this->pc() + 2 * InstWidth));
}
// Advance the PC.
@@ -335,11 +335,11 @@
{
Base::_pc = Base::_npc;
Base::_npc = _nnpc;
- _nnpc += sizeof(MachInst);
+ _nnpc += InstWidth;
}
bool
- operator == (const DelaySlotPCState<MachInst> &opc) const
+ operator == (const DelaySlotPCState<InstWidth> &opc) const
{
return Base::_pc == opc._pc &&
Base::_npc == opc._npc &&
@@ -347,7 +347,7 @@
}
bool
- operator != (const DelaySlotPCState<MachInst> &opc) const
+ operator != (const DelaySlotPCState<InstWidth> &opc) const
{
return !(*this == opc);
}
@@ -367,9 +367,9 @@
}
};
-template <class MachInst>
+template <int InstWidth>
std::ostream &
-operator<<(std::ostream & os, const DelaySlotPCState<MachInst> &pc)
+operator<<(std::ostream & os, const DelaySlotPCState<InstWidth> &pc)
{
ccprintf(os, "(%#x=>%#x=>%#x)",
pc.pc(), pc.npc(), pc.nnpc());
@@ -377,11 +377,11 @@
}
// A PC with a delay slot and a microcode PC.
-template <class MachInst>
-class DelaySlotUPCState : public DelaySlotPCState<MachInst>
+template <int InstWidth>
+class DelaySlotUPCState : public DelaySlotPCState<InstWidth>
{
protected:
- typedef DelaySlotPCState<MachInst> Base;
+ typedef DelaySlotPCState<InstWidth> Base;
MicroPC _upc;
MicroPC _nupc;
@@ -435,7 +435,7 @@
}
bool
- operator == (const DelaySlotUPCState<MachInst> &opc) const
+ operator == (const DelaySlotUPCState<InstWidth> &opc) const
{
return Base::_pc == opc._pc &&
Base::_npc == opc._npc &&
@@ -444,7 +444,7 @@
}
bool
- operator != (const DelaySlotUPCState<MachInst> &opc) const
+ operator != (const DelaySlotUPCState<InstWidth> &opc) const
{
return !(*this == opc);
}
@@ -466,9 +466,9 @@
}
};
-template <class MachInst>
+template <int InstWidth>
std::ostream &
-operator<<(std::ostream & os, const DelaySlotUPCState<MachInst> &pc)
+operator<<(std::ostream & os, const DelaySlotUPCState<InstWidth> &pc)
{
ccprintf(os, "(%#x=>%#x=>%#x).(%d=>%d)",
pc.pc(), pc.npc(), pc.nnpc(), pc.upc(), pc.nupc());
diff --git a/src/arch/mips/types.hh b/src/arch/mips/types.hh
index 9168363..33a3afc 100644
--- a/src/arch/mips/types.hh
+++ b/src/arch/mips/types.hh
@@ -38,7 +38,7 @@
typedef uint32_t MachInst;
typedef uint64_t ExtMachInst;
-typedef GenericISA::DelaySlotPCState<MachInst> PCState;
+typedef GenericISA::DelaySlotPCState<4> PCState;
//used in FP convert & round function
enum ConvertType
diff --git a/src/arch/null/types.hh b/src/arch/null/types.hh
index 3fa7479..9a8295e 100644
--- a/src/arch/null/types.hh
+++ b/src/arch/null/types.hh
@@ -42,14 +42,8 @@
namespace NullISA
{
- typedef uint32_t MachInst;
- class PCState : public GenericISA::UPCState<MachInst>
- {
- protected:
-
- typedef GenericISA::UPCState<MachInst> Base;
- };
+typedef GenericISA::UPCState<4> PCState;
}
diff --git a/src/arch/power/types.hh b/src/arch/power/types.hh
index 1e896e4..cd060cc 100644
--- a/src/arch/power/types.hh
+++ b/src/arch/power/types.hh
@@ -81,7 +81,7 @@
Bitfield<19, 12> fxm;
EndBitUnion(ExtMachInst)
-typedef GenericISA::SimplePCState<MachInst> PCState;
+typedef GenericISA::SimplePCState<4> PCState;
// typedef uint64_t LargestRead;
// // Need to use 64 bits to make sure that read requests get handled
properly
diff --git a/src/arch/riscv/types.hh b/src/arch/riscv/types.hh
index 38923b8..68c3f98 100644
--- a/src/arch/riscv/types.hh
+++ b/src/arch/riscv/types.hh
@@ -50,7 +50,7 @@
typedef uint32_t MachInst;
typedef uint64_t ExtMachInst;
-class PCState : public GenericISA::UPCState<MachInst>
+class PCState : public GenericISA::UPCState<4>
{
private:
bool _compressed;
diff --git a/src/arch/sparc/types.hh b/src/arch/sparc/types.hh
index 885bdc9..ffb9806 100644
--- a/src/arch/sparc/types.hh
+++ b/src/arch/sparc/types.hh
@@ -38,7 +38,7 @@
typedef uint32_t MachInst;
typedef uint64_t ExtMachInst;
-typedef GenericISA::DelaySlotUPCState<MachInst> PCState;
+typedef GenericISA::DelaySlotUPCState<4> PCState;
}
diff --git a/src/arch/x86/types.hh b/src/arch/x86/types.hh
index 422cada..f2b612f 100644
--- a/src/arch/x86/types.hh
+++ b/src/arch/x86/types.hh
@@ -287,10 +287,10 @@
return true;
}
-class PCState : public GenericISA::UPCState<MachInst>
+class PCState : public GenericISA::UPCState<8>
{
protected:
- typedef GenericISA::UPCState<MachInst> Base;
+ typedef GenericISA::UPCState<8> Base;
uint8_t _size;
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/40176
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: I797876a33d27e759c7a6e23a658179201fabfa47
Gerrit-Change-Number: 40176
Gerrit-PatchSet: 27
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s