2 * Copyright (c) 2004-2006 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef __CPU_BASE_DYN_INST_HH__
32 #define __CPU_BASE_DYN_INST_HH__
38 #include "arch/faults.hh"
39 #include "base/fast_alloc.hh"
40 #include "base/trace.hh"
41 #include "config/full_system.hh"
42 #include "cpu/o3/comm.hh"
43 #include "cpu/exetrace.hh"
44 #include "cpu/inst_seq.hh"
45 #include "cpu/op_class.hh"
46 #include "cpu/static_inst.hh"
47 #include "mem/packet.hh"
48 #include "sim/system.hh"
52 * Defines a dynamic instruction context.
55 // Forward declaration.
59 class BaseDynInst : public FastAlloc, public RefCounted
62 // Typedef for the CPU.
63 typedef typename Impl::CPUType ImplCPU;
64 typedef typename ImplCPU::ImplState ImplState;
66 // Logical register index type.
67 typedef TheISA::RegIndex RegIndex;
68 // Integer register type.
69 typedef TheISA::IntReg IntReg;
70 // Floating point register type.
71 typedef TheISA::FloatReg FloatReg;
73 // The DynInstPtr type.
74 typedef typename Impl::DynInstPtr DynInstPtr;
76 // The list of instructions iterator type.
77 typedef typename std::list<DynInstPtr>::iterator ListIt;
80 MaxInstSrcRegs = TheISA::MaxInstSrcRegs, /// Max source regs
81 MaxInstDestRegs = TheISA::MaxInstDestRegs, /// Max dest regs
84 /** The StaticInst used by this BaseDynInst. */
85 StaticInstPtr staticInst;
87 ////////////////////////////////////////////
89 // INSTRUCTION EXECUTION
91 ////////////////////////////////////////////
92 /** InstRecord that tracks this instructions. */
93 Trace::InstRecord *traceData;
96 * Does a read to a given address.
97 * @param addr The address to read.
98 * @param data The read's data is written into this parameter.
99 * @param flags The request's flags.
100 * @return Returns any fault due to the read.
103 Fault read(Addr addr, T &data, unsigned flags);
106 * Does a write to a given address.
107 * @param data The data to be written.
108 * @param addr The address to write to.
109 * @param flags The request's flags.
110 * @param res The result of the write (for load locked/store conditionals).
111 * @return Returns any fault due to the write.
114 Fault write(T data, Addr addr, unsigned flags,
117 void prefetch(Addr addr, unsigned flags);
118 void writeHint(Addr addr, int size, unsigned flags);
119 Fault copySrcTranslate(Addr src);
120 Fault copy(Addr dest);
122 /** @todo: Consider making this private. */
124 /** The sequence number of the instruction. */
128 IqEntry, /// Instruction is in the IQ
129 RobEntry, /// Instruction is in the ROB
130 LsqEntry, /// Instruction is in the LSQ
131 Completed, /// Instruction has completed
132 ResultReady, /// Instruction has its result
133 CanIssue, /// Instruction can issue and execute
134 Issued, /// Instruction has issued
135 Executed, /// Instruction has executed
136 CanCommit, /// Instruction can commit
137 AtCommit, /// Instruction has reached commit
138 Committed, /// Instruction has committed
139 Squashed, /// Instruction is squashed
140 SquashedInIQ, /// Instruction is squashed in the IQ
141 SquashedInLSQ, /// Instruction is squashed in the LSQ
142 SquashedInROB, /// Instruction is squashed in the ROB
143 RecoverInst, /// Is a recover instruction
144 BlockingInst, /// Is a blocking instruction
145 ThreadsyncWait, /// Is a thread synchronization instruction
146 SerializeBefore, /// Needs to serialize on
147 /// instructions ahead of it
148 SerializeAfter, /// Needs to serialize instructions behind it
149 SerializeHandled, /// Serialization has been handled
153 /** The status of this BaseDynInst. Several bits can be set. */
154 std::bitset<NumStatus> status;
156 /** The thread this instruction is from. */
159 /** data address space ID, for loads & stores. */
162 /** How many source registers are ready. */
165 /** Pointer to the Impl's CPU object. */
168 /** Pointer to the thread state. */
171 /** The kind of fault this instruction has generated. */
174 /** Pointer to the data for the memory access. */
177 /** The effective virtual address (lds & stores only). */
180 /** Is the effective virtual address valid. */
183 /** The effective physical address. */
186 /** Effective virtual address for a copy source. */
189 /** Effective physical address for a copy source. */
190 Addr copySrcPhysEffAddr;
192 /** The memory request flags (from translation). */
193 unsigned memReqFlags;
201 /** The result of the instruction; assumes for now that there's only one
202 * destination register.
206 /** Records changes to result? */
209 /** PC of this instruction. */
212 /** Micro PC of this instruction. */
216 /** Next non-speculative PC. It is not filled in at fetch, but rather
217 * once the target of the branch is truly known (either decode or
222 /** Next non-speculative NPC. Target PC for Mips or Sparc. */
225 /** Next non-speculative micro PC. */
228 /** Predicted next PC. */
231 /** Predicted next NPC. */
234 /** Predicted next microPC */
237 /** If this is a branch that was predicted taken */
242 /** Count of total number of dynamic instructions. */
243 static int instcount;
249 /** Whether or not the source register is ready.
250 * @todo: Not sure this should be here vs the derived class.
252 bool _readySrcRegIdx[MaxInstSrcRegs];
255 /** Flattened register index of the destination registers of this
258 TheISA::RegIndex _flatDestRegIdx[TheISA::MaxInstDestRegs];
260 /** Flattened register index of the source registers of this
263 TheISA::RegIndex _flatSrcRegIdx[TheISA::MaxInstSrcRegs];
265 /** Physical register index of the destination registers of this
268 PhysRegIndex _destRegIdx[TheISA::MaxInstDestRegs];
270 /** Physical register index of the source registers of this
273 PhysRegIndex _srcRegIdx[TheISA::MaxInstSrcRegs];
275 /** Physical register index of the previous producers of the
276 * architected destinations.
278 PhysRegIndex _prevDestRegIdx[TheISA::MaxInstDestRegs];
282 /** Returns the physical register index of the i'th destination
285 PhysRegIndex renamedDestRegIdx(int idx) const
287 return _destRegIdx[idx];
290 /** Returns the physical register index of the i'th source register. */
291 PhysRegIndex renamedSrcRegIdx(int idx) const
293 return _srcRegIdx[idx];
296 /** Returns the flattened register index of the i'th destination
299 TheISA::RegIndex flattenedDestRegIdx(int idx) const
301 return _flatDestRegIdx[idx];
304 /** Returns the flattened register index of the i'th source register */
305 TheISA::RegIndex flattenedSrcRegIdx(int idx) const
307 return _flatSrcRegIdx[idx];
310 /** Returns the physical register index of the previous physical register
311 * that remapped to the same logical register index.
313 PhysRegIndex prevDestRegIdx(int idx) const
315 return _prevDestRegIdx[idx];
318 /** Renames a destination register to a physical register. Also records
319 * the previous physical register that the logical register mapped to.
321 void renameDestReg(int idx,
322 PhysRegIndex renamed_dest,
323 PhysRegIndex previous_rename)
325 _destRegIdx[idx] = renamed_dest;
326 _prevDestRegIdx[idx] = previous_rename;
329 /** Renames a source logical register to the physical register which
330 * has/will produce that logical register's result.
331 * @todo: add in whether or not the source register is ready.
333 void renameSrcReg(int idx, PhysRegIndex renamed_src)
335 _srcRegIdx[idx] = renamed_src;
338 /** Flattens a source architectural register index into a logical index.
340 void flattenSrcReg(int idx, TheISA::RegIndex flattened_src)
342 _flatSrcRegIdx[idx] = flattened_src;
345 /** Flattens a destination architectural register index into a logical
348 void flattenDestReg(int idx, TheISA::RegIndex flattened_dest)
350 _flatDestRegIdx[idx] = flattened_dest;
352 /** BaseDynInst constructor given a binary instruction.
353 * @param staticInst A StaticInstPtr to the underlying instruction.
354 * @param PC The PC of the instruction.
355 * @param pred_PC The predicted next PC.
356 * @param pred_NPC The predicted next NPC.
357 * @param seq_num The sequence number of the instruction.
358 * @param cpu Pointer to the instruction's CPU.
360 BaseDynInst(StaticInstPtr staticInst, Addr PC, Addr NPC, Addr microPC,
361 Addr pred_PC, Addr pred_NPC, Addr pred_MicroPC,
362 InstSeqNum seq_num, ImplCPU *cpu);
364 /** BaseDynInst constructor given a binary instruction.
365 * @param inst The binary instruction.
366 * @param PC The PC of the instruction.
367 * @param pred_PC The predicted next PC.
368 * @param pred_NPC The predicted next NPC.
369 * @param seq_num The sequence number of the instruction.
370 * @param cpu Pointer to the instruction's CPU.
372 BaseDynInst(TheISA::ExtMachInst inst, Addr PC, Addr NPC, Addr microPC,
373 Addr pred_PC, Addr pred_NPC, Addr pred_MicroPC,
374 InstSeqNum seq_num, ImplCPU *cpu);
376 /** BaseDynInst constructor given a StaticInst pointer.
377 * @param _staticInst The StaticInst for this BaseDynInst.
379 BaseDynInst(StaticInstPtr &_staticInst);
381 /** BaseDynInst destructor. */
385 /** Function to initialize variables in the constructors. */
389 /** Dumps out contents of this BaseDynInst. */
392 /** Dumps out contents of this BaseDynInst into given string. */
393 void dump(std::string &outstring);
395 /** Read this CPU's ID. */
396 int readCpuId() { return cpu->readCpuId(); }
398 /** Returns the fault type. */
399 Fault getFault() { return fault; }
401 /** Checks whether or not this instruction has had its branch target
402 * calculated yet. For now it is not utilized and is hacked to be
404 * @todo: Actually use this instruction.
406 bool doneTargCalc() { return false; }
408 /** Returns the next PC. This could be the speculative next PC if it is
409 * called prior to the actual branch target being calculated.
411 Addr readNextPC() { return nextPC; }
413 /** Returns the next NPC. This could be the speculative next NPC if it is
414 * called prior to the actual branch target being calculated.
418 #if ISA_HAS_DELAY_SLOT
421 return nextPC + sizeof(TheISA::MachInst);
425 Addr readNextMicroPC()
430 /** Set the predicted target of this current instruction. */
431 void setPredTarg(Addr predicted_PC, Addr predicted_NPC,
432 Addr predicted_MicroPC)
434 predPC = predicted_PC;
435 predNPC = predicted_NPC;
436 predMicroPC = predicted_MicroPC;
439 /** Returns the predicted PC immediately after the branch. */
440 Addr readPredPC() { return predPC; }
442 /** Returns the predicted PC two instructions after the branch */
443 Addr readPredNPC() { return predNPC; }
445 /** Returns the predicted micro PC after the branch */
446 Addr readPredMicroPC() { return predMicroPC; }
448 /** Returns whether the instruction was predicted taken or not. */
454 void setPredTaken(bool predicted_taken)
456 predTaken = predicted_taken;
459 /** Returns whether the instruction mispredicted. */
462 return readPredPC() != readNextPC() ||
463 readPredNPC() != readNextNPC() ||
464 readPredMicroPC() != readNextMicroPC();
468 // Instruction types. Forward checks to StaticInst object.
470 bool isNop() const { return staticInst->isNop(); }
471 bool isMemRef() const { return staticInst->isMemRef(); }
472 bool isLoad() const { return staticInst->isLoad(); }
473 bool isStore() const { return staticInst->isStore(); }
474 bool isStoreConditional() const
475 { return staticInst->isStoreConditional(); }
476 bool isInstPrefetch() const { return staticInst->isInstPrefetch(); }
477 bool isDataPrefetch() const { return staticInst->isDataPrefetch(); }
478 bool isCopy() const { return staticInst->isCopy(); }
479 bool isInteger() const { return staticInst->isInteger(); }
480 bool isFloating() const { return staticInst->isFloating(); }
481 bool isControl() const { return staticInst->isControl(); }
482 bool isCall() const { return staticInst->isCall(); }
483 bool isReturn() const { return staticInst->isReturn(); }
484 bool isDirectCtrl() const { return staticInst->isDirectCtrl(); }
485 bool isIndirectCtrl() const { return staticInst->isIndirectCtrl(); }
486 bool isCondCtrl() const { return staticInst->isCondCtrl(); }
487 bool isUncondCtrl() const { return staticInst->isUncondCtrl(); }
488 bool isCondDelaySlot() const { return staticInst->isCondDelaySlot(); }
489 bool isThreadSync() const { return staticInst->isThreadSync(); }
490 bool isSerializing() const { return staticInst->isSerializing(); }
491 bool isSerializeBefore() const
492 { return staticInst->isSerializeBefore() || status[SerializeBefore]; }
493 bool isSerializeAfter() const
494 { return staticInst->isSerializeAfter() || status[SerializeAfter]; }
495 bool isMemBarrier() const { return staticInst->isMemBarrier(); }
496 bool isWriteBarrier() const { return staticInst->isWriteBarrier(); }
497 bool isNonSpeculative() const { return staticInst->isNonSpeculative(); }
498 bool isQuiesce() const { return staticInst->isQuiesce(); }
499 bool isIprAccess() const { return staticInst->isIprAccess(); }
500 bool isUnverifiable() const { return staticInst->isUnverifiable(); }
501 bool isSyscall() const { return staticInst->isSyscall(); }
502 bool isMacroop() const { return staticInst->isMacroop(); }
503 bool isMicroop() const { return staticInst->isMicroop(); }
504 bool isDelayedCommit() const { return staticInst->isDelayedCommit(); }
505 bool isLastMicroop() const { return staticInst->isLastMicroop(); }
506 bool isFirstMicroop() const { return staticInst->isFirstMicroop(); }
507 bool isMicroBranch() const { return staticInst->isMicroBranch(); }
509 /** Temporarily sets this instruction as a serialize before instruction. */
510 void setSerializeBefore() { status.set(SerializeBefore); }
512 /** Clears the serializeBefore part of this instruction. */
513 void clearSerializeBefore() { status.reset(SerializeBefore); }
515 /** Checks if this serializeBefore is only temporarily set. */
516 bool isTempSerializeBefore() { return status[SerializeBefore]; }
518 /** Temporarily sets this instruction as a serialize after instruction. */
519 void setSerializeAfter() { status.set(SerializeAfter); }
521 /** Clears the serializeAfter part of this instruction.*/
522 void clearSerializeAfter() { status.reset(SerializeAfter); }
524 /** Checks if this serializeAfter is only temporarily set. */
525 bool isTempSerializeAfter() { return status[SerializeAfter]; }
527 /** Sets the serialization part of this instruction as handled. */
528 void setSerializeHandled() { status.set(SerializeHandled); }
530 /** Checks if the serialization part of this instruction has been
531 * handled. This does not apply to the temporary serializing
532 * state; it only applies to this instruction's own permanent
535 bool isSerializeHandled() { return status[SerializeHandled]; }
537 /** Returns the opclass of this instruction. */
538 OpClass opClass() const { return staticInst->opClass(); }
540 /** Returns the branch target address. */
541 Addr branchTarget() const { return staticInst->branchTarget(PC); }
543 /** Returns the number of source registers. */
544 int8_t numSrcRegs() const { return staticInst->numSrcRegs(); }
546 /** Returns the number of destination registers. */
547 int8_t numDestRegs() const { return staticInst->numDestRegs(); }
549 // the following are used to track physical register usage
550 // for machines with separate int & FP reg files
551 int8_t numFPDestRegs() const { return staticInst->numFPDestRegs(); }
552 int8_t numIntDestRegs() const { return staticInst->numIntDestRegs(); }
554 /** Returns the logical register index of the i'th destination register. */
555 RegIndex destRegIdx(int i) const { return staticInst->destRegIdx(i); }
557 /** Returns the logical register index of the i'th source register. */
558 RegIndex srcRegIdx(int i) const { return staticInst->srcRegIdx(i); }
560 /** Returns the result of an integer instruction. */
561 uint64_t readIntResult() { return instResult.integer; }
563 /** Returns the result of a floating point instruction. */
564 float readFloatResult() { return (float)instResult.dbl; }
566 /** Returns the result of a floating point (double) instruction. */
567 double readDoubleResult() { return instResult.dbl; }
569 /** Records an integer register being set to a value. */
570 void setIntRegOperand(const StaticInst *si, int idx, uint64_t val)
573 instResult.integer = val;
576 /** Records an fp register being set to a value. */
577 void setFloatRegOperand(const StaticInst *si, int idx, FloatReg val,
582 instResult.dbl = (double)val;
583 else if (width == 64)
584 instResult.dbl = val;
586 panic("Unsupported width!");
590 /** Records an fp register being set to a value. */
591 void setFloatRegOperand(const StaticInst *si, int idx, FloatReg val)
594 instResult.dbl = (double)val;
597 /** Records an fp register being set to an integer value. */
598 void setFloatRegOperandBits(const StaticInst *si, int idx, uint64_t val,
602 instResult.integer = val;
605 /** Records an fp register being set to an integer value. */
606 void setFloatRegOperandBits(const StaticInst *si, int idx, uint64_t val)
609 instResult.integer = val;
612 /** Records that one of the source registers is ready. */
613 void markSrcRegReady();
615 /** Marks a specific register as ready. */
616 void markSrcRegReady(RegIndex src_idx);
618 /** Returns if a source register is ready. */
619 bool isReadySrcRegIdx(int idx) const
621 return this->_readySrcRegIdx[idx];
624 /** Sets this instruction as completed. */
625 void setCompleted() { status.set(Completed); }
627 /** Returns whether or not this instruction is completed. */
628 bool isCompleted() const { return status[Completed]; }
630 /** Marks the result as ready. */
631 void setResultReady() { status.set(ResultReady); }
633 /** Returns whether or not the result is ready. */
634 bool isResultReady() const { return status[ResultReady]; }
636 /** Sets this instruction as ready to issue. */
637 void setCanIssue() { status.set(CanIssue); }
639 /** Returns whether or not this instruction is ready to issue. */
640 bool readyToIssue() const { return status[CanIssue]; }
642 /** Clears this instruction being able to issue. */
643 void clearCanIssue() { status.reset(CanIssue); }
645 /** Sets this instruction as issued from the IQ. */
646 void setIssued() { status.set(Issued); }
648 /** Returns whether or not this instruction has issued. */
649 bool isIssued() const { return status[Issued]; }
651 /** Clears this instruction as being issued. */
652 void clearIssued() { status.reset(Issued); }
654 /** Sets this instruction as executed. */
655 void setExecuted() { status.set(Executed); }
657 /** Returns whether or not this instruction has executed. */
658 bool isExecuted() const { return status[Executed]; }
660 /** Sets this instruction as ready to commit. */
661 void setCanCommit() { status.set(CanCommit); }
663 /** Clears this instruction as being ready to commit. */
664 void clearCanCommit() { status.reset(CanCommit); }
666 /** Returns whether or not this instruction is ready to commit. */
667 bool readyToCommit() const { return status[CanCommit]; }
669 void setAtCommit() { status.set(AtCommit); }
671 bool isAtCommit() { return status[AtCommit]; }
673 /** Sets this instruction as committed. */
674 void setCommitted() { status.set(Committed); }
676 /** Returns whether or not this instruction is committed. */
677 bool isCommitted() const { return status[Committed]; }
679 /** Sets this instruction as squashed. */
680 void setSquashed() { status.set(Squashed); }
682 /** Returns whether or not this instruction is squashed. */
683 bool isSquashed() const { return status[Squashed]; }
685 //Instruction Queue Entry
686 //-----------------------
687 /** Sets this instruction as a entry the IQ. */
688 void setInIQ() { status.set(IqEntry); }
690 /** Sets this instruction as a entry the IQ. */
691 void clearInIQ() { status.reset(IqEntry); }
693 /** Returns whether or not this instruction has issued. */
694 bool isInIQ() const { return status[IqEntry]; }
696 /** Sets this instruction as squashed in the IQ. */
697 void setSquashedInIQ() { status.set(SquashedInIQ); status.set(Squashed);}
699 /** Returns whether or not this instruction is squashed in the IQ. */
700 bool isSquashedInIQ() const { return status[SquashedInIQ]; }
703 //Load / Store Queue Functions
704 //-----------------------
705 /** Sets this instruction as a entry the LSQ. */
706 void setInLSQ() { status.set(LsqEntry); }
708 /** Sets this instruction as a entry the LSQ. */
709 void removeInLSQ() { status.reset(LsqEntry); }
711 /** Returns whether or not this instruction is in the LSQ. */
712 bool isInLSQ() const { return status[LsqEntry]; }
714 /** Sets this instruction as squashed in the LSQ. */
715 void setSquashedInLSQ() { status.set(SquashedInLSQ);}
717 /** Returns whether or not this instruction is squashed in the LSQ. */
718 bool isSquashedInLSQ() const { return status[SquashedInLSQ]; }
721 //Reorder Buffer Functions
722 //-----------------------
723 /** Sets this instruction as a entry the ROB. */
724 void setInROB() { status.set(RobEntry); }
726 /** Sets this instruction as a entry the ROB. */
727 void clearInROB() { status.reset(RobEntry); }
729 /** Returns whether or not this instruction is in the ROB. */
730 bool isInROB() const { return status[RobEntry]; }
732 /** Sets this instruction as squashed in the ROB. */
733 void setSquashedInROB() { status.set(SquashedInROB); }
735 /** Returns whether or not this instruction is squashed in the ROB. */
736 bool isSquashedInROB() const { return status[SquashedInROB]; }
738 /** Read the PC of this instruction. */
739 const Addr readPC() const { return PC; }
741 /**Read the micro PC of this instruction. */
742 const Addr readMicroPC() const { return microPC; }
744 /** Set the next PC of this instruction (its actual target). */
745 void setNextPC(Addr val)
750 /** Set the next NPC of this instruction (the target in Mips or Sparc).*/
751 void setNextNPC(Addr val)
753 #if ISA_HAS_DELAY_SLOT
758 void setNextMicroPC(Addr val)
763 /** Sets the ASID. */
764 void setASID(short addr_space_id) { asid = addr_space_id; }
766 /** Sets the thread id. */
767 void setTid(unsigned tid) { threadNumber = tid; }
769 /** Sets the pointer to the thread state. */
770 void setThreadState(ImplState *state) { thread = state; }
772 /** Returns the thread context. */
773 ThreadContext *tcBase() { return thread->getTC(); }
776 /** Instruction effective address.
777 * @todo: Consider if this is necessary or not.
781 /** Whether or not the effective address calculation is completed.
782 * @todo: Consider if this is necessary or not.
786 /** Is this instruction's memory access uncacheable. */
789 /** Has this instruction generated a memory request. */
793 /** Sets the effective address. */
794 void setEA(Addr &ea) { instEffAddr = ea; eaCalcDone = true; }
796 /** Returns the effective address. */
797 const Addr &getEA() const { return instEffAddr; }
799 /** Returns whether or not the eff. addr. calculation has been completed. */
800 bool doneEACalc() { return eaCalcDone; }
802 /** Returns whether or not the eff. addr. source registers are ready. */
805 /** Whether or not the memory operation is done. */
808 /** Is this instruction's memory access uncacheable. */
809 bool uncacheable() { return isUncacheable; }
811 /** Has this instruction generated a memory request. */
812 bool hasRequest() { return reqMade; }
815 /** Load queue index. */
818 /** Store queue index. */
821 /** Iterator pointing to this BaseDynInst in the list of all insts. */
824 /** Returns iterator to this instruction in the list of all insts. */
825 ListIt &getInstListIt() { return instListIt; }
827 /** Sets iterator for this instruction in the list of all insts. */
828 void setInstListIt(ListIt _instListIt) { instListIt = _instListIt; }
831 /** Returns the number of consecutive store conditional failures. */
832 unsigned readStCondFailures()
833 { return thread->storeCondFailures; }
835 /** Sets the number of consecutive store conditional failures. */
836 void setStCondFailures(unsigned sc_failures)
837 { thread->storeCondFailures = sc_failures; }
843 BaseDynInst<Impl>::read(Addr addr, T &data, unsigned flags)
846 Request *req = new Request();
847 req->setVirt(asid, addr, sizeof(T), flags, this->PC);
848 req->setThreadContext(thread->readCpuId(), threadNumber);
850 if ((req->getVaddr() & (TheISA::VMPageSize - 1)) + req->getSize() >
851 TheISA::VMPageSize) {
853 return TheISA::genAlignmentFault();
856 fault = cpu->translateDataReadReq(req, thread);
858 if (req->isUncacheable())
859 isUncacheable = true;
861 if (fault == NoFault) {
862 effAddr = req->getVaddr();
864 physEffAddr = req->getPaddr();
865 memReqFlags = req->getFlags();
868 if (cpu->system->memctrl->badaddr(physEffAddr)) {
869 fault = TheISA::genMachineCheckFault();
873 fault = cpu->read(req, data, lqIdx);
876 fault = cpu->read(req, data, lqIdx);
879 // Return a fixed value to keep simulation deterministic even
880 // along misspeculated paths.
883 // Commit will have to clean up whatever happened. Set this
884 // instruction as executed.
890 traceData->setAddr(addr);
891 traceData->setData(data);
900 BaseDynInst<Impl>::write(T data, Addr addr, unsigned flags, uint64_t *res)
903 traceData->setAddr(addr);
904 traceData->setData(data);
908 Request *req = new Request();
909 req->setVirt(asid, addr, sizeof(T), flags, this->PC);
910 req->setThreadContext(thread->readCpuId(), threadNumber);
912 if ((req->getVaddr() & (TheISA::VMPageSize - 1)) + req->getSize() >
913 TheISA::VMPageSize) {
915 return TheISA::genAlignmentFault();
918 fault = cpu->translateDataWriteReq(req, thread);
920 if (req->isUncacheable())
921 isUncacheable = true;
923 if (fault == NoFault) {
924 effAddr = req->getVaddr();
926 physEffAddr = req->getPaddr();
927 memReqFlags = req->getFlags();
929 if (req->isCondSwap()) {
931 req->setExtraData(*res);
934 if (cpu->system->memctrl->badaddr(physEffAddr)) {
935 fault = TheISA::genMachineCheckFault();
937 fault = cpu->write(req, data, sqIdx);
940 fault = cpu->write(req, data, sqIdx);
949 #endif // __CPU_BASE_DYN_INST_HH__