* add p cc
[mascara-docs.git] / compilers / pcc / pcc-1.0.0 / arch / pdp10 / macdefs.h
blob3b246febd014d7cccc59094cb9e2091da0b8f4cc
1 /* $Id: macdefs.h,v 1.30 2009/01/24 21:43:49 gmcgarry Exp $ */
2 /*
3 * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
4 * All rights reserved.
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
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.
30 * Machine-dependent defines for both passes.
34 * Convert (multi-)character constant to integer.
35 * Assume: If only one value; store at left side (char size), otherwise
36 * treat it as an integer.
38 #define makecc(val,i) { \
39 if (i == 0) { lastcon = val; \
40 } else if (i == 1) { lastcon = (lastcon << 9) | val; lastcon <<= 18; \
41 } else { lastcon |= (val << (27 - (i * 9))); } }
43 #define ARGINIT 36 /* # bits below fp where arguments start */
44 #define AUTOINIT 36 /* # bits above fp where automatics start */
47 * Storage space requirements
49 #define SZCHAR 9
50 #define SZBOOL 36
51 #define SZINT 36
52 #define SZFLOAT 36
53 #define SZDOUBLE 72
54 #define SZLDOUBLE 72
55 #define SZLONG 36
56 #define SZSHORT 18
57 #define SZPOINT(x) 36
58 #define SZLONGLONG 72
61 * Alignment constraints
63 #define ALCHAR 9
64 #define ALBOOL 36
65 #define ALINT 36
66 #define ALFLOAT 36
67 #define ALDOUBLE 36
68 #define ALLDOUBLE 36
69 #define ALLONG 36
70 #define ALLONGLONG 36
71 #define ALSHORT 18
72 #define ALPOINT 36
73 #define ALSTRUCT 36
74 #define ALSTACK 36
77 * Max values.
79 #define MIN_CHAR -256
80 #define MAX_CHAR 255
81 #define MAX_UCHAR 511
82 #define MIN_SHORT -131072
83 #define MAX_SHORT 131071
84 #define MAX_USHORT 262143
85 #define MIN_INT (-0377777777777LL-1)
86 #define MAX_INT 0377777777777LL
87 #define MAX_UNSIGNED 0777777777777ULL
88 #define MIN_LONG (-0377777777777LL-1)
89 #define MAX_LONG 0377777777777LL
90 #define MAX_ULONG 0777777777777ULL
91 #define MIN_LONGLONG (000777777777777777777777LL-1) /* XXX cross */
92 #define MAX_LONGLONG 000777777777777777777777LL /* XXX cross */
93 #define MAX_ULONGLONG 001777777777777777777777ULL /* XXX cross */
95 /* Default char is unsigned */
96 #define TARGET_STDARGS
97 #define CHAR_UNSIGNED
98 #define BOOL_TYPE INT
101 * Use large-enough types.
103 typedef long long CONSZ;
104 typedef unsigned long long U_CONSZ;
105 typedef long long OFFSZ;
107 #define CONFMT "0%llo" /* format for printing constants */
108 #define LABFMT ".L%d" /* format for printing labels */
109 #define STABLBL ".LL%d" /* format for stab (debugging) labels */
111 #undef BACKAUTO /* stack grows negatively for automatics */
112 #undef BACKTEMP /* stack grows negatively for temporaries */
114 #undef FIELDOPS /* no bit-field instructions */
115 #undef RTOLBYTES /* bytes are numbered left to right */
117 #define ENUMSIZE(high,low) INT /* enums are always stored in full int */
119 /* Definitions mostly used in pass2 */
121 #define BYTEOFF(x) ((x)&03)
122 #define wdal(k) (BYTEOFF(k)==0)
123 #define BITOOR(x) ((x)/36) /* bit offset to oreg offset */
125 #define STOARG(p)
126 #define STOFARG(p)
127 #define STOSTARG(p)
128 #define genfcall(a,b) gencall(a,b)
130 #define szty(t) (((t) == DOUBLE || (t) == FLOAT || \
131 (t) == LONGLONG || (t) == ULONGLONG) ? 2 : 1)
133 #define shltype(o, p) \
134 ((o) == REG || (o) == NAME || (o) == ICON || \
135 (o) == OREG || ((o) == UMUL && shumul((p)->n_left, SOREG)))
137 #undef SPECIAL_INTEGERS
140 * Special shapes used in code generation.
142 #define SUSHCON (SPECIAL|6) /* unsigned short constant */
143 #define SNSHCON (SPECIAL|7) /* negative short constant */
144 #define SILDB (SPECIAL|8) /* use ildb here */
147 * Register allocator definitions.
149 * The pdp10 has 16 general-purpose registers, but the two
150 * highest are used as sp and fp. Register 0 has special
151 * constraints in its possible use as index register.
152 * All regs can be used as pairs, named by the lowest number.
153 * In here we call the registers Rn and the pairs XRn, in assembler
154 * just its number prefixed with %.
156 * R1/XR1 are return registers.
158 * R0 is currently not used.
161 #define MAXREGS 29 /* 16 + 13 regs */
162 #define NUMCLASS 2
164 #define R0 00
165 #define R1 01
166 #define R2 02
167 #define R3 03
168 #define R4 04
169 #define R5 05
170 #define R6 06
171 #define R7 07
172 #define R10 010
173 #define R11 011
174 #define R12 012
175 #define R13 013
176 #define R14 014
177 #define R15 015
178 #define R16 016
179 #define R17 017
180 #define FPREG R16 /* frame pointer */
181 #define STKREG R17 /* stack pointer */
184 #define XR0 020
185 #define XR1 021
186 #define XR2 022
187 #define XR3 023
188 #define XR4 024
189 #define XR5 025
190 #define XR6 026
191 #define XR7 027
192 #define XR10 030
193 #define XR11 031
194 #define XR12 032
195 #define XR13 033
196 #define XR14 034
199 #define RSTATUS \
200 0, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \
201 SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \
202 SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, \
203 SAREG|PERMREG, SAREG|PERMREG, 0, 0, \
204 SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, \
205 SBREG, SBREG, SBREG, SBREG, SBREG,
207 #define ROVERLAP \
208 { XR0, -1 }, \
209 { XR0, XR1, -1 }, \
210 { XR1, XR2, -1 }, \
211 { XR2, XR3, -1 }, \
212 { XR3, XR4, -1 }, \
213 { XR4, XR5, -1 }, \
214 { XR5, XR6, -1 }, \
215 { XR6, XR7, -1 }, \
216 { XR7, XR10, -1 }, \
217 { XR10, XR11, -1 }, \
218 { XR11, XR12, -1 }, \
219 { XR12, XR13, -1 }, \
220 { XR13, XR14, -1 }, \
221 { XR14, -1 }, \
222 { -1 }, \
223 { -1 }, \
224 { R0, R1, XR1, -1 }, \
225 { R1, R2, XR0, XR2, -1 }, \
226 { R2, R3, XR1, XR3, -1 }, \
227 { R3, R4, XR2, XR4, -1 }, \
228 { R4, R5, XR3, XR5, -1 }, \
229 { R5, R6, XR4, XR6, -1 }, \
230 { R6, R7, XR5, XR7, -1 }, \
231 { R7, R10, XR6, XR10, -1 }, \
232 { R10, R11, XR7, XR11, -1 }, \
233 { R11, R12, XR10, XR12, -1 }, \
234 { R12, R13, XR11, XR13, -1 }, \
235 { R13, R14, XR12, XR14, -1 }, \
236 { R14, R15, XR13, -1 },
238 /* Return a register class based on the type of the node */
239 #define PCLASS(p) (szty(p->n_type) == 2 ? SBREG : SAREG)
240 #define RETREG(x) (szty(x) == 2 ? XR1 : R1)
241 #define DECRA(x,y) (((x) >> (y*6)) & 63) /* decode encoded regs */
242 #define ENCRD(x) (x) /* Encode dest reg in n_reg */
243 #define ENCRA1(x) ((x) << 6) /* A1 */
244 #define ENCRA2(x) ((x) << 12) /* A2 */
245 #define ENCRA(x,y) ((x) << (6+y*6)) /* encode regs in int */
246 #define GCLASS(x) (x < 16 ? CLASSA : CLASSB)
247 int COLORMAP(int c, int *r);