2 * Copyright (c) 2003 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 __ISA_TRAITS_HH__
30 #define __ISA_TRAITS_HH__
41 template <class ISA> class StaticInst;
42 template <class ISA> class StaticInstPtr;
48 typedef uint32_t MachInst;
49 typedef uint64_t Addr;
50 typedef uint8_t RegIndex;
53 MemoryEnd = 0xffffffffffffffffULL,
59 MaxRegsOfAnyType = 32,
60 // Static instruction parameters
64 // semantically meaningful register indices
65 ZeroReg = 31, // architecturally meaningful
66 // the rest of these depend on the ABI
68 GlobalPointerReg = 29,
69 ReturnAddressReg = 26,
78 LogVMPageSize = 13, // 8K bytes
79 VMPageSize = (1 << LogVMPageSize),
81 BranchPredAddrShiftAmt = 2, // instructions are 4-byte aligned
89 // These enumerate all the registers for dependence tracking.
91 // 0..31 are the integer regs 0..31
92 // 32..63 are the FP regs 0..31, i.e. use (reg + FP_Base_DepTag)
94 Ctrl_Base_DepTag = 64,
95 Fpcr_DepTag = 64, // floating point control register
100 typedef uint64_t IntReg;
101 typedef IntReg IntRegFile[NumIntRegs];
103 // floating point register file entry type
110 uint64_t q[NumFloatRegs]; // integer qword view
111 double d[NumFloatRegs]; // double-precision floating point view
114 // control register file contents
115 typedef uint64_t MiscReg;
117 uint64_t fpcr; // floating point condition codes
118 uint64_t uniq; // process-unique register
119 bool lock_flag; // lock flag for LL/SC
120 Addr lock_addr; // lock address for LL/SC
125 typedef uint64_t InternalProcReg;
127 #include "isa_fullsys_traits.hh"
131 NumInternalProcRegs = 0
137 NumIntRegs + NumFloatRegs + NumMiscRegs + NumInternalProcRegs
147 IntRegFile intRegFile; // (signed) integer register file
148 FloatRegFile floatRegFile; // floating point register file
149 MiscRegFile miscRegs; // control register file
150 Addr pc; // program counter
151 Addr npc; // next-cycle program counter
153 IntReg palregs[NumIntRegs]; // PAL shadow registers
154 InternalProcReg ipr[NumInternalProcRegs]; // internal processor regs
155 int intrlock; // interrupt register lock flag
156 int intrflag; // interrupt flag
157 bool pal_shadow; // using pal_shadow registers
158 #endif // FULL_SYSTEM
159 // Are these architectural, or just for convenience?
160 uint8_t opcode, ra; // current instruction details (for intr's)
163 static StaticInstPtr<AlphaISA> decodeInst(MachInst);
167 // An impossible number for instruction annotations
168 ITOUCH_ANNOTE = 0xffffffff,
173 extractInstructionPrefetchTarget(const MachInst &IR, Addr PC) {
178 static inline bool isCallerSaveIntegerRegister(unsigned int reg) {
179 panic("register classification not implemented");
180 return (reg >= 1 && reg <= 8 || reg >= 22 && reg <= 25 || reg == 27);
183 static inline bool isCalleeSaveIntegerRegister(unsigned int reg) {
184 panic("register classification not implemented");
185 return (reg >= 9 && reg <= 15);
188 static inline bool isCallerSaveFloatRegister(unsigned int reg) {
189 panic("register classification not implemented");
193 static inline bool isCalleeSaveFloatRegister(unsigned int reg) {
194 panic("register classification not implemented");
198 static inline Addr alignAddress(const Addr &addr,
199 unsigned int nbytes) {
200 return (addr & ~(nbytes - 1));
203 // Instruction address compression hooks
204 static inline Addr realPCToFetchPC(const Addr &addr) {
208 static inline Addr fetchPCToRealPC(const Addr &addr) {
212 // the size of "fetched" instructions (not necessarily the size
213 // of real instructions for PISA)
214 static inline size_t fetchInstSize() {
215 return sizeof(MachInst);
218 static inline MachInst makeRegisterCopy(int dest, int src) {
219 panic("makeRegisterCopy not implemented");
223 // Machine operations
225 static void saveMachineReg(AnyReg &savereg, const RegFile ®_file,
228 static void restoreMachineReg(RegFile ®s, const AnyReg ®,
232 static void serializeSpecialRegs(const Serializeable::Proxy &proxy,
233 const RegFile ®s);
235 static void unserializeSpecialRegs(IniFile &db,
236 const std::string &category,
243 typedef AlphaISA TheISA;
245 typedef TheISA::MachInst MachInst;
246 typedef TheISA::Addr Addr;
247 typedef TheISA::RegIndex RegIndex;
248 typedef TheISA::IntReg IntReg;
249 typedef TheISA::IntRegFile IntRegFile;
250 typedef TheISA::FloatReg FloatReg;
251 typedef TheISA::FloatRegFile FloatRegFile;
252 typedef TheISA::MiscReg MiscReg;
253 typedef TheISA::MiscRegFile MiscRegFile;
254 typedef TheISA::AnyReg AnyReg;
255 typedef TheISA::RegFile RegFile;
257 const int NumIntRegs = TheISA::NumIntRegs;
258 const int NumFloatRegs = TheISA::NumFloatRegs;
259 const int NumMiscRegs = TheISA::NumMiscRegs;
260 const int TotalNumRegs = TheISA::TotalNumRegs;
261 const int VMPageSize = TheISA::VMPageSize;
262 const int LogVMPageSize = TheISA::LogVMPageSize;
263 const int ZeroReg = TheISA::ZeroReg;
264 const int StackPointerReg = TheISA::StackPointerReg;
265 const int GlobalPointerReg = TheISA::GlobalPointerReg;
266 const int ReturnAddressReg = TheISA::ReturnAddressReg;
267 const int ReturnValueReg = TheISA::ReturnValueReg;
268 const int ArgumentReg0 = TheISA::ArgumentReg0;
269 const int ArgumentReg1 = TheISA::ArgumentReg1;
270 const int BranchPredAddrShiftAmt = TheISA::BranchPredAddrShiftAmt;
273 typedef TheISA::InternalProcReg InternalProcReg;
274 const int NumInternalProcRegs = TheISA::NumInternalProcRegs;
275 const int NumInterruptLevels = TheISA::NumInterruptLevels;
277 // more stuff that should be imported here, but I'm too tired to do it
282 #endif // __ALPHA_ISA_H__