registers.hh revision 12104:edd63f9c6184
11689SN/A/* 21689SN/A * Copyright (c) 2013 ARM Limited 31689SN/A * Copyright (c) 2014-2015 Sven Karlsson 41689SN/A * All rights reserved 51689SN/A * 61689SN/A * The license below extends only to copyright in the software and shall 71689SN/A * not be construed as granting a license to any other intellectual 81689SN/A * property including but not limited to intellectual property relating 91689SN/A * to a hardware implementation of the functionality of the software 101689SN/A * licensed hereunder. You may use the software subject to the license 111689SN/A * terms below provided that you ensure that this notice is replicated 121689SN/A * unmodified and in its entirety in all distributions of the software, 131689SN/A * modified or unmodified, in source code or in binary form. 141689SN/A * 151689SN/A * Copyright (c) 2016 RISC-V Foundation 161689SN/A * Copyright (c) 2016 The University of Virginia 171689SN/A * All rights reserved. 181689SN/A * 191689SN/A * Redistribution and use in source and binary forms, with or without 201689SN/A * modification, are permitted provided that the following conditions are 211689SN/A * met: redistributions of source code must retain the above copyright 221689SN/A * notice, this list of conditions and the following disclaimer; 231689SN/A * redistributions in binary form must reproduce the above copyright 241689SN/A * notice, this list of conditions and the following disclaimer in the 251689SN/A * documentation and/or other materials provided with the distribution; 261689SN/A * neither the name of the copyright holders nor the names of its 272665Ssaidi@eecs.umich.edu * contributors may be used to endorse or promote products derived from 282665Ssaidi@eecs.umich.edu * this software without specific prior written permission. 292665Ssaidi@eecs.umich.edu * 301689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 311689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 321755SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 331755SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 341060SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 351060SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 361060SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 372165SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 382170SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 391681SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 401858SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 411717SN/A * 421060SN/A * Authors: Andreas Hansson 431858SN/A * Sven Karlsson 441681SN/A * Alec Roelke 451681SN/A */ 461681SN/A 471063SN/A#ifndef __ARCH_RISCV_REGISTERS_HH__ 481060SN/A#define __ARCH_RISCV_REGISTERS_HH__ 491060SN/A 501060SN/A#include <map> 511060SN/A#include <string> 521060SN/A 531061SN/A#include "arch/generic/types.hh" 541060SN/A#include "arch/isa_traits.hh" 551060SN/A#include "arch/riscv/generated/max_inst_regs.hh" 562107SN/A#include "base/types.hh" 572107SN/A 582107SN/Anamespace RiscvISA { 592107SN/A 602159SN/Ausing RiscvISAInst::MaxInstSrcRegs; 612159SN/Ausing RiscvISAInst::MaxInstDestRegs; 621060SN/Aconst int MaxMiscDestRegs = 1; 631061SN/A 641060SN/Atypedef uint64_t IntReg; 651060SN/Atypedef uint64_t FloatRegBits; 661060SN/Atypedef double FloatReg; 671060SN/Atypedef uint8_t CCReg; // Not applicable to Riscv 681060SN/Atypedef uint64_t MiscReg; 691060SN/A 701060SN/Aconst int NumIntArchRegs = 32; 711060SN/Aconst int NumMicroIntRegs = 1; 721681SN/Aconst int NumIntRegs = NumIntArchRegs + NumMicroIntRegs; 731060SN/Aconst int NumFloatRegs = 32; 741060SN/Aconst int NumCCRegs = 0; 751060SN/Aconst int NumMiscRegs = 4096; 761060SN/A 771060SN/A// Semantically meaningful register indices 781060SN/Aconst int ZeroReg = 0; 791060SN/Aconst int ReturnAddrReg = 1; 801060SN/Aconst int StackPointerReg = 2; 811060SN/Aconst int GlobalPointerReg = 3; 821060SN/Aconst int ThreadPointerReg = 4; 831060SN/Aconst int FramePointerReg = 8; 841060SN/Aconst int ReturnValueRegs[] = {10, 11}; 851060SN/Aconst int ReturnValueReg = ReturnValueRegs[0]; 861060SN/Aconst int ArgumentRegs[] = {10, 11, 12, 13, 14, 15, 16, 17}; 871060SN/Aconst int AMOTempReg = 32; 881061SN/A 891061SN/Aconst char* const RegisterNames[] = {"zero", "ra", "sp", "gp", 901060SN/A "tp", "t0", "t1", "t2", 911060SN/A "s0", "s1", "a0", "a1", 921060SN/A "a2", "a3", "a4", "a5", 931060SN/A "a6", "a7", "s2", "s3", 941060SN/A "s4", "s5", "s6", "s7", 952455SN/A "s8", "s9", "s10", "s11", 961060SN/A "t3", "t4", "t5", "t6"}; 971060SN/A 981060SN/Aconst int SyscallNumReg = ArgumentRegs[7]; 991060SN/Aconst int SyscallArgumentRegs[] = {ArgumentRegs[0], ArgumentRegs[1], 1001062SN/A ArgumentRegs[2], ArgumentRegs[3]}; 1011061SN/Aconst int SyscallPseudoReturnReg = ReturnValueRegs[0]; 1022455SN/A 1031060SN/Aconst int NumHpmcounter = 29; 1042455SN/Aconst int NumHpmcounterh = 29; 1052455SN/Aconst int NumMhpmcounter = 29; 1062455SN/Aconst int NumMhpmevent = 29; 1072455SN/Aenum MiscRegIndex { 1081060SN/A MISCREG_USTATUS = 0x000, 1091060SN/A MISCREG_UIE = 0x004, 1102455SN/A MISCREG_UTVEC = 0x005, 1111060SN/A MISCREG_USCRATCH = 0x040, 1121060SN/A MISCREG_UEPC = 0x041, 1131060SN/A MISCREG_UCAUSE = 0x042, 1141060SN/A MISCREG_UBADADDR = 0x043, 1151062SN/A MISCREG_UIP = 0x044, 1161061SN/A MISCREG_FFLAGS = 0x001, 1172455SN/A MISCREG_FRM = 0x002, 1181060SN/A MISCREG_FCSR = 0x003, 1192455SN/A MISCREG_CYCLE = 0xC00, 1202455SN/A MISCREG_TIME = 0xC01, 1212455SN/A MISCREG_INSTRET = 0xC02, 1222455SN/A MISCREG_HPMCOUNTER_BASE = 0xC03, 1231060SN/A MISCREG_CYCLEH = 0xC80, 1241060SN/A MISCREG_TIMEH = 0xC81, 1252455SN/A MISCREG_INSTRETH = 0xC82, 1261060SN/A MISCREG_HPMCOUNTERH_BASE = 0xC83, 1271060SN/A 1281060SN/A MISCREG_SSTATUS = 0x100, 1291060SN/A MISCREG_SEDELEG = 0x102, 1301062SN/A MISCREG_SIDELEG = 0x103, 1311061SN/A MISCREG_SIE = 0x104, 1322455SN/A MISCREG_STVEC = 0x105, 1331060SN/A MISCREG_SSCRATCH = 0x140, 1342455SN/A MISCREG_SEPC = 0x141, 1352455SN/A MISCREG_SCAUSE = 0x142, 1362455SN/A MISCREG_SBADADDR = 0x143, 1372455SN/A MISCREG_SIP = 0x144, 1382455SN/A MISCREG_SPTBR = 0x180, 1392455SN/A 1402455SN/A MISCREG_HSTATUS = 0x200, 1412455SN/A MISCREG_HEDELEG = 0x202, 1422455SN/A MISCREG_HIDELEG = 0x203, 1432455SN/A MISCREG_HIE = 0x204, 1442455SN/A MISCREG_HTVEC = 0x205, 1452455SN/A MISCREG_HSCRATCH = 0x240, 1462455SN/A MISCREG_HEPC = 0x241, 1472455SN/A MISCREG_HCAUSE = 0x242, 1482455SN/A MISCREG_HBADADDR = 0x243, 1492455SN/A MISCREG_HIP = 0x244, 1502455SN/A 1512455SN/A MISCREG_MVENDORID = 0xF11, 1522455SN/A MISCREG_MARCHID = 0xF12, 1531060SN/A MISCREG_MIMPID = 0xF13, 1541060SN/A MISCREG_MHARTID = 0xF14, 1551060SN/A MISCREG_MSTATUS = 0x300, 1561060SN/A MISCREG_MISA = 0x301, 1571061SN/A MISCREG_MEDELEG = 0x302, 1581061SN/A MISCREG_MIDELEG = 0x303, 1591060SN/A MISCREG_MIE = 0x304, 1601060SN/A MISCREG_MTVEC = 0x305, 1611060SN/A MISCREG_MSCRATCH = 0x340, 1621060SN/A MISCREG_MEPC = 0x341, 1631060SN/A MISCREG_MCAUSE = 0x342, 1641060SN/A MISCREG_MBADADDR = 0x343, 1652455SN/A MISCREG_MIP = 0x344, 1661060SN/A MISCREG_MBASE = 0x380, 1671060SN/A MISCREG_MBOUND = 0x381, 1681060SN/A MISCREG_MIBASE = 0x382, 1691060SN/A MISCREG_MIBOUND = 0x383, 1701062SN/A MISCREG_MDBASE = 0x384, 1711061SN/A MISCREG_MDBOUND = 0x385, 1722455SN/A MISCREG_MCYCLE = 0xB00, 1732455SN/A MISCREG_MINSTRET = 0xB02, 1741060SN/A MISCREG_MHPMCOUNTER_BASE = 0xB03, 1752455SN/A MISCREG_MUCOUNTEREN = 0x320, 1761060SN/A MISCREG_MSCOUNTEREN = 0x321, 1771060SN/A MISCREG_MHCOUNTEREN = 0x322, 1782455SN/A MISCREG_MHPMEVENT_BASE = 0x323, 1791060SN/A 1801060SN/A MISCREG_TSELECT = 0x7A0, 1811060SN/A MISCREG_TDATA1 = 0x7A1, 1821060SN/A MISCREG_TDATA2 = 0x7A2, 1831062SN/A MISCREG_TDATA3 = 0x7A3, 1841061SN/A MISCREG_DCSR = 0x7B0, 1852455SN/A MISCREG_DPC = 0x7B1, 1862455SN/A MISCREG_DSCRATCH = 0x7B2 1871060SN/A}; 1882455SN/A 1891060SN/A} 1901060SN/A 1912455SN/A#endif // __ARCH_RISCV_REGISTERS_HH__ 1921060SN/A