Quick Search:

Mode

Context

Displaying the whole file. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.26
 
1.27
 
MAIN:ragge:20121228160249
 
macdefs.h
_>11 /*      $Id$    */
 22 /*
 33  * Copyright (c) 2008 Michael Shalayeff
 44  * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
 55  * All rights reserved.
 66  *
 77  * Redistribution and use in source and binary forms, with or without
 88  * modification, are permitted provided that the following conditions
 99  * are met:
 1010  * 1. Redistributions of source code must retain the above copyright
 1111  *    notice, this list of conditions and the following disclaimer.
 1212  * 2. Redistributions in binary form must reproduce the above copyright
 1313  *    notice, this list of conditions and the following disclaimer in the
 1414  *    documentation and/or other materials provided with the distribution.
 1515  * 3. The name of the author may not be used to endorse or promote products
 1616  *    derived from this software without specific prior written permission
 1717  *
 1818  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 1919  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 2020  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 2121  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 2222  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 2323  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 2424  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 2525  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 2626  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 2727  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 2828  */
 2929 
 3030 /*
 3131  * Machine-dependent defines for both passes.
 3232  */
 3333 
 3434 /*
 3535  * Convert (multi-)character constant to integer.
 3636  */
 3737 #define makecc(val,i)   lastcon = (lastcon<<8)|((val<<24)>>24);
 3838 
 3939 #define ARGINIT         128     /* # bits above fp where arguments start */
 4040 #define AUTOINIT        0       /* # bits below fp where automatics start */
 4141 
 4242 /*
 4343  * Storage space requirements
 4444  */
 4545 #define SZCHAR          8
 4646 #define SZBOOL          8
 4747 #define SZSHORT         16
 4848 #define SZINT           32
 4949 #define SZLONG          64
 5050 #define SZPOINT(t)      64
 5151 #define SZLONGLONG      64
 5252 #define SZFLOAT         32
 5353 #define SZDOUBLE        64
 5454 #define SZLDOUBLE       128
 5555 
 5656 /*
 5757  * Alignment constraints
 5858  */
 5959 #define ALCHAR          8
 6060 #define ALBOOL          8
 6161 #define ALSHORT         16
 6262 #define ALINT           32
 6363 #define ALLONG          64
 6464 #define ALPOINT         64
 6565 #define ALLONGLONG      64
 6666 #define ALFLOAT         32
 6767 #define ALDOUBLE        64
 6868 #define ALLDOUBLE       128
 6969 /* #undef ALSTRUCT      amd64 struct alignment is member defined */
 7070 #define ALSTACK         64
 7171 #define ALMAX           128
 7272 
 7373 /*
 7474  * Min/max values.
 7575  */
 7676 #define MIN_CHAR        -128
 7777 #define MAX_CHAR        127
 7878 #define MAX_UCHAR       255
 7979 #define MIN_SHORT       -32768
 8080 #define MAX_SHORT       32767
 8181 #define MAX_USHORT      65535
 8282 #define MIN_INT         (-0x7fffffff-1)
 8383 #define MAX_INT         0x7fffffff
 8484 #define MAX_UNSIGNED    0xffffffffU
 8585 #define MIN_LONG        0x8000000000000000LL
 8686 #define MAX_LONG        0x7fffffffffffffffLL
 8787 #define MAX_ULONG       0xffffffffffffffffULL
 8888 #define MIN_LONGLONG    0x8000000000000000LL
 8989 #define MAX_LONGLONG    0x7fffffffffffffffLL
 9090 #define MAX_ULONGLONG   0xffffffffffffffffULL
 9191 
 9292 /* Default char is signed */
 9393 #undef  CHAR_UNSIGNED
 9494 #define BOOL_TYPE       UCHAR   /* what used to store _Bool */
 9595 
 9696 /*
 9797  * Use large-enough types.
 9898  */
 9999 typedef long long CONSZ;
 100100 typedef unsigned long long U_CONSZ;
 101101 typedef long long OFFSZ;
 102102 
 103103 #define CONFMT  "%lld"          /* format for printing constants */
 104104 #define LABFMT  ".L%d"          /* format for printing labels */
 105105 #define STABLBL ".LL%d"         /* format for stab (debugging) labels */
 106106 #ifdef LANG_F77
 107107 #define BLANKCOMMON "_BLNK_"
 108108 #define MSKIREG  (M(TYSHORT)|M(TYLONG))
 109109 #define TYIREG TYLONG
 110110 #define FSZLENG  FSZLONG
 111111 #define AUTOREG EBP
 112112 #define ARGREG  EBP
 113113 #define ARGOFFSET 8
 114114 #endif
 115115 
 116116 #define BACKAUTO                /* stack grows negatively for automatics */
 117117 #define BACKTEMP                /* stack grows negatively for temporaries */
 118118 
 119119 #undef  FIELDOPS                /* no bit-field instructions */
 120120 #define TARGET_ENDIAN TARGET_LE /* little-endian only */
 121121 
 122122 #define FINDMOPS        /* i386 has instructions that modifies memory */
 123123 
 124124 #define CC_DIV_0        /* division by zero is safe in the compiler */
 125125 
 126126 /* Definitions mostly used in pass2 */
 127127 
 128128 #define BYTEOFF(x)      ((x)&07)
 129129 #define wdal(k)         (BYTEOFF(k)==0)
 130130 #define BITOOR(x)       (x)     /* bit offset to oreg offset XXX die! */
 131131 
 132132 #define STOARG(p)
 133133 #define STOFARG(p)
 134134 #define STOSTARG(p)
 135135 #define genfcall(a,b)   gencall(a,b)
 136136 
 137137 /* How many integer registers are needed? (used for stack allocation) */
 138138 #define szty(t) (t < LONG || t == FLOAT ? 1 : t == LDOUBLE ? 4 : 2)
 139139 
 140140 /*
 141141  * The amd64 architecture has a much cleaner interface to its registers
 142142  * than the x86, even though a part of the register block comes from
 143143  * the x86 architecture.  Therefore currently only two non-overlapping
 144144  * register classes are used; integer and xmm registers.
 145145  *
 146146  * All registers are given a sequential number to
 147147  * identify it which must match rnames[] in local2.c.
 148148  *
 149149  * The classes used on amd64 are:
 150150  *      A - integer registers
 151151  *      B - xmm registers
 152152  *      C - x87 registers
 153153  */
 154154 #define RAX     000
 155155 #define RDX     001
 156156 #define RCX     002
 157157 #define RBX     003
 158158 #define RSI     004
 159159 #define RDI     005
 160160 #define RBP     006
 161161 #define RSP     007
 162162 #define R08     010
 163163 #define R09     011
 164164 #define R10     012
 165165 #define R11     013
 166166 #define R12     014
 167167 #define R13     015
 168168 #define R14     016
 169169 #define R15     017
 170170 
 171171 #define XMM0    020
 172172 #define XMM1    021
 173173 #define XMM2    022
 174174 #define XMM3    023
 175175 #define XMM4    024
 176176 #define XMM5    025
 177177 #define XMM6    026
 178178 #define XMM7    027
 179179 #define XMM8    030
 180180 #define XMM9    031
 181181 #define XMM10   032
 182182 #define XMM11   033
 183183 #define XMM12   034
 184184 #define XMM13   035
 185185 #define XMM14   036
 186186 #define XMM15   037
 187187 
 188188 #define MAXREGS 050     /* 40 registers */
 189189 
 190190 #define RSTATUS \
 191191         SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|PERMREG,     \
 192192         SAREG|TEMPREG, SAREG|TEMPREG, 0, 0,                             \
 193193         SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG,     \
 194194         SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG,     \
 195195         SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG,     \
 196196         SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG,     \
 197197         SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG,     \
 198198         SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG,     \
 199199         SCREG, SCREG, SCREG, SCREGSCREG, SCREG, SCREG, SCREG,
 200200 
 201201 
 202202 /* no overlapping registers at all */
 203203 #define ROVERLAP \
 204204         { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, \
 205205         { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, \
 206206         { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, \
 207207         { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, \
 208208         { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 },
 209209 
 210210 
 211211 /* Return a register class based on the type of the node */
 212212 #define PCLASS(p) (p->n_type == FLOAT || p->n_type == DOUBLE ? SBREG : \
 213213                    p->n_type == LDOUBLE ? SCREG : SAREG)
 214214 
 215215 #define NUMCLASS        3       /* highest number of reg classes used */
 216216 
 217217 int COLORMAP(int c, int *r);
 218218 #define GCLASS(x) (x < 16 ? CLASSA : x < 32 ? CLASSB : CLASSC)
 219219 #define DECRA(x,y)      (((x) >> (y*8)) & 255)  /* decode encoded regs */
 220220 #define ENCRD(x)        (x)             /* Encode dest reg in n_reg */
 221221 #define ENCRA1(x)       ((x) << 8)      /* A1 */
 222222 #define ENCRA2(x)       ((x) << 16)     /* A2 */
 223223 #define ENCRA(x,y)      ((x) << (8+y*8))        /* encode regs in int */
 224224 
 225225 #define RETREG(x)       (x == FLOAT || x == DOUBLE ? XMM0 : \
 226226                          x == LDOUBLE ? 32 : RAX)
 227227 
 228228 /* XXX - to die */
 229229 #define FPREG   RBP     /* frame pointer */
 230230 #define STKREG  RSP     /* stack pointer */
 231231 
 232232 #define SHSTR           (MAXSPECIAL+1)  /* short struct */
 233233 #define SFUNCALL        (MAXSPECIAL+2)  /* struct assign after function call */
 234234 #define SPCON           (MAXSPECIAL+3)  /* positive nonnamed constant */
 235235 
 236236 /*
 237237  * Specials that indicate the applicability of machine idioms.
 238238  */
 239239 #define SMIXOR          (MAXSPECIAL+4)
 240240 #define SMILWXOR        (MAXSPECIAL+5)
 241241 #define SMIHWXOR        (MAXSPECIAL+6)
 242242 #define SCON32          (MAXSPECIAL+7)  /* 32-bit constant */
 243243 
 244244 /*
 245245  * i386-specific symbol table flags.
 246246  */
 247247 #define SBEENHERE       SLOCAL1
 248248 
 249249 /*
 250250  * Extended assembler macros.
 251251  */
 252252 int xasmconstregs(char *);
 253253 void targarg(char *w, void *arg, int n);
 254254 #define XASM_TARGARG(w, ary)    \
<>255 -        (w[1] == 'b' || w[1] == 'h' || w[1] == 'w' || w[1] == 'k' ? \
 256 -        w++, targarg(w, ary, n), 1 : 0)
  255+        (w[1] == 'b' || w[1] == 'h' || w[1] == 'w' || w[1] == 'k' || \
  256+         w[1] == 'q' ? w++, targarg(w, ary, n), 1 : 0)
<_257257 int numconv(void *ip, void *p, void *q);
 258258 #define XASM_NUMCONV(ip, p, q)  numconv(ip, p, q)
 259259 #define XASMCONSTREGS(x)        xasmconstregs(x)
 260260 
 261261 /*
 262262  * builtins.
 263263  */
 264264 #define TARGET_VALIST
 265265 #define TARGET_STDARGS
 266266 #define TARGET_BUILTINS                                                 \
 267267         { "__builtin_stdarg_start", amd64_builtin_stdarg_start,         \
 268268                                                 0, 2, 0, VOID },        \
 269269         { "__builtin_va_start", amd64_builtin_stdarg_start,             \
 270270                                                 0, 2, 0, VOID },        \
 271271         { "__builtin_va_arg", amd64_builtin_va_arg, BTNORVAL|BTNOPROTO, \
 272272                                                         2, 0, 0 },      \
 273273         { "__builtin_va_end", amd64_builtin_va_end, 0, 1, 0, VOID },    \
 274274         { "__builtin_va_copy", amd64_builtin_va_copy, 0, 2, 0, VOID },
 275275 
 276276 #define NODE struct node
 277277 struct node;
 278278 struct bitable;
 279279 NODE *amd64_builtin_stdarg_start(const struct bitable *, NODE *a);
 280280 NODE *amd64_builtin_va_arg(const struct bitable *, NODE *a);
 281281 NODE *amd64_builtin_va_end(const struct bitable *, NODE *a);
 282282 NODE *amd64_builtin_va_copy(const struct bitable *, NODE *a);
 283283 #undef NODE
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-09-24 00:26 +0200