xref: /netbsd/external/bsd/pcc/dist/pcc/arch/pdp10/macdefs.h (revision 6550d01e)
1 /*	Id: macdefs.h,v 1.30 2009/01/24 21:43:49 gmcgarry Exp 	*/
2 /*	$NetBSD: macdefs.h,v 1.1.1.3 2010/06/03 18:57:23 plunky Exp $	*/
3 /*
4  * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. The name of the author may not be used to endorse or promote products
16  *    derived from this software without specific prior written permission
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 /*
31  * Machine-dependent defines for both passes.
32  */
33 
34 /*
35  * Convert (multi-)character constant to integer.
36  * Assume: If only one value; store at left side (char size), otherwise
37  * treat it as an integer.
38  */
39 #define makecc(val,i) {			\
40 	if (i == 0) { lastcon = val;	\
41 	} else if (i == 1) { lastcon = (lastcon << 9) | val; lastcon <<= 18; \
42 	} else { lastcon |= (val << (27 - (i * 9))); } }
43 
44 #define ARGINIT		36	/* # bits below fp where arguments start */
45 #define AUTOINIT	36	/* # bits above fp where automatics start */
46 
47 /*
48  * Storage space requirements
49  */
50 #define SZCHAR		9
51 #define SZBOOL		36
52 #define SZINT		36
53 #define SZFLOAT		36
54 #define SZDOUBLE	72
55 #define SZLDOUBLE	72
56 #define SZLONG		36
57 #define SZSHORT		18
58 #define SZPOINT(x)	36
59 #define SZLONGLONG	72
60 
61 /*
62  * Alignment constraints
63  */
64 #define ALCHAR		9
65 #define ALBOOL		36
66 #define ALINT		36
67 #define ALFLOAT		36
68 #define ALDOUBLE	36
69 #define ALLDOUBLE	36
70 #define ALLONG		36
71 #define ALLONGLONG	36
72 #define ALSHORT		18
73 #define ALPOINT		36
74 #define ALSTRUCT	36
75 #define ALSTACK		36
76 
77 /*
78  * Max values.
79  */
80 #define	MIN_CHAR	-256
81 #define	MAX_CHAR	255
82 #define	MAX_UCHAR	511
83 #define	MIN_SHORT	-131072
84 #define	MAX_SHORT	131071
85 #define	MAX_USHORT	262143
86 #define	MIN_INT		(-0377777777777LL-1)
87 #define	MAX_INT		0377777777777LL
88 #define	MAX_UNSIGNED	0777777777777ULL
89 #define	MIN_LONG	(-0377777777777LL-1)
90 #define	MAX_LONG	0377777777777LL
91 #define	MAX_ULONG	0777777777777ULL
92 #define	MIN_LONGLONG	(000777777777777777777777LL-1)	/* XXX cross */
93 #define	MAX_LONGLONG	000777777777777777777777LL	/* XXX cross */
94 #define	MAX_ULONGLONG	001777777777777777777777ULL	/* XXX cross */
95 
96 /* Default char is unsigned */
97 #define TARGET_STDARGS
98 #define	CHAR_UNSIGNED
99 #define	BOOL_TYPE	INT
100 
101 /*
102  * Use large-enough types.
103  */
104 typedef	long long CONSZ;
105 typedef	unsigned long long U_CONSZ;
106 typedef long long OFFSZ;
107 
108 #define CONFMT	"0%llo"		/* format for printing constants */
109 #define LABFMT	".L%d"		/* format for printing labels */
110 #define STABLBL ".LL%d"		/* format for stab (debugging) labels */
111 
112 #undef BACKAUTO 		/* stack grows negatively for automatics */
113 #undef BACKTEMP 		/* stack grows negatively for temporaries */
114 
115 #undef	FIELDOPS		/* no bit-field instructions */
116 #undef	RTOLBYTES		/* bytes are numbered left to right */
117 
118 #define ENUMSIZE(high,low) INT	/* enums are always stored in full int */
119 
120 /* Definitions mostly used in pass2 */
121 
122 #define BYTEOFF(x)	((x)&03)
123 #define wdal(k)		(BYTEOFF(k)==0)
124 #define BITOOR(x)	((x)/36)		/* bit offset to oreg offset */
125 
126 #define STOARG(p)
127 #define STOFARG(p)
128 #define STOSTARG(p)
129 #define genfcall(a,b)	gencall(a,b)
130 
131 #define	szty(t)	(((t) == DOUBLE || (t) == FLOAT || \
132 	(t) == LONGLONG || (t) == ULONGLONG) ? 2 : 1)
133 
134 #define	shltype(o, p) \
135 	((o) == REG || (o) == NAME || (o) == ICON || \
136 	 (o) == OREG || ((o) == UMUL && shumul((p)->n_left, SOREG)))
137 
138 #undef	SPECIAL_INTEGERS
139 
140 /*
141  * Special shapes used in code generation.
142  */
143 #define	SUSHCON	(SPECIAL|6)	/* unsigned short constant */
144 #define	SNSHCON	(SPECIAL|7)	/* negative short constant */
145 #define	SILDB	(SPECIAL|8)	/* use ildb here */
146 
147 /*
148  * Register allocator definitions.
149  *
150  * The pdp10 has 16 general-purpose registers, but the two
151  * highest are used as sp and fp.  Register 0 has special
152  * constraints in its possible use as index register.
153  * All regs can be used as pairs, named by the lowest number.
154  * In here we call the registers Rn and the pairs XRn, in assembler
155  * just its number prefixed with %.
156  *
157  * R1/XR1 are return registers.
158  *
159  * R0 is currently not used.
160  */
161 
162 #define	MAXREGS		29 /* 16 + 13 regs */
163 #define	NUMCLASS	2
164 
165 #define R0	00
166 #define R1	01
167 #define R2	02
168 #define R3	03
169 #define R4	04
170 #define R5	05
171 #define R6	06
172 #define R7	07
173 #define R10	010
174 #define R11	011
175 #define R12	012
176 #define R13	013
177 #define R14	014
178 #define R15	015
179 #define R16	016
180 #define R17	017
181 #define FPREG	R16		/* frame pointer */
182 #define STKREG	R17		/* stack pointer */
183 
184 
185 #define XR0	020
186 #define XR1	021
187 #define XR2	022
188 #define XR3	023
189 #define XR4	024
190 #define XR5	025
191 #define XR6	026
192 #define XR7	027
193 #define XR10	030
194 #define XR11	031
195 #define XR12	032
196 #define XR13	033
197 #define XR14	034
198 
199 
200 #define RSTATUS \
201 	0, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG,			\
202 	SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG,	\
203 	SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG,	\
204 	SAREG|PERMREG, SAREG|PERMREG, 0, 0,				\
205 	SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG,		\
206 	SBREG, SBREG, SBREG, SBREG, SBREG,
207 
208 #define ROVERLAP \
209         { XR0, -1 },			\
210         { XR0, XR1, -1 },		\
211         { XR1, XR2, -1 },		\
212         { XR2, XR3, -1 },		\
213         { XR3, XR4, -1 },		\
214         { XR4, XR5, -1 },		\
215         { XR5, XR6, -1 },		\
216         { XR6, XR7, -1 },		\
217         { XR7, XR10, -1 },		\
218         { XR10, XR11, -1 },		\
219         { XR11, XR12, -1 },		\
220         { XR12, XR13, -1 },		\
221         { XR13, XR14, -1 },		\
222         { XR14, -1 },			\
223         { -1 },				\
224         { -1 },				\
225         { R0, R1, XR1, -1 },		\
226         { R1, R2, XR0, XR2, -1 },	\
227         { R2, R3, XR1, XR3, -1 },	\
228         { R3, R4, XR2, XR4, -1 },	\
229         { R4, R5, XR3, XR5, -1 },	\
230         { R5, R6, XR4, XR6, -1 },	\
231         { R6, R7, XR5, XR7, -1 },	\
232         { R7, R10, XR6, XR10, -1 },	\
233         { R10, R11, XR7, XR11, -1 },	\
234         { R11, R12, XR10, XR12, -1 },	\
235         { R12, R13, XR11, XR13, -1 },	\
236         { R13, R14, XR12, XR14, -1 },	\
237         { R14, R15, XR13, -1 },
238 
239 /* Return a register class based on the type of the node */
240 #define PCLASS(p) (szty(p->n_type) == 2 ? SBREG : SAREG)
241 #define RETREG(x) (szty(x) == 2 ? XR1 : R1)
242 #define DECRA(x,y)      (((x) >> (y*6)) & 63)   /* decode encoded regs */
243 #define ENCRD(x)        (x)             /* Encode dest reg in n_reg */
244 #define ENCRA1(x)       ((x) << 6)      /* A1 */
245 #define ENCRA2(x)       ((x) << 12)     /* A2 */
246 #define ENCRA(x,y)      ((x) << (6+y*6))        /* encode regs in int */
247 #define GCLASS(x)	(x < 16 ? CLASSA : CLASSB)
248 int COLORMAP(int c, int *r);
249