1
/* $Id: macdefs.h,v 1.23 2007/11/16 22:23:04 gmcgarry Exp $ */
3
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions
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.
32
#define makecc(val,i) lastcon = (lastcon<<8)|((val<<8)>>8);
34
#define ARGINIT 40 /* # bits above fp where arguments start */
35
#define AUTOINIT 0 /* # bits below fp where automatics start */
38
* Convert (multi-)character constant to integer.
39
* Assume: If only one value; store at left side (char size), otherwise
40
* treat it as an integer.
44
* Storage space requirements
54
/* pointers are of different sizes on m16c */
55
#define SZPOINT(t) (ISFTN(DECREF(t)) ? 32 : 16)
58
* Alignment constraints
78
#define MIN_SHORT -32768
79
#define MAX_SHORT 32767
80
#define MAX_USHORT 65535
81
#define MIN_INT -32768
83
#define MAX_UNSIGNED 65535
84
#define MIN_LONG -2147483648
85
#define MAX_LONG 2147483647
86
#define MAX_ULONG 4294967295UL
87
#define MIN_LONGLONG -2147483648
88
#define MAX_LONGLONG 2147483647
89
#define MAX_ULONGLONG 4294967295UL
91
/* Default char is unsigned */
95
* Use large-enough types.
97
typedef long long CONSZ;
98
typedef unsigned long long U_CONSZ;
99
typedef long long OFFSZ;
101
#define CONFMT "%lld" /* format for printing constants */
102
#define LABFMT "L%d" /* format for printing labels */
104
#define BACKAUTO /* stack grows negatively for automatics */
105
#define BACKTEMP /* stack grows negatively for temporaries */
107
#undef FIELDOPS /* no bit-field instructions */
108
#define RTOLBYTES /* bytes are numbered right to left */
110
/* Definitions mostly used in pass2 */
113
#define BITOOR(x) ((x)/SZCHAR) /* bit offset to oreg offset */
118
#define genfcall(a,b) gencall(a,b)
120
#define szty(t) (((t) == LONG || (t) == ULONG || \
121
(ISPTR(t) && ISFTN(DECREF(t)))) ? 2 : 1)
124
* m16c register classes:
125
* A - 16-bit data registers R0-R3
126
* B - 16-bit address registers A0-A1
127
* C - 8-bit data registers R0H, R0L, R1H, R1L
145
#define NUMCLASS 4 /* Number of register classes */
147
#define RETREG(x) (x == CHAR || x == UCHAR ? R0L : R0)
149
#define FPREG FB /* frame pointer */
150
#define STKREG SP /* stack pointer */
153
#define REGSZ 8 /* Number of registers */
154
#define MINRVAR R1 /* first register variable */
155
#define MAXRVAR R2 /* last register variable */
158
#define MAXREGS 12 /* 12 registers */
161
SAREG|TEMPREG, SAREG|PERMREG, SAREG|TEMPREG, SAREG|PERMREG, \
162
SBREG|TEMPREG, SBREG|PERMREG, 0, 0, SCREG, SCREG, SCREG, SCREG,
181
#define PCLASS(p) (p->n_type <= UCHAR ? SCREG : ISPTR(p->n_type) ? SBREG:SAREG)
183
int COLORMAP(int c, int *r);
184
#define GCLASS(x) (x < 4 ? CLASSA : x < 6 ? CLASSB : x < 12 ? CLASSC : CLASSD)
185
#define DECRA(x,y) (((x) >> (y*6)) & 63) /* decode encoded regs */
186
#define ENCRD(x) (x) /* Encode dest reg in n_reg */
187
#define ENCRA1(x) ((x) << 6) /* A1 */
188
#define ENCRA2(x) ((x) << 12) /* A2 */
189
#define ENCRA(x,y) ((x) << (6+y*6)) /* encode regs in int */
191
#define MYADDEDGE(x, t)
196
#define SFTN (SPECIAL|6)