github.com/ader1990/go@v0.0.0-20140630135419-8c24447fa791/src/cmd/5c/gc.h (about) 1 // Inferno utils/5c/gc.h 2 // http://code.google.com/p/inferno-os/source/browse/utils/5c/gc.h 3 // 4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. 5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) 6 // Portions Copyright © 1997-1999 Vita Nuova Limited 7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com) 8 // Portions Copyright © 2004,2006 Bruce Ellis 9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) 10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others 11 // Portions Copyright © 2009 The Go Authors. All rights reserved. 12 // 13 // Permission is hereby granted, free of charge, to any person obtaining a copy 14 // of this software and associated documentation files (the "Software"), to deal 15 // in the Software without restriction, including without limitation the rights 16 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 // copies of the Software, and to permit persons to whom the Software is 18 // furnished to do so, subject to the following conditions: 19 // 20 // The above copyright notice and this permission notice shall be included in 21 // all copies or substantial portions of the Software. 22 // 23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 // THE SOFTWARE. 30 31 #include <u.h> 32 #include "../cc/cc.h" 33 #include "../5l/5.out.h" 34 35 /* 36 * 5c/arm 37 * Arm 7500 38 */ 39 #define SZ_CHAR 1 40 #define SZ_SHORT 2 41 #define SZ_INT 4 42 #define SZ_LONG 4 43 #define SZ_IND 4 44 #define SZ_FLOAT 4 45 #define SZ_VLONG 8 46 #define SZ_DOUBLE 8 47 #define FNX 100 48 49 typedef struct Case Case; 50 typedef struct C1 C1; 51 typedef struct Multab Multab; 52 typedef struct Hintab Hintab; 53 typedef struct Reg Reg; 54 typedef struct Rgn Rgn; 55 56 57 #define R0ISZERO 0 58 59 #define A ((Addr*)0) 60 61 #define INDEXED 9 62 #define P ((Prog*)0) 63 64 struct Case 65 { 66 Case* link; 67 int32 val; 68 int32 label; 69 char def; 70 char isv; 71 }; 72 #define C ((Case*)0) 73 74 struct C1 75 { 76 int32 val; 77 int32 label; 78 }; 79 80 struct Multab 81 { 82 int32 val; 83 char code[20]; 84 }; 85 86 struct Hintab 87 { 88 ushort val; 89 char hint[10]; 90 }; 91 92 struct Reg 93 { 94 int32 pc; 95 int32 rpo; /* reverse post ordering */ 96 97 Bits set; 98 Bits use1; 99 Bits use2; 100 101 Bits refbehind; 102 Bits refahead; 103 Bits calbehind; 104 Bits calahead; 105 Bits regdiff; 106 Bits act; 107 108 int32 regu; 109 int32 loop; /* could be shorter */ 110 111 112 Reg* log5; 113 int32 active; 114 115 Reg* p1; 116 Reg* p2; 117 Reg* p2link; 118 Reg* s1; 119 Reg* s2; 120 Reg* link; 121 Prog* prog; 122 }; 123 #define R ((Reg*)0) 124 125 #define NRGN 600 126 struct Rgn 127 { 128 Reg* enter; 129 short cost; 130 short varno; 131 short regno; 132 }; 133 134 EXTERN int32 breakpc; 135 EXTERN int32 nbreak; 136 EXTERN Case* cases; 137 EXTERN Node constnode; 138 EXTERN Node fconstnode; 139 EXTERN int32 continpc; 140 EXTERN int32 curarg; 141 EXTERN int32 cursafe; 142 EXTERN int32 isbigendian; 143 EXTERN Prog* lastp; 144 EXTERN int32 maxargsafe; 145 EXTERN int mnstring; 146 EXTERN Multab multab[20]; 147 EXTERN int retok; 148 extern int hintabsize; 149 EXTERN Node* nodrat; 150 EXTERN Node* nodret; 151 EXTERN Node* nodsafe; 152 EXTERN int32 nrathole; 153 EXTERN int32 nstring; 154 EXTERN Prog* p; 155 EXTERN int32 pc; 156 EXTERN Node regnode; 157 EXTERN char string[NSNAME]; 158 EXTERN Sym* symrathole; 159 EXTERN Node znode; 160 EXTERN Prog zprog; 161 EXTERN char reg[NREG+NFREG]; 162 EXTERN int32 exregoffset; 163 EXTERN int32 exfregoffset; 164 EXTERN int suppress; 165 166 #define BLOAD(r) band(bnot(r->refbehind), r->refahead) 167 #define BSTORE(r) band(bnot(r->calbehind), r->calahead) 168 #define LOAD(r) (~r->refbehind.b[z] & r->refahead.b[z]) 169 #define STORE(r) (~r->calbehind.b[z] & r->calahead.b[z]) 170 171 #define bset(a,n) ((a).b[(n)/32]&(1L<<(n)%32)) 172 173 #define CLOAD 4 174 #define CREF 5 175 #define CINF 1000 176 #define LOOP 3 177 178 EXTERN Rgn region[NRGN]; 179 EXTERN Rgn* rgp; 180 EXTERN int nregion; 181 EXTERN int nvar; 182 183 EXTERN Bits externs; 184 EXTERN Bits params; 185 EXTERN Bits consts; 186 EXTERN Bits addrs; 187 188 EXTERN int32 regbits; 189 EXTERN int32 exregbits; 190 191 EXTERN int change; 192 193 EXTERN Reg* firstr; 194 EXTERN Reg* lastr; 195 EXTERN Reg zreg; 196 EXTERN Reg* freer; 197 EXTERN int32* idom; 198 EXTERN Reg** rpo2r; 199 EXTERN int32 maxnr; 200 201 extern char* anames[]; 202 extern Hintab hintab[]; 203 204 /* 205 * sgen.c 206 */ 207 void codgen(Node*, Node*); 208 void gen(Node*); 209 void noretval(int); 210 void usedset(Node*, int); 211 void xcom(Node*); 212 int bcomplex(Node*, Node*); 213 Prog* gtext(Sym*, int32); 214 vlong argsize(void); 215 216 /* 217 * cgen.c 218 */ 219 void cgen(Node*, Node*); 220 void reglcgen(Node*, Node*, Node*); 221 void lcgen(Node*, Node*); 222 void bcgen(Node*, int); 223 void boolgen(Node*, int, Node*); 224 void sugen(Node*, Node*, int32); 225 void layout(Node*, Node*, int, int, Node*); 226 void cgenrel(Node*, Node*); 227 228 /* 229 * txt.c 230 */ 231 void ginit(void); 232 void gclean(void); 233 void nextpc(void); 234 void gargs(Node*, Node*, Node*); 235 void garg1(Node*, Node*, Node*, int, Node**); 236 Node* nodconst(int32); 237 Node* nod32const(vlong); 238 Node* nodfconst(double); 239 void nodreg(Node*, Node*, int); 240 void regret(Node*, Node*); 241 int tmpreg(void); 242 void regalloc(Node*, Node*, Node*); 243 void regfree(Node*); 244 void regialloc(Node*, Node*, Node*); 245 void regsalloc(Node*, Node*); 246 void regaalloc1(Node*, Node*); 247 void regaalloc(Node*, Node*); 248 void regind(Node*, Node*); 249 void gprep(Node*, Node*); 250 void raddr(Node*, Prog*); 251 void naddr(Node*, Addr*); 252 void gmovm(Node*, Node*, int); 253 void gmove(Node*, Node*); 254 void gmover(Node*, Node*); 255 void gins(int a, Node*, Node*); 256 void gopcode(int, Node*, Node*, Node*); 257 int samaddr(Node*, Node*); 258 void gbranch(int); 259 void patch(Prog*, int32); 260 int sconst(Node*); 261 int sval(int32); 262 void gpseudo(int, Sym*, Node*); 263 void gprefetch(Node*); 264 void gpcdata(int, int); 265 266 /* 267 * swt.c 268 */ 269 int swcmp(const void*, const void*); 270 void doswit(Node*); 271 void swit1(C1*, int, int32, Node*); 272 void swit2(C1*, int, int32, Node*); 273 void newcase(void); 274 void bitload(Node*, Node*, Node*, Node*, Node*); 275 void bitstore(Node*, Node*, Node*, Node*, Node*); 276 int mulcon(Node*, Node*); 277 Multab* mulcon0(int32); 278 void nullwarn(Node*, Node*); 279 void outcode(void); 280 281 /* 282 * list 283 */ 284 void listinit(void); 285 286 /* 287 * reg.c 288 */ 289 Reg* rega(void); 290 int rcmp(const void*, const void*); 291 void regopt(Prog*); 292 void addmove(Reg*, int, int, int); 293 Bits mkvar(Addr*, int); 294 void prop(Reg*, Bits, Bits); 295 void loopit(Reg*, int32); 296 void synch(Reg*, Bits); 297 uint32 allreg(uint32, Rgn*); 298 void paint1(Reg*, int); 299 uint32 paint2(Reg*, int); 300 void paint3(Reg*, int, int32, int); 301 void addreg(Addr*, int); 302 303 /* 304 * peep.c 305 */ 306 void peep(void); 307 void excise(Reg*); 308 Reg* uniqp(Reg*); 309 Reg* uniqs(Reg*); 310 int regtyp(Addr*); 311 int regzer(Addr*); 312 int anyvar(Addr*); 313 int subprop(Reg*); 314 int copyprop(Reg*); 315 int shiftprop(Reg*); 316 void constprop(Addr*, Addr*, Reg*); 317 int copy1(Addr*, Addr*, Reg*, int); 318 int copyu(Prog*, Addr*, Addr*); 319 320 int copyas(Addr*, Addr*); 321 int copyau(Addr*, Addr*); 322 int copyau1(Prog*, Addr*); 323 int copysub(Addr*, Addr*, Addr*, int); 324 int copysub1(Prog*, Addr*, Addr*, int); 325 326 int32 RtoB(int); 327 int32 FtoB(int); 328 int BtoR(int32); 329 int BtoF(int32); 330 331 void predicate(void); 332 int isbranch(Prog *); 333 int predicable(Prog *p); 334 int modifiescpsr(Prog *p);