2 * Copyright (c) 2003-2004 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 __ARCH_ALPHA_ISA_TRAITS_HH__
30 #define __ARCH_ALPHA_ISA_TRAITS_HH__
32 #include "arch/alpha/faults.hh"
33 #include "base/misc.hh"
34 #include "sim/host.hh"
42 template <class ISA> class StaticInst;
43 template <class ISA> class StaticInstPtr;
46 int DTB_ASN_ASN(uint64_t reg);
47 int ITB_ASN_ASN(uint64_t reg);
54 typedef uint32_t MachInst;
55 typedef uint64_t Addr;
56 typedef uint8_t RegIndex;
59 MemoryEnd = 0xffffffffffffffffULL,
65 MaxRegsOfAnyType = 32,
66 // Static instruction parameters
70 // semantically meaningful register indices
71 ZeroReg = 31, // architecturally meaningful
72 // the rest of these depend on the ABI
74 GlobalPointerReg = 29,
75 ReturnAddressReg = 26,
84 LogVMPageSize = 13, // 8K bytes
85 VMPageSize = (1 << LogVMPageSize),
87 BranchPredAddrShiftAmt = 2, // instructions are 4-byte aligned
95 // These enumerate all the registers for dependence tracking.
97 // 0..31 are the integer regs 0..31
98 // 32..63 are the FP regs 0..31, i.e. use (reg + FP_Base_DepTag)
100 Ctrl_Base_DepTag = 64,
101 Fpcr_DepTag = 64, // floating point control register
106 typedef uint64_t IntReg;
107 typedef IntReg IntRegFile[NumIntRegs];
109 // floating point register file entry type
116 uint64_t q[NumFloatRegs]; // integer qword view
117 double d[NumFloatRegs]; // double-precision floating point view
120 // control register file contents
121 typedef uint64_t MiscReg;
123 uint64_t fpcr; // floating point condition codes
124 uint64_t uniq; // process-unique register
125 bool lock_flag; // lock flag for LL/SC
126 Addr lock_addr; // lock address for LL/SC
129 static const Addr PageShift = 13;
130 static const Addr PageBytes = ULL(1) << PageShift;
131 static const Addr PageMask = ~(PageBytes - 1);
132 static const Addr PageOffset = PageBytes - 1;
136 typedef uint64_t InternalProcReg;
138 #include "arch/alpha/isa_fullsys_traits.hh"
142 NumInternalProcRegs = 0
148 NumIntRegs + NumFloatRegs + NumMiscRegs + NumInternalProcRegs
158 IntRegFile intRegFile; // (signed) integer register file
159 FloatRegFile floatRegFile; // floating point register file
160 MiscRegFile miscRegs; // control register file
161 Addr pc; // program counter
162 Addr npc; // next-cycle program counter
164 IntReg palregs[NumIntRegs]; // PAL shadow registers
165 InternalProcReg ipr[NumInternalProcRegs]; // internal processor regs
166 int intrflag; // interrupt flag
167 bool pal_shadow; // using pal_shadow registers
168 inline int instAsid() { return EV5::ITB_ASN_ASN(ipr[IPR_ITB_ASN]); }
169 inline int dataAsid() { return EV5::DTB_ASN_ASN(ipr[IPR_DTB_ASN]); }
170 #endif // FULL_SYSTEM
172 void serialize(std::ostream &os);
173 void unserialize(Checkpoint *cp, const std::string §ion);
176 static StaticInstPtr<AlphaISA> decodeInst(MachInst);
178 // return a no-op instruction... used for instruction fetch faults
179 static const MachInst NoopMachInst;
183 // An impossible number for instruction annotations
184 ITOUCH_ANNOTE = 0xffffffff,
187 static inline bool isCallerSaveIntegerRegister(unsigned int reg) {
188 panic("register classification not implemented");
189 return (reg >= 1 && reg <= 8 || reg >= 22 && reg <= 25 || reg == 27);
192 static inline bool isCalleeSaveIntegerRegister(unsigned int reg) {
193 panic("register classification not implemented");
194 return (reg >= 9 && reg <= 15);
197 static inline bool isCallerSaveFloatRegister(unsigned int reg) {
198 panic("register classification not implemented");
202 static inline bool isCalleeSaveFloatRegister(unsigned int reg) {
203 panic("register classification not implemented");
207 static inline Addr alignAddress(const Addr &addr,
208 unsigned int nbytes) {
209 return (addr & ~(nbytes - 1));
212 // Instruction address compression hooks
213 static inline Addr realPCToFetchPC(const Addr &addr) {
217 static inline Addr fetchPCToRealPC(const Addr &addr) {
221 // the size of "fetched" instructions (not necessarily the size
222 // of real instructions for PISA)
223 static inline size_t fetchInstSize() {
224 return sizeof(MachInst);
227 static inline MachInst makeRegisterCopy(int dest, int src) {
228 panic("makeRegisterCopy not implemented");
232 // Machine operations
234 static void saveMachineReg(AnyReg &savereg, const RegFile ®_file,
237 static void restoreMachineReg(RegFile ®s, const AnyReg ®,
241 static void serializeSpecialRegs(const Serializable::Proxy &proxy,
242 const RegFile ®s);
244 static void unserializeSpecialRegs(const IniFile *db,
245 const std::string &category,
251 * Function to insure ISA semantics about 0 registers.
252 * @param xc The execution context.
255 static void zeroRegisters(XC *xc);
259 typedef AlphaISA TheISA;
261 typedef TheISA::MachInst MachInst;
262 typedef TheISA::Addr Addr;
263 typedef TheISA::RegIndex RegIndex;
264 typedef TheISA::IntReg IntReg;
265 typedef TheISA::IntRegFile IntRegFile;
266 typedef TheISA::FloatReg FloatReg;
267 typedef TheISA::FloatRegFile FloatRegFile;
268 typedef TheISA::MiscReg MiscReg;
269 typedef TheISA::MiscRegFile MiscRegFile;
270 typedef TheISA::AnyReg AnyReg;
271 typedef TheISA::RegFile RegFile;
273 const int NumIntRegs = TheISA::NumIntRegs;
274 const int NumFloatRegs = TheISA::NumFloatRegs;
275 const int NumMiscRegs = TheISA::NumMiscRegs;
276 const int TotalNumRegs = TheISA::TotalNumRegs;
277 const int VMPageSize = TheISA::VMPageSize;
278 const int LogVMPageSize = TheISA::LogVMPageSize;
279 const int ZeroReg = TheISA::ZeroReg;
280 const int StackPointerReg = TheISA::StackPointerReg;
281 const int GlobalPointerReg = TheISA::GlobalPointerReg;
282 const int ReturnAddressReg = TheISA::ReturnAddressReg;
283 const int ReturnValueReg = TheISA::ReturnValueReg;
284 const int ArgumentReg0 = TheISA::ArgumentReg0;
285 const int ArgumentReg1 = TheISA::ArgumentReg1;
286 const int BranchPredAddrShiftAmt = TheISA::BranchPredAddrShiftAmt;
287 const int MaxAddr = (Addr)-1;
290 typedef TheISA::InternalProcReg InternalProcReg;
291 const int NumInternalProcRegs = TheISA::NumInternalProcRegs;
292 const int NumInterruptLevels = TheISA::NumInterruptLevels;
294 #include "arch/alpha/ev5.hh"
297 #endif // __ARCH_ALPHA_ISA_TRAITS_HH__