arch: Promote instReady to the base InstDecoder class.

Move the instDone flag, and the instReady function which was
consistently implemented just to return it, to the base InstDecoder
class. This flag can still be accessed easily from the subclasses, but
now it can be retrieved with just an InstDecoder pointer without a
virtual function call.

Change-Id: I8c662aa01da8fe33ffe679071c701e0aadc1a795
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52072
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2021-10-25 02:03:03 -07:00
parent 21d7ae9508
commit 29950b81ce
7 changed files with 15 additions and 40 deletions

View File

@@ -66,7 +66,6 @@ class Decoder : public InstDecoder
ExtMachInst emi;
uint32_t data;
bool bigThumb;
bool instDone;
bool outOfBytes;
int offset;
bool foundIt;
@@ -146,16 +145,6 @@ class Decoder : public InstDecoder
*/
bool needMoreBytes() const { return outOfBytes; }
/**
* Is an instruction ready to be decoded?
*
* CPU models call this method to determine if decode() will
* return a new instruction on the next call. It typically only
* returns false if the decoder hasn't received enough data to
* decode a full instruction.
*/
bool instReady() const { return instDone; }
/**
* Feed data to the decoder.
*

View File

@@ -43,6 +43,8 @@ class InstDecoder
size_t _moreBytesSize;
Addr _pcMask;
bool instDone = false;
public:
template <typename MoreBytesType>
InstDecoder(MoreBytesType *mb_buf) :
@@ -56,6 +58,16 @@ class InstDecoder
void *moreBytesPtr() const { return _moreBytesPtr; }
size_t moreBytesSize() const { return _moreBytesSize; }
Addr pcMask() const { return _pcMask; }
/**
* Is an instruction ready to be decoded?
*
* CPU models call this method to determine if decode() will
* return a new instruction on the next call. It typically only
* returns false if the decoder hasn't received enough data to
* decode a full instruction.
*/
bool instReady() const { return instDone; }
};
} // namespace gem5

View File

@@ -50,10 +50,9 @@ class Decoder : public InstDecoder
//The extended machine instruction being generated
ExtMachInst emi;
uint32_t machInst;
bool instDone;
public:
Decoder(ISA* isa = nullptr) : InstDecoder(&machInst), instDone(false)
Decoder(ISA* isa = nullptr) : InstDecoder(&machInst)
{}
void
@@ -82,12 +81,6 @@ class Decoder : public InstDecoder
return true;
}
bool
instReady()
{
return instDone;
}
void takeOverFrom(Decoder *old) {}
protected:

View File

@@ -48,10 +48,9 @@ class Decoder : public InstDecoder
protected:
// The extended machine instruction being generated
ExtMachInst emi;
bool instDone;
public:
Decoder(ISA* isa=nullptr) : InstDecoder(&emi), instDone(false) {}
Decoder(ISA* isa=nullptr) : InstDecoder(&emi) {}
void
process()
@@ -79,12 +78,6 @@ class Decoder : public InstDecoder
return true;
}
bool
instReady()
{
return instDone;
}
void takeOverFrom(Decoder *old) {}
protected:

View File

@@ -57,7 +57,6 @@ class Decoder : public InstDecoder
//The extended machine instruction being generated
ExtMachInst emi;
uint32_t machInst;
bool instDone;
StaticInstPtr decodeInst(ExtMachInst mach_inst);
@@ -79,7 +78,6 @@ class Decoder : public InstDecoder
void moreBytes(const PCStateBase &pc, Addr fetchPC);
bool needMoreBytes() { return more; }
bool instReady() { return instDone; }
void takeOverFrom(Decoder *old) {}
StaticInstPtr decode(PCStateBase &nextPC);

View File

@@ -48,11 +48,10 @@ class Decoder : public InstDecoder
// The extended machine instruction being generated
ExtMachInst emi;
uint32_t machInst;
bool instDone;
RegVal asi;
public:
Decoder(ISA* isa=nullptr) : InstDecoder(&machInst), instDone(false), asi(0)
Decoder(ISA* isa=nullptr) : InstDecoder(&machInst), asi(0)
{}
void process() {}
@@ -89,12 +88,6 @@ class Decoder : public InstDecoder
return true;
}
bool
instReady()
{
return instDone;
}
void
setContext(RegVal _asi)
{

View File

@@ -176,8 +176,6 @@ class Decoder : public InstDecoder
protected:
// Whether or not we're out of bytes.
bool outOfBytes = true;
// Whether we've completed generating an ExtMachInst.
bool instDone = false;
// The size of the displacement value.
int displacementSize;
// The size of the immediate value.
@@ -324,7 +322,6 @@ class Decoder : public InstDecoder
}
bool needMoreBytes() { return outOfBytes; }
bool instReady() { return instDone; }
void
updateNPC(X86ISA::PCState &nextPC)