arch,cpu: Move endianness conversion of inst bytes into the ISA.
It doesn't matter if the bytes are converted before or after they're fed into the decoder. The ISA already knows what endianness to use implicitly, and this frees the CPU which doesn't from having to worry about it. Change-Id: Id6574ee81bbf4f032c1d7b2901a664f2bd014fbc Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22343 Maintainer: Gabe Black <gabeblack@google.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -66,7 +66,7 @@ class Decoder
|
||||
void
|
||||
moreBytes(const PCState &pc, Addr fetchPC, MachInst inst)
|
||||
{
|
||||
ext_inst = inst;
|
||||
ext_inst = letoh(inst);
|
||||
instDone = true;
|
||||
if (FullSystem)
|
||||
ext_inst |= (static_cast<ExtMachInst>(pc.pc() & 0x1) << 32);
|
||||
|
||||
@@ -154,7 +154,7 @@ Decoder::consumeBytes(int numBytes)
|
||||
void
|
||||
Decoder::moreBytes(const PCState &pc, Addr fetchPC, MachInst inst)
|
||||
{
|
||||
data = inst;
|
||||
data = letoh(inst);
|
||||
offset = (fetchPC >= pc.instAddr()) ? 0 : pc.instAddr() - fetchPC;
|
||||
emi.thumb = pc.thumb();
|
||||
emi.aarch64 = pc.aarch64();
|
||||
|
||||
@@ -68,7 +68,7 @@ class Decoder
|
||||
void
|
||||
moreBytes(const PCState &pc, Addr fetchPC, MachInst inst)
|
||||
{
|
||||
emi = inst;
|
||||
emi = letoh(inst);
|
||||
instDone = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class Decoder
|
||||
void
|
||||
moreBytes(const PCState &pc, Addr fetchPC, MachInst inst)
|
||||
{
|
||||
emi = inst;
|
||||
emi = betoh(inst);
|
||||
instDone = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ void Decoder::reset()
|
||||
void
|
||||
Decoder::moreBytes(const PCState &pc, Addr fetchPC, MachInst inst)
|
||||
{
|
||||
inst = letoh(inst);
|
||||
DPRINTF(Decode, "Requesting bytes 0x%08x from address %#x\n", inst,
|
||||
fetchPC);
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ class Decoder
|
||||
void
|
||||
moreBytes(const PCState &pc, Addr fetchPC, MachInst inst)
|
||||
{
|
||||
emi = inst;
|
||||
emi = betoh(inst);
|
||||
// The I bit, bit 13, is used to figure out where the ASI
|
||||
// should come from. Use that in the ExtMachInst. This is
|
||||
// slightly redundant, but it removes the need to put a condition
|
||||
|
||||
@@ -310,7 +310,7 @@ class Decoder
|
||||
DPRINTF(Decoder, "Getting more bytes.\n");
|
||||
basePC = fetchPC;
|
||||
offset = (fetchPC >= pc.instAddr()) ? 0 : pc.instAddr() - fetchPC;
|
||||
fetchChunk = data;
|
||||
fetchChunk = letoh(data);
|
||||
outOfBytes = false;
|
||||
process();
|
||||
}
|
||||
|
||||
@@ -285,7 +285,6 @@ Checker<Impl>::verify(const DynInstPtr &completed_inst)
|
||||
|
||||
pkt->dataStatic(&machInst);
|
||||
icachePort->sendFunctional(pkt);
|
||||
machInst = gtoh(machInst);
|
||||
|
||||
delete pkt;
|
||||
}
|
||||
|
||||
@@ -376,12 +376,10 @@ Fetch2::evaluate()
|
||||
} else {
|
||||
uint8_t *line = line_in->line;
|
||||
|
||||
TheISA::MachInst inst_word;
|
||||
/* The instruction is wholly in the line, can just
|
||||
* assign */
|
||||
inst_word = TheISA::gtoh(
|
||||
*(reinterpret_cast<TheISA::MachInst *>
|
||||
(line + fetch_info.inputIndex)));
|
||||
auto inst_word = *reinterpret_cast<TheISA::MachInst *>
|
||||
(line + fetch_info.inputIndex);
|
||||
|
||||
if (!decoder->instReady()) {
|
||||
decoder->moreBytes(fetch_info.pc,
|
||||
|
||||
@@ -1285,8 +1285,7 @@ DefaultFetch<Impl>::fetch(bool &status_change)
|
||||
break;
|
||||
}
|
||||
|
||||
MachInst inst = TheISA::gtoh(cacheInsts[blkOffset]);
|
||||
decoder[tid]->moreBytes(thisPC, fetchAddr, inst);
|
||||
decoder[tid]->moreBytes(thisPC, fetchAddr, cacheInsts[blkOffset]);
|
||||
|
||||
if (decoder[tid]->needMoreBytes()) {
|
||||
blkOffset++;
|
||||
|
||||
@@ -503,8 +503,6 @@ BaseSimpleCPU::preExecute()
|
||||
thread->comInstEventQueue.serviceEvents(t_info.numInst);
|
||||
|
||||
// decode the instruction
|
||||
inst = gtoh(inst);
|
||||
|
||||
TheISA::PCState pcState = thread->pcState();
|
||||
|
||||
if (isRomMicroPC(pcState.microPC())) {
|
||||
|
||||
Reference in New Issue
Block a user