| [a7de7182] | 1 | /* $Id: macdefs.h,v 1.23 2007/11/16 22:23:04 gmcgarry Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
|
|---|
| 4 | * All rights reserved.
|
|---|
| 5 | *
|
|---|
| 6 | * Redistribution and use in source and binary forms, with or without
|
|---|
| 7 | * modification, are permitted provided that the following conditions
|
|---|
| 8 | * are met:
|
|---|
| 9 | * 1. Redistributions of source code must retain the above copyright
|
|---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
|---|
| 11 | * 2. Redistributions in binary form must reproduce the above copyright
|
|---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
|---|
| 13 | * documentation and/or other materials provided with the distribution.
|
|---|
| 14 | * 3. The name of the author may not be used to endorse or promote products
|
|---|
| 15 | * derived from this software without specific prior written permission
|
|---|
| 16 | *
|
|---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 27 | */
|
|---|
| 28 |
|
|---|
| 29 | /*
|
|---|
| 30 | * Machine-dependent defines for both passes.
|
|---|
| 31 | */
|
|---|
| 32 | #define makecc(val,i) lastcon = (lastcon<<8)|((val<<8)>>8);
|
|---|
| 33 |
|
|---|
| 34 | #define ARGINIT 40 /* # bits above fp where arguments start */
|
|---|
| 35 | #define AUTOINIT 0 /* # bits below fp where automatics start */
|
|---|
| 36 |
|
|---|
| 37 | /*
|
|---|
| 38 | * Convert (multi-)character constant to integer.
|
|---|
| 39 | * Assume: If only one value; store at left side (char size), otherwise
|
|---|
| 40 | * treat it as an integer.
|
|---|
| 41 | */
|
|---|
| 42 |
|
|---|
| 43 | /*
|
|---|
| 44 | * Storage space requirements
|
|---|
| 45 | */
|
|---|
| 46 | #define SZCHAR 8
|
|---|
| 47 | #define SZINT 16
|
|---|
| 48 | #define SZFLOAT 16
|
|---|
| 49 | #define SZDOUBLE 16
|
|---|
| 50 | #define SZLDOUBLE 16
|
|---|
| 51 | #define SZLONG 32
|
|---|
| 52 | #define SZSHORT 16
|
|---|
| 53 | #define SZLONGLONG 32
|
|---|
| 54 | /* pointers are of different sizes on m16c */
|
|---|
| 55 | #define SZPOINT(t) (ISFTN(DECREF(t)) ? 32 : 16)
|
|---|
| 56 |
|
|---|
| 57 | /*
|
|---|
| 58 | * Alignment constraints
|
|---|
| 59 | */
|
|---|
| 60 | #define ALCHAR 8
|
|---|
| 61 | #define ALINT 16
|
|---|
| 62 | #define ALFLOAT 16
|
|---|
| 63 | #define ALDOUBLE 16
|
|---|
| 64 | #define ALLDOUBLE 16
|
|---|
| 65 | #define ALLONG 16
|
|---|
| 66 | #define ALLONGLONG 16
|
|---|
| 67 | #define ALSHORT 16
|
|---|
| 68 | #define ALPOINT 16
|
|---|
| 69 | #define ALSTRUCT 16
|
|---|
| 70 | #define ALSTACK 16
|
|---|
| 71 |
|
|---|
| 72 | /*
|
|---|
| 73 | * Min/max values.
|
|---|
| 74 | */
|
|---|
| 75 | #define MIN_CHAR -128
|
|---|
| 76 | #define MAX_CHAR 127
|
|---|
| 77 | #define MAX_UCHAR 255
|
|---|
| 78 | #define MIN_SHORT -32768
|
|---|
| 79 | #define MAX_SHORT 32767
|
|---|
| 80 | #define MAX_USHORT 65535
|
|---|
| 81 | #define MIN_INT -32768
|
|---|
| 82 | #define MAX_INT 32767
|
|---|
| 83 | #define MAX_UNSIGNED 65535
|
|---|
| 84 | #define MIN_LONG -2147483648
|
|---|
| 85 | #define MAX_LONG 2147483647
|
|---|
| 86 | #define MAX_ULONG 4294967295UL
|
|---|
| 87 | #define MIN_LONGLONG -2147483648
|
|---|
| 88 | #define MAX_LONGLONG 2147483647
|
|---|
| 89 | #define MAX_ULONGLONG 4294967295UL
|
|---|
| 90 |
|
|---|
| 91 | /* Default char is unsigned */
|
|---|
| 92 | #undef CHAR_UNSIGNED
|
|---|
| 93 |
|
|---|
| 94 | /*
|
|---|
| 95 | * Use large-enough types.
|
|---|
| 96 | */
|
|---|
| 97 | typedef long long CONSZ;
|
|---|
| 98 | typedef unsigned long long U_CONSZ;
|
|---|
| 99 | typedef long long OFFSZ;
|
|---|
| 100 |
|
|---|
| 101 | #define CONFMT "%lld" /* format for printing constants */
|
|---|
| 102 | #define LABFMT "L%d" /* format for printing labels */
|
|---|
| 103 |
|
|---|
| 104 | #define BACKAUTO /* stack grows negatively for automatics */
|
|---|
| 105 | #define BACKTEMP /* stack grows negatively for temporaries */
|
|---|
| 106 |
|
|---|
| 107 | #undef FIELDOPS /* no bit-field instructions */
|
|---|
| 108 | #define RTOLBYTES /* bytes are numbered right to left */
|
|---|
| 109 |
|
|---|
| 110 | /* Definitions mostly used in pass2 */
|
|---|
| 111 |
|
|---|
| 112 | #define BYTEOFF(x) 1
|
|---|
| 113 | #define BITOOR(x) ((x)/SZCHAR) /* bit offset to oreg offset */
|
|---|
| 114 |
|
|---|
| 115 | #define STOARG(p)
|
|---|
| 116 | #define STOFARG(p)
|
|---|
| 117 | #define STOSTARG(p)
|
|---|
| 118 | #define genfcall(a,b) gencall(a,b)
|
|---|
| 119 |
|
|---|
| 120 | #define szty(t) (((t) == LONG || (t) == ULONG || \
|
|---|
| 121 | (ISPTR(t) && ISFTN(DECREF(t)))) ? 2 : 1)
|
|---|
| 122 |
|
|---|
| 123 | /*
|
|---|
| 124 | * m16c register classes:
|
|---|
| 125 | * A - 16-bit data registers R0-R3
|
|---|
| 126 | * B - 16-bit address registers A0-A1
|
|---|
| 127 | * C - 8-bit data registers R0H, R0L, R1H, R1L
|
|---|
| 128 | */
|
|---|
| 129 |
|
|---|
| 130 | #define R0 0
|
|---|
| 131 | #define R2 1
|
|---|
| 132 | #define R1 2
|
|---|
| 133 | #define R3 3
|
|---|
| 134 |
|
|---|
| 135 | #define A0 4
|
|---|
| 136 | #define A1 5
|
|---|
| 137 | #define FB 6
|
|---|
| 138 | #define SP 7
|
|---|
| 139 |
|
|---|
| 140 | #define R0H 8
|
|---|
| 141 | #define R0L 9
|
|---|
| 142 | #define R1H 10
|
|---|
| 143 | #define R1L 11
|
|---|
| 144 |
|
|---|
| 145 | #define NUMCLASS 4 /* Number of register classes */
|
|---|
| 146 |
|
|---|
| 147 | #define RETREG(x) (x == CHAR || x == UCHAR ? R0L : R0)
|
|---|
| 148 |
|
|---|
| 149 | #define FPREG FB /* frame pointer */
|
|---|
| 150 | #define STKREG SP /* stack pointer */
|
|---|
| 151 |
|
|---|
| 152 | #if 0
|
|---|
| 153 | #define REGSZ 8 /* Number of registers */
|
|---|
| 154 | #define MINRVAR R1 /* first register variable */
|
|---|
| 155 | #define MAXRVAR R2 /* last register variable */
|
|---|
| 156 | #endif
|
|---|
| 157 |
|
|---|
| 158 | #define MAXREGS 12 /* 12 registers */
|
|---|
| 159 |
|
|---|
| 160 | #define RSTATUS \
|
|---|
| 161 | SAREG|TEMPREG, SAREG|PERMREG, SAREG|TEMPREG, SAREG|PERMREG, \
|
|---|
| 162 | SBREG|TEMPREG, SBREG|PERMREG, 0, 0, SCREG, SCREG, SCREG, SCREG,
|
|---|
| 163 |
|
|---|
| 164 | #define ROVERLAP \
|
|---|
| 165 | {R0H, R0L, -1},\
|
|---|
| 166 | {-1},\
|
|---|
| 167 | {R1H, R1L, -1},\
|
|---|
| 168 | {-1},\
|
|---|
| 169 | \
|
|---|
| 170 | {-1},\
|
|---|
| 171 | {-1},\
|
|---|
| 172 | \
|
|---|
| 173 | {-1},\
|
|---|
| 174 | {-1},\
|
|---|
| 175 | \
|
|---|
| 176 | {R0, -1},\
|
|---|
| 177 | {R0, -1},\
|
|---|
| 178 | {R1, -1},\
|
|---|
| 179 | {R1, -1},
|
|---|
| 180 |
|
|---|
| 181 | #define PCLASS(p) (p->n_type <= UCHAR ? SCREG : ISPTR(p->n_type) ? SBREG:SAREG)
|
|---|
| 182 |
|
|---|
| 183 | int COLORMAP(int c, int *r);
|
|---|
| 184 | #define GCLASS(x) (x < 4 ? CLASSA : x < 6 ? CLASSB : x < 12 ? CLASSC : CLASSD)
|
|---|
| 185 | #define DECRA(x,y) (((x) >> (y*6)) & 63) /* decode encoded regs */
|
|---|
| 186 | #define ENCRD(x) (x) /* Encode dest reg in n_reg */
|
|---|
| 187 | #define ENCRA1(x) ((x) << 6) /* A1 */
|
|---|
| 188 | #define ENCRA2(x) ((x) << 12) /* A2 */
|
|---|
| 189 | #define ENCRA(x,y) ((x) << (6+y*6)) /* encode regs in int */
|
|---|
| 190 |
|
|---|
| 191 | #define MYADDEDGE(x, t)
|
|---|
| 192 |
|
|---|
| 193 | #ifndef NEW_READER
|
|---|
| 194 | //#define TAILCALL
|
|---|
| 195 | #endif
|
|---|
| 196 | #define SFTN (SPECIAL|6)
|
|---|