1 /* Id: macdefs.h,v 1.9 2015/11/24 17:35:12 ragge Exp */ 2 /* $NetBSD: macdefs.h,v 1.1.1.5 2016/02/09 20:28:24 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 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 /* 29 * Machine-dependent defines for Data General Nova. 30 */ 31 32 /* 33 * Convert (multi-)character constant to integer. 34 */ 35 #define makecc(val,i) lastcon = (lastcon<<8)|(val); 36 37 /* 38 * Storage space requirements 39 */ 40 #define SZCHAR 8 41 #define SZBOOL 8 42 #define SZINT 16 43 #define SZFLOAT 32 44 #define SZDOUBLE 64 45 #define SZLDOUBLE 64 46 #define SZLONG 32 47 #define SZSHORT 16 48 #define SZLONGLONG 64 49 #define SZPOINT(t) 16 /* Actually 15 */ 50 51 /* 52 * Alignment constraints 53 */ 54 #define ALCHAR 8 55 #define ALBOOL 8 56 #define ALINT 16 57 #define ALFLOAT 16 58 #define ALDOUBLE 16 59 #define ALLDOUBLE 16 60 #define ALLONG 16 61 #define ALLONGLONG 16 62 #define ALSHORT 16 63 #define ALPOINT 16 64 #define ALSTRUCT 16 65 #define ALSTACK 16 66 67 /* 68 * Min/max values. 69 */ 70 #define MIN_CHAR -128 71 #define MAX_CHAR 127 72 #define MAX_UCHAR 255 73 #define MIN_SHORT -32768 74 #define MAX_SHORT 32767 75 #define MAX_USHORT 65535 76 #define MIN_INT MIN_SHORT 77 #define MAX_INT MAX_SHORT 78 #define MAX_UNSIGNED MAX_USHORT 79 #define MIN_LONG 0x80000000L 80 #define MAX_LONG 0x7fffffffL 81 #define MAX_ULONG 0xffffffffUL 82 #define MIN_LONGLONG 0x8000000000000000LL 83 #define MAX_LONGLONG 0x7fffffffffffffffLL 84 #define MAX_ULONGLONG 0xffffffffffffffffULL 85 86 /* Default char is unsigned */ 87 #define CHAR_UNSIGNED 88 #define WORD_ADDRESSED 89 #define BOOL_TYPE UCHAR 90 #define MYALIGN /* provide private alignment function */ 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 "0%lo" /* format for printing constants */ 100 #define LABFMT "L%d" /* format for printing labels */ 101 #define STABLBL "LL%d" /* format for stab (debugging) labels */ 102 103 #define BACKAUTO /* stack grows negatively for automatics */ 104 #define BACKTEMP /* stack grows negatively for temporaries */ 105 #define ARGINIT 0 /* first arg at 0 offset */ 106 #define AUTOINIT 32 /* first var below 32-bit offset */ 107 108 109 #undef FIELDOPS /* no bit-field instructions */ 110 #define TARGET_ENDIAN TARGET_BE 111 112 /* Definitions mostly used in pass2 */ 113 114 #define BYTEOFF(x) ((x)&01) 115 #define wdal(k) (BYTEOFF(k)==0) 116 117 #define szty(t) ((t) == DOUBLE || (t) == LDOUBLE || \ 118 (t) == LONGLONG || (t) == ULONGLONG ? 4 : \ 119 ((t) == LONG || (t) == ULONG || (t) == FLOAT) ? 2 : 1) 120 121 /* 122 * The Nova has two register classes. Note that the space used in 123 * zero page is considered stack. 124 * Register 6 and 7 are FP and SP (in zero page). 125 * 126 * The classes used on Nova are: 127 * A - AC0-AC3 (as non-index registers) : reg 0-3 128 * B - AC2-AC3 (as index registers) : reg 4-5 129 * FP/SP as 6/7. 130 */ 131 #define MAXREGS 8 /* 0-29 */ 132 133 #define RSTATUS \ 134 SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \ 135 SBREG|TEMPREG, SBREG|TEMPREG, 0, 0 136 137 #define ROVERLAP \ 138 { -1 }, { -1 }, { 4, -1 }, { 5, -1 }, { 2, -1 }, { 3, -1 }, \ 139 { -1 }, { -1 } 140 141 /* Return a register class based on the type of the node */ 142 /* Used in tshape, avoid matching fp/sp as reg */ 143 #define PCLASS(p) (p->n_op == REG && regno(p) > 5 ? 0 : \ 144 ISPTR(p->n_type) ? SBREG : SAREG) 145 146 #define NUMCLASS 2 /* highest number of reg classes used */ 147 148 int COLORMAP(int c, int *r); 149 #define GCLASS(x) (x < 4 ? CLASSA : CLASSB) 150 #define DECRA(x,y) (((x) >> (y*6)) & 63) /* decode encoded regs */ 151 #define ENCRD(x) (x) /* Encode dest reg in n_reg */ 152 #define ENCRA1(x) ((x) << 6) /* A1 */ 153 #define ENCRA2(x) ((x) << 12) /* A2 */ 154 #define ENCRA(x,y) ((x) << (6+y*6)) /* encode regs in int */ 155 #define RETREG(x) (0) /* ? Sanity */ 156 157 #define FPREG 6 /* frame pointer */ 158 #define STKREG 7 /* stack pointer */ 159 160 #define MAXZP 030 /* number of locations used as stack */ 161 #define ZPOFF 050 /* offset of zero page regs */ 162 163 #define MYSTOREMOD 164 #define MYLONGTEMP(p,w) { \ 165 if (w->r_class == 0) { \ 166 w->r_color = freetemp(szty(p->n_type)); \ 167 w->r_class = FPREG; \ 168 } \ 169 if (w->r_color < MAXZP*2) { /* color in bytes */ \ 170 p->n_op = NAME; \ 171 p->n_lval = w->r_color/2 + ZPOFF; \ 172 p->n_name = ""; \ 173 break; \ 174 } \ 175 } 176 177 /* 178 * special shapes for sp/fp. 179 */ 180 #define SLDFPSP (MAXSPECIAL+1) /* load fp or sp */ 181 #define NATIVE_FLOATING_POINT 182