2 * Copyright (c) 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.
32 #ifndef __CPU_O3_MIPS_DYN_INST_HH__
33 #define __CPU_O3_MIPS_DYN_INST_HH__
35 #include "arch/isa_traits.hh"
36 #include "cpu/base_dyn_inst.hh"
37 #include "cpu/inst_seq.hh"
38 #include "cpu/o3/mips/cpu.hh"
39 #include "cpu/o3/mips/impl.hh"
44 * Mostly implementation & ISA specific MipsDynInst. As with most
45 * other classes in the new CPU model, it is templated on the Impl to
46 * allow for passing in of all types, such as the CPU type and the ISA
47 * type. The MipsDynInst serves as the primary interface to the CPU
48 * for instructions that are executing.
51 class MipsDynInst : public BaseDynInst<Impl>
54 /** Typedef for the CPU. */
55 typedef typename Impl::O3CPU O3CPU;
57 /** Logical register index type. */
58 typedef TheISA::RegIndex RegIndex;
59 /** Integer register index type. */
60 typedef TheISA::IntReg IntReg;
61 typedef TheISA::FloatReg FloatReg;
62 typedef TheISA::FloatRegBits FloatRegBits;
63 /** Misc register index type. */
64 typedef TheISA::MiscReg MiscReg;
67 MaxInstSrcRegs = TheISA::MaxInstSrcRegs, //< Max source regs
68 MaxInstDestRegs = TheISA::MaxInstDestRegs, //< Max dest regs
72 /** BaseDynInst constructor given a binary instruction. */
73 MipsDynInst(ExtMachInst inst,
75 Addr Pred_PC, Addr Pred_NPC,
76 InstSeqNum seq_num, O3CPU *cpu);
78 /** BaseDynInst constructor given a static inst pointer. */
79 MipsDynInst(StaticInstPtr &_staticInst);
81 /** Executes the instruction.*/
84 /** Initiates the access. Only valid for memory operations. */
87 /** Completes the access. Only valid for memory operations. */
88 Fault completeAcc(PacketPtr pkt);
91 /** Initializes variables. */
95 /** Reads a miscellaneous register. */
96 MiscReg readMiscReg(int misc_reg)
98 return this->cpu->readMiscReg(misc_reg, this->threadNumber);
101 /** Reads a misc. register, including any side-effects the read
102 * might have as defined by the architecture.
104 MiscReg readMiscRegWithEffect(int misc_reg)
106 return this->cpu->readMiscRegWithEffect(misc_reg, this->threadNumber);
109 /** Sets a misc. register. */
110 void setMiscReg(int misc_reg, const MiscReg &val)
112 this->instResult.integer = val;
113 this->cpu->setMiscReg(misc_reg, val, this->threadNumber);
116 /** Sets a misc. register, including any side-effects the write
117 * might have as defined by the architecture.
119 void setMiscRegWithEffect(int misc_reg, const MiscReg &val)
121 return this->cpu->setMiscRegWithEffect(misc_reg, val,
125 /** Calls a syscall. */
126 void syscall(int64_t callnum);
130 // The register accessor methods provide the index of the
131 // instruction's operand (e.g., 0 or 1), not the architectural
132 // register index, to simplify the implementation of register
133 // renaming. We find the architectural register index by indexing
134 // into the instruction's own operand index table. Note that a
135 // raw pointer to the StaticInst is provided instead of a
136 // ref-counted StaticInstPtr to redice overhead. This is fine as
137 // long as these methods don't copy the pointer into any long-term
138 // storage (which is pretty hard to imagine they would have reason
141 uint64_t readIntRegOperand(const StaticInst *si, int idx)
143 return this->cpu->readIntReg(this->_srcRegIdx[idx]);
146 FloatReg readFloatRegOperand(const StaticInst *si, int idx, int width)
148 return this->cpu->readFloatReg(this->_srcRegIdx[idx], width);
151 FloatReg readFloatRegOperand(const StaticInst *si, int idx)
153 return this->cpu->readFloatReg(this->_srcRegIdx[idx]);
156 FloatRegBits readFloatRegOperandBits(const StaticInst *si, int idx,
159 return this->cpu->readFloatRegBits(this->_srcRegIdx[idx], width);
162 FloatRegBits readFloatRegOperandBits(const StaticInst *si, int idx)
164 return this->cpu->readFloatRegBits(this->_srcRegIdx[idx]);
167 /** @todo: Make results into arrays so they can handle multiple dest
170 void setIntRegOperand(const StaticInst *si, int idx, uint64_t val)
172 this->cpu->setIntReg(this->_destRegIdx[idx], val);
173 BaseDynInst<Impl>::setIntRegOperand(si, idx, val);
176 void setFloatRegOperand(const StaticInst *si, int idx, FloatReg val,
179 this->cpu->setFloatReg(this->_destRegIdx[idx], val, width);
180 BaseDynInst<Impl>::setFloatRegOperand(si, idx, val, width);
183 void setFloatRegOperand(const StaticInst *si, int idx, FloatReg val)
185 this->cpu->setFloatReg(this->_destRegIdx[idx], val);
186 BaseDynInst<Impl>::setFloatRegOperand(si, idx, val);
189 void setFloatRegOperandBits(const StaticInst *si, int idx,
190 FloatRegBits val, int width)
192 this->cpu->setFloatRegBits(this->_destRegIdx[idx], val, width);
193 BaseDynInst<Impl>::setFloatRegOperandBits(si, idx, val);
196 void setFloatRegOperandBits(const StaticInst *si, int idx,
199 this->cpu->setFloatRegBits(this->_destRegIdx[idx], val);
200 BaseDynInst<Impl>::setFloatRegOperandBits(si, idx, val);
204 /** Calculates EA part of a memory instruction. Currently unused,
205 * though it may be useful in the future if we want to split
206 * memory operations into EA calculation and memory access parts.
210 return this->staticInst->eaCompInst()->execute(this, this->traceData);
213 /** Does the memory access part of a memory instruction. Currently unused,
214 * though it may be useful in the future if we want to split
215 * memory operations into EA calculation and memory access parts.
219 return this->staticInst->memAccInst()->execute(this, this->traceData);
223 #endif // __CPU_O3_MIPS_DYN_INST_HH__