1 /* Id: macdefs.h,v 1.21 2015/11/24 17:35:11 ragge Exp */ 2 /* $NetBSD: macdefs.h,v 1.1.1.6 2016/02/09 20:28:15 plunky Exp $ */ 3 4 /* 5 * Copyright (c) 2007 Michael Shalayeff 6 * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se). 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. The name of the author may not be used to endorse or promote products 18 * derived from this software without specific prior written permission 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 /* 33 * Convert (multi-)character constant to integer. 34 */ 35 #define makecc(val,i) (lastcon = (lastcon<<8)|((val<<24)>>24)) 36 37 #define ARGINIT (32*8) /* bits below fp where args start */ 38 #define AUTOINIT (4*8) /* bits above fp where locals start */ 39 40 /* 41 * storage sizes 42 */ 43 #define SZCHAR 8 44 #define SZBOOL 8 45 #define SZINT 32 46 #define SZFLOAT 32 47 #define SZDOUBLE 64 48 #define SZLDOUBLE 64 /* or later 128 */ 49 #define SZLONG 32 50 #define SZSHORT 16 51 #define SZLONGLONG 64 52 #define SZPOINT(t) 32 53 54 /* 55 * alignment requirements 56 */ 57 #define ALCHAR 8 58 #define ALBOOL 8 59 #define ALINT 32 60 #define ALFLOAT 32 61 #define ALDOUBLE 64 62 #define ALLDOUBLE 64 /* 128 later */ 63 #define ALLONG 32 64 #define ALLONGLONG 32 65 #define ALSHORT 16 66 #define ALPOINT 32 67 #define ALSTRUCT 32 68 #define ALSTACK 64 69 70 /* 71 * type value limits 72 */ 73 #define MIN_CHAR -128 74 #define MAX_CHAR 127 75 #define MAX_UCHAR 255 76 #define MIN_SHORT -32768 77 #define MAX_SHORT 32767 78 #define MAX_USHORT 65535 79 #define MIN_INT (-0x7fffffff-1) 80 #define MAX_INT 0x7fffffff 81 #define MAX_UNSIGNED 0xffffffff 82 #define MIN_LONG MIN_INT 83 #define MAX_LONG MAX_INT 84 #define MAX_ULONG MAX_UNSIGNED 85 #define MIN_LONGLONG (-0x7fffffffffffffffLL-1) 86 #define MAX_LONGLONG 0x7fffffffffffffffLL 87 #define MAX_ULONGLONG 0xffffffffffffffffULL 88 89 #undef CHAR_UNSIGNED 90 #define BOOL_TYPE CHAR 91 92 typedef long long CONSZ; 93 typedef unsigned long long U_CONSZ; 94 typedef long long OFFSZ; 95 96 #define CONFMT "%lld" /* format for printing constants */ 97 #define LABFMT ".L%d" /* format for printing labels */ 98 #define STABLBL ".LL%d" /* format for stab (debugging) labels */ 99 100 #undef BACKAUTO /* stack grows upwards */ 101 #undef BACKTEMP /* stack grows upwards */ 102 103 #define FIELDOPS /* have bit field ops */ 104 #define TARGET_ENDIAN TARGET_BE 105 #define TARGET_FLT_EVAL_METHOD 0 /* all as their type */ 106 107 #define BYTEOFF(x) ((x)&03) 108 #define wdal(k) (BYTEOFF(k)==0) 109 110 #define STOARG(p) 111 #define STOFARG(p) 112 #define STOSTARG(p) 113 114 #define szty(t) (((t) == DOUBLE || (t) == LONGLONG || (t) == ULONGLONG) ? 2 : \ 115 (t) == LDOUBLE ? 2 : 1) 116 117 #define R0 0 118 #define R1 1 119 #define RP 2 120 #define FP 3 121 #define R4 4 122 #define R5 5 123 #define R6 6 124 #define R7 7 125 #define R8 8 126 #define R9 9 127 #define R10 10 128 #define R11 11 129 #define R12 12 130 #define R13 13 131 #define R14 14 132 #define R15 15 133 #define R16 16 134 #define R17 17 135 #define R18 18 136 #define T4 19 137 #define T3 20 138 #define T2 21 139 #define T1 22 140 #define ARG3 23 141 #define ARG2 24 142 #define ARG1 25 143 #define ARG0 26 144 #define DP 27 145 #define RET0 28 146 #define RET1 29 147 #define SP 30 148 #define R31 31 149 150 /* double regs overlay */ 151 #define RD0 32 /* r0:r0 */ 152 #define RD1 33 /* r1:r31 */ 153 #define RD2 34 /* r1:t4 */ 154 #define RD3 35 /* r1:t3 */ 155 #define RD4 36 /* r1:t2 */ 156 #define RD5 37 /* r1:t1 */ 157 #define RD6 38 /* r31:t4 */ 158 #define RD7 39 /* r31:t3 */ 159 #define RD8 40 /* r31:t2 */ 160 #define RD9 41 /* r31:t1 */ 161 #define RD10 42 /* r4:r18 */ 162 #define RD11 43 /* r5:r4 */ 163 #define RD12 44 /* r6:r5 */ 164 #define RD13 45 /* r7:r6 */ 165 #define RD14 46 /* r8:r7 */ 166 #define RD15 47 /* r9:r8 */ 167 #define RD16 48 /* r10:r9 */ 168 #define RD17 49 /* r11:r10 */ 169 #define RD18 50 /* r12:r11 */ 170 #define RD19 51 /* r13:r12 */ 171 #define RD20 52 /* r14:r13 */ 172 #define RD21 53 /* r15:r14 */ 173 #define RD22 54 /* r16:r15 */ 174 #define RD23 55 /* r17:r16 */ 175 #define RD24 56 /* r18:r17 */ 176 #define TD4 57 /* t1:t4 */ 177 #define TD3 58 /* t4:t3 */ 178 #define TD2 59 /* t3:t2 */ 179 #define TD1 60 /* t2:t1 */ 180 #define AD2 61 /* arg3:arg2 */ 181 #define AD1 62 /* arg1:arg0 */ 182 #define RETD0 63 /* ret1:ret0 */ 183 184 /* FPU regs */ 185 #define FR0 64 186 #define FR4 65 187 #define FR5 66 188 #define FR6 67 189 #define FR7 68 190 #define FR8 69 191 #define FR9 70 192 #define FR10 71 193 #define FR11 72 194 #define FR12 73 195 #define FR13 74 196 #define FR14 75 197 #define FR15 76 198 #define FR16 77 199 #define FR17 78 200 #define FR18 79 201 #define FR19 80 202 #define FR20 81 203 #define FR21 82 204 #define FR22 83 205 #define FR23 84 206 #define FR24 85 207 #define FR25 86 208 #define FR26 87 209 #define FR27 88 210 #define FR28 89 211 #define FR29 90 212 #define FR30 91 213 #define FR31 92 214 215 #define FR0L 93 216 #define FR0R 94 217 #define FR4L 95 218 #define FR4R 96 219 #define FR5L 97 220 #define FR5R 98 221 #define FR6L 99 222 #define FR6R 100 223 #define FR7L 101 224 #define FR7R 102 225 #define FR8L 103 226 #define FR8R 104 227 #define FR9L 105 228 #define FR9R 106 229 #define FR10L 107 230 #define FR10R 108 231 #define FR11L 109 232 #define FR11R 110 233 #define FR12L 111 234 #define FR12R 112 235 #define FR13L 113 236 #define FR13R 114 237 #define FR14L 115 238 #define FR14R 116 239 #define FR15L 117 240 #define FR15R 118 241 #define FR16L 119 242 #define FR16R 120 243 #define FR17L 121 244 #define FR17R 122 245 #define FR18L 123 246 #define FR18R 124 247 #ifdef __hppa64__ 248 #define FR19L 125 249 #define FR19R 126 250 #define FR20L 127 251 #define FR20R 128 252 #define FR21L 129 253 #define FR21R 130 254 #define FR22L 131 255 #define FR22R 132 256 #define FR23L 133 257 #define FR23R 134 258 #define FR24L 135 259 #define FR24R 136 260 #define FR25L 137 261 #define FR25R 138 262 #define FR26L 139 263 #define FR26R 140 264 #define FR27L 141 265 #define FR27R 142 266 #define FR28L 143 267 #define FR28R 144 268 #define FR29L 145 269 #define FR29R 146 270 #define FR30L 147 271 #define FR30R 148 272 #define FR31L 149 273 #define FR31R 150 274 275 #define MAXREGS 151 276 #else 277 #define MAXREGS 125 278 #endif 279 280 #define RSTATUS \ 281 0, SAREG|TEMPREG, 0, 0, SAREG|PERMREG, SAREG|PERMREG, \ 282 SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, \ 283 SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, \ 284 SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, \ 285 SAREG|PERMREG, \ 286 SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \ 287 SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \ 288 0, SAREG|TEMPREG, SAREG|TEMPREG, 0, SAREG|TEMPREG, \ 289 /* double overlays */ \ 290 0, \ 291 SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, \ 292 SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, \ 293 SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, \ 294 SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, \ 295 /* double-precision floats */ \ 296 0, \ 297 SDREG|TEMPREG, SDREG|TEMPREG, SDREG|TEMPREG, SDREG|TEMPREG, \ 298 SDREG|TEMPREG, SDREG|TEMPREG, SDREG|TEMPREG, SDREG|TEMPREG, \ 299 SDREG|PERMREG, SDREG|PERMREG, SDREG|PERMREG, SDREG|PERMREG, \ 300 SDREG|PERMREG, SDREG|PERMREG, SDREG|PERMREG, SDREG|PERMREG, \ 301 SDREG|PERMREG, SDREG|PERMREG, \ 302 SDREG|TEMPREG, SDREG|TEMPREG, SDREG|TEMPREG, SDREG|TEMPREG, \ 303 SDREG|TEMPREG, SDREG|TEMPREG, SDREG|TEMPREG, SDREG|TEMPREG, \ 304 SDREG|TEMPREG, SDREG|TEMPREG, \ 305 /* single-precision floats */ \ 306 0, 0, \ 307 SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, \ 308 SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, \ 309 SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, \ 310 SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, 311 #ifdef __hppa64__ 312 SCREG, SCREG, \ 313 SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, \ 314 SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, \ 315 SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, 316 #endif 317 318 #define ROVERLAP \ 319 { -1 }, \ 320 { RD1, RD2, RD3, RD4, RD5, -1 },\ 321 { -1 }, { -1 }, \ 322 { RD10, RD11, -1 }, \ 323 { RD11, RD12, -1 }, \ 324 { RD12, RD13, -1 }, \ 325 { RD13, RD14, -1 }, \ 326 { RD14, RD15, -1 }, \ 327 { RD15, RD16, -1 }, \ 328 { RD16, RD17, -1 }, \ 329 { RD17, RD18, -1 }, \ 330 { RD18, RD19, -1 }, \ 331 { RD19, RD20, -1 }, \ 332 { RD20, RD21, -1 }, \ 333 { RD21, RD22, -1 }, \ 334 { RD22, RD23, -1 }, \ 335 { RD23, RD24, -1 }, \ 336 { RD24, RD10, -1 }, \ 337 { TD1, TD4, -1 }, \ 338 { TD3, TD2, -1 }, \ 339 { TD1, TD2, -1 }, \ 340 { TD1, TD4, -1 }, \ 341 { AD2, -1 }, { AD2, -1 }, \ 342 { AD1, -1 }, { AD1, -1 }, \ 343 { -1 }, \ 344 { RETD0, -1 }, { RETD0, -1 }, \ 345 { -1 }, \ 346 { RD1, RD5, RD6, RD7, RD8, -1 },\ 347 { -1 }, \ 348 { R1, R31, -1 }, \ 349 { R1, T4, -1 }, \ 350 { R1, T3, -1 }, \ 351 { R1, T2, -1 }, \ 352 { R1, T1, -1 }, \ 353 { R31, T4, -1 }, \ 354 { R31, T3, -1 }, \ 355 { R31, T2, -1 }, \ 356 { R31, T1, -1 }, \ 357 { R4, R18, -1 }, \ 358 { R5, R4, -1 }, \ 359 { R6, R5, -1 }, \ 360 { R7, R6, -1 }, \ 361 { R8, R7, -1 }, \ 362 { R9, R8, -1 }, \ 363 { R10, R9, -1 }, \ 364 { R11, R10, -1 }, \ 365 { R12, R11, -1 }, \ 366 { R13, R12, -1 }, \ 367 { R14, R15, -1 }, \ 368 { R15, R14, -1 }, \ 369 { R16, R15, -1 }, \ 370 { R17, R16, -1 }, \ 371 { R18, R17, -1 }, \ 372 { T1, T4, -1 }, \ 373 { T4, T3, -1 }, \ 374 { T3, T2, -1 }, \ 375 { T2, T1, -1 }, \ 376 { ARG3, ARG2, -1 }, \ 377 { ARG1, ARG0, -1 }, \ 378 { RET1, RET0, -1 }, \ 379 { -1 }, \ 380 { FR4L, FR4R, -1 }, \ 381 { FR5L, FR5R, -1 }, \ 382 { FR6L, FR6R, -1 }, \ 383 { FR7L, FR7R, -1 }, \ 384 { FR8L, FR8R, -1 }, \ 385 { FR9L, FR9R, -1 }, \ 386 { FR10L, FR10R, -1 }, \ 387 { FR11L, FR11R, -1 }, \ 388 { FR12L, FR12R, -1 }, \ 389 { FR13L, FR13R, -1 }, \ 390 { FR14L, FR14R, -1 }, \ 391 { FR15L, FR15R, -1 }, \ 392 { FR16L, FR16R, -1 }, \ 393 { FR17L, FR17R, -1 }, \ 394 { FR18L, FR18R, -1 }, \ 395 { -1 }, \ 396 { -1 }, \ 397 { -1 }, \ 398 { -1 }, \ 399 { -1 }, \ 400 { -1 }, \ 401 { -1 }, \ 402 { -1 }, \ 403 { -1 }, \ 404 { -1 }, \ 405 { -1 }, \ 406 { -1 }, \ 407 { -1 }, \ 408 { -1 }, { -1 }, \ 409 { FR4, -1 }, { FR4, -1 }, \ 410 { FR5, -1 }, { FR5, -1 }, \ 411 { FR6, -1 }, { FR6, -1 }, \ 412 { FR7, -1 }, { FR7, -1 }, \ 413 { FR8, -1 }, { FR8, -1 }, \ 414 { FR9, -1 }, { FR9, -1 }, \ 415 { FR10, -1 }, { FR10, -1 }, \ 416 { FR11, -1 }, { FR11, -1 }, \ 417 { FR12, -1 }, { FR12, -1 }, \ 418 { FR13, -1 }, { FR13, -1 }, \ 419 { FR14, -1 }, { FR14, -1 }, \ 420 { FR15, -1 }, { FR15, -1 }, \ 421 { FR16, -1 }, { FR16, -1 }, \ 422 { FR17, -1 }, { FR17, -1 }, \ 423 { FR18, -1 }, { FR18, -1 }, 424 #ifdef __hppa64__ 425 { FR19, -1 }, { FR19, -1 }, \ 426 { FR20, -1 }, { FR20, -1 }, \ 427 { FR21, -1 }, { FR21, -1 }, \ 428 { FR22, -1 }, { FR22, -1 }, \ 429 { FR23, -1 }, { FR23, -1 }, \ 430 { FR24, -1 }, { FR24, -1 }, \ 431 { FR25, -1 }, { FR25, -1 }, \ 432 { FR26, -1 }, { FR26, -1 }, \ 433 { FR27, -1 }, { FR27, -1 }, \ 434 { FR28, -1 }, { FR28, -1 }, \ 435 { FR29, -1 }, { FR29, -1 }, \ 436 { FR30, -1 }, { FR30, -1 }, \ 437 { FR31, -1 }, { FR31, -1 }, 438 #endif 439 440 #define PCLASS(p) \ 441 (p->n_type == LONGLONG || p->n_type == ULONGLONG ? SBREG : \ 442 (p->n_type == FLOAT ? SCREG : \ 443 (p->n_type == DOUBLE || p->n_type == LDOUBLE ? SDREG : SAREG))) 444 445 #define NUMCLASS 4 /* highest number of reg classes used */ 446 447 int COLORMAP(int c, int *r); 448 #define PERMTYPE(x) ((x) < 32? INT : ((x) < 64? LONGLONG : ((x) < 93? LDOUBLE : FLOAT))) 449 #define GCLASS(x) ((x) < 32? CLASSA : ((x) < 64? CLASSB : ((x) < 93? CLASSD : CLASSC))) 450 #define DECRA(x,y) (((x) >> (y*8)) & 255) /* decode encoded regs */ 451 #define ENCRD(x) (x) /* Encode dest reg in n_reg */ 452 #define ENCRA1(x) ((x) << 8) /* A1 */ 453 #define ENCRA2(x) ((x) << 16) /* A2 */ 454 #define ENCRA(x,y) ((x) << (8+y*8)) /* encode regs in int */ 455 #define RETREG(x) (x == LONGLONG || x == ULONGLONG ? RETD0 : \ 456 x == FLOAT? FR4L : \ 457 x == DOUBLE || x == LDOUBLE ? FR4 : RET0) 458 459 #define FPREG FP /* frame pointer */ 460 #define STKREG SP /* stack pointer */ 461 462 #define MYREADER(p) myreader(p) 463 #define MYCANON(p) mycanon(p) 464 #define MYOPTIM 465 466 #define SFUNCALL (MAXSPECIAL+1) /* struct assign after function call */ 467 #define SPCNHI (MAXSPECIAL+2) /* high 21bits constant */ 468 #define SPCON (MAXSPECIAL+3) /* smaller constant */ 469 #define SPICON (MAXSPECIAL+4) /* even smaller constant */ 470 #define SPCNHW (MAXSPECIAL+5) /* LL const w/ 0 in low word */ 471 #define SPCNLW (MAXSPECIAL+6) /* LL const w/ 0 in high word */ 472 #define SPIMM (MAXSPECIAL+7) /* immidiate const for depi/comib */ 473 #define SPNAME (MAXSPECIAL+8) /* ext symbol reference load/store */ 474 #define NATIVE_FLOATING_POINT 475