Home | History | Annotate | Line # | Download | only in m16c
      1 /*	Id: macdefs.h,v 1.26 2015/11/24 17:35:11 ragge Exp 	*/
      2 /*	$NetBSD: macdefs.h,v 1.1.1.5 2016/02/09 20:28:20 plunky Exp $	*/
      3 /*
      4  * Copyright (c) 2003 Anders Magnusson (ragge (at) 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 TARGET_ENDIAN TARGET_LE
    110 
    111 /* Definitions mostly used in pass2 */
    112 
    113 #define BYTEOFF(x)	1
    114 
    115 #define STOARG(p)
    116 #define STOFARG(p)
    117 #define STOSTARG(p)
    118 #define genfcall(a,b)	gencall(a,b)
    119 
    120 #define szty(t) (((t) == LONG || (t) == ULONG || \
    121 	(ISPTR(t) && ISFTN(DECREF(t)))) ? 2 : 1)
    122 
    123 /*
    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
    128  */
    129 
    130 #define R0	0
    131 #define R2	1
    132 #define R1	2
    133 #define R3	3
    134 
    135 #define A0	4
    136 #define A1	5
    137 #define FB	6
    138 #define SP	7
    139 
    140 #define R0H     8
    141 #define R0L     9
    142 #define R1H     10
    143 #define R1L     11
    144 
    145 #define NUMCLASS 4      /* Number of register classes */
    146 
    147 #define RETREG(x)	(x == CHAR || x == UCHAR ? R0L : R0)
    148 
    149 #define FPREG	FB	/* frame pointer */
    150 #define STKREG	SP	/* stack pointer */
    151 
    152 #if 0
    153 #define REGSZ	8	/* Number of registers */
    154 #define MINRVAR R1	/* first register variable */
    155 #define MAXRVAR R2	/* last register variable */
    156 #endif
    157 
    158 #define MAXREGS 12 /* 12 registers */
    159 
    160 #define RSTATUS \
    161 	SAREG|TEMPREG, SAREG|PERMREG, SAREG|TEMPREG, SAREG|PERMREG, \
    162 	SBREG|TEMPREG, SBREG|PERMREG, 0, 0, SCREG, SCREG, SCREG, SCREG,
    163 
    164 #define ROVERLAP \
    165 	{R0H, R0L, -1},\
    166 	{-1},\
    167 	{R1H, R1L, -1},\
    168 	{-1},\
    169 \
    170 	{-1},\
    171 	{-1},\
    172 \
    173 	{-1},\
    174 	{-1},\
    175 \
    176 	{R0, -1},\
    177 	{R0, -1},\
    178 	{R1, -1},\
    179 	{R1, -1},
    180 
    181 #define PCLASS(p) (p->n_type <= UCHAR ? SCREG : ISPTR(p->n_type) ? SBREG:SAREG)
    182 
    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 */
    190 
    191 #define	MYADDEDGE(x, t)
    192 
    193 #ifndef NEW_READER
    194 //#define TAILCALL
    195 #endif
    196 #define	SFTN	(SPECIAL|6)
    197 #define NATIVE_FLOATING_POINT
    198