isa_traits.hh revision 5228
17087Snate@binkert.org/*
27087Snate@binkert.org * Copyright (c) 2003-2005 The Regents of The University of Michigan
37087Snate@binkert.org * All rights reserved.
47087Snate@binkert.org *
57087Snate@binkert.org * Redistribution and use in source and binary forms, with or without
67087Snate@binkert.org * modification, are permitted provided that the following conditions are
77087Snate@binkert.org * met: redistributions of source code must retain the above copyright
87087Snate@binkert.org * notice, this list of conditions and the following disclaimer;
97087Snate@binkert.org * redistributions in binary form must reproduce the above copyright
107087Snate@binkert.org * notice, this list of conditions and the following disclaimer in the
117087Snate@binkert.org * documentation and/or other materials provided with the distribution;
127087Snate@binkert.org * neither the name of the copyright holders nor the names of its
134158Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
144158Sgblack@eecs.umich.edu * this software without specific prior written permission.
154158Sgblack@eecs.umich.edu *
164158Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
174158Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
184158Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
194158Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
204158Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
214158Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
224158Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
234158Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
244158Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
254158Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
264158Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
274158Sgblack@eecs.umich.edu *
284158Sgblack@eecs.umich.edu * Authors: Gabe Black
294158Sgblack@eecs.umich.edu *          Korey Sewell
304158Sgblack@eecs.umich.edu */
314158Sgblack@eecs.umich.edu
324158Sgblack@eecs.umich.edu#ifndef __ARCH_MIPS_ISA_TRAITS_HH__
334158Sgblack@eecs.umich.edu#define __ARCH_MIPS_ISA_TRAITS_HH__
344158Sgblack@eecs.umich.edu
354158Sgblack@eecs.umich.edu#include "arch/mips/max_inst_regs.hh"
364158Sgblack@eecs.umich.edu#include "arch/mips/types.hh"
374158Sgblack@eecs.umich.edu#include "sim/host.hh"
384158Sgblack@eecs.umich.edu
394158Sgblack@eecs.umich.edunamespace LittleEndianGuest {};
404158Sgblack@eecs.umich.edu
414158Sgblack@eecs.umich.edu#define TARGET_MIPS
424158Sgblack@eecs.umich.edu
434323Sgblack@eecs.umich.educlass StaticInstPtr;
444323Sgblack@eecs.umich.edu
454158Sgblack@eecs.umich.edunamespace MipsISA
464158Sgblack@eecs.umich.edu{
474323Sgblack@eecs.umich.edu    using namespace LittleEndianGuest;
484323Sgblack@eecs.umich.edu    using MipsISAInst::MaxInstSrcRegs;
494323Sgblack@eecs.umich.edu    using MipsISAInst::MaxInstDestRegs;
504323Sgblack@eecs.umich.edu
514158Sgblack@eecs.umich.edu    StaticInstPtr decodeInst(ExtMachInst);
524158Sgblack@eecs.umich.edu
534158Sgblack@eecs.umich.edu    // MIPS DOES a delay slot
544158Sgblack@eecs.umich.edu    #define ISA_HAS_DELAY_SLOT 1
554158Sgblack@eecs.umich.edu
567965Sgblack@eecs.umich.edu    const Addr PageShift = 13;
574601Sgblack@eecs.umich.edu    const Addr PageBytes = ULL(1) << PageShift;
585786Sgblack@eecs.umich.edu    const Addr PageMask = ~(PageBytes - 1);
595083Sgblack@eecs.umich.edu    const Addr PageOffset = PageBytes - 1;
604679Sgblack@eecs.umich.edu
616516Sgblack@eecs.umich.edu    // return a no-op instruction... used for instruction fetch faults
624679Sgblack@eecs.umich.edu    const ExtMachInst NoopMachInst = 0x00000000;
634679Sgblack@eecs.umich.edu
644158Sgblack@eecs.umich.edu    // Constants Related to the number of registers
656329Sgblack@eecs.umich.edu    const int NumIntArchRegs = 32;
664528Sgblack@eecs.umich.edu    const int NumIntSpecialRegs = 9;
674158Sgblack@eecs.umich.edu    const int NumFloatArchRegs = 32;
684158Sgblack@eecs.umich.edu    const int NumFloatSpecialRegs = 5;
694158Sgblack@eecs.umich.edu
704616Sgblack@eecs.umich.edu    // semantically meaningful register indices
716345Sgblack@eecs.umich.edu    const int ZeroReg = 0;
726345Sgblack@eecs.umich.edu    const int AssemblerReg = 1;
734158Sgblack@eecs.umich.edu    const int ReturnValueReg = 2;
744158Sgblack@eecs.umich.edu    const int ReturnValueReg1 = 2;
754158Sgblack@eecs.umich.edu    const int ReturnValueReg2 = 3;
764616Sgblack@eecs.umich.edu
775666Sgblack@eecs.umich.edu    const int ArgumentReg[] = {4, 5, 6, 7};
787629Sgblack@eecs.umich.edu    const int NumArgumentRegs = sizeof(ArgumentReg) / sizeof(const int);
797629Sgblack@eecs.umich.edu
807629Sgblack@eecs.umich.edu    const int KernelReg0 = 26;
815912Sgblack@eecs.umich.edu    const int KernelReg1 = 27;
824158Sgblack@eecs.umich.edu    const int GlobalPointerReg = 28;
834158Sgblack@eecs.umich.edu    const int StackPointerReg = 29;
845425Sgblack@eecs.umich.edu    const int FramePointerReg = 30;
854158Sgblack@eecs.umich.edu    const int ReturnAddressReg = 31;
864158Sgblack@eecs.umich.edu
874158Sgblack@eecs.umich.edu    const int SyscallNumReg = ReturnValueReg1;
884158Sgblack@eecs.umich.edu    const int SyscallPseudoReturnReg = ReturnValueReg2;
894158Sgblack@eecs.umich.edu    const int SyscallSuccessReg = ArgumentReg[3];
904158Sgblack@eecs.umich.edu
914158Sgblack@eecs.umich.edu    const int LogVMPageSize = 13;	// 8K bytes
924158Sgblack@eecs.umich.edu    const int VMPageSize = (1 << LogVMPageSize);
934158Sgblack@eecs.umich.edu
944158Sgblack@eecs.umich.edu    const int BranchPredAddrShiftAmt = 2; // instructions are 4-byte aligned
954158Sgblack@eecs.umich.edu
964158Sgblack@eecs.umich.edu    const int MachineBytes = 4;
974158Sgblack@eecs.umich.edu    const int WordBytes = 4;
984158Sgblack@eecs.umich.edu    const int HalfwordBytes = 2;
994158Sgblack@eecs.umich.edu    const int ByteBytes = 1;
1004158Sgblack@eecs.umich.edu
1014158Sgblack@eecs.umich.edu    const int ANNOTE_NONE = 0;
1024158Sgblack@eecs.umich.edu    const uint32_t ITOUCH_ANNOTE = 0xffffffff;
1034158Sgblack@eecs.umich.edu
1044158Sgblack@eecs.umich.edu    // Enumerate names for 'Control' Registers in the CPU
1054158Sgblack@eecs.umich.edu    // Reference MIPS32 Arch. for Programmers, Vol. III, Ch.8
1064158Sgblack@eecs.umich.edu    // (Register Number-Register Select) Summary of Register
1074158Sgblack@eecs.umich.edu    //------------------------------------------------------
1084158Sgblack@eecs.umich.edu    // The first set of names classify the CP0 names as Register Banks
1094158Sgblack@eecs.umich.edu    // for easy indexing when using the 'RD + SEL' index combination
1104158Sgblack@eecs.umich.edu    // in CP0 instructions.
1114158Sgblack@eecs.umich.edu    enum MiscRegTags {
1125659Sgblack@eecs.umich.edu        Index = 0,       //Bank 0: 0 - 3
1136336Sgblack@eecs.umich.edu        MVPControl,
1147629Sgblack@eecs.umich.edu        MVPConf0,
1155118Sgblack@eecs.umich.edu        MVPConf1,
1164158Sgblack@eecs.umich.edu
1176570Sgblack@eecs.umich.edu        Random = 8,      //Bank 1: 8 - 15
1184158Sgblack@eecs.umich.edu        VPEControl,
1194158Sgblack@eecs.umich.edu        VPEConf0,
1204158Sgblack@eecs.umich.edu        VPEConf1,
1214158Sgblack@eecs.umich.edu        YQMask,
1224158Sgblack@eecs.umich.edu        VPESchedule,
1235920Sgblack@eecs.umich.edu        VPEScheFBack,
1245789Sgblack@eecs.umich.edu        VPEOpt,
1254158Sgblack@eecs.umich.edu
1264158Sgblack@eecs.umich.edu        EntryLo0 = 16,   //Bank 2: 16 - 23
1274158Sgblack@eecs.umich.edu        TCStatus,
1284158Sgblack@eecs.umich.edu        TCBind,
1294158Sgblack@eecs.umich.edu        TCRestart,
130        TCHalt,
131        TCContext,
132        TCSchedule,
133        TCScheFBack,
134
135        EntryLo1 = 24,   // Bank 3: 24
136
137        Context = 32,    // Bank 4: 32 - 33
138        ContextConfig,
139
140        //PageMask = 40, //Bank 5: 40 - 41
141        PageGrain = 41,
142
143        Wired = 48,          //Bank 6:48-55
144        SRSConf0,
145        SRSConf1,
146        SRSConf2,
147        SRSConf3,
148        SRSConf4,
149
150        HWRena = 56,         //Bank 7: 56-63
151
152        BadVAddr = 64,       //Bank 8: 64-71
153
154        Count = 72,          //Bank 9: 72-79
155
156        EntryHi = 80,        //Bank 10: 80-87
157
158        Compare = 88,        //Bank 11: 88-95
159
160        Status = 96,         //Bank 12: 96-103
161        IntCtl,
162        SRSCtl,
163        SRSMap,
164
165        Cause = 104,         //Bank 13: 104-111
166
167        EPC = 112,           //Bank 14: 112-119
168
169        PRId = 120,          //Bank 15: 120-127,
170        EBase,
171
172        Config = 128,        //Bank 16: 128-135
173        Config1,
174        Config2,
175        Config3,
176        Config4,
177        Config5,
178        Config6,
179        Config7,
180
181
182        LLAddr = 136,        //Bank 17: 136-143
183
184        WatchLo0 = 144,      //Bank 18: 144-151
185        WatchLo1,
186        WatchLo2,
187        WatchLo3,
188        WatchLo4,
189        WatchLo5,
190        WatchLo6,
191        WatchLo7,
192
193        WatchHi0 = 152,     //Bank 19: 152-159
194        WatchHi1,
195        WatchHi2,
196        WatchHi3,
197        WatchHi4,
198        WatchHi5,
199        WatchHi6,
200        WatchHi7,
201
202        XCContext64 = 160, //Bank 20: 160-167
203
204                           //Bank 21: 168-175
205
206                           //Bank 22: 176-183
207
208        Debug = 184,       //Bank 23: 184-191
209        TraceControl1,
210        TraceControl2,
211        UserTraceData,
212        TraceBPC,
213
214        DEPC = 192,        //Bank 24: 192-199
215
216        PerfCnt0 = 200,    //Bank 25: 200-207
217        PerfCnt1,
218        PerfCnt2,
219        PerfCnt3,
220        PerfCnt4,
221        PerfCnt5,
222        PerfCnt6,
223        PerfCnt7,
224
225        ErrCtl = 208,      //Bank 26: 208-215
226
227        CacheErr0 = 216,   //Bank 27: 216-223
228        CacheErr1,
229        CacheErr2,
230        CacheErr3,
231
232        TagLo0 = 224,      //Bank 28: 224-231
233        DataLo1,
234        TagLo2,
235        DataLo3,
236        TagLo4,
237        DataLo5,
238        TagLo6,
239        DataLo7,
240
241        TagHi0 = 232,      //Bank 29: 232-239
242        DataHi1,
243        TagHi2,
244        DataHi3,
245        TagHi4,
246        DataHi5,
247        TagHi6,
248        DataHi7,
249
250
251        ErrorEPC = 240,    //Bank 30: 240-247
252
253        DESAVE = 248,       //Bank 31: 248-256
254
255        LLFlag = 257,
256
257        NumControlRegs
258    };
259
260    const int NumIntRegs = NumIntArchRegs + NumIntSpecialRegs;        //HI & LO Regs
261    const int NumFloatRegs = NumFloatArchRegs + NumFloatSpecialRegs;//
262    const int NumMiscRegs = NumControlRegs;
263
264    const int TotalNumRegs = NumIntRegs + NumFloatRegs + NumMiscRegs;
265
266    const int TotalDataRegs = NumIntRegs + NumFloatRegs;
267
268    // These help enumerate all the registers for dependence tracking.
269    const int FP_Base_DepTag = NumIntRegs;
270    const int Ctrl_Base_DepTag = FP_Base_DepTag + NumFloatRegs;
271};
272
273using namespace MipsISA;
274
275#endif // __ARCH_MIPS_ISA_TRAITS_HH__
276