Skip to content

Commit

Permalink
refactor instruction EL decode (#68)
Browse files Browse the repository at this point in the history
* isPriv function is removed from instruction and added to the coreimpl

---------

Co-authored-by: Bryan Perdrizat <[email protected]>
  • Loading branch information
BugraEryilmaz and branylagaffe authored Oct 2, 2024
1 parent b526e40 commit b5cd711
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 21 deletions.
6 changes: 0 additions & 6 deletions components/CommonQEMU/Slices/ArchitecturalInstruction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class ArchitecturalInstruction : public boost::counted_base
bool thePerformed;
bool theCommitted;
bool theSync;
bool thePriv;
bool theShadow;
bool theTrace; // a traced instruction
bool theIsAtomic;
Expand All @@ -72,7 +71,6 @@ class ArchitecturalInstruction : public boost::counted_base
, thePerformed(false)
, theCommitted(false)
, theSync(anOriginal->theSync)
, thePriv(anOriginal->thePriv)
, theShadow(true)
, theTrace(anOriginal->theTrace)
, theStartTime(0)
Expand All @@ -97,7 +95,6 @@ class ArchitecturalInstruction : public boost::counted_base
, thePerformed(false)
, theCommitted(false)
, theSync(false)
, thePriv(false)
, theShadow(false)
, theTrace(false)
, theStartTime(0)
Expand All @@ -122,7 +119,6 @@ class ArchitecturalInstruction : public boost::counted_base
, thePerformed(false)
, theCommitted(false)
, theSync(false)
, thePriv(false)
, theShadow(false)
, theTrace(false)
, theIsAtomic(false)
Expand Down Expand Up @@ -152,7 +148,6 @@ class ArchitecturalInstruction : public boost::counted_base
bool isRmw() const { return (theOperation == Rmw); }
bool isMEMBAR() const { return (theOperation == Membar); }
bool isSync() const { return theSync; }
bool isPriv() const { return thePriv; }

bool isShadow() const { return theShadow; }

Expand Down Expand Up @@ -200,7 +195,6 @@ class ArchitecturalInstruction : public boost::counted_base

// InorderInstructionImpl Interface functions
void setSync() { theSync = true; }
void setPriv() { thePriv = true; }

// Set operation types
void setIsNop() { theOperation = Nop; }
Expand Down
1 change: 0 additions & 1 deletion components/Decoder/Instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ ArchInstruction::ArchInstruction(VirtualMemoryAddress aPC,
, theUsesFpDiv(false)
, theUsesFpSqrt(false)
, theInsnSourceLevel(eL1I)
, thePriv(false)
{
}

Expand Down
5 changes: 0 additions & 5 deletions components/Decoder/Instruction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class ArchInstruction : public nuArch::Instruction
bool theUsesFpDiv;
bool theUsesFpSqrt;
tFillLevel theInsnSourceLevel;
bool thePriv;

public:
virtual bool usesIntAlu() const;
Expand Down Expand Up @@ -245,9 +244,6 @@ class ArchInstruction : public nuArch::Instruction

virtual VirtualMemoryAddress pcNext() const { return thePCReg; }

virtual bool isPriv() const { return thePriv; }
virtual void makePriv() { thePriv = true; }

virtual bool isTrap() const { return theRaisedException != kException_None; }
virtual boost::intrusive_ptr<BPredState> bpState() const { return theBPState; }
bool isBranch() const { return theInstructionClass == clsBranch; }
Expand Down Expand Up @@ -320,7 +316,6 @@ class ArchInstruction : public nuArch::Instruction
, theUsesFpDiv(false)
, theUsesFpSqrt(false)
, theInsnSourceLevel(eL1I)
, thePriv(false)
{
}

Expand Down
4 changes: 2 additions & 2 deletions components/uArch/CoreModel/accounting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ CoreImpl::accountCommit(boost::intrusive_ptr<Instruction> anInstruction, bool aR
level = 3 /* idle */;
else if (anInstruction->isTrap())
level = 2 /* trap */;
else if (anInstruction->isPriv())
else if (isPrivileged())
level = 1 /* system */;
int32_t spin = (theSpinning) ? 4 : 0;

Expand Down Expand Up @@ -383,7 +383,7 @@ CoreImpl::accountRetire(boost::intrusive_ptr<Instruction> anInst)
if (theIsSpeculating) { ++theRetiresSinceCheckpoint; }

// Determine cycle category (always based on last retire in cycle)
bool system = theROB.front()->isPriv();
bool system = isPrivileged();

theIsIdle = Flexus::Qemu::Processor::getProcessor(theNode).is_busy() ? false : true;

Expand Down
2 changes: 1 addition & 1 deletion components/uArch/CoreModel/arbiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ CoreImpl::issue(boost::intrusive_ptr<Instruction> anInstruction)
op->theSize = mshr.theSize = lsq_entry->theSize;
mshr.theWaitingLSQs.push_back(lsq_entry);
op->thePC = lsq_entry->theInstruction->pc();
bool system = lsq_entry->theInstruction->isPriv();
bool system = isPrivileged();
if (lsq_entry->theValue) {
op->theValue = *lsq_entry->theValue;
} else {
Expand Down
5 changes: 5 additions & 0 deletions components/uArch/CoreModel/construct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,11 @@ CoreImpl::setPC(uint64_t aPC)
thePC = aPC;
}

bool CoreImpl::isPrivileged()
{
return currentEL() != 0;
}

CoreModel*
CoreModel::construct(uArchOptions_t options,
std::function<int(bool)> advance,
Expand Down
1 change: 1 addition & 0 deletions components/uArch/CoreModel/coreModelImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ class CoreImpl : public CoreModel
void setSPSR_el(uint8_t anEL, uint64_t aVal);
uint64_t getSPSR_el(uint8_t anEL);
void setDAIF(uint32_t aDAIF);
bool isPrivileged();

/* Msutherl: API to read system register value using QEMU encoding */
uint64_t readUnhashedSysReg(uint8_t opc0, uint8_t opc1, uint8_t opc2, uint8_t crn, uint8_t crm);
Expand Down
6 changes: 3 additions & 3 deletions components/uArch/CoreModel/cycle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ CoreImpl::retireMem(boost::intrusive_ptr<Instruction> anInsn)

// TRACE TRACKER : Notify trace tracker of store
// uint64_t logical_timestamp = theCommitNumber + theSRB.size();
theTraceTracker.store(theNode, eCore, iter->thePaddr, anInsn->pc(), false /*unknown*/, anInsn->isPriv(), 0);
theTraceTracker.store(theNode, eCore, iter->thePaddr, anInsn->pc(), false /*unknown*/, isPrivileged(), 0);
}

if (iter->theOperation == kRMW) {
Expand Down Expand Up @@ -672,7 +672,7 @@ CoreImpl::retireMem(boost::intrusive_ptr<Instruction> anInsn)
// TRACE TRACKER : Notify trace tracker of load commit
// uint64_t logical_timestamp = theCommitNumber + theSRB.size();
theTraceTracker
.access(theNode, eCore, iter->thePaddr, anInsn->pc(), false, false, false, anInsn->isPriv(), 0);
.access(theNode, eCore, iter->thePaddr, anInsn->pc(), false, false, false, isPrivileged(), 0);
theTraceTracker.commit(theNode, eCore, iter->thePaddr, anInsn->pc(), 0);
/* CMU-ONLY-BLOCK-BEGIN */
// if (theTrackParallelAccesses ) {
Expand Down Expand Up @@ -722,7 +722,7 @@ CoreImpl::retireMem(boost::intrusive_ptr<Instruction> anInsn)

// TRACE TRACKER : Notify trace tracker of store
// uint64_t logical_timestamp = theCommitNumber + theSRB.size();
theTraceTracker.store(theNode, eCore, iter->thePaddr, anInsn->pc(), false /*unknown*/, anInsn->isPriv(), 0);
theTraceTracker.store(theNode, eCore, iter->thePaddr, anInsn->pc(), false /*unknown*/, isPrivileged(), 0);

requireWritePermission(iter);
}
Expand Down
2 changes: 1 addition & 1 deletion components/uArch/CoreModel/memreply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ CoreImpl::invalidate(PhysicalMemoryAddress anAddress)
++theRaces;
race_counted = true;
}
bool system = temp->theInstruction->isPriv();
bool system = isPrivileged();

// if its a completed load, and it has a higher sequence number than
// first_incomplete, the load attempts forwarding. If forwarding fails,
Expand Down
2 changes: 0 additions & 2 deletions components/uArch/uArchInterfaces.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,6 @@ struct Instruction : public Flexus::SharedTypes::AbstractInstruction

virtual VirtualMemoryAddress pc() const = 0;
virtual VirtualMemoryAddress pcNext() const = 0;
virtual bool isPriv() const = 0;
virtual void makePriv() = 0;
virtual bool isTrap() const = 0;
virtual bool preValidate() = 0;
virtual bool advancesSimics() const = 0;
Expand Down

0 comments on commit b5cd711

Please sign in to comment.