xref: /netbsd/external/bsd/pcc/dist/pcc/arch/nova/macdefs.h (revision 6550d01e)
1 /*	Id: macdefs.h,v 1.2 2007/11/16 22:27:42 gmcgarry Exp 	*/
2 /*	$NetBSD: macdefs.h,v 1.1.1.2 2010/06/03 18:57:21 plunky Exp $	*/
3 /*
4  * Copyright (c) 2006 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 Data General Nova.
32  */
33 
34 /*
35  * Convert (multi-)character constant to integer.
36  */
37 #define makecc(val,i)	lastcon = (lastcon<<8)|(val);
38 
39 #define ARGINIT		16	/* adjusted in MD code */
40 #define AUTOINIT	16	/* adjusted in MD code */
41 
42 /*
43  * Storage space requirements
44  */
45 #define SZCHAR		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	32
53 #define SZPOINT(t)	16	/* Actually 15 */
54 
55 /*
56  * Alignment constraints
57  */
58 #define ALCHAR		8
59 #define ALINT		16
60 #define ALFLOAT		16
61 #define ALDOUBLE	16
62 #define ALLDOUBLE	16
63 #define ALLONG		16
64 #define ALLONGLONG	16
65 #define ALSHORT		16
66 #define ALPOINT		16
67 #define ALSTRUCT	16
68 #define ALSTACK		16
69 
70 /*
71  * Min/max values.
72  */
73 #define	MIN_CHAR	-128
74 #define	MAX_CHAR	127
75 #define	MAX_UCHAR	255
76 #define	MIN_SHORT	-32768
77 #define	MAX_SHORT	32767
78 #define	MAX_USHORT	65535
79 #define	MIN_INT		MIN_SHORT
80 #define	MAX_INT		MAX_SHORT
81 #define	MAX_UNSIGNED	MAX_USHORT
82 #define	MIN_LONG	0x80000000L
83 #define	MAX_LONG	0x7fffffffL
84 #define	MAX_ULONG	0xffffffffUL
85 #define	MIN_LONGLONG	MIN_LONG
86 #define	MAX_LONGLONG	MAX_LONG
87 #define	MAX_ULONGLONG	MAX_ULONG
88 
89 /* Default char is unsigned */
90 #define	CHAR_UNSIGNED
91 
92 /*
93  * Use large-enough types.
94  */
95 typedef	long CONSZ;
96 typedef	unsigned long U_CONSZ;
97 typedef long OFFSZ;
98 
99 #define CONFMT	"%ld"		/* format for printing constants */
100 #define LABFMT	".L%d"		/* format for printing labels */
101 #define	STABLBL	".LL%d"		/* format for stab (debugging) labels */
102 #ifdef FORTRAN
103 #define XL 8
104 #define	FLABELFMT "%s:\n"
105 #define USETEXT ".text"
106 #define USECONST ".data\t0" 	/* XXX - fix */
107 #define USEBSS  ".data\t1" 	/* XXX - fix */
108 #define USEINIT ".data\t2" 	/* XXX - fix */
109 #define MAXREGVAR 3             /* XXX - fix */
110 #define BLANKCOMMON "_BLNK_"
111 #define MSKIREG  (M(TYSHORT)|M(TYLONG))
112 #define TYIREG TYLONG
113 #define FSZLENG  FSZLONG
114 #define FUDGEOFFSET 1
115 #define	AUTOREG	EBP
116 #define	ARGREG	EBP
117 #define ARGOFFSET 4
118 #endif
119 
120 #define BACKAUTO 		/* stack grows negatively for automatics */
121 #define BACKTEMP 		/* stack grows negatively for temporaries */
122 
123 #undef	FIELDOPS		/* no bit-field instructions */
124 #define	RTOLBYTES		/* bytes are numbered right to left */
125 
126 #define ENUMSIZE(high,low) INT	/* enums are always stored in full int */
127 
128 /* Definitions mostly used in pass2 */
129 
130 #define BYTEOFF(x)	((x)&01)
131 #define wdal(k)		(BYTEOFF(k)==0)
132 #define BITOOR(x)	(x)	/* bit offset to oreg offset XXX die! */
133 
134 #define STOARG(p)
135 #define STOFARG(p)
136 #define STOSTARG(p)
137 #define genfcall(a,b)	gencall(a,b)
138 
139 #define	szty(t)	(((t) == DOUBLE || (t) == LDOUBLE) ? 4 : \
140 	((t) == LONGLONG || (t) == ULONGLONG || \
141 	 (t) == LONG || (t) == ULONG) ? 2 : 1)
142 
143 /*
144  * The Nova has three register classes.  Note that the space used in
145  * zero page is considered registers.
146  * Register 28 and 29 are FP and SP.
147  *
148  * The classes used on Nova are:
149  *	A - AC0-AC3 (as non-index registers)	: reg 0-3
150  *	B - AC2-AC3 (as index registers)	: reg 2-3
151  *	C - address 50-77 in memory		: reg 4-27
152  */
153 #define	MAXREGS	30	/* 0-29 */
154 
155 #define	RSTATUS	\
156 	SAREG|TEMPREG, SAREG|TEMPREG, SAREG|SBREG|TEMPREG, SAREG|SBREG|TEMPREG,\
157 	SCREG|TEMPREG, SCREG|TEMPREG, SCREG|TEMPREG, SCREG|TEMPREG,	\
158 	SCREG|TEMPREG, SCREG|TEMPREG, SCREG|TEMPREG, SCREG|TEMPREG,	\
159 	SCREG|PERMREG, SCREG|PERMREG, SCREG|PERMREG, SCREG|PERMREG,	\
160 	SCREG|PERMREG, SCREG|PERMREG, SCREG|PERMREG, SCREG|PERMREG,	\
161 	SCREG|PERMREG, SCREG|PERMREG, SCREG|PERMREG, SCREG|PERMREG,	\
162 	SCREG|PERMREG, SCREG|PERMREG, SCREG|PERMREG, SCREG|PERMREG,	\
163 	0,	0
164 
165 #define	ROVERLAP \
166 	{ -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 },	\
167 	{ -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 },	\
168 	{ -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 },	\
169 	{ -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 },
170 
171 
172 /* Return a register class based on the type of the node */
173 /* all types in all classes */
174 #define PCLASS(p) (SAREG|SBREG|SCREG)
175 
176 #define	NUMCLASS 	4	/* highest number of reg classes used */
177 				/* XXX - must be 4 */
178 
179 int COLORMAP(int c, int *r);
180 #define	GCLASS(x) (x < 4 ? CLASSA : CLASSC)
181 #define DECRA(x,y)	(((x) >> (y*6)) & 63)	/* decode encoded regs */
182 #define	ENCRD(x)	(x)		/* Encode dest reg in n_reg */
183 #define ENCRA1(x)	((x) << 6)	/* A1 */
184 #define ENCRA2(x)	((x) << 12)	/* A2 */
185 #define ENCRA(x,y)	((x) << (6+y*6))	/* encode regs in int */
186 #define	RETREG(x)	(0) /* ? Sanity */
187 
188 /* XXX - to die */
189 #define FPREG	28	/* frame pointer */
190 #define STKREG	29	/* stack pointer */
191