1 | /* $Id: macdefs.h,v 1.4 2009/01/24 21:43:49 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 |
|
---|
33 | /*
|
---|
34 | * Convert (multi-)character constant to integer.
|
---|
35 | */
|
---|
36 | #define makecc(val,i) lastcon = i ? (val<<8)|lastcon : val
|
---|
37 |
|
---|
38 | #define ARGINIT 32 /* # bits above r5 where arguments start */
|
---|
39 | #define AUTOINIT 64 /* # bits below r5 where automatics start */
|
---|
40 |
|
---|
41 | /*
|
---|
42 | * Storage space requirements
|
---|
43 | */
|
---|
44 | #define SZCHAR 8
|
---|
45 | #define SZBOOL 8
|
---|
46 | #define SZINT 16
|
---|
47 | #define SZFLOAT 32
|
---|
48 | #define SZDOUBLE 64
|
---|
49 | #define SZLDOUBLE 64
|
---|
50 | #define SZLONG 32
|
---|
51 | #define SZSHORT 16
|
---|
52 | #define SZLONGLONG 64
|
---|
53 | #define SZPOINT(t) 16
|
---|
54 |
|
---|
55 | /*
|
---|
56 | * Alignment constraints
|
---|
57 | */
|
---|
58 | #define ALCHAR 8
|
---|
59 | #define ALBOOL 8
|
---|
60 | #define ALINT 16
|
---|
61 | #define ALFLOAT 16
|
---|
62 | #define ALDOUBLE 16
|
---|
63 | #define ALLDOUBLE 16
|
---|
64 | #define ALLONG 16
|
---|
65 | #define ALLONGLONG 16
|
---|
66 | #define ALSHORT 16
|
---|
67 | #define ALPOINT 16
|
---|
68 | #define ALSTRUCT 16
|
---|
69 | #define ALSTACK 16
|
---|
70 |
|
---|
71 | /*
|
---|
72 | * Min/max values.
|
---|
73 | */
|
---|
74 | #define MIN_CHAR -128
|
---|
75 | #define MAX_CHAR 127
|
---|
76 | #define MAX_UCHAR 255
|
---|
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
|
---|
89 |
|
---|
90 | /* Default char is signed */
|
---|
91 | #undef CHAR_UNSIGNED
|
---|
92 | #define BOOL_TYPE CHAR /* what used to store _Bool */
|
---|
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 | #ifdef LANG_F77
|
---|
104 | #define BLANKCOMMON "_BLNK_"
|
---|
105 | #define MSKIREG (M(TYSHORT)|M(TYLONG))
|
---|
106 | #define TYIREG TYLONG
|
---|
107 | #define FSZLENG FSZLONG
|
---|
108 | #define AUTOREG EBP
|
---|
109 | #define ARGREG EBP
|
---|
110 | #define ARGOFFSET 8
|
---|
111 | #endif
|
---|
112 |
|
---|
113 | #define BACKAUTO /* stack grows negatively for automatics */
|
---|
114 | #define BACKTEMP /* stack grows negatively for temporaries */
|
---|
115 |
|
---|
116 | #undef FIELDOPS /* no bit-field instructions */
|
---|
117 | #define RTOLBYTES /* bytes are numbered right to left */
|
---|
118 |
|
---|
119 | #define ENUMSIZE(high,low) INT /* enums are always stored in full int */
|
---|
120 |
|
---|
121 | /* Definitions mostly used in pass2 */
|
---|
122 |
|
---|
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! */
|
---|
126 |
|
---|
127 | #define STOARG(p)
|
---|
128 | #define STOFARG(p)
|
---|
129 | #define STOSTARG(p)
|
---|
130 | #define genfcall(a,b) gencall(a,b)
|
---|
131 |
|
---|
132 | #define FINDMOPS /* pdp11 has instructions that modifies memory */
|
---|
133 |
|
---|
134 | #define szty(t) ((t) == DOUBLE || (t) == LONGLONG || (t) == ULONGLONG ? 4 : \
|
---|
135 | (t) == FLOAT || (t) == LONG || (t) == ULONG ? 2 : 1)
|
---|
136 |
|
---|
137 | /*
|
---|
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.
|
---|
141 | *
|
---|
142 | * The classes used on pdp11 are:
|
---|
143 | * A - 16-bit
|
---|
144 | * B - 32-bit (concatenated 16-bit)
|
---|
145 | * C - floating point
|
---|
146 | */
|
---|
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 */
|
---|
155 |
|
---|
156 | #define R01 010
|
---|
157 | #define R12 011
|
---|
158 | #define R23 012
|
---|
159 | #define R34 013
|
---|
160 |
|
---|
161 | #define FR0 020
|
---|
162 | #define FR1 021
|
---|
163 | #define FR2 022
|
---|
164 | #define FR3 023
|
---|
165 | #define FR4 024
|
---|
166 | #define FR5 025
|
---|
167 | #define FR6 026
|
---|
168 | #define FR7 027
|
---|
169 |
|
---|
170 | #define MAXREGS 030 /* 24 registers */
|
---|
171 |
|
---|
172 | #define RSTATUS \
|
---|
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
|
---|
176 |
|
---|
177 | #define ROVERLAP \
|
---|
178 | /* 8 basic registers */\
|
---|
179 | { R01, -1 }, \
|
---|
180 | { R01, R12, -1 }, \
|
---|
181 | { R12, R23, -1 }, \
|
---|
182 | { R23, R34, -1 }, \
|
---|
183 | { R34, -1 }, \
|
---|
184 | { -1 }, \
|
---|
185 | { -1 }, \
|
---|
186 | { -1 }, \
|
---|
187 | \
|
---|
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 }, \
|
---|
193 | { -1 }, \
|
---|
194 | { -1 }, \
|
---|
195 | { -1 }, \
|
---|
196 | { -1 }, \
|
---|
197 | \
|
---|
198 | /* The fp registers do not overlap with anything */\
|
---|
199 | { -1 },\
|
---|
200 | { -1 },\
|
---|
201 | { -1 },\
|
---|
202 | { -1 },\
|
---|
203 | { -1 },\
|
---|
204 | { -1 },\
|
---|
205 | { -1 },\
|
---|
206 | { -1 },
|
---|
207 |
|
---|
208 |
|
---|
209 | /* Return a register class based on the type of the node */
|
---|
210 |
|
---|
211 | #define PCLASS(p) (p->n_type < LONG || p->n_type > BTMASK ? SAREG : \
|
---|
212 | (p->n_type == LONG || p->n_type == ULONG ? SBREG : SCREG))
|
---|
213 |
|
---|
214 | #define NUMCLASS 3 /* highest number of reg classes used */
|
---|
215 |
|
---|
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)
|
---|
225 |
|
---|
226 | //#define R2REGS 1 /* permit double indexing */
|
---|
227 |
|
---|
228 | /* XXX - to die */
|
---|
229 | #define FPREG R5 /* frame pointer */
|
---|
230 | #define STKREG SP /* stack pointer */
|
---|
231 |
|
---|
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 */
|
---|