xref: /netbsd/external/bsd/pcc/dist/pcc/arch/m16c/macdefs.h (revision 6550d01e)
1 /*	Id: macdefs.h,v 1.23 2007/11/16 22:23:04 gmcgarry Exp 	*/
2 /*	$NetBSD: macdefs.h,v 1.1.1.2 2010/06/03 18:57:17 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 #define makecc(val,i)   lastcon = (lastcon<<8)|((val<<8)>>8);
34 
35 #define ARGINIT		40	/* # bits above fp where arguments start */
36 #define AUTOINIT	0	/* # bits below fp where automatics start */
37 
38 /*
39  * Convert (multi-)character constant to integer.
40  * Assume: If only one value; store at left side (char size), otherwise
41  * treat it as an integer.
42  */
43 
44 /*
45  * Storage space requirements
46  */
47 #define SZCHAR		8
48 #define SZINT		16
49 #define SZFLOAT         16
50 #define SZDOUBLE        16
51 #define SZLDOUBLE       16
52 #define SZLONG		32
53 #define SZSHORT		16
54 #define SZLONGLONG      32
55 /* pointers are of different sizes on m16c */
56 #define SZPOINT(t) 	(ISFTN(DECREF(t)) ? 32 : 16)
57 
58 /*
59  * Alignment constraints
60  */
61 #define ALCHAR		8
62 #define ALINT		16
63 #define ALFLOAT		16
64 #define ALDOUBLE	16
65 #define ALLDOUBLE	16
66 #define ALLONG		16
67 #define ALLONGLONG	16
68 #define ALSHORT		16
69 #define ALPOINT		16
70 #define ALSTRUCT	16
71 #define ALSTACK		16
72 
73 /*
74  * Min/max values.
75  */
76 #define MIN_CHAR	-128
77 #define MAX_CHAR	127
78 #define MAX_UCHAR	255
79 #define MIN_SHORT	-32768
80 #define MAX_SHORT	32767
81 #define MAX_USHORT	65535
82 #define MIN_INT		-32768
83 #define MAX_INT		32767
84 #define MAX_UNSIGNED	65535
85 #define MIN_LONG	-2147483648
86 #define MAX_LONG	2147483647
87 #define MAX_ULONG	4294967295UL
88 #define MIN_LONGLONG	-2147483648
89 #define MAX_LONGLONG	2147483647
90 #define MAX_ULONGLONG	4294967295UL
91 
92 /* Default char is unsigned */
93 #undef	CHAR_UNSIGNED
94 
95 /*
96  * Use large-enough types.
97  */
98 typedef long long CONSZ;
99 typedef unsigned long long U_CONSZ;
100 typedef long long OFFSZ;
101 
102 #define CONFMT	"%lld"		/* format for printing constants */
103 #define LABFMT	"L%d"		/* format for printing labels */
104 
105 #define BACKAUTO		/* stack grows negatively for automatics */
106 #define BACKTEMP		/* stack grows negatively for temporaries */
107 
108 #undef	FIELDOPS		/* no bit-field instructions */
109 #define RTOLBYTES		/* bytes are numbered right to left */
110 
111 /* Definitions mostly used in pass2 */
112 
113 #define BYTEOFF(x)	1
114 #define BITOOR(x)	((x)/SZCHAR)	/* bit offset to oreg offset */
115 
116 #define STOARG(p)
117 #define STOFARG(p)
118 #define STOSTARG(p)
119 #define genfcall(a,b)	gencall(a,b)
120 
121 #define szty(t) (((t) == LONG || (t) == ULONG || \
122 	(ISPTR(t) && ISFTN(DECREF(t)))) ? 2 : 1)
123 
124 /*
125  * m16c register classes:
126  * A - 16-bit data registers R0-R3
127  * B - 16-bit address registers A0-A1
128  * C - 8-bit data registers R0H, R0L, R1H, R1L
129  */
130 
131 #define R0	0
132 #define R2	1
133 #define R1	2
134 #define R3	3
135 
136 #define A0	4
137 #define A1	5
138 #define FB	6
139 #define SP	7
140 
141 #define R0H     8
142 #define R0L     9
143 #define R1H     10
144 #define R1L     11
145 
146 #define NUMCLASS 4      /* Number of register classes */
147 
148 #define RETREG(x)	(x == CHAR || x == UCHAR ? R0L : R0)
149 
150 #define FPREG	FB	/* frame pointer */
151 #define STKREG	SP	/* stack pointer */
152 
153 #if 0
154 #define REGSZ	8	/* Number of registers */
155 #define MINRVAR R1	/* first register variable */
156 #define MAXRVAR R2	/* last register variable */
157 #endif
158 
159 #define MAXREGS 12 /* 12 registers */
160 
161 #define RSTATUS \
162 	SAREG|TEMPREG, SAREG|PERMREG, SAREG|TEMPREG, SAREG|PERMREG, \
163 	SBREG|TEMPREG, SBREG|PERMREG, 0, 0, SCREG, SCREG, SCREG, SCREG,
164 
165 #define ROVERLAP \
166 	{R0H, R0L, -1},\
167 	{-1},\
168 	{R1H, R1L, -1},\
169 	{-1},\
170 \
171 	{-1},\
172 	{-1},\
173 \
174 	{-1},\
175 	{-1},\
176 \
177 	{R0, -1},\
178 	{R0, -1},\
179 	{R1, -1},\
180 	{R1, -1},
181 
182 #define PCLASS(p) (p->n_type <= UCHAR ? SCREG : ISPTR(p->n_type) ? SBREG:SAREG)
183 
184 int COLORMAP(int c, int *r);
185 #define	GCLASS(x) (x < 4 ? CLASSA : x < 6 ? CLASSB : x < 12 ? CLASSC : CLASSD)
186 #define DECRA(x,y)	(((x) >> (y*6)) & 63)	/* decode encoded regs */
187 #define	ENCRD(x)	(x)		/* Encode dest reg in n_reg */
188 #define ENCRA1(x)	((x) << 6)	/* A1 */
189 #define ENCRA2(x)	((x) << 12)	/* A2 */
190 #define ENCRA(x,y)	((x) << (6+y*6))	/* encode regs in int */
191 
192 #define	MYADDEDGE(x, t)
193 
194 #ifndef NEW_READER
195 //#define TAILCALL
196 #endif
197 #define	SFTN	(SPECIAL|6)
198