1 /* $Id: macdefs.h,v 1.30 2009/01/24 21:43:49 gmcgarry Exp $ */
3 * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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
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.
30 * Machine-dependent defines for both passes.
34 * Convert (multi-)character constant to integer.
35 * Assume: If only one value; store at left side (char size), otherwise
36 * treat it as an integer.
38 #define makecc(val,i) { \
39 if (i == 0) { lastcon = val; \
40 } else if (i == 1) { lastcon = (lastcon << 9) | val; lastcon <<= 18; \
41 } else { lastcon |= (val << (27 - (i * 9))); } }
43 #define ARGINIT 36 /* # bits below fp where arguments start */
44 #define AUTOINIT 36 /* # bits above fp where automatics start */
47 * Storage space requirements
61 * Alignment constraints
82 #define MIN_SHORT -131072
83 #define MAX_SHORT 131071
84 #define MAX_USHORT 262143
85 #define MIN_INT (-0377777777777LL-1)
86 #define MAX_INT 0377777777777LL
87 #define MAX_UNSIGNED 0777777777777ULL
88 #define MIN_LONG (-0377777777777LL-1)
89 #define MAX_LONG 0377777777777LL
90 #define MAX_ULONG 0777777777777ULL
91 #define MIN_LONGLONG (000777777777777777777777LL-1) /* XXX cross */
92 #define MAX_LONGLONG 000777777777777777777777LL /* XXX cross */
93 #define MAX_ULONGLONG 001777777777777777777777ULL /* XXX cross */
95 /* Default char is unsigned */
96 #define TARGET_STDARGS
101 * Use large-enough types.
103 typedef long long CONSZ
;
104 typedef unsigned long long U_CONSZ
;
105 typedef long long OFFSZ
;
107 #define CONFMT "0%llo" /* format for printing constants */
108 #define LABFMT ".L%d" /* format for printing labels */
109 #define STABLBL ".LL%d" /* format for stab (debugging) labels */
111 #undef BACKAUTO /* stack grows negatively for automatics */
112 #undef BACKTEMP /* stack grows negatively for temporaries */
114 #undef FIELDOPS /* no bit-field instructions */
115 #undef RTOLBYTES /* bytes are numbered left to right */
117 #define ENUMSIZE(high,low) INT /* enums are always stored in full int */
119 /* Definitions mostly used in pass2 */
121 #define BYTEOFF(x) ((x)&03)
122 #define wdal(k) (BYTEOFF(k)==0)
123 #define BITOOR(x) ((x)/36) /* bit offset to oreg offset */
128 #define genfcall(a,b) gencall(a,b)
130 #define szty(t) (((t) == DOUBLE || (t) == FLOAT || \
131 (t) == LONGLONG || (t) == ULONGLONG) ? 2 : 1)
133 #define shltype(o, p) \
134 ((o) == REG || (o) == NAME || (o) == ICON || \
135 (o) == OREG || ((o) == UMUL && shumul((p)->n_left, SOREG)))
137 #undef SPECIAL_INTEGERS
140 * Special shapes used in code generation.
142 #define SUSHCON (SPECIAL|6) /* unsigned short constant */
143 #define SNSHCON (SPECIAL|7) /* negative short constant */
144 #define SILDB (SPECIAL|8) /* use ildb here */
147 * Register allocator definitions.
149 * The pdp10 has 16 general-purpose registers, but the two
150 * highest are used as sp and fp. Register 0 has special
151 * constraints in its possible use as index register.
152 * All regs can be used as pairs, named by the lowest number.
153 * In here we call the registers Rn and the pairs XRn, in assembler
154 * just its number prefixed with %.
156 * R1/XR1 are return registers.
158 * R0 is currently not used.
161 #define MAXREGS 29 /* 16 + 13 regs */
180 #define FPREG R16 /* frame pointer */
181 #define STKREG R17 /* stack pointer */
200 0, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \
201 SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \
202 SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, \
203 SAREG|PERMREG, SAREG|PERMREG, 0, 0, \
204 SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, \
205 SBREG, SBREG, SBREG, SBREG, SBREG,
217 { XR10, XR11, -1 }, \
218 { XR11, XR12, -1 }, \
219 { XR12, XR13, -1 }, \
220 { XR13, XR14, -1 }, \
224 { R0, R1, XR1, -1 }, \
225 { R1, R2, XR0, XR2, -1 }, \
226 { R2, R3, XR1, XR3, -1 }, \
227 { R3, R4, XR2, XR4, -1 }, \
228 { R4, R5, XR3, XR5, -1 }, \
229 { R5, R6, XR4, XR6, -1 }, \
230 { R6, R7, XR5, XR7, -1 }, \
231 { R7, R10, XR6, XR10, -1 }, \
232 { R10, R11, XR7, XR11, -1 }, \
233 { R11, R12, XR10, XR12, -1 }, \
234 { R12, R13, XR11, XR13, -1 }, \
235 { R13, R14, XR12, XR14, -1 }, \
236 { R14, R15, XR13, -1 },
238 /* Return a register class based on the type of the node */
239 #define PCLASS(p) (szty(p->n_type) == 2 ? SBREG : SAREG)
240 #define RETREG(x) (szty(x) == 2 ? XR1 : R1)
241 #define DECRA(x,y) (((x) >> (y*6)) & 63) /* decode encoded regs */
242 #define ENCRD(x) (x) /* Encode dest reg in n_reg */
243 #define ENCRA1(x) ((x) << 6) /* A1 */
244 #define ENCRA2(x) ((x) << 12) /* A2 */
245 #define ENCRA(x,y) ((x) << (6+y*6)) /* encode regs in int */
246 #define GCLASS(x) (x < 16 ? CLASSA : CLASSB)
247 int COLORMAP(int c
, int *r
);