2 * Copyright (c) 2007 MIPS Technologies, Inc.
3 * Copyright (c) 2004-2006 The Regents of The University of Michigan
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef __CPU_INORDER_DYN_INST_HH__
34 #define __CPU_INORDER_DYN_INST_HH__
40 #include "arch/faults.hh"
41 #include "arch/isa_traits.hh"
43 #include "arch/types.hh"
44 #include "arch/utility.hh"
45 #include "base/fast_alloc.hh"
46 #include "base/trace.hh"
47 #include "base/types.hh"
48 #include "config/full_system.hh"
49 #include "config/the_isa.hh"
50 #include "cpu/inorder/inorder_trace.hh"
51 #include "cpu/inorder/pipeline_traits.hh"
52 #include "cpu/inorder/resource.hh"
53 #include "cpu/inorder/resource_sked.hh"
54 #include "cpu/inorder/thread_state.hh"
55 #include "cpu/exetrace.hh"
56 #include "cpu/inst_seq.hh"
57 #include "cpu/op_class.hh"
58 #include "cpu/static_inst.hh"
59 #include "cpu/thread_context.hh"
60 #include "debug/InOrderDynInst.hh"
61 #include "mem/packet.hh"
62 #include "sim/system.hh"
64 #if THE_ISA == ALPHA_ISA
65 #include "arch/alpha/ev5.hh"
70 * Defines a dynamic instruction context for a inorder CPU model.
73 // Forward declaration.
75 class ResourceRequest;
78 class InOrderDynInst : public FastAlloc, public RefCounted
81 // Binary machine instruction type.
82 typedef TheISA::MachInst MachInst;
83 // Extended machine instruction type
84 typedef TheISA::ExtMachInst ExtMachInst;
85 // Logical register index type.
86 typedef TheISA::RegIndex RegIndex;
87 // Integer register type.
88 typedef TheISA::IntReg IntReg;
89 // Floating point register type.
90 typedef TheISA::FloatReg FloatReg;
91 // Floating point register type.
92 typedef TheISA::MiscReg MiscReg;
94 typedef short int PhysRegIndex;
96 /** The refcounted DynInst pointer to be used. In most cases this is
97 * what should be used, and not DynInst*.
99 typedef RefCountingPtr<InOrderDynInst> DynInstPtr;
101 // The list of instructions iterator type.
102 typedef std::list<DynInstPtr>::iterator ListIt;
105 MaxInstSrcRegs = TheISA::MaxInstSrcRegs, /// Max source regs
106 MaxInstDestRegs = TheISA::MaxInstDestRegs, /// Max dest regs
110 /** BaseDynInst constructor given a binary instruction.
111 * @param seq_num The sequence number of the instruction.
112 * @param cpu Pointer to the instruction's CPU.
113 * NOTE: Must set Binary Instrution through Member Function
115 InOrderDynInst(InOrderCPU *cpu, InOrderThreadState *state,
116 InstSeqNum seq_num, ThreadID tid, unsigned asid = 0);
118 /** InOrderDynInst destructor. */
122 /** The sequence number of the instruction. */
125 /** If this instruction is squashing, the number should we squash behind. */
126 InstSeqNum squashSeqNum;
129 RegDepMapEntry, /// Instruction is entered onto the RegDepMap
130 IqEntry, /// Instruction is in the IQ
131 RobEntry, /// Instruction is in the ROB
132 LsqEntry, /// Instruction is in the LSQ
133 Completed, /// Instruction has completed
134 ResultReady, /// Instruction has its result
135 CanIssue, /// Instruction can issue and execute
136 Issued, /// Instruction has issued
137 Executed, /// Instruction has executed
138 CanCommit, /// Instruction can commit
139 AtCommit, /// Instruction has reached commit
140 Committed, /// Instruction has committed
141 Squashed, /// Instruction is squashed
142 SquashedInIQ, /// Instruction is squashed in the IQ
143 SquashedInLSQ, /// Instruction is squashed in the LSQ
144 SquashedInROB, /// Instruction is squashed in the ROB
145 RecoverInst, /// Is a recover instruction
146 BlockingInst, /// Is a blocking instruction
147 ThreadsyncWait, /// Is a thread synchronization instruction
148 SerializeBefore, /// Needs to serialize on
149 /// instructions ahead of it
150 SerializeAfter, /// Needs to serialize instructions behind it
151 SerializeHandled, /// Serialization has been handled
152 RemoveList, /// Is Instruction on Remove List?
156 /** The status of this BaseDynInst. Several bits can be set. */
157 std::bitset<NumStatus> status;
159 /** The thread this instruction is from. */
162 /** data address space ID, for loads & stores. */
165 /** The virtual processor number */
166 short virtProcNumber;
168 /** The StaticInst used by this BaseDynInst. */
169 StaticInstPtr staticInst;
171 /** InstRecord that tracks this instructions. */
172 Trace::InOrderTraceRecord *traceData;
174 /** Pointer to the Impl's CPU object. */
177 /** Pointer to the thread state. */
178 InOrderThreadState *thread;
180 /** The kind of fault this instruction has generated. */
183 /** The memory request. */
186 /** Pointer to the data for the memory access. */
189 /** Data used for a store for operation. */
192 /** Data used for a store for operation. */
195 /** List of active resource requests for this instruction */
196 std::list<ResourceRequest*> reqList;
198 /** The effective virtual address (lds & stores only). */
201 /** The effective physical address. */
204 /** The memory request flags (from translation). */
205 unsigned memReqFlags;
207 /** How many source registers are ready. */
210 /** An instruction src/dest has to be one of these types */
216 //@TODO: Naming Convention for Enums?
225 /** Result of an instruction execution */
232 : type(None), tick(0)
239 /** The source of the instruction; assumes for now that there's only one
240 * destination register.
242 InstValue instSrc[MaxInstSrcRegs];
244 /** The result of the instruction; assumes for now that there's only one
245 * destination register.
247 InstResult instResult[MaxInstDestRegs];
249 /** PC of this instruction. */
252 /** Predicted next PC. */
253 TheISA::PCState predPC;
255 /** Address to get/write data from/to */
256 /* Fetching address when inst. starts, Data address for load/store after fetch*/
259 /** Whether or not the source register is ready.
260 * @todo: Not sure this should be here vs the derived class.
262 bool _readySrcRegIdx[MaxInstSrcRegs];
264 /** Flattened register index of the destination registers of this
267 TheISA::RegIndex _flatDestRegIdx[TheISA::MaxInstDestRegs];
269 /** Flattened register index of the source registers of this
272 TheISA::RegIndex _flatSrcRegIdx[TheISA::MaxInstSrcRegs];
274 /** Physical register index of the destination registers of this
277 PhysRegIndex _destRegIdx[MaxInstDestRegs];
279 /** Physical register index of the source registers of this
282 PhysRegIndex _srcRegIdx[MaxInstSrcRegs];
284 /** Physical register index of the previous producers of the
285 * architected destinations.
287 PhysRegIndex _prevDestRegIdx[MaxInstDestRegs];
292 /** Function to initialize variables in the constructors. */
298 PacketDataPtr splitMemData;
299 RequestPtr splitMemReq;
304 uint8_t split2ndData;
305 PacketDataPtr split2ndDataPtr;
306 unsigned split2ndFlags;
309 uint64_t *split2ndStoreDataPtr;
312 ////////////////////////////////////////////////////////////
314 // BASE INSTRUCTION INFORMATION.
316 ////////////////////////////////////////////////////////////
317 std::string instName()
318 { return (staticInst) ? staticInst->getName() : "undecoded-inst"; }
320 void setMachInst(ExtMachInst inst);
322 ExtMachInst getMachInst() { return staticInst->machInst; }
324 /** Sets the StaticInst. */
325 void setStaticInst(StaticInstPtr &static_inst);
327 /** Sets the sequence number. */
328 void setSeqNum(InstSeqNum seq_num) { seqNum = seq_num; }
330 /** Sets the ASID. */
331 void setASID(short addr_space_id) { asid = addr_space_id; }
333 /** Reads the thread id. */
334 short readTid() { return threadNumber; }
336 /** Sets the thread id. */
337 void setTid(ThreadID tid) { threadNumber = tid; }
339 void setVpn(int id) { virtProcNumber = id; }
341 int readVpn() { return virtProcNumber; }
343 /** Sets the pointer to the thread state. */
344 void setThreadState(InOrderThreadState *state) { thread = state; }
346 /** Returns the thread context. */
347 ThreadContext *tcBase() { return thread->getTC(); }
349 /** Returns the fault type. */
350 Fault getFault() { return fault; }
352 ////////////////////////////////////////////////////////////
354 // INSTRUCTION TYPES - Forward checks to StaticInst object.
356 ////////////////////////////////////////////////////////////
357 bool isNop() const { return staticInst->isNop(); }
358 bool isMemRef() const { return staticInst->isMemRef(); }
359 bool isLoad() const { return staticInst->isLoad(); }
360 bool isStore() const { return staticInst->isStore(); }
361 bool isStoreConditional() const
362 { return staticInst->isStoreConditional(); }
363 bool isInstPrefetch() const { return staticInst->isInstPrefetch(); }
364 bool isDataPrefetch() const { return staticInst->isDataPrefetch(); }
365 bool isInteger() const { return staticInst->isInteger(); }
366 bool isFloating() const { return staticInst->isFloating(); }
367 bool isControl() const { return staticInst->isControl(); }
368 bool isCall() const { return staticInst->isCall(); }
369 bool isReturn() const { return staticInst->isReturn(); }
370 bool isDirectCtrl() const { return staticInst->isDirectCtrl(); }
371 bool isIndirectCtrl() const { return staticInst->isIndirectCtrl(); }
372 bool isCondCtrl() const { return staticInst->isCondCtrl(); }
373 bool isUncondCtrl() const { return staticInst->isUncondCtrl(); }
374 bool isCondDelaySlot() const { return staticInst->isCondDelaySlot(); }
376 bool isThreadSync() const { return staticInst->isThreadSync(); }
377 bool isSerializing() const { return staticInst->isSerializing(); }
378 bool isSerializeBefore() const
379 { return staticInst->isSerializeBefore() || status[SerializeBefore]; }
380 bool isSerializeAfter() const
381 { return staticInst->isSerializeAfter() || status[SerializeAfter]; }
382 bool isMemBarrier() const { return staticInst->isMemBarrier(); }
383 bool isWriteBarrier() const { return staticInst->isWriteBarrier(); }
384 bool isNonSpeculative() const { return staticInst->isNonSpeculative(); }
385 bool isQuiesce() const { return staticInst->isQuiesce(); }
386 bool isIprAccess() const { return staticInst->isIprAccess(); }
387 bool isUnverifiable() const { return staticInst->isUnverifiable(); }
389 /////////////////////////////////////////////
391 // RESOURCE SCHEDULING
393 /////////////////////////////////////////////
394 typedef ThePipeline::RSkedPtr RSkedPtr;
398 RSkedIt frontSked_end;
401 RSkedIt backSked_end;
403 RSkedIt curSkedEntry;
405 void setFrontSked(RSkedPtr front_sked)
407 frontSked = front_sked;
408 frontSked_end.init(frontSked);
409 frontSked_end = frontSked->end();
410 //DPRINTF(InOrderDynInst, "Set FrontSked End to : %x \n" ,
411 // frontSked_end.getIt()/*, frontSked->end()*/);
412 //assert(frontSked_end == frontSked->end());
414 // This initializes instruction to be able
415 // to walk the resource schedule
416 curSkedEntry.init(frontSked);
417 curSkedEntry = frontSked->begin();
420 void setBackSked(RSkedPtr back_sked)
422 backSked = back_sked;
423 backSked_end.init(backSked);
424 backSked_end = backSked->end();
427 void setNextStage(int stage_num) { nextStage = stage_num; }
428 int getNextStage() { return nextStage; }
430 /** Print Resource Schedule */
433 if (frontSked != NULL) {
437 if (backSked != NULL) {
442 /** Return Next Resource Stage To Be Used */
445 assert((inFrontEnd && curSkedEntry != frontSked_end) ||
446 (!inFrontEnd && curSkedEntry != backSked_end));
448 return curSkedEntry->stageNum;
452 /** Return Next Resource To Be Used */
455 assert((inFrontEnd && curSkedEntry != frontSked_end) ||
456 (!inFrontEnd && curSkedEntry != backSked_end));
458 return curSkedEntry->resNum;
461 /** Finish using a schedule entry, increment to next entry */
462 bool finishSkedEntry()
466 if (inFrontEnd && curSkedEntry == frontSked_end) {
467 DPRINTF(InOrderDynInst, "[sn:%i] Switching to "
468 "back end schedule.\n", seqNum);
469 assert(backSked != NULL);
470 curSkedEntry.init(backSked);
471 curSkedEntry = backSked->begin();
473 } else if (!inFrontEnd && curSkedEntry == backSked_end) {
477 DPRINTF(InOrderDynInst, "[sn:%i] Next Stage: %i "
478 "Next Resource: %i.\n", seqNum, curSkedEntry->stageNum,
479 curSkedEntry->resNum);
484 /** Release a Resource Request (Currently Unused) */
485 void releaseReq(ResourceRequest* req);
487 ////////////////////////////////////////////
489 // INSTRUCTION EXECUTION
491 ////////////////////////////////////////////
492 /** Returns the opclass of this instruction. */
493 OpClass opClass() const { return staticInst->opClass(); }
495 /** Executes the instruction.*/
500 unsigned getCurResSlot() { return curResSlot; }
502 void setCurResSlot(unsigned slot_num) { curResSlot = slot_num; }
504 /** Calls a syscall. */
506 /** Calls hardware return from error interrupt. */
508 /** Traps to handle specified fault. */
509 void trap(Fault fault);
510 bool simPalCheck(int palFunc);
512 /** Calls a syscall. */
513 void syscall(int64_t callnum);
516 ////////////////////////////////////////////////////////////
518 // MULTITHREADING INTERFACE TO CPU MODELS
520 ////////////////////////////////////////////////////////////
521 virtual void deallocateContext(int thread_num);
523 ////////////////////////////////////////////////////////////
525 // PROGRAM COUNTERS - PC/NPC/NPC
527 ////////////////////////////////////////////////////////////
528 /** Read the PC of this instruction. */
529 const TheISA::PCState &pcState() const { return pc; }
531 /** Sets the PC of this instruction. */
532 void pcState(const TheISA::PCState &_pc) { pc = _pc; }
534 const Addr instAddr() { return pc.instAddr(); }
535 const Addr nextInstAddr() { return pc.nextInstAddr(); }
536 const MicroPC microPC() { return pc.microPC(); }
538 ////////////////////////////////////////////////////////////
542 ////////////////////////////////////////////////////////////
543 /** Set the predicted target of this current instruction. */
544 void setPredTarg(const TheISA::PCState &predictedPC)
545 { predPC = predictedPC; }
547 /** Returns the predicted target of the branch. */
548 TheISA::PCState readPredTarg() { return predPC; }
550 /** Returns the predicted PC immediately after the branch. */
551 Addr predInstAddr() { return predPC.instAddr(); }
553 /** Returns the predicted PC two instructions after the branch */
554 Addr predNextInstAddr() { return predPC.nextInstAddr(); }
556 /** Returns the predicted micro PC after the branch */
557 Addr readPredMicroPC() { return predPC.microPC(); }
559 /** Returns whether the instruction was predicted taken or not. */
560 bool predTaken() { return predictTaken; }
562 /** Returns whether the instruction mispredicted. */
566 TheISA::PCState nextPC = pc;
567 TheISA::advancePC(nextPC, staticInst);
568 return !(nextPC == predPC);
571 /** Returns the branch target address. */
572 TheISA::PCState branchTarget() const
573 { return staticInst->branchTarget(pc); }
575 /** Checks whether or not this instruction has had its branch target
576 * calculated yet. For now it is not utilized and is hacked to be
578 * @todo: Actually use this instruction.
580 bool doneTargCalc() { return false; }
582 void setBranchPred(bool prediction) { predictTaken = prediction; }
588 bool procDelaySlotOnMispred;
590 void setSquashInfo(unsigned stage_num);
592 ////////////////////////////////////////////
596 ////////////////////////////////////////////
598 * Does a read to a given address.
599 * @param addr The address to read.
600 * @param data The read's data is written into this parameter.
601 * @param flags The request's flags.
602 * @return Returns any fault due to the read.
605 Fault read(Addr addr, T &data, unsigned flags);
607 Fault readBytes(Addr addr, uint8_t *data, unsigned size, unsigned flags);
610 * Does a write to a given address.
611 * @param data The data to be written.
612 * @param addr The address to write to.
613 * @param flags The request's flags.
614 * @param res The result of the write (for load locked/store conditionals).
615 * @return Returns any fault due to the write.
618 Fault write(T data, Addr addr, unsigned flags,
621 Fault writeBytes(uint8_t *data, unsigned size,
622 Addr addr, unsigned flags, uint64_t *res);
624 /** Initiates a memory access - Calculate Eff. Addr & Initiate Memory
625 * Access Only valid for memory operations.
629 /** Completes a memory access - Only valid for memory operations. */
630 Fault completeAcc(Packet *pkt);
632 /** Calculates Eff. Addr. part of a memory instruction. */
635 /** Read Effective Address from instruction & do memory access */
638 RequestPtr fetchMemReq;
639 RequestPtr dataMemReq;
644 { return memAddrReady; }
646 void setMemAddr(Addr addr)
647 { memAddr = addr; memAddrReady = true;}
650 { memAddrReady = false;}
655 /** Sets the effective address. */
656 void setEA(Addr &ea) { instEffAddr = ea; eaCalcDone = true; }
658 /** Returns the effective address. */
659 const Addr &getEA() const { return instEffAddr; }
661 /** Returns whether or not the eff. addr. calculation has been completed.*/
662 bool doneEACalc() { return eaCalcDone; }
664 /** Returns whether or not the eff. addr. source registers are ready.
665 * Assume that src registers 1..n-1 are the ones that the
666 * EA calc depends on. (i.e. src reg 0 is the source of the data to be
671 for (int i = 1; i < numSrcRegs(); ++i) {
672 if (!_readySrcRegIdx[i])
679 //////////////////////////////////////////////////
681 // SOURCE-DESTINATION REGISTER INDEXING
683 //////////////////////////////////////////////////
684 /** Returns the number of source registers. */
685 int8_t numSrcRegs() const { return staticInst->numSrcRegs(); }
687 /** Returns the number of destination registers. */
688 int8_t numDestRegs() const { return staticInst->numDestRegs(); }
690 // the following are used to track physical register usage
691 // for machines with separate int & FP reg files
692 int8_t numFPDestRegs() const { return staticInst->numFPDestRegs(); }
693 int8_t numIntDestRegs() const { return staticInst->numIntDestRegs(); }
695 /** Returns the logical register index of the i'th destination register. */
696 RegIndex destRegIdx(int i) const { return staticInst->destRegIdx(i); }
698 /** Returns the logical register index of the i'th source register. */
699 RegIndex srcRegIdx(int i) const { return staticInst->srcRegIdx(i); }
701 //////////////////////////////////////////////////
703 // RENAME/PHYSICAL REGISTER FILE SUPPORT
705 //////////////////////////////////////////////////
706 /** Returns the physical register index of the i'th destination
709 PhysRegIndex renamedDestRegIdx(int idx) const
711 return _destRegIdx[idx];
714 /** Returns the physical register index of the i'th source register. */
715 PhysRegIndex renamedSrcRegIdx(int idx) const
717 return _srcRegIdx[idx];
720 /** Flattens a source architectural register index into a logical index.
722 void flattenSrcReg(int idx, TheISA::RegIndex flattened_src)
724 _flatSrcRegIdx[idx] = flattened_src;
727 /** Flattens a destination architectural register index into a logical
730 void flattenDestReg(int idx, TheISA::RegIndex flattened_dest)
732 _flatDestRegIdx[idx] = flattened_dest;
735 /** Returns the flattened register index of the i'th destination
738 TheISA::RegIndex flattenedDestRegIdx(int idx) const
740 return _flatDestRegIdx[idx];
743 /** Returns the flattened register index of the i'th source register */
744 TheISA::RegIndex flattenedSrcRegIdx(int idx) const
746 return _flatSrcRegIdx[idx];
749 /** Returns the physical register index of the previous physical register
750 * that remapped to the same logical register index.
752 PhysRegIndex prevDestRegIdx(int idx) const
754 return _prevDestRegIdx[idx];
757 /** Returns if a source register is ready. */
758 bool isReadySrcRegIdx(int idx) const
760 return this->_readySrcRegIdx[idx];
763 /** Records that one of the source registers is ready. */
764 void markSrcRegReady()
766 if (++readyRegs == numSrcRegs()) {
767 status.set(CanIssue);
771 /** Marks a specific register as ready. */
772 void markSrcRegReady(RegIndex src_idx)
774 _readySrcRegIdx[src_idx] = true;
779 /** Renames a destination register to a physical register. Also records
780 * the previous physical register that the logical register mapped to.
782 void renameDestReg(int idx,
783 PhysRegIndex renamed_dest,
784 PhysRegIndex previous_rename)
786 _destRegIdx[idx] = renamed_dest;
787 _prevDestRegIdx[idx] = previous_rename;
790 /** Renames a source logical register to the physical register which
791 * has/will produce that logical register's result.
792 * @todo: add in whether or not the source register is ready.
794 void renameSrcReg(int idx, PhysRegIndex renamed_src)
796 _srcRegIdx[idx] = renamed_src;
800 PhysRegIndex readDestRegIdx(int idx)
802 return _destRegIdx[idx];
805 void setDestRegIdx(int idx, PhysRegIndex dest_idx)
807 _destRegIdx[idx] = dest_idx;
810 int getDestIdxNum(PhysRegIndex dest_idx)
812 for (int i=0; i < staticInst->numDestRegs(); i++) {
813 if (_flatDestRegIdx[i] == dest_idx)
820 PhysRegIndex readSrcRegIdx(int idx)
822 return _srcRegIdx[idx];
825 void setSrcRegIdx(int idx, PhysRegIndex src_idx)
827 _srcRegIdx[idx] = src_idx;
830 int getSrcIdxNum(PhysRegIndex src_idx)
832 for (int i=0; i < staticInst->numSrcRegs(); i++) {
833 if (_srcRegIdx[i] == src_idx)
840 ////////////////////////////////////////////////////
842 // SOURCE-DESTINATION REGISTER VALUES
844 ////////////////////////////////////////////////////
846 /** Functions that sets an integer or floating point
847 * source register to a value. */
848 void setIntSrc(int idx, uint64_t val);
849 void setFloatSrc(int idx, FloatReg val);
850 void setFloatRegBitsSrc(int idx, uint64_t val);
852 uint64_t* getIntSrcPtr(int idx) { return &instSrc[idx].integer; }
853 uint64_t readIntSrc(int idx) { return instSrc[idx].integer; }
855 /** These Instructions read a integer/float/misc. source register
856 * value in the instruction. The instruction's execute function will
857 * call these and it is the interface that is used by the ISA descr.
858 * language (which is why the name isnt readIntSrc(...)) Note: That
859 * the source reg. value is set using the setSrcReg() function.
861 IntReg readIntRegOperand(const StaticInst *si, int idx, ThreadID tid = 0);
862 FloatReg readFloatRegOperand(const StaticInst *si, int idx);
863 TheISA::FloatRegBits readFloatRegOperandBits(const StaticInst *si, int idx);
864 MiscReg readMiscReg(int misc_reg);
865 MiscReg readMiscRegNoEffect(int misc_reg);
866 MiscReg readMiscRegOperand(const StaticInst *si, int idx);
867 MiscReg readMiscRegOperandNoEffect(const StaticInst *si, int idx);
869 /** Returns the result value instruction. */
870 ResultType resultType(int idx)
872 return instResult[idx].type;
875 uint64_t readIntResult(int idx)
877 return instResult[idx].val.integer;
880 /** Depending on type, return Float or Double */
881 double readFloatResult(int idx)
883 return instResult[idx].val.dbl;
886 Tick readResultTime(int idx) { return instResult[idx].tick; }
888 uint64_t* getIntResultPtr(int idx) { return &instResult[idx].val.integer; }
890 /** This is the interface that an instruction will use to write
891 * it's destination register.
893 void setIntRegOperand(const StaticInst *si, int idx, IntReg val);
894 void setFloatRegOperand(const StaticInst *si, int idx, FloatReg val);
895 void setFloatRegOperandBits(const StaticInst *si, int idx,
896 TheISA::FloatRegBits val);
897 void setMiscReg(int misc_reg, const MiscReg &val);
898 void setMiscRegNoEffect(int misc_reg, const MiscReg &val);
899 void setMiscRegOperand(const StaticInst *si, int idx, const MiscReg &val);
900 void setMiscRegOperandNoEffect(const StaticInst *si, int idx,
903 virtual uint64_t readRegOtherThread(unsigned idx,
904 ThreadID tid = InvalidThreadID);
905 virtual void setRegOtherThread(unsigned idx, const uint64_t &val,
906 ThreadID tid = InvalidThreadID);
908 /** Sets the number of consecutive store conditional failures. */
909 void setStCondFailures(unsigned sc_failures)
910 { thread->storeCondFailures = sc_failures; }
912 //////////////////////////////////////////////////////////////
914 // INSTRUCTION STATUS FLAGS (READ/SET)
916 //////////////////////////////////////////////////////////////
917 /** Sets this instruction as entered on the CPU Reg Dep Map */
918 void setRegDepEntry() { status.set(RegDepMapEntry); }
920 /** Returns whether or not the entry is on the CPU Reg Dep Map */
921 bool isRegDepEntry() const { return status[RegDepMapEntry]; }
923 /** Sets this instruction as entered on the CPU Reg Dep Map */
924 void setRemoveList() { status.set(RemoveList); }
926 /** Returns whether or not the entry is on the CPU Reg Dep Map */
927 bool isRemoveList() const { return status[RemoveList]; }
929 /** Sets this instruction as completed. */
930 void setCompleted() { status.set(Completed); }
932 /** Returns whether or not this instruction is completed. */
933 bool isCompleted() const { return status[Completed]; }
935 /** Marks the result as ready. */
936 void setResultReady() { status.set(ResultReady); }
938 /** Returns whether or not the result is ready. */
939 bool isResultReady() const { return status[ResultReady]; }
941 /** Sets this instruction as ready to issue. */
942 void setCanIssue() { status.set(CanIssue); }
944 /** Returns whether or not this instruction is ready to issue. */
945 bool readyToIssue() const { return status[CanIssue]; }
947 /** Sets this instruction as issued from the IQ. */
948 void setIssued() { status.set(Issued); }
950 /** Returns whether or not this instruction has issued. */
951 bool isIssued() const { return status[Issued]; }
953 /** Sets this instruction as executed. */
954 void setExecuted() { status.set(Executed); }
956 /** Returns whether or not this instruction has executed. */
957 bool isExecuted() const { return status[Executed]; }
959 /** Sets this instruction as ready to commit. */
960 void setCanCommit() { status.set(CanCommit); }
962 /** Clears this instruction as being ready to commit. */
963 void clearCanCommit() { status.reset(CanCommit); }
965 /** Returns whether or not this instruction is ready to commit. */
966 bool readyToCommit() const { return status[CanCommit]; }
968 void setAtCommit() { status.set(AtCommit); }
970 bool isAtCommit() { return status[AtCommit]; }
972 /** Sets this instruction as committed. */
973 void setCommitted() { status.set(Committed); }
975 /** Returns whether or not this instruction is committed. */
976 bool isCommitted() const { return status[Committed]; }
978 /** Sets this instruction as squashed. */
979 void setSquashed() { status.set(Squashed); }
981 /** Returns whether or not this instruction is squashed. */
982 bool isSquashed() const { return status[Squashed]; }
984 /** Temporarily sets this instruction as a serialize before instruction. */
985 void setSerializeBefore() { status.set(SerializeBefore); }
987 /** Clears the serializeBefore part of this instruction. */
988 void clearSerializeBefore() { status.reset(SerializeBefore); }
990 /** Checks if this serializeBefore is only temporarily set. */
991 bool isTempSerializeBefore() { return status[SerializeBefore]; }
993 /** Temporarily sets this instruction as a serialize after instruction. */
994 void setSerializeAfter() { status.set(SerializeAfter); }
996 /** Clears the serializeAfter part of this instruction.*/
997 void clearSerializeAfter() { status.reset(SerializeAfter); }
999 /** Checks if this serializeAfter is only temporarily set. */
1000 bool isTempSerializeAfter() { return status[SerializeAfter]; }
1002 /** Sets the serialization part of this instruction as handled. */
1003 void setSerializeHandled() { status.set(SerializeHandled); }
1005 /** Checks if the serialization part of this instruction has been
1006 * handled. This does not apply to the temporary serializing
1007 * state; it only applies to this instruction's own permanent
1008 * serializing state.
1010 bool isSerializeHandled() { return status[SerializeHandled]; }
1013 /** Instruction effective address.
1014 * @todo: Consider if this is necessary or not.
1018 /** Whether or not the effective address calculation is completed.
1019 * @todo: Consider if this is necessary or not.
1024 /** Load queue index. */
1027 /** Store queue index. */
1030 /** Iterator pointing to this BaseDynInst in the list of all insts. */
1035 /** Returns iterator to this instruction in the list of all insts. */
1036 ListIt getInstListIt() { return instListIt; }
1038 /** Sets iterator for this instruction in the list of all insts. */
1039 void setInstListIt(ListIt _instListIt) { onInstList = true; instListIt = _instListIt; }
1041 /** Count of total number of dynamic instructions. */
1042 static int instcount;
1044 void resetInstCount();
1046 /** Dumps out contents of this BaseDynInst. */
1049 /** Dumps out contents of this BaseDynInst into given string. */
1050 void dump(std::string &outstring);
1052 //inline int curCount() { return curCount(); }
1056 #endif // __CPU_BASE_DYN_INST_HH__