2 * Copyright (c) 2006 The Regents of The University of Michigan
3 * Copyright (c) 2007 MIPS Technologies, Inc.
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.
30 #ifndef __ARCH_MIPS_REGISTERS_HH__
31 #define __ARCH_MIPS_REGISTERS_HH__
33 #include "arch/generic/vec_pred_reg.hh"
34 #include "arch/generic/vec_reg.hh"
35 #include "arch/mips/generated/max_inst_regs.hh"
36 #include "base/logging.hh"
37 #include "base/types.hh"
44 using MipsISAInst::MaxInstSrcRegs;
45 using MipsISAInst::MaxInstDestRegs;
46 using MipsISAInst::MaxMiscDestRegs;
48 // Constants Related to the number of registers
49 const int NumIntArchRegs = 32;
50 const int NumIntSpecialRegs = 9;
51 const int NumFloatArchRegs = 32;
52 const int NumFloatSpecialRegs = 5;
54 const int MaxShadowRegSets = 16; // Maximum number of shadow register sets
55 const int NumIntRegs = NumIntArchRegs + NumIntSpecialRegs; //HI & LO Regs
56 const int NumFloatRegs = NumFloatArchRegs + NumFloatSpecialRegs;//
57 const int NumVecRegs = 1; // Not applicable to MIPS
58 // (1 to prevent warnings)
59 const int NumVecPredRegs = 1; // Not applicable to MIPS
60 // (1 to prevent warnings)
61 const int NumCCRegs = 0;
63 const uint32_t MIPS32_QNAN = 0x7fbfffff;
64 const uint64_t MIPS64_QNAN = ULL(0x7ff7ffffffffffff);
66 enum FPControlRegNums {
67 FLOATREG_FIR = NumFloatArchRegs,
90 INTREG_LO = NumIntArchRegs,
91 INTREG_DSP_LO0 = INTREG_LO,
93 INTREG_DSP_HI0 = INTREG_HI,
107 // semantically meaningful register indices
108 const int ZeroReg = 0;
109 const int SyscallSuccessReg = 7;
110 const int FirstArgumentReg = 4;
111 const int ReturnValueReg = 2;
113 const int StackPointerReg = 29;
115 const int SyscallPseudoReturnReg = 3;
117 // Enumerate names for 'Control' Registers in the CPU
118 // Reference MIPS32 Arch. for Programmers, Vol. III, Ch.8
119 // (Register Number-Register Select) Summary of Register
120 //------------------------------------------------------
121 // The first set of names classify the CP0 names as Register Banks
122 // for easy indexing when using the 'RD + SEL' index combination
123 // in CP0 instructions.
125 MISCREG_INDEX = 0, //Bank 0: 0 - 3
130 MISCREG_CP0_RANDOM = 8, //Bank 1: 8 - 15
135 MISCREG_VPE_SCHEDULE,
136 MISCREG_VPE_SCHEFBACK,
139 MISCREG_ENTRYLO0 = 16, //Bank 2: 16 - 23
146 MISCREG_TC_SCHEFBACK,
148 MISCREG_ENTRYLO1 = 24, // Bank 3: 24
150 MISCREG_CONTEXT = 32, // Bank 4: 32 - 33
151 MISCREG_CONTEXT_CONFIG,
153 MISCREG_PAGEMASK = 40, //Bank 5: 40 - 41
154 MISCREG_PAGEGRAIN = 41,
156 MISCREG_WIRED = 48, //Bank 6:48-55
163 MISCREG_HWRENA = 56, //Bank 7: 56-63
165 MISCREG_BADVADDR = 64, //Bank 8: 64-71
167 MISCREG_COUNT = 72, //Bank 9: 72-79
169 MISCREG_ENTRYHI = 80, //Bank 10: 80-87
171 MISCREG_COMPARE = 88, //Bank 11: 88-95
173 MISCREG_STATUS = 96, //Bank 12: 96-103
178 MISCREG_CAUSE = 104, //Bank 13: 104-111
180 MISCREG_EPC = 112, //Bank 14: 112-119
182 MISCREG_PRID = 120, //Bank 15: 120-127,
185 MISCREG_CONFIG = 128, //Bank 16: 128-135
195 MISCREG_LLADDR = 136, //Bank 17: 136-143
197 MISCREG_WATCHLO0 = 144, //Bank 18: 144-151
206 MISCREG_WATCHHI0 = 152, //Bank 19: 152-159
215 MISCREG_XCCONTEXT64 = 160, //Bank 20: 160-167
221 MISCREG_DEBUG = 184, //Bank 23: 184-191
222 MISCREG_TRACE_CONTROL1,
223 MISCREG_TRACE_CONTROL2,
224 MISCREG_USER_TRACE_DATA,
227 MISCREG_DEPC = 192, //Bank 24: 192-199
229 MISCREG_PERFCNT0 = 200, //Bank 25: 200-207
238 MISCREG_ERRCTL = 208, //Bank 26: 208-215
240 MISCREG_CACHEERR0 = 216, //Bank 27: 216-223
245 MISCREG_TAGLO0 = 224, //Bank 28: 224-231
254 MISCREG_TAGHI0 = 232, //Bank 29: 232-239
264 MISCREG_ERROR_EPC = 240, //Bank 30: 240-247
266 MISCREG_DESAVE = 248, //Bank 31: 248-256
268 MISCREG_LLFLAG = 257,
274 const int NumMiscRegs = MISCREG_NUMREGS;
276 // Not applicable to MIPS
277 using VecElem = ::DummyVecElem;
278 using VecReg = ::DummyVecReg;
279 using ConstVecReg = ::DummyConstVecReg;
280 using VecRegContainer = ::DummyVecRegContainer;
281 constexpr unsigned NumVecElemPerVecReg = ::DummyNumVecElemPerVecReg;
282 constexpr size_t VecRegSizeBytes = ::DummyVecRegSizeBytes;
284 // Not applicable to MIPS
285 using VecPredReg = ::DummyVecPredReg;
286 using ConstVecPredReg = ::DummyConstVecPredReg;
287 using VecPredRegContainer = ::DummyVecPredRegContainer;
288 constexpr size_t VecPredRegSizeBits = ::DummyVecPredRegSizeBits;
289 constexpr bool VecPredRegHasPackedRepr = ::DummyVecPredRegHasPackedRepr;
291 } // namespace MipsISA