github.com/rohankumardubey/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/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 Adr Adr; 50 typedef struct Prog Prog; 51 typedef struct Case Case; 52 typedef struct C1 C1; 53 typedef struct Multab Multab; 54 typedef struct Hintab Hintab; 55 typedef struct Var Var; 56 typedef struct Reg Reg; 57 typedef struct Rgn Rgn; 58 59 60 #define R0ISZERO 0 61 62 struct Adr 63 { 64 int32 offset; 65 int32 offset2; 66 double dval; 67 char sval[NSNAME]; 68 Ieee ieee; 69 70 Sym* sym; 71 char type; 72 uchar reg; 73 char name; 74 char etype; 75 }; 76 #define A ((Adr*)0) 77 78 #define INDEXED 9 79 struct Prog 80 { 81 Adr from; 82 Adr to; 83 Prog* link; 84 int32 lineno; 85 char as; 86 uchar reg; 87 uchar scond; 88 }; 89 #define P ((Prog*)0) 90 91 struct Case 92 { 93 Case* link; 94 int32 val; 95 int32 label; 96 char def; 97 char isv; 98 }; 99 #define C ((Case*)0) 100 101 struct C1 102 { 103 int32 val; 104 int32 label; 105 }; 106 107 struct Multab 108 { 109 int32 val; 110 char code[20]; 111 }; 112 113 struct Hintab 114 { 115 ushort val; 116 char hint[10]; 117 }; 118 119 struct Var 120 { 121 int32 offset; 122 Sym* sym; 123 char name; 124 char etype; 125 }; 126 127 struct Reg 128 { 129 int32 pc; 130 int32 rpo; /* reverse post ordering */ 131 132 Bits set; 133 Bits use1; 134 Bits use2; 135 136 Bits refbehind; 137 Bits refahead; 138 Bits calbehind; 139 Bits calahead; 140 Bits regdiff; 141 Bits act; 142 143 int32 regu; 144 int32 loop; /* could be shorter */ 145 146 147 Reg* log5; 148 int32 active; 149 150 Reg* p1; 151 Reg* p2; 152 Reg* p2link; 153 Reg* s1; 154 Reg* s2; 155 Reg* link; 156 Prog* prog; 157 }; 158 #define R ((Reg*)0) 159 160 #define NRGN 600 161 struct Rgn 162 { 163 Reg* enter; 164 short cost; 165 short varno; 166 short regno; 167 }; 168 169 EXTERN int32 breakpc; 170 EXTERN int32 nbreak; 171 EXTERN Case* cases; 172 EXTERN Node constnode; 173 EXTERN Node fconstnode; 174 EXTERN int32 continpc; 175 EXTERN int32 curarg; 176 EXTERN int32 cursafe; 177 EXTERN Prog* firstp; 178 EXTERN int32 isbigendian; 179 EXTERN Prog* lastp; 180 EXTERN int32 maxargsafe; 181 EXTERN int mnstring; 182 EXTERN Multab multab[20]; 183 EXTERN int retok; 184 extern int hintabsize; 185 EXTERN Node* nodrat; 186 EXTERN Node* nodret; 187 EXTERN Node* nodsafe; 188 EXTERN int32 nrathole; 189 EXTERN int32 nstring; 190 EXTERN Prog* p; 191 EXTERN int32 pc; 192 EXTERN Node regnode; 193 EXTERN char string[NSNAME]; 194 EXTERN Sym* symrathole; 195 EXTERN Node znode; 196 EXTERN Prog zprog; 197 EXTERN char reg[NREG+NFREG]; 198 EXTERN int32 exregoffset; 199 EXTERN int32 exfregoffset; 200 EXTERN int suppress; 201 202 #define BLOAD(r) band(bnot(r->refbehind), r->refahead) 203 #define BSTORE(r) band(bnot(r->calbehind), r->calahead) 204 #define LOAD(r) (~r->refbehind.b[z] & r->refahead.b[z]) 205 #define STORE(r) (~r->calbehind.b[z] & r->calahead.b[z]) 206 207 #define bset(a,n) ((a).b[(n)/32]&(1L<<(n)%32)) 208 209 #define CLOAD 4 210 #define CREF 5 211 #define CINF 1000 212 #define LOOP 3 213 214 EXTERN Rgn region[NRGN]; 215 EXTERN Rgn* rgp; 216 EXTERN int nregion; 217 EXTERN int nvar; 218 219 EXTERN Bits externs; 220 EXTERN Bits params; 221 EXTERN Bits consts; 222 EXTERN Bits addrs; 223 224 EXTERN int32 regbits; 225 EXTERN int32 exregbits; 226 227 EXTERN int change; 228 229 EXTERN Reg* firstr; 230 EXTERN Reg* lastr; 231 EXTERN Reg zreg; 232 EXTERN Reg* freer; 233 EXTERN Var var[NVAR]; 234 EXTERN int32* idom; 235 EXTERN Reg** rpo2r; 236 EXTERN int32 maxnr; 237 238 extern char* anames[]; 239 extern Hintab hintab[]; 240 241 /* 242 * sgen.c 243 */ 244 void codgen(Node*, Node*); 245 void gen(Node*); 246 void noretval(int); 247 void usedset(Node*, int); 248 void xcom(Node*); 249 int bcomplex(Node*, Node*); 250 Prog* gtext(Sym*, int32); 251 vlong argsize(void); 252 253 /* 254 * cgen.c 255 */ 256 void cgen(Node*, Node*); 257 void reglcgen(Node*, Node*, Node*); 258 void lcgen(Node*, Node*); 259 void bcgen(Node*, int); 260 void boolgen(Node*, int, Node*); 261 void sugen(Node*, Node*, int32); 262 void layout(Node*, Node*, int, int, Node*); 263 void cgenrel(Node*, Node*); 264 265 /* 266 * txt.c 267 */ 268 void ginit(void); 269 void gclean(void); 270 void nextpc(void); 271 void gargs(Node*, Node*, Node*); 272 void garg1(Node*, Node*, Node*, int, Node**); 273 Node* nodconst(int32); 274 Node* nod32const(vlong); 275 Node* nodfconst(double); 276 void nodreg(Node*, Node*, int); 277 void regret(Node*, Node*); 278 int tmpreg(void); 279 void regalloc(Node*, Node*, Node*); 280 void regfree(Node*); 281 void regialloc(Node*, Node*, Node*); 282 void regsalloc(Node*, Node*); 283 void regaalloc1(Node*, Node*); 284 void regaalloc(Node*, Node*); 285 void regind(Node*, Node*); 286 void gprep(Node*, Node*); 287 void raddr(Node*, Prog*); 288 void naddr(Node*, Adr*); 289 void gmovm(Node*, Node*, int); 290 void gmove(Node*, Node*); 291 void gmover(Node*, Node*); 292 void gins(int a, Node*, Node*); 293 void gopcode(int, Node*, Node*, Node*); 294 int samaddr(Node*, Node*); 295 void gbranch(int); 296 void patch(Prog*, int32); 297 int sconst(Node*); 298 int sval(int32); 299 void gpseudo(int, Sym*, Node*); 300 void gprefetch(Node*); 301 void gpcdata(int, int); 302 303 /* 304 * swt.c 305 */ 306 int swcmp(const void*, const void*); 307 void doswit(Node*); 308 void swit1(C1*, int, int32, Node*); 309 void swit2(C1*, int, int32, Node*); 310 void newcase(void); 311 void bitload(Node*, Node*, Node*, Node*, Node*); 312 void bitstore(Node*, Node*, Node*, Node*, Node*); 313 int mulcon(Node*, Node*); 314 Multab* mulcon0(int32); 315 void nullwarn(Node*, Node*); 316 void outcode(void); 317 void ieeedtod(Ieee*, double); 318 319 /* 320 * list 321 */ 322 void listinit(void); 323 int Pconv(Fmt*); 324 int Aconv(Fmt*); 325 int Dconv(Fmt*); 326 int Sconv(Fmt*); 327 int Nconv(Fmt*); 328 int Bconv(Fmt*); 329 int Rconv(Fmt*); 330 331 /* 332 * reg.c 333 */ 334 Reg* rega(void); 335 int rcmp(const void*, const void*); 336 void regopt(Prog*); 337 void addmove(Reg*, int, int, int); 338 Bits mkvar(Adr*, int); 339 void prop(Reg*, Bits, Bits); 340 void loopit(Reg*, int32); 341 void synch(Reg*, Bits); 342 uint32 allreg(uint32, Rgn*); 343 void paint1(Reg*, int); 344 uint32 paint2(Reg*, int); 345 void paint3(Reg*, int, int32, int); 346 void addreg(Adr*, int); 347 348 /* 349 * peep.c 350 */ 351 void peep(void); 352 void excise(Reg*); 353 Reg* uniqp(Reg*); 354 Reg* uniqs(Reg*); 355 int regtyp(Adr*); 356 int regzer(Adr*); 357 int anyvar(Adr*); 358 int subprop(Reg*); 359 int copyprop(Reg*); 360 int shiftprop(Reg*); 361 void constprop(Adr*, Adr*, Reg*); 362 int copy1(Adr*, Adr*, Reg*, int); 363 int copyu(Prog*, Adr*, Adr*); 364 365 int copyas(Adr*, Adr*); 366 int copyau(Adr*, Adr*); 367 int copyau1(Prog*, Adr*); 368 int copysub(Adr*, Adr*, Adr*, int); 369 int copysub1(Prog*, Adr*, Adr*, int); 370 371 int32 RtoB(int); 372 int32 FtoB(int); 373 int BtoR(int32); 374 int BtoF(int32); 375 376 void predicate(void); 377 int isbranch(Prog *); 378 int predicable(Prog *p); 379 int modifiescpsr(Prog *p); 380 381 #pragma varargck type "A" int 382 #pragma varargck type "B" Bits 383 #pragma varargck type "D" Adr* 384 #pragma varargck type "N" Adr* 385 #pragma varargck type "R" Adr* 386 #pragma varargck type "P" Prog* 387 #pragma varargck type "S" char*