2 * Copyright (c) 2004-2005 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.
29 #ifndef __CPU_O3_CPU_ALPHA_DYN_INST_HH__
30 #define __CPU_O3_CPU_ALPHA_DYN_INST_HH__
32 #include "cpu/base_dyn_inst.hh"
33 #include "cpu/o3/alpha_cpu.hh"
34 #include "cpu/o3/alpha_impl.hh"
35 #include "cpu/inst_seq.hh"
38 * Mostly implementation specific AlphaDynInst. It is templated in case there
39 * are other implementations that are similar enough to be able to use this
40 * class without changes. This is mainly useful if there are multiple similar
41 * CPU implementations of the same ISA.
45 class AlphaDynInst : public BaseDynInst<Impl>
48 /** Typedef for the CPU. */
49 typedef typename Impl::FullCPU FullCPU;
51 /** Binary machine instruction type. */
52 typedef TheISA::MachInst MachInst;
53 /** Logical register index type. */
54 typedef TheISA::RegIndex RegIndex;
55 /** Integer register index type. */
56 typedef TheISA::IntReg IntReg;
57 /** Misc register index type. */
58 typedef TheISA::MiscReg MiscReg;
61 MaxInstSrcRegs = TheISA::MaxInstSrcRegs, //< Max source regs
62 MaxInstDestRegs = TheISA::MaxInstDestRegs, //< Max dest regs
66 /** BaseDynInst constructor given a binary instruction. */
67 AlphaDynInst(MachInst inst, Addr PC, Addr Pred_PC, InstSeqNum seq_num,
70 /** BaseDynInst constructor given a static inst pointer. */
71 AlphaDynInst(StaticInstPtr &_staticInst);
73 /** Executes the instruction.*/
76 return this->fault = this->staticInst->execute(this, this->traceData);
80 MiscReg readMiscReg(int misc_reg)
82 // Dummy function for now.
83 // @todo: Fix this once reg file gets fixed.
87 MiscReg readMiscRegWithEffect(int misc_reg, Fault &fault)
89 // Dummy function for now.
90 // @todo: Fix this once reg file gets fixed.
94 Fault setMiscReg(int misc_reg, const MiscReg &val)
96 // Dummy function for now.
97 // @todo: Fix this once reg file gets fixed.
101 Fault setMiscRegWithEffect(int misc_reg, const MiscReg &val)
103 // Dummy function for now.
104 // @todo: Fix this once reg file gets fixed.
111 void setIntrFlag(int val);
113 void trap(Fault fault);
114 bool simPalCheck(int palFunc);
122 /** Physical register index of the destination registers of this
125 PhysRegIndex _destRegIdx[MaxInstDestRegs];
127 /** Physical register index of the source registers of this
130 PhysRegIndex _srcRegIdx[MaxInstSrcRegs];
132 /** Physical register index of the previous producers of the
133 * architected destinations.
135 PhysRegIndex _prevDestRegIdx[MaxInstDestRegs];
139 // The register accessor methods provide the index of the
140 // instruction's operand (e.g., 0 or 1), not the architectural
141 // register index, to simplify the implementation of register
142 // renaming. We find the architectural register index by indexing
143 // into the instruction's own operand index table. Note that a
144 // raw pointer to the StaticInst is provided instead of a
145 // ref-counted StaticInstPtr to redice overhead. This is fine as
146 // long as these methods don't copy the pointer into any long-term
147 // storage (which is pretty hard to imagine they would have reason
150 uint64_t readIntReg(const StaticInst *si, int idx)
152 return this->cpu->readIntReg(_srcRegIdx[idx]);
155 FloatReg readFloatReg(const StaticInst *si, int idx, int width)
157 return this->cpu->readFloatReg(_srcRegIdx[idx], width);
160 FloatReg readFloatReg(const StaticInst *si, int idx)
162 return this->cpu->readFloatReg(_srcRegIdx[idx]);
165 FloatRegBits readFloatRegBits(const StaticInst *si, int idx, int width)
167 return this->cpu->readFloatRegBits(_srcRegIdx[idx], width);
170 FloatRegBits readFloatRegBits(const StaticInst *si, int idx)
172 return this->cpu->readFloatRegBits(_srcRegIdx[idx]);
175 /** @todo: Make results into arrays so they can handle multiple dest
178 void setIntReg(const StaticInst *si, int idx, uint64_t val)
180 this->cpu->setIntReg(_destRegIdx[idx], val);
181 this->instResult.integer = val;
184 void setFloatReg(const StaticInst *si, int idx, FloatReg val, int width)
186 this->cpu->setFloatReg(_destRegIdx[idx], val, width);
187 this->instResult.fp = val;
190 void setFloatReg(const StaticInst *si, int idx, FloatReg val)
192 this->cpu->setFloatReg(_destRegIdx[idx], val);
193 this->instResult.dbl = val;
196 void setFloatRegBits(const StaticInst *si, int idx,
197 FloatRegBits val, int width)
199 this->cpu->setFloatRegBits(_destRegIdx[idx], val, width);
200 this->instResult.integer = val;
203 void setFloatRegBits(const StaticInst *si, int idx, FloatRegBits val)
205 this->cpu->setFloatRegBits(_destRegIdx[idx], val);
206 this->instResult.integer = val;
209 /** Returns the physical register index of the i'th destination
212 PhysRegIndex renamedDestRegIdx(int idx) const
214 return _destRegIdx[idx];
217 /** Returns the physical register index of the i'th source register. */
218 PhysRegIndex renamedSrcRegIdx(int idx) const
220 return _srcRegIdx[idx];
223 /** Returns the physical register index of the previous physical register
224 * that remapped to the same logical register index.
226 PhysRegIndex prevDestRegIdx(int idx) const
228 return _prevDestRegIdx[idx];
231 /** Renames a destination register to a physical register. Also records
232 * the previous physical register that the logical register mapped to.
234 void renameDestReg(int idx,
235 PhysRegIndex renamed_dest,
236 PhysRegIndex previous_rename)
238 _destRegIdx[idx] = renamed_dest;
239 _prevDestRegIdx[idx] = previous_rename;
242 /** Renames a source logical register to the physical register which
243 * has/will produce that logical register's result.
244 * @todo: add in whether or not the source register is ready.
246 void renameSrcReg(int idx, PhysRegIndex renamed_src)
248 _srcRegIdx[idx] = renamed_src;
254 return this->staticInst->eaCompInst()->execute(this, this->traceData);
259 return this->staticInst->memAccInst()->execute(this, this->traceData);
263 #endif // __CPU_O3_CPU_ALPHA_DYN_INST_HH__