xref: /netbsd-src/external/bsd/pcc/dist/pcc/arch/vax/macdefs.h (revision 411dcbec990c8aa9c57d3bd2f4bcacadec0b1ab5)
1 /*	Id: macdefs.h,v 1.22 2015/11/24 17:35:12 ragge Exp 	*/
2 /*	$NetBSD: macdefs.h,v 1.1.1.6 2016/02/09 20:28:36 plunky Exp $	*/
3 /*
4  * Copyright(C) Caldera International Inc. 2001-2002. 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  *
10  * Redistributions of source code and documentation must retain the above
11  * copyright notice, this list of conditions and the following disclaimer.
12  * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditionsand the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * All advertising materials mentioning features or use of this software
16  * must display the following acknowledgement:
17  * 	This product includes software developed or owned by Caldera
18  *	International, Inc.
19  * Neither the name of Caldera International, Inc. nor the names of other
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
24  * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
25  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27  * DISCLAIMED.  IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
28  * FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT,
32  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
33  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  */
36 
37 # define makecc(val,i)  lastcon = (lastcon<<8)|((val<<24)>>24);
38 
39 # define  ARGINIT 32
40 # define  AUTOINIT 0
41 # define  SZCHAR 8
42 # define  SZBOOL 8
43 # define  SZINT 32
44 # define  SZFLOAT 32
45 # define  SZDOUBLE 64
46 # define  SZLDOUBLE 64	/* XXX use longer? */
47 # define  SZLONG 32
48 # define  SZLONGLONG 64
49 # define  SZSHORT 16
50 # define SZPOINT(t) 32
51 # define ALCHAR 8
52 # define ALBOOL 8
53 # define ALINT 32
54 # define ALFLOAT 32
55 # define ALDOUBLE 32
56 # define ALLDOUBLE 32
57 # define ALLONG 32
58 # define ALLONGLONG 32
59 # define ALSHORT 16
60 # define ALPOINT 32
61 # define ALSTRUCT 8
62 # define  ALSTACK 32
63 #define MYVAARGSZ SZINT
64 
65 /*
66  * Min/max values.
67  */
68 #define MIN_CHAR        -128
69 #define MAX_CHAR        127
70 #define MAX_UCHAR       255
71 #define MIN_SHORT       -32768
72 #define MAX_SHORT       32767
73 #define MAX_USHORT      65535
74 #define MIN_INT         (-0x7fffffff-1)
75 #define MAX_INT         0x7fffffff
76 #define MAX_UNSIGNED    0xffffffff
77 #define MIN_LONG        MIN_INT
78 #define MAX_LONG        MAX_INT
79 #define MAX_ULONG       MAX_UNSIGNED
80 #define MIN_LONGLONG    0x8000000000000000LL
81 #define MAX_LONGLONG    0x7fffffffffffffffLL
82 #define MAX_ULONGLONG   0xffffffffffffffffULL
83 
84 /* Default char is signed */
85 #undef  CHAR_UNSIGNED
86 #define BOOL_TYPE       CHAR    /* what used to store _Bool */
87 #define	HASP2ALIGN
88 /*	size in which constants are converted */
89 /*	should be long if feasable */
90 
91 typedef long long CONSZ;
92 typedef unsigned long long U_CONSZ;
93 
94 # define CONFMT "%lld"
95 # define LABFMT ".L%d"
96 # define STABLBL ".LL%d"
97 
98 /*	size in which offsets are kept
99  *	should be large enough to cover address space in bits
100  */
101 typedef long long OFFSZ;
102 
103 /* register cookie for stack poINTer */
104 
105 
106 /* show stack grows negatively */
107 #define BACKAUTO
108 #define BACKTEMP
109 
110 /* show field hardware support on VAX */
111 /* XXX notyet */
112 #undef FIELDOPS
113 
114 /* bytes are numbered from right to left */
115 #define TARGET_ENDIAN TARGET_LE
116 #define	UNALIGNED_ACCESS
117 
118 /* we want prtree included */
119 # define STDPRTREE
120 
121 /*	VAX-11/780 Registers */
122 
123 	/* scratch registers */
124 # define R0 0
125 # define R1 1
126 # define R2 2
127 # define R3 3
128 # define R4 4
129 # define R5 5
130 
131 	/* register variables */
132 # define R6 6
133 # define R7 7
134 # define R8 8
135 # define R9 9
136 # define R10 10
137 # define R11 11
138 
139 	/* special purpose */
140 # define AP 12		/* argument pointer */
141 # define FP 13		/* frame pointer */
142 # define SP 14	/* stack pointer */
143 # define PC 15	/* program counter */
144 
145 	/* floating registers */
146 
147 	/* there are no floating point registers on the VAX */
148 	/* but there are concatenated regs */
149 	/* we call them XR? */
150 #define	XR0	16
151 #define	XR1	17
152 #define	XR2	18
153 #define	XR3	19
154 #define	XR4	20
155 #define	XR5	21
156 #define	XR6	22
157 #define	XR7	23
158 #define	XR8	24
159 #define	XR9	25
160 #define	XR10	26
161 
162 
163 
164 
165 extern int fregs;
166 extern int maxargs;
167 
168 # define BYTEOFF(x) ((x)&03)
169 # define wdal(k) (BYTEOFF(k)==0)
170 
171 # define REGSZ 16
172 
173 # define TMPREG FP
174 
175 //# define R2REGS   /* permit double indexing */
176 
177 # define STOARG(p)     /* just evaluate the arguments, and be done with it... */
178 # define STOFARG(p)
179 # define STOSTARG(p)
180 # define genfcall(a,b) gencall(a,b)
181 
182 # define NESTCALL
183 
184 /*
185  * Register allocator stuff.
186  * The register allocator sees this as 16 general regs (AREGs)
187  * and 11 64-bit concatenated regs. (BREGs)
188  */
189 #define MAXREGS 033     /* 27 registers */
190 
191 #define RSTATUS \
192         SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG,     \
193         SAREG|TEMPREG, SAREG|TEMPREG, SAREG|PERMREG, SAREG|PERMREG,	\
194         SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG,	\
195 	0, 0, 0, 0, /* do not care about ap, fp, sp or pc */		\
196 	SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG,		\
197 	SBREG, SBREG, SBREG,
198 
199 #define ROVERLAP \
200 	{ XR0, -1 },			\
201 	{ XR0, XR1, -1 },		\
202 	{ XR1, XR2, -1 },		\
203 	{ XR2, XR3, -1 },		\
204 	{ XR3, XR4, -1 },		\
205 	{ XR4, XR5, -1 },		\
206 	{ XR5, XR6, -1 },		\
207 	{ XR6, XR7, -1 },		\
208 	{ XR7, XR8, -1 },		\
209 	{ XR8, XR9, -1 },		\
210 	{ XR9, XR10, -1 },		\
211 	{ XR10, -1 },			\
212 	{ -1 },				\
213 	{ -1 },				\
214 	{ -1 },				\
215 	{ -1 },				\
216 	{ R0, R1, XR1, -1 },		\
217 	{ R1, R2, XR0, XR2, -1 },	\
218 	{ R2, R3, XR1, XR3, -1 },	\
219 	{ R3, R4, XR2, XR4, -1 },	\
220 	{ R4, R5, XR3, XR5, -1 },	\
221 	{ R5, R6, XR4, XR6, -1 },	\
222 	{ R6, R7, XR5, XR7, -1 },	\
223 	{ R7, R8, XR6, XR8, -1 },	\
224 	{ R8, R9, XR7, XR9, -1 },	\
225 	{ R9, R10, XR8, XR10, -1 },	\
226 	{ R10, R11, XR9, -1 },
227 
228 #define NUMCLASS        2       /* highest number of reg classes used */
229 
230 /* size, in registers, needed to hold thing of type t */
231 #define	szty(t)	(((t) == DOUBLE || (t) == LONGLONG || (t) == ULONGLONG) ? 2 : 1)
232 #define FPREG	FP	/* frame pointer */
233 #define STKREG	SP
234 #define ARGREG	AP
235 
236 #define DECRA(x,y)      (((x) >> (y*6)) & 63)   /* decode encoded regs */
237 #define ENCRD(x)        (x)             /* Encode dest reg in n_reg */
238 #define ENCRA1(x)       ((x) << 6)      /* A1 */
239 #define ENCRA2(x)       ((x) << 12)     /* A2 */
240 #define ENCRA(x,y)      ((x) << (6+y*6))        /* encode regs in int */
241 
242 #define PCLASS(p)	(szty(p->n_type) == 2 ? SBREG : SAREG)
243 #define RETREG(x)	(szty(x) == 2 ? XR0 : R0)
244 #define GCLASS(x)	(x < XR0 ? CLASSA : CLASSB)
245 int xasmconstregs(char *s);
246 #define XASMCONSTREGS(x) xasmconstregs(x)
247 int COLORMAP(int c, int *r);
248 
249 #define	SNCON		(MAXSPECIAL+1)	/* named constand */
250 
251 #define TARGET_FLT_EVAL_METHOD	0	/* all as their type */
252 /*
253  * Builtins.
254  */
255 #ifdef LANG_CXX
256 #define P1ND struct node
257 #else
258 #define P1ND struct p1node
259 #endif
260 struct p1node;
261 struct bitable;
262 
263 #define	TARGET_FFS		/* target-specific ffs */
264 P1ND *builtin_ffs(const struct bitable *, P1ND *a);
265 P1ND *builtin_ffsl(const struct bitable *, P1ND *a);
266 P1ND *builtin_ffsll(const struct bitable *, P1ND *a);
267 #undef P1ND
268 #define NATIVE_FLOATING_POINT
269