1 /* $Id: macdefs.h,v 1.4 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.
36 #define makecc(val,i) lastcon = i ? (val<<8)|lastcon : val
38 #define ARGINIT 32 /* # bits above r5 where arguments start */
39 #define AUTOINIT 64 /* # bits below r5 where automatics start */
42 * Storage space requirements
56 * Alignment constraints
77 #define MIN_SHORT -32768
78 #define MAX_SHORT 32767
79 #define MAX_USHORT 65535
80 #define MIN_INT (-0x7fff-1)
81 #define MAX_INT 0x7fff
82 #define MAX_UNSIGNED 0xffff
83 #define MIN_LONG (-0x7fffffff-1)
84 #define MAX_LONG 0x7fffffff
85 #define MAX_ULONG 0xffffffff
86 #define MIN_LONGLONG 0x8000000000000000LL
87 #define MAX_LONGLONG 0x7fffffffffffffffLL
88 #define MAX_ULONGLONG 0xffffffffffffffffULL
90 /* Default char is signed */
92 #define BOOL_TYPE CHAR /* what used to store _Bool */
95 * Use large-enough types.
97 typedef long long CONSZ
;
98 typedef unsigned long long U_CONSZ
;
99 typedef long long OFFSZ
;
101 #define CONFMT "%lld" /* format for printing constants */
102 #define LABFMT "L%d" /* format for printing labels */
104 #define BLANKCOMMON "_BLNK_"
105 #define MSKIREG (M(TYSHORT)|M(TYLONG))
106 #define TYIREG TYLONG
107 #define FSZLENG FSZLONG
113 #define BACKAUTO /* stack grows negatively for automatics */
114 #define BACKTEMP /* stack grows negatively for temporaries */
116 #undef FIELDOPS /* no bit-field instructions */
117 #define RTOLBYTES /* bytes are numbered right to left */
119 #define ENUMSIZE(high,low) INT /* enums are always stored in full int */
121 /* Definitions mostly used in pass2 */
123 #define BYTEOFF(x) ((x)&01)
124 #define wdal(k) (BYTEOFF(k)==0)
125 #define BITOOR(x) (x) /* bit offset to oreg offset XXX die! */
130 #define genfcall(a,b) gencall(a,b)
132 #define FINDMOPS /* pdp11 has instructions that modifies memory */
134 #define szty(t) ((t) == DOUBLE || (t) == LONGLONG || (t) == ULONGLONG ? 4 : \
135 (t) == FLOAT || (t) == LONG || (t) == ULONG ? 2 : 1)
138 * The pdp11 has 3 register classes, 16-bit, 32-bit and floats.
139 * Class membership and overlaps are defined in the macros RSTATUS
140 * and ROVERLAP below.
142 * The classes used on pdp11 are:
144 * B - 32-bit (concatenated 16-bit)
147 #define R0 000 /* Scratch and return register */
148 #define R1 001 /* Scratch and secondary return register */
149 #define R2 002 /* Scratch register */
150 #define R3 003 /* Scratch register */
151 #define R4 004 /* Scratch register */
152 #define R5 005 /* Frame pointer */
153 #define SP 006 /* Stack pointer */
154 #define PC 007 /* Program counter */
170 #define MAXREGS 030 /* 24 registers */
173 SAREG|TEMPREG, SAREG|TEMPREG, SAREG, SAREG, SAREG, 0, 0, 0, \
174 SBREG, SBREG, SBREG, SBREG, 0, 0, 0, 0, \
175 SCREG, SCREG, SCREG, SCREG, 0, 0, 0, 0
178 /* 8 basic registers */\
188 /* 4 long registers */\
189 { R0, R1, R12, -1 }, \
190 { R1, R2, R01, R23, -1 }, \
191 { R2, R3, R12, R34, -1 }, \
192 { R3, R4, R23, -1 }, \
198 /* The fp registers do not overlap with anything */\
209 /* Return a register class based on the type of the node */
211 #define PCLASS(p) (p->n_type < LONG || p->n_type > BTMASK ? SAREG : \
212 (p->n_type == LONG || p->n_type == ULONG ? SBREG : SCREG))
214 #define NUMCLASS 3 /* highest number of reg classes used */
216 int COLORMAP(int c
, int *r
);
217 #define GCLASS(x) (x < 8 ? CLASSA : x < 16 ? CLASSB : CLASSC)
218 #define DECRA(x,y) (((x) >> (y*5)) & 31) /* decode encoded regs */
219 #define ENCRD(x) (x) /* Encode dest reg in n_reg */
220 #define ENCRA1(x) ((x) << 5) /* A1 */
221 #define ENCRA2(x) ((x) << 10) /* A2 */
222 #define ENCRA(x,y) ((x) << (5+y*5)) /* encode regs in int */
223 #define RETREG(x) ((x) == LONG || (x) == ULONG ? R01 : \
224 (x) == FLOAT || (x) == DOUBLE ? FR0 : R0)
226 //#define R2REGS 1 /* permit double indexing */
229 #define FPREG R5 /* frame pointer */
230 #define STKREG SP /* stack pointer */
232 /* A bunch of specials to make life easier for pdp11 */
233 #define SANDSCON (MAXSPECIAL+1)
234 #define SINCB (MAXSPECIAL+2) /* post-increment */
235 #define SINCW (MAXSPECIAL+3) /* post-increment */
236 #define SARGSUB (MAXSPECIAL+4) /* arg pointer to array */
237 #define SARGINC (MAXSPECIAL+5) /* post-increment arg */