intregs.hh revision 8301
1/* 2 * Copyright (c) 2010 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated 11 * unmodified and in its entirety in all distributions of the software, 12 * modified or unmodified, in source code or in binary form. 13 * 14 * Copyright (c) 2009 The Regents of The University of Michigan 15 * All rights reserved. 16 * 17 * Redistribution and use in source and binary forms, with or without 18 * modification, are permitted provided that the following conditions are 19 * met: redistributions of source code must retain the above copyright 20 * notice, this list of conditions and the following disclaimer; 21 * redistributions in binary form must reproduce the above copyright 22 * notice, this list of conditions and the following disclaimer in the 23 * documentation and/or other materials provided with the distribution; 24 * neither the name of the copyright holders nor the names of its 25 * contributors may be used to endorse or promote products derived from 26 * this software without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 * 40 * Authors: Gabe Black 41 */ 42 43#include <cassert> 44 45#ifndef __ARCH_ARM_INTREGS_HH__ 46#define __ARCH_ARM_INTREGS_HH__ 47 48#include "arch/arm/types.hh" 49 50namespace ArmISA 51{ 52 53enum IntRegIndex 54{ 55 /* All the unique register indices. */ 56 INTREG_R0, 57 INTREG_R1, 58 INTREG_R2, 59 INTREG_R3, 60 INTREG_R4, 61 INTREG_R5, 62 INTREG_R6, 63 INTREG_R7, 64 INTREG_R8, 65 INTREG_R9, 66 INTREG_R10, 67 INTREG_R11, 68 INTREG_R12, 69 INTREG_R13, 70 INTREG_SP = INTREG_R13, 71 INTREG_R14, 72 INTREG_LR = INTREG_R14, 73 INTREG_R15, 74 INTREG_PC = INTREG_R15, 75 76 INTREG_R13_SVC, 77 INTREG_SP_SVC = INTREG_R13_SVC, 78 INTREG_R14_SVC, 79 INTREG_LR_SVC = INTREG_R14_SVC, 80 81 INTREG_R13_MON, 82 INTREG_SP_MON = INTREG_R13_MON, 83 INTREG_R14_MON, 84 INTREG_LR_MON = INTREG_R14_MON, 85 86 INTREG_R13_ABT, 87 INTREG_SP_ABT = INTREG_R13_ABT, 88 INTREG_R14_ABT, 89 INTREG_LR_ABT = INTREG_R14_ABT, 90 91 INTREG_R13_UND, 92 INTREG_SP_UND = INTREG_R13_UND, 93 INTREG_R14_UND, 94 INTREG_LR_UND = INTREG_R14_UND, 95 96 INTREG_R13_IRQ, 97 INTREG_SP_IRQ = INTREG_R13_IRQ, 98 INTREG_R14_IRQ, 99 INTREG_LR_IRQ = INTREG_R14_IRQ, 100 101 INTREG_R8_FIQ, 102 INTREG_R9_FIQ, 103 INTREG_R10_FIQ, 104 INTREG_R11_FIQ, 105 INTREG_R12_FIQ, 106 INTREG_R13_FIQ, 107 INTREG_SP_FIQ = INTREG_R13_FIQ, 108 INTREG_R14_FIQ, 109 INTREG_LR_FIQ = INTREG_R14_FIQ, 110 111 INTREG_ZERO, // Dummy zero reg since there has to be one. 112 INTREG_UREG0, 113 INTREG_UREG1, 114 INTREG_UREG2, 115 INTREG_CONDCODES_F, 116 INTREG_CONDCODES_Q, 117 INTREG_CONDCODES_GE, 118 INTREG_FPCONDCODES, 119 120 NUM_INTREGS, 121 NUM_ARCH_INTREGS = INTREG_PC + 1, 122 123 /* All the aliased indexes. */ 124 125 /* USR mode */ 126 INTREG_R0_USR = INTREG_R0, 127 INTREG_R1_USR = INTREG_R1, 128 INTREG_R2_USR = INTREG_R2, 129 INTREG_R3_USR = INTREG_R3, 130 INTREG_R4_USR = INTREG_R4, 131 INTREG_R5_USR = INTREG_R5, 132 INTREG_R6_USR = INTREG_R6, 133 INTREG_R7_USR = INTREG_R7, 134 INTREG_R8_USR = INTREG_R8, 135 INTREG_R9_USR = INTREG_R9, 136 INTREG_R10_USR = INTREG_R10, 137 INTREG_R11_USR = INTREG_R11, 138 INTREG_R12_USR = INTREG_R12, 139 INTREG_R13_USR = INTREG_R13, 140 INTREG_SP_USR = INTREG_SP, 141 INTREG_R14_USR = INTREG_R14, 142 INTREG_LR_USR = INTREG_LR, 143 INTREG_R15_USR = INTREG_R15, 144 INTREG_PC_USR = INTREG_PC, 145 146 /* SVC mode */ 147 INTREG_R0_SVC = INTREG_R0, 148 INTREG_R1_SVC = INTREG_R1, 149 INTREG_R2_SVC = INTREG_R2, 150 INTREG_R3_SVC = INTREG_R3, 151 INTREG_R4_SVC = INTREG_R4, 152 INTREG_R5_SVC = INTREG_R5, 153 INTREG_R6_SVC = INTREG_R6, 154 INTREG_R7_SVC = INTREG_R7, 155 INTREG_R8_SVC = INTREG_R8, 156 INTREG_R9_SVC = INTREG_R9, 157 INTREG_R10_SVC = INTREG_R10, 158 INTREG_R11_SVC = INTREG_R11, 159 INTREG_R12_SVC = INTREG_R12, 160 INTREG_PC_SVC = INTREG_PC, 161 INTREG_R15_SVC = INTREG_R15, 162 163 /* MON mode */ 164 INTREG_R0_MON = INTREG_R0, 165 INTREG_R1_MON = INTREG_R1, 166 INTREG_R2_MON = INTREG_R2, 167 INTREG_R3_MON = INTREG_R3, 168 INTREG_R4_MON = INTREG_R4, 169 INTREG_R5_MON = INTREG_R5, 170 INTREG_R6_MON = INTREG_R6, 171 INTREG_R7_MON = INTREG_R7, 172 INTREG_R8_MON = INTREG_R8, 173 INTREG_R9_MON = INTREG_R9, 174 INTREG_R10_MON = INTREG_R10, 175 INTREG_R11_MON = INTREG_R11, 176 INTREG_R12_MON = INTREG_R12, 177 INTREG_PC_MON = INTREG_PC, 178 INTREG_R15_MON = INTREG_R15, 179 180 /* ABT mode */ 181 INTREG_R0_ABT = INTREG_R0, 182 INTREG_R1_ABT = INTREG_R1, 183 INTREG_R2_ABT = INTREG_R2, 184 INTREG_R3_ABT = INTREG_R3, 185 INTREG_R4_ABT = INTREG_R4, 186 INTREG_R5_ABT = INTREG_R5, 187 INTREG_R6_ABT = INTREG_R6, 188 INTREG_R7_ABT = INTREG_R7, 189 INTREG_R8_ABT = INTREG_R8, 190 INTREG_R9_ABT = INTREG_R9, 191 INTREG_R10_ABT = INTREG_R10, 192 INTREG_R11_ABT = INTREG_R11, 193 INTREG_R12_ABT = INTREG_R12, 194 INTREG_PC_ABT = INTREG_PC, 195 INTREG_R15_ABT = INTREG_R15, 196 197 /* UND mode */ 198 INTREG_R0_UND = INTREG_R0, 199 INTREG_R1_UND = INTREG_R1, 200 INTREG_R2_UND = INTREG_R2, 201 INTREG_R3_UND = INTREG_R3, 202 INTREG_R4_UND = INTREG_R4, 203 INTREG_R5_UND = INTREG_R5, 204 INTREG_R6_UND = INTREG_R6, 205 INTREG_R7_UND = INTREG_R7, 206 INTREG_R8_UND = INTREG_R8, 207 INTREG_R9_UND = INTREG_R9, 208 INTREG_R10_UND = INTREG_R10, 209 INTREG_R11_UND = INTREG_R11, 210 INTREG_R12_UND = INTREG_R12, 211 INTREG_PC_UND = INTREG_PC, 212 INTREG_R15_UND = INTREG_R15, 213 214 /* IRQ mode */ 215 INTREG_R0_IRQ = INTREG_R0, 216 INTREG_R1_IRQ = INTREG_R1, 217 INTREG_R2_IRQ = INTREG_R2, 218 INTREG_R3_IRQ = INTREG_R3, 219 INTREG_R4_IRQ = INTREG_R4, 220 INTREG_R5_IRQ = INTREG_R5, 221 INTREG_R6_IRQ = INTREG_R6, 222 INTREG_R7_IRQ = INTREG_R7, 223 INTREG_R8_IRQ = INTREG_R8, 224 INTREG_R9_IRQ = INTREG_R9, 225 INTREG_R10_IRQ = INTREG_R10, 226 INTREG_R11_IRQ = INTREG_R11, 227 INTREG_R12_IRQ = INTREG_R12, 228 INTREG_PC_IRQ = INTREG_PC, 229 INTREG_R15_IRQ = INTREG_R15, 230 231 /* FIQ mode */ 232 INTREG_R0_FIQ = INTREG_R0, 233 INTREG_R1_FIQ = INTREG_R1, 234 INTREG_R2_FIQ = INTREG_R2, 235 INTREG_R3_FIQ = INTREG_R3, 236 INTREG_R4_FIQ = INTREG_R4, 237 INTREG_R5_FIQ = INTREG_R5, 238 INTREG_R6_FIQ = INTREG_R6, 239 INTREG_R7_FIQ = INTREG_R7, 240 INTREG_PC_FIQ = INTREG_PC, 241 INTREG_R15_FIQ = INTREG_R15, 242}; 243 244typedef IntRegIndex IntRegMap[NUM_ARCH_INTREGS]; 245 246const IntRegMap IntRegUsrMap = { 247 INTREG_R0_USR, INTREG_R1_USR, INTREG_R2_USR, INTREG_R3_USR, 248 INTREG_R4_USR, INTREG_R5_USR, INTREG_R6_USR, INTREG_R7_USR, 249 INTREG_R8_USR, INTREG_R9_USR, INTREG_R10_USR, INTREG_R11_USR, 250 INTREG_R12_USR, INTREG_R13_USR, INTREG_R14_USR, INTREG_R15_USR 251}; 252 253static inline IntRegIndex 254INTREG_USR(unsigned index) 255{ 256 assert(index < NUM_ARCH_INTREGS); 257 return IntRegUsrMap[index]; 258} 259 260const IntRegMap IntRegSvcMap = { 261 INTREG_R0_SVC, INTREG_R1_SVC, INTREG_R2_SVC, INTREG_R3_SVC, 262 INTREG_R4_SVC, INTREG_R5_SVC, INTREG_R6_SVC, INTREG_R7_SVC, 263 INTREG_R8_SVC, INTREG_R9_SVC, INTREG_R10_SVC, INTREG_R11_SVC, 264 INTREG_R12_SVC, INTREG_R13_SVC, INTREG_R14_SVC, INTREG_R15_SVC 265}; 266 267static inline IntRegIndex 268INTREG_SVC(unsigned index) 269{ 270 assert(index < NUM_ARCH_INTREGS); 271 return IntRegSvcMap[index]; 272} 273 274const IntRegMap IntRegMonMap = { 275 INTREG_R0_MON, INTREG_R1_MON, INTREG_R2_MON, INTREG_R3_MON, 276 INTREG_R4_MON, INTREG_R5_MON, INTREG_R6_MON, INTREG_R7_MON, 277 INTREG_R8_MON, INTREG_R9_MON, INTREG_R10_MON, INTREG_R11_MON, 278 INTREG_R12_MON, INTREG_R13_MON, INTREG_R14_MON, INTREG_R15_MON 279}; 280 281static inline IntRegIndex 282INTREG_MON(unsigned index) 283{ 284 assert(index < NUM_ARCH_INTREGS); 285 return IntRegMonMap[index]; 286} 287 288const IntRegMap IntRegAbtMap = { 289 INTREG_R0_ABT, INTREG_R1_ABT, INTREG_R2_ABT, INTREG_R3_ABT, 290 INTREG_R4_ABT, INTREG_R5_ABT, INTREG_R6_ABT, INTREG_R7_ABT, 291 INTREG_R8_ABT, INTREG_R9_ABT, INTREG_R10_ABT, INTREG_R11_ABT, 292 INTREG_R12_ABT, INTREG_R13_ABT, INTREG_R14_ABT, INTREG_R15_ABT 293}; 294 295static inline IntRegIndex 296INTREG_ABT(unsigned index) 297{ 298 assert(index < NUM_ARCH_INTREGS); 299 return IntRegAbtMap[index]; 300} 301 302const IntRegMap IntRegUndMap = { 303 INTREG_R0_UND, INTREG_R1_UND, INTREG_R2_UND, INTREG_R3_UND, 304 INTREG_R4_UND, INTREG_R5_UND, INTREG_R6_UND, INTREG_R7_UND, 305 INTREG_R8_UND, INTREG_R9_UND, INTREG_R10_UND, INTREG_R11_UND, 306 INTREG_R12_UND, INTREG_R13_UND, INTREG_R14_UND, INTREG_R15_UND 307}; 308 309static inline IntRegIndex 310INTREG_UND(unsigned index) 311{ 312 assert(index < NUM_ARCH_INTREGS); 313 return IntRegUndMap[index]; 314} 315 316const IntRegMap IntRegIrqMap = { 317 INTREG_R0_IRQ, INTREG_R1_IRQ, INTREG_R2_IRQ, INTREG_R3_IRQ, 318 INTREG_R4_IRQ, INTREG_R5_IRQ, INTREG_R6_IRQ, INTREG_R7_IRQ, 319 INTREG_R8_IRQ, INTREG_R9_IRQ, INTREG_R10_IRQ, INTREG_R11_IRQ, 320 INTREG_R12_IRQ, INTREG_R13_IRQ, INTREG_R14_IRQ, INTREG_R15_IRQ 321}; 322 323static inline IntRegIndex 324INTREG_IRQ(unsigned index) 325{ 326 assert(index < NUM_ARCH_INTREGS); 327 return IntRegIrqMap[index]; 328} 329 330const IntRegMap IntRegFiqMap = { 331 INTREG_R0_FIQ, INTREG_R1_FIQ, INTREG_R2_FIQ, INTREG_R3_FIQ, 332 INTREG_R4_FIQ, INTREG_R5_FIQ, INTREG_R6_FIQ, INTREG_R7_FIQ, 333 INTREG_R8_FIQ, INTREG_R9_FIQ, INTREG_R10_FIQ, INTREG_R11_FIQ, 334 INTREG_R12_FIQ, INTREG_R13_FIQ, INTREG_R14_FIQ, INTREG_R15_FIQ 335}; 336 337static inline IntRegIndex 338INTREG_FIQ(unsigned index) 339{ 340 assert(index < NUM_ARCH_INTREGS); 341 return IntRegFiqMap[index]; 342} 343 344static const unsigned intRegsPerMode = NUM_INTREGS; 345 346static inline int 347intRegInMode(OperatingMode mode, int reg) 348{ 349 assert(reg < NUM_ARCH_INTREGS); 350 return mode * intRegsPerMode + reg; 351} 352 353} 354 355#endif 356