github.com/yanyiwu/go@v0.0.0-20150106053140-03d6637dbb7f/src/cmd/gc/go.h (about) 1 // Copyright 2009 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 #include <bio.h> 6 #include <link.h> 7 8 #undef OAPPEND 9 10 // avoid <ctype.h> 11 #undef isblank 12 #define isblank goisblank 13 14 #ifndef EXTERN 15 #define EXTERN extern 16 #endif 17 18 #undef BUFSIZ 19 20 // The parser's maximum stack size. 21 // We have to use a #define macro here since yacc 22 // or bison will check for its definition and use 23 // a potentially smaller value if it is undefined. 24 #define YYMAXDEPTH 500 25 26 enum 27 { 28 NHUNK = 50000, 29 BUFSIZ = 8192, 30 NSYMB = 500, 31 NHASH = 1024, 32 STRINGSZ = 200, 33 MAXALIGN = 7, 34 UINF = 100, 35 36 PRIME1 = 3, 37 38 AUNK = 100, 39 40 // These values are known by runtime. 41 // The MEMx and NOEQx values must run in parallel. See algtype. 42 AMEM = 0, 43 AMEM0, 44 AMEM8, 45 AMEM16, 46 AMEM32, 47 AMEM64, 48 AMEM128, 49 ANOEQ, 50 ANOEQ0, 51 ANOEQ8, 52 ANOEQ16, 53 ANOEQ32, 54 ANOEQ64, 55 ANOEQ128, 56 ASTRING, 57 AINTER, 58 ANILINTER, 59 ASLICE, 60 AFLOAT32, 61 AFLOAT64, 62 ACPLX64, 63 ACPLX128, 64 65 BADWIDTH = -1000000000, 66 67 MaxStackVarSize = 10*1024*1024, 68 }; 69 70 extern vlong MAXWIDTH; 71 72 /* 73 * note this is the representation 74 * of the compilers string literals, 75 * it is not the runtime representation 76 */ 77 typedef struct Strlit Strlit; 78 struct Strlit 79 { 80 int32 len; 81 char s[1]; // variable 82 }; 83 84 enum 85 { 86 Mpscale = 29, // safely smaller than bits in a long 87 Mpprec = 16, // Mpscale*Mpprec is max number of bits 88 Mpnorm = Mpprec - 1, // significant words in a normalized float 89 Mpbase = 1L << Mpscale, 90 Mpsign = Mpbase >> 1, 91 Mpmask = Mpbase - 1, 92 Mpdebug = 0, 93 }; 94 95 typedef struct Mpint Mpint; 96 struct Mpint 97 { 98 long a[Mpprec]; 99 uchar neg; 100 uchar ovf; 101 }; 102 103 typedef struct Mpflt Mpflt; 104 struct Mpflt 105 { 106 Mpint val; 107 short exp; 108 }; 109 110 typedef struct Mpcplx Mpcplx; 111 struct Mpcplx 112 { 113 Mpflt real; 114 Mpflt imag; 115 }; 116 117 typedef struct Val Val; 118 struct Val 119 { 120 short ctype; 121 union 122 { 123 short reg; // OREGISTER 124 short bval; // bool value CTBOOL 125 Mpint* xval; // int CTINT, rune CTRUNE 126 Mpflt* fval; // float CTFLT 127 Mpcplx* cval; // float CTCPLX 128 Strlit* sval; // string CTSTR 129 } u; 130 }; 131 132 // prevent incompatible type signatures between libgc and 8g on Plan 9 133 #pragma incomplete struct Array 134 135 typedef struct Array Array; 136 typedef struct Bvec Bvec; 137 typedef struct Pkg Pkg; 138 typedef struct Sym Sym; 139 typedef struct Node Node; 140 typedef struct NodeList NodeList; 141 typedef struct Type Type; 142 typedef struct Label Label; 143 144 struct Type 145 { 146 uchar etype; 147 uchar nointerface; 148 uchar noalg; 149 uchar chan; 150 uchar trecur; // to detect loops 151 uchar printed; 152 uchar embedded; // TFIELD embedded type 153 uchar siggen; 154 uchar funarg; // on TSTRUCT and TFIELD 155 uchar copyany; 156 uchar local; // created in this file 157 uchar deferwidth; 158 uchar broke; // broken type definition. 159 uchar isddd; // TFIELD is ... argument 160 uchar align; 161 uchar haspointers; // 0 unknown, 1 no, 2 yes 162 163 Node* nod; // canonical OTYPE node 164 Type* orig; // original type (type literal or predefined type) 165 int lineno; 166 167 // TFUNC 168 int thistuple; 169 int outtuple; 170 int intuple; 171 uchar outnamed; 172 173 Type* method; 174 Type* xmethod; 175 176 Sym* sym; 177 int32 vargen; // unique name for OTYPE/ONAME 178 179 Node* nname; 180 vlong argwid; 181 182 // most nodes 183 Type* type; // actual type for TFIELD, element type for TARRAY, TCHAN, TMAP, TPTRxx 184 vlong width; // offset in TFIELD, width in all others 185 186 // TFIELD 187 Type* down; // next struct field, also key type in TMAP 188 Type* outer; // outer struct 189 Strlit* note; // literal string annotation 190 191 // TARRAY 192 vlong bound; // negative is dynamic array 193 194 // TMAP 195 Type* bucket; // internal type representing a hash bucket 196 Type* hmap; // internal type representing a Hmap (map header object) 197 Type* hiter; // internal type representing hash iterator state 198 Type* map; // link from the above 3 internal types back to the map type. 199 200 int32 maplineno; // first use of TFORW as map key 201 int32 embedlineno; // first use of TFORW as embedded type 202 203 // for TFORW, where to copy the eventual value to 204 NodeList *copyto; 205 206 Node *lastfn; // for usefield 207 }; 208 #define T ((Type*)0) 209 210 typedef struct InitEntry InitEntry; 211 typedef struct InitPlan InitPlan; 212 213 struct InitEntry 214 { 215 vlong xoffset; // struct, array only 216 Node *key; // map only 217 Node *expr; 218 }; 219 220 struct InitPlan 221 { 222 vlong lit; // bytes of initialized non-zero literals 223 vlong zero; // bytes of zeros 224 vlong expr; // bytes of run-time computed expressions 225 226 InitEntry *e; 227 int len; 228 int cap; 229 }; 230 231 enum 232 { 233 EscUnknown, 234 EscHeap, 235 EscScope, 236 EscNone, 237 EscReturn, 238 EscNever, 239 EscBits = 3, 240 EscMask = (1<<EscBits) - 1, 241 EscContentEscapes = 1<<EscBits, // value obtained by indirect of parameter escapes to some returned result 242 EscReturnBits = EscBits+1, 243 }; 244 245 struct Node 246 { 247 // Tree structure. 248 // Generic recursive walks should follow these fields. 249 Node* left; 250 Node* right; 251 Node* ntest; 252 Node* nincr; 253 NodeList* ninit; 254 NodeList* nbody; 255 NodeList* nelse; 256 NodeList* list; 257 NodeList* rlist; 258 259 uchar op; 260 uchar nointerface; 261 uchar ullman; // sethi/ullman number 262 uchar addable; // type of addressability - 0 is not addressable 263 uchar trecur; // to detect loops 264 uchar etype; // op for OASOP, etype for OTYPE, exclam for export 265 uchar bounded; // bounds check unnecessary 266 uchar class; // PPARAM, PAUTO, PEXTERN, etc 267 uchar method; // OCALLMETH name 268 uchar embedded; // ODCLFIELD embedded type 269 uchar colas; // OAS resulting from := 270 uchar diag; // already printed error about this 271 uchar noescape; // func arguments do not escape 272 uchar nosplit; // func should not execute on separate stack 273 uchar builtin; // built-in name, like len or close 274 uchar nowritebarrier; // emit compiler error instead of write barrier 275 uchar walkdef; 276 uchar typecheck; 277 uchar local; 278 uchar dodata; 279 uchar initorder; 280 uchar used; 281 uchar isddd; 282 uchar readonly; 283 uchar implicit; 284 uchar addrtaken; // address taken, even if not moved to heap 285 uchar dupok; // duplicate definitions ok (for func) 286 uchar wrapper; // is method wrapper (for func) 287 uchar reslice; // this is a reslice x = x[0:y] or x = append(x, ...) 288 schar likely; // likeliness of if statement 289 uchar hasbreak; // has break statement 290 uchar needzero; // if it contains pointers, needs to be zeroed on function entry 291 uchar needctxt; // function uses context register (has closure variables) 292 uint esc; // EscXXX 293 int funcdepth; 294 295 // most nodes 296 Type* type; 297 Node* orig; // original form, for printing, and tracking copies of ONAMEs 298 299 // func 300 Node* nname; 301 Node* shortname; 302 NodeList* enter; 303 NodeList* exit; 304 NodeList* cvars; // closure params 305 NodeList* dcl; // autodcl for this func/closure 306 NodeList* inl; // copy of the body for use in inlining 307 NodeList* inldcl; // copy of dcl for use in inlining 308 309 // OLITERAL/OREGISTER 310 Val val; 311 312 // ONAME 313 Node* ntype; 314 Node* defn; // ONAME: initializing assignment; OLABEL: labeled statement 315 Node* pack; // real package for import . names 316 Node* curfn; // function for local variables 317 Type* paramfld; // TFIELD for this PPARAM; also for ODOT, curfn 318 319 // ONAME func param with PHEAP 320 Node* heapaddr; // temp holding heap address of param 321 Node* stackparam; // OPARAM node referring to stack copy of param 322 Node* alloc; // allocation call 323 324 // ONAME closure param with PPARAMREF 325 Node* outer; // outer PPARAMREF in nested closure 326 Node* closure; // ONAME/PHEAP <-> ONAME/PPARAMREF 327 328 // ONAME substitute while inlining 329 Node* inlvar; 330 331 // OPACK 332 Pkg* pkg; 333 334 // OARRAYLIT, OMAPLIT, OSTRUCTLIT. 335 InitPlan* initplan; 336 337 // Escape analysis. 338 NodeList* escflowsrc; // flow(this, src) 339 NodeList* escretval; // on OCALLxxx, list of dummy return values 340 int escloopdepth; // -1: global, 0: return variables, 1:function top level, increased inside function for every loop or label to mark scopes 341 342 Sym* sym; // various 343 int32 vargen; // unique name for OTYPE/ONAME 344 int32 lineno; 345 int32 endlineno; 346 vlong xoffset; 347 vlong stkdelta; // offset added by stack frame compaction phase. 348 int32 ostk; 349 int32 iota; 350 uint32 walkgen; 351 int32 esclevel; 352 void* opt; // for optimization passes 353 }; 354 #define N ((Node*)0) 355 356 /* 357 * Every node has a walkgen field. 358 * If you want to do a traversal of a node graph that 359 * might contain duplicates and want to avoid 360 * visiting the same nodes twice, increment walkgen 361 * before starting. Then before processing a node, do 362 * 363 * if(n->walkgen == walkgen) 364 * return; 365 * n->walkgen = walkgen; 366 * 367 * Such a walk cannot call another such walk recursively, 368 * because of the use of the global walkgen. 369 */ 370 EXTERN uint32 walkgen; 371 372 struct NodeList 373 { 374 Node* n; 375 NodeList* next; 376 NodeList* end; 377 }; 378 379 enum 380 { 381 SymExport = 1<<0, // to be exported 382 SymPackage = 1<<1, 383 SymExported = 1<<2, // already written out by export 384 SymUniq = 1<<3, 385 SymSiggen = 1<<4, 386 SymAsm = 1<<5, 387 }; 388 389 struct Sym 390 { 391 ushort lexical; 392 uchar flags; 393 uchar sym; // huffman encoding in object file 394 Sym* link; 395 int32 npkg; // number of imported packages with this name 396 uint32 uniqgen; 397 Pkg* importdef; // where imported definition was found 398 char* linkname; // link name 399 400 // saved and restored by dcopy 401 Pkg* pkg; 402 char* name; // variable name 403 Node* def; // definition: ONAME OTYPE OPACK or OLITERAL 404 Label* label; // corresponding label (ephemeral) 405 int32 block; // blocknumber to catch redeclaration 406 int32 lastlineno; // last declaration for diagnostic 407 Pkg* origpkg; // original package for . import 408 LSym* lsym; 409 }; 410 #define S ((Sym*)0) 411 412 EXTERN Sym* dclstack; 413 414 struct Pkg 415 { 416 char* name; // package name 417 Strlit* path; // string literal used in import statement 418 Sym* pathsym; 419 char* prefix; // escaped path for use in symbol table 420 Pkg* link; 421 uchar imported; // export data of this package was parsed 422 char exported; // import line written in export data 423 char direct; // imported directly 424 char safe; // whether the package is marked as safe 425 }; 426 427 typedef struct Iter Iter; 428 struct Iter 429 { 430 int done; 431 Type* tfunc; 432 Type* t; 433 Node** an; 434 Node* n; 435 }; 436 437 // Node ops. 438 enum 439 { 440 OXXX, 441 442 // names 443 ONAME, // var, const or func name 444 ONONAME, // unnamed arg or return value: f(int, string) (int, error) { etc } 445 OTYPE, // type name 446 OPACK, // import 447 OLITERAL, // literal 448 449 // expressions 450 OADD, // x + y 451 OSUB, // x - y 452 OOR, // x | y 453 OXOR, // x ^ y 454 OADDSTR, // s + "foo" 455 OADDR, // &x 456 OANDAND, // b0 && b1 457 OAPPEND, // append 458 OARRAYBYTESTR, // string(bytes) 459 OARRAYBYTESTRTMP, // string(bytes) ephemeral 460 OARRAYRUNESTR, // string(runes) 461 OSTRARRAYBYTE, // []byte(s) 462 OSTRARRAYRUNE, // []rune(s) 463 OAS, // x = y or x := y 464 OAS2, // x, y, z = xx, yy, zz 465 OAS2FUNC, // x, y = f() 466 OAS2RECV, // x, ok = <-c 467 OAS2MAPR, // x, ok = m["foo"] 468 OAS2DOTTYPE, // x, ok = I.(int) 469 OASOP, // x += y 470 OCALL, // function call, method call or type conversion, possibly preceded by defer or go. 471 OCALLFUNC, // f() 472 OCALLMETH, // t.Method() 473 OCALLINTER, // err.Error() 474 OCALLPART, // t.Method (without ()) 475 OCAP, // cap 476 OCLOSE, // close 477 OCLOSURE, // f = func() { etc } 478 OCMPIFACE, // err1 == err2 479 OCMPSTR, // s1 == s2 480 OCOMPLIT, // composite literal, typechecking may convert to a more specific OXXXLIT. 481 OMAPLIT, // M{"foo":3, "bar":4} 482 OSTRUCTLIT, // T{x:3, y:4} 483 OARRAYLIT, // [2]int{3, 4} 484 OPTRLIT, // &T{x:3, y:4} 485 OCONV, // var i int; var u uint; i = int(u) 486 OCONVIFACE, // I(t) 487 OCONVNOP, // type Int int; var i int; var j Int; i = int(j) 488 OCOPY, // copy 489 ODCL, // var x int 490 ODCLFUNC, // func f() or func (r) f() 491 ODCLFIELD, // struct field, interface field, or func/method argument/return value. 492 ODCLCONST, // const pi = 3.14 493 ODCLTYPE, // type Int int 494 ODELETE, // delete 495 ODOT, // t.x 496 ODOTPTR, // p.x that is implicitly (*p).x 497 ODOTMETH, // t.Method 498 ODOTINTER, // err.Error 499 OXDOT, // t.x, typechecking may convert to a more specific ODOTXXX. 500 ODOTTYPE, // e = err.(MyErr) 501 ODOTTYPE2, // e, ok = err.(MyErr) 502 OEQ, // x == y 503 ONE, // x != y 504 OLT, // x < y 505 OLE, // x <= y 506 OGE, // x >= y 507 OGT, // x > y 508 OIND, // *p 509 OINDEX, // a[i] 510 OINDEXMAP, // m[s] 511 OKEY, // The x:3 in t{x:3, y:4}, the 1:2 in a[1:2], the 2:20 in [3]int{2:20}, etc. 512 OPARAM, // The on-stack copy of a parameter or return value that escapes. 513 OLEN, // len 514 OMAKE, // make, typechecking may convert to a more specific OMAKEXXX. 515 OMAKECHAN, // make(chan int) 516 OMAKEMAP, // make(map[string]int) 517 OMAKESLICE, // make([]int, 0) 518 OMUL, // x * y 519 ODIV, // x / y 520 OMOD, // x % y 521 OLSH, // x << u 522 ORSH, // x >> u 523 OAND, // x & y 524 OANDNOT, // x &^ y 525 ONEW, // new 526 ONOT, // !b 527 OCOM, // ^x 528 OPLUS, // +x 529 OMINUS, // -y 530 OOROR, // b1 || b2 531 OPANIC, // panic 532 OPRINT, // print 533 OPRINTN, // println 534 OPAREN, // (x) 535 OSEND, // c <- x 536 OSLICE, // v[1:2], typechecking may convert to a more specific OSLICEXXX. 537 OSLICEARR, // a[1:2] 538 OSLICESTR, // s[1:2] 539 OSLICE3, // v[1:2:3], typechecking may convert to OSLICE3ARR. 540 OSLICE3ARR, // a[1:2:3] 541 ORECOVER, // recover 542 ORECV, // <-c 543 ORUNESTR, // string(i) 544 OSELRECV, // case x = <-c: 545 OSELRECV2, // case x, ok = <-c: 546 OIOTA, // iota 547 OREAL, // real 548 OIMAG, // imag 549 OCOMPLEX, // complex 550 551 // statements 552 OBLOCK, // block of code 553 OBREAK, // break 554 OCASE, // case, after being verified by swt.c's casebody. 555 OXCASE, // case, before verification. 556 OCONTINUE, // continue 557 ODEFER, // defer 558 OEMPTY, // no-op 559 OFALL, // fallthrough, after being verified by swt.c's casebody. 560 OXFALL, // fallthrough, before verification. 561 OFOR, // for 562 OGOTO, // goto 563 OIF, // if 564 OLABEL, // label: 565 OPROC, // go 566 ORANGE, // range 567 ORETURN, // return 568 OSELECT, // select 569 OSWITCH, // switch x 570 OTYPESW, // switch err.(type) 571 572 // types 573 OTCHAN, // chan int 574 OTMAP, // map[string]int 575 OTSTRUCT, // struct{} 576 OTINTER, // interface{} 577 OTFUNC, // func() 578 OTARRAY, // []int, [8]int, [N]int or [...]int 579 580 // misc 581 ODDD, // func f(args ...int) or f(l...) or var a = [...]int{0, 1, 2}. 582 ODDDARG, // func f(args ...int), introduced by escape analysis. 583 OINLCALL, // intermediary representation of an inlined call. 584 OEFACE, // itable and data words of an empty-interface value. 585 OITAB, // itable word of an interface value. 586 OSPTR, // base pointer of a slice or string. 587 OCLOSUREVAR, // variable reference at beginning of closure function 588 OCFUNC, // reference to c function pointer (not go func value) 589 OCHECKNIL, // emit code to ensure pointer/interface not nil 590 OVARKILL, // variable is dead 591 592 // arch-specific registers 593 OREGISTER, // a register, such as AX. 594 OINDREG, // offset plus indirect of a register, such as 8(SP). 595 596 // 386/amd64-specific opcodes 597 OCMP, // compare: ACMP. 598 ODEC, // decrement: ADEC. 599 OINC, // increment: AINC. 600 OEXTEND, // extend: ACWD/ACDQ/ACQO. 601 OHMUL, // high mul: AMUL/AIMUL for unsigned/signed (OMUL uses AIMUL for both). 602 OLROT, // left rotate: AROL. 603 ORROTC, // right rotate-carry: ARCR. 604 ORETJMP, // return to other function 605 606 OEND, 607 }; 608 609 enum 610 { 611 Txxx, // 0 612 613 TINT8, TUINT8, // 1 614 TINT16, TUINT16, 615 TINT32, TUINT32, 616 TINT64, TUINT64, 617 TINT, TUINT, TUINTPTR, 618 619 TCOMPLEX64, // 12 620 TCOMPLEX128, 621 622 TFLOAT32, // 14 623 TFLOAT64, 624 625 TBOOL, // 16 626 627 TPTR32, TPTR64, // 17 628 629 TFUNC, // 19 630 TARRAY, 631 T_old_DARRAY, 632 TSTRUCT, // 22 633 TCHAN, 634 TMAP, 635 TINTER, // 25 636 TFORW, 637 TFIELD, 638 TANY, 639 TSTRING, 640 TUNSAFEPTR, 641 642 // pseudo-types for literals 643 TIDEAL, // 31 644 TNIL, 645 TBLANK, 646 647 // pseudo-type for frame layout 648 TFUNCARGS, 649 TCHANARGS, 650 TINTERMETH, 651 652 NTYPE, 653 }; 654 655 enum 656 { 657 CTxxx, 658 659 CTINT, 660 CTRUNE, 661 CTFLT, 662 CTCPLX, 663 CTSTR, 664 CTBOOL, 665 CTNIL, 666 }; 667 668 enum 669 { 670 /* types of channel */ 671 /* must match ../../pkg/nreflect/type.go:/Chandir */ 672 Cxxx, 673 Crecv = 1<<0, 674 Csend = 1<<1, 675 Cboth = Crecv | Csend, 676 }; 677 678 // declaration context 679 enum 680 { 681 Pxxx, 682 683 PEXTERN, // global variable 684 PAUTO, // local variables 685 PPARAM, // input arguments 686 PPARAMOUT, // output results 687 PPARAMREF, // closure variable reference 688 PFUNC, // global function 689 690 PDISCARD, // discard during parse of duplicate import 691 692 PHEAP = 1<<7, // an extra bit to identify an escaped variable 693 }; 694 695 enum 696 { 697 Etop = 1<<1, // evaluated at statement level 698 Erv = 1<<2, // evaluated in value context 699 Etype = 1<<3, 700 Ecall = 1<<4, // call-only expressions are ok 701 Efnstruct = 1<<5, // multivalue function returns are ok 702 Eiota = 1<<6, // iota is ok 703 Easgn = 1<<7, // assigning to expression 704 Eindir = 1<<8, // indirecting through expression 705 Eaddr = 1<<9, // taking address of expression 706 Eproc = 1<<10, // inside a go statement 707 Ecomplit = 1<<11, // type in composite literal 708 }; 709 710 #define BITS 3 711 #define NVAR (BITS*sizeof(uint64)*8) 712 713 typedef struct Bits Bits; 714 struct Bits 715 { 716 uint64 b[BITS]; 717 }; 718 719 EXTERN Bits zbits; 720 721 struct Bvec 722 { 723 int32 n; // number of bits 724 uint32 b[]; 725 }; 726 727 typedef struct Var Var; 728 struct Var 729 { 730 vlong offset; 731 Node* node; 732 Var* nextinnode; 733 int width; 734 char name; 735 char etype; 736 char addr; 737 }; 738 739 EXTERN Var var[NVAR]; 740 741 typedef struct Typedef Typedef; 742 struct Typedef 743 { 744 char* name; 745 int etype; 746 int sameas; 747 }; 748 749 extern Typedef typedefs[]; 750 751 typedef struct Sig Sig; 752 struct Sig 753 { 754 char* name; 755 Pkg* pkg; 756 Sym* isym; 757 Sym* tsym; 758 Type* type; 759 Type* mtype; 760 int32 offset; 761 Sig* link; 762 }; 763 764 typedef struct Io Io; 765 struct Io 766 { 767 char* infile; 768 Biobuf* bin; 769 int32 ilineno; 770 int nlsemi; 771 int eofnl; 772 int last; 773 int peekc; 774 int peekc1; // second peekc for ... 775 char* cp; // used for content when bin==nil 776 int importsafe; 777 }; 778 779 typedef struct Dlist Dlist; 780 struct Dlist 781 { 782 Type* field; 783 }; 784 785 typedef struct Idir Idir; 786 struct Idir 787 { 788 Idir* link; 789 char* dir; 790 }; 791 792 /* 793 * argument passing to/from 794 * smagic and umagic 795 */ 796 typedef struct Magic Magic; 797 struct Magic 798 { 799 int w; // input for both - width 800 int s; // output for both - shift 801 int bad; // output for both - unexpected failure 802 803 // magic multiplier for signed literal divisors 804 int64 sd; // input - literal divisor 805 int64 sm; // output - multiplier 806 807 // magic multiplier for unsigned literal divisors 808 uint64 ud; // input - literal divisor 809 uint64 um; // output - multiplier 810 int ua; // output - adder 811 }; 812 813 struct Label 814 { 815 uchar used; 816 Sym* sym; 817 Node* def; 818 NodeList* use; 819 Label* link; 820 821 // for use during gen 822 Prog* gotopc; // pointer to unresolved gotos 823 Prog* labelpc; // pointer to code 824 Prog* breakpc; // pointer to code 825 Prog* continpc; // pointer to code 826 }; 827 #define L ((Label*)0) 828 829 /* 830 * note this is the runtime representation 831 * of the compilers arrays. 832 * 833 * typedef struct 834 * { // must not move anything 835 * uchar array[8]; // pointer to data 836 * uchar nel[4]; // number of elements 837 * uchar cap[4]; // allocated number of elements 838 * } Array; 839 */ 840 EXTERN int Array_array; // runtime offsetof(Array,array) - same for String 841 EXTERN int Array_nel; // runtime offsetof(Array,nel) - same for String 842 EXTERN int Array_cap; // runtime offsetof(Array,cap) 843 EXTERN int sizeof_Array; // runtime sizeof(Array) 844 845 846 /* 847 * note this is the runtime representation 848 * of the compilers strings. 849 * 850 * typedef struct 851 * { // must not move anything 852 * uchar array[8]; // pointer to data 853 * uchar nel[4]; // number of elements 854 * } String; 855 */ 856 EXTERN int sizeof_String; // runtime sizeof(String) 857 858 EXTERN Dlist dotlist[10]; // size is max depth of embeddeds 859 860 EXTERN Io curio; 861 EXTERN Io pushedio; 862 EXTERN int32 lexlineno; 863 EXTERN int32 lineno; 864 EXTERN int32 prevlineno; 865 866 EXTERN Fmt pragcgobuf; 867 868 EXTERN char* infile; 869 EXTERN char* outfile; 870 EXTERN Biobuf* bout; 871 EXTERN int nerrors; 872 EXTERN int nsavederrors; 873 EXTERN int nsyntaxerrors; 874 EXTERN int safemode; 875 EXTERN int nolocalimports; 876 EXTERN char namebuf[NSYMB]; 877 EXTERN char lexbuf[NSYMB]; 878 EXTERN char litbuf[NSYMB]; 879 EXTERN int debug[256]; 880 EXTERN char* debugstr; 881 EXTERN int debug_checknil; 882 EXTERN Sym* hash[NHASH]; 883 EXTERN Sym* importmyname; // my name for package 884 EXTERN Pkg* localpkg; // package being compiled 885 EXTERN Pkg* importpkg; // package being imported 886 EXTERN Pkg* structpkg; // package that declared struct, during import 887 EXTERN Pkg* builtinpkg; // fake package for builtins 888 EXTERN Pkg* gostringpkg; // fake pkg for Go strings 889 EXTERN Pkg* itabpkg; // fake pkg for itab cache 890 EXTERN Pkg* runtimepkg; // package runtime 891 EXTERN Pkg* racepkg; // package runtime/race 892 EXTERN Pkg* stringpkg; // fake package for C strings 893 EXTERN Pkg* typepkg; // fake package for runtime type info (headers) 894 EXTERN Pkg* typelinkpkg; // fake package for runtime type info (data) 895 EXTERN Pkg* weaktypepkg; // weak references to runtime type info 896 EXTERN Pkg* unsafepkg; // package unsafe 897 EXTERN Pkg* trackpkg; // fake package for field tracking 898 EXTERN Pkg* rawpkg; // fake package for raw symbol names 899 EXTERN Pkg* phash[128]; 900 EXTERN int tptr; // either TPTR32 or TPTR64 901 extern char* runtimeimport; 902 extern char* unsafeimport; 903 EXTERN char* myimportpath; 904 EXTERN Idir* idirs; 905 EXTERN char* localimport; 906 EXTERN char* asmhdr; 907 908 EXTERN Type* types[NTYPE]; 909 EXTERN Type* idealstring; 910 EXTERN Type* idealbool; 911 EXTERN Type* bytetype; 912 EXTERN Type* runetype; 913 EXTERN Type* errortype; 914 EXTERN uchar simtype[NTYPE]; 915 EXTERN uchar isptr[NTYPE]; 916 EXTERN uchar isforw[NTYPE]; 917 EXTERN uchar isint[NTYPE]; 918 EXTERN uchar isfloat[NTYPE]; 919 EXTERN uchar iscomplex[NTYPE]; 920 EXTERN uchar issigned[NTYPE]; 921 EXTERN uchar issimple[NTYPE]; 922 923 EXTERN uchar okforeq[NTYPE]; 924 EXTERN uchar okforadd[NTYPE]; 925 EXTERN uchar okforand[NTYPE]; 926 EXTERN uchar okfornone[NTYPE]; 927 EXTERN uchar okforcmp[NTYPE]; 928 EXTERN uchar okforbool[NTYPE]; 929 EXTERN uchar okforcap[NTYPE]; 930 EXTERN uchar okforlen[NTYPE]; 931 EXTERN uchar okforarith[NTYPE]; 932 EXTERN uchar okforconst[NTYPE]; 933 EXTERN uchar* okfor[OEND]; 934 EXTERN uchar iscmp[OEND]; 935 936 EXTERN Mpint* minintval[NTYPE]; 937 EXTERN Mpint* maxintval[NTYPE]; 938 EXTERN Mpflt* minfltval[NTYPE]; 939 EXTERN Mpflt* maxfltval[NTYPE]; 940 941 EXTERN NodeList* xtop; 942 EXTERN NodeList* externdcl; 943 EXTERN NodeList* closures; 944 EXTERN NodeList* exportlist; 945 EXTERN NodeList* importlist; // imported functions and methods with inlinable bodies 946 EXTERN NodeList* funcsyms; 947 EXTERN int dclcontext; // PEXTERN/PAUTO 948 EXTERN int incannedimport; 949 EXTERN int statuniqgen; // name generator for static temps 950 EXTERN int loophack; 951 952 EXTERN int32 iota; 953 EXTERN NodeList* lastconst; 954 EXTERN Node* lasttype; 955 EXTERN vlong maxarg; 956 EXTERN vlong stksize; // stack size for current frame 957 EXTERN vlong stkptrsize; // prefix of stack containing pointers 958 EXTERN int32 blockgen; // max block number 959 EXTERN int32 block; // current block number 960 EXTERN int hasdefer; // flag that curfn has defer statetment 961 962 EXTERN Node* curfn; 963 964 EXTERN int widthptr; 965 EXTERN int widthint; 966 EXTERN int widthreg; 967 968 EXTERN Node* typesw; 969 EXTERN Node* nblank; 970 971 extern int thechar; 972 extern char* thestring; 973 extern LinkArch* thelinkarch; 974 EXTERN int use_sse; 975 976 EXTERN char* hunk; 977 EXTERN int32 nhunk; 978 EXTERN int32 thunk; 979 980 EXTERN int funcdepth; 981 EXTERN int typecheckok; 982 EXTERN int compiling_runtime; 983 EXTERN int compiling_wrappers; 984 EXTERN int use_writebarrier; 985 EXTERN int pure_go; 986 EXTERN char* flag_installsuffix; 987 EXTERN int flag_race; 988 EXTERN int flag_largemodel; 989 EXTERN int noescape; 990 EXTERN int nosplit; 991 EXTERN int nowritebarrier; 992 EXTERN int debuglive; 993 EXTERN Link* ctxt; 994 995 EXTERN int nointerface; 996 EXTERN int fieldtrack_enabled; 997 EXTERN int precisestack_enabled; 998 EXTERN int writearchive; 999 1000 EXTERN Biobuf bstdout; 1001 1002 EXTERN int nacl; 1003 1004 /* 1005 * y.tab.c 1006 */ 1007 int yyparse(void); 1008 1009 /* 1010 * align.c 1011 */ 1012 int argsize(Type *t); 1013 void checkwidth(Type *t); 1014 void defercheckwidth(void); 1015 void dowidth(Type *t); 1016 void resumecheckwidth(void); 1017 vlong rnd(vlong o, vlong r); 1018 void typeinit(void); 1019 1020 /* 1021 * array.c 1022 */ 1023 Array* arraynew(int32 capacity, int32 size); 1024 void arrayfree(Array *array); 1025 int32 arraylength(Array *array); 1026 void* arrayget(Array *array, int32 index); 1027 void arrayset(Array *array, int32 index, void *element); 1028 void arrayadd(Array *array, void *element); 1029 void arraysort(Array* array, int (*cmp)(const void*, const void*)); 1030 1031 /* 1032 * bits.c 1033 */ 1034 int Qconv(Fmt *fp); 1035 Bits band(Bits a, Bits b); 1036 int bany(Bits *a); 1037 int beq(Bits a, Bits b); 1038 int bitno(uint64 b); 1039 Bits blsh(uint n); 1040 Bits bnot(Bits a); 1041 int bnum(Bits a); 1042 Bits bor(Bits a, Bits b); 1043 int btest(Bits *a, uint n); 1044 void biset(Bits *a, uint n); 1045 void biclr(Bits *a, uint n); 1046 1047 /* 1048 * bv.c 1049 */ 1050 Bvec* bvalloc(int32 n); 1051 void bvandnot(Bvec *dst, Bvec *src1, Bvec *src2); 1052 int bvcmp(Bvec *bv1, Bvec *bv2); 1053 void bvcopy(Bvec *dst, Bvec *src); 1054 Bvec* bvconcat(Bvec *src1, Bvec *src2); 1055 int bvget(Bvec *bv, int32 i); 1056 int32 bvnext(Bvec *bv, int32 i); 1057 int bvisempty(Bvec *bv); 1058 void bvnot(Bvec *bv); 1059 void bvor(Bvec *dst, Bvec *src1, Bvec *src2); 1060 void bvand(Bvec *dst, Bvec *src1, Bvec *src2); 1061 void bvprint(Bvec *bv); 1062 void bvreset(Bvec *bv, int32 i); 1063 void bvresetall(Bvec *bv); 1064 void bvset(Bvec *bv, int32 i); 1065 1066 /* 1067 * closure.c 1068 */ 1069 Node* closurebody(NodeList *body); 1070 void closurehdr(Node *ntype); 1071 void typecheckclosure(Node *func, int top); 1072 Node* walkclosure(Node *func, NodeList **init); 1073 void typecheckpartialcall(Node*, Node*); 1074 Node* walkpartialcall(Node*, NodeList**); 1075 1076 /* 1077 * const.c 1078 */ 1079 int cmpslit(Node *l, Node *r); 1080 int consttype(Node *n); 1081 void convconst(Node *con, Type *t, Val *val); 1082 void convlit(Node **np, Type *t); 1083 void convlit1(Node **np, Type *t, int explicit); 1084 void defaultlit(Node **np, Type *t); 1085 void defaultlit2(Node **lp, Node **rp, int force); 1086 void evconst(Node *n); 1087 int isconst(Node *n, int ct); 1088 int isgoconst(Node *n); 1089 Node* nodcplxlit(Val r, Val i); 1090 Node* nodlit(Val v); 1091 long nonnegconst(Node *n); 1092 int doesoverflow(Val v, Type *t); 1093 void overflow(Val v, Type *t); 1094 int smallintconst(Node *n); 1095 Val toint(Val v); 1096 Mpflt* truncfltlit(Mpflt *oldv, Type *t); 1097 1098 /* 1099 * cplx.c 1100 */ 1101 void complexadd(int op, Node *nl, Node *nr, Node *res); 1102 void complexbool(int op, Node *nl, Node *nr, int true, int likely, Prog *to); 1103 void complexgen(Node *n, Node *res); 1104 void complexminus(Node *nl, Node *res); 1105 void complexmove(Node *f, Node *t); 1106 void complexmul(Node *nl, Node *nr, Node *res); 1107 int complexop(Node *n, Node *res); 1108 void nodfconst(Node *n, Type *t, Mpflt* fval); 1109 1110 /* 1111 * dcl.c 1112 */ 1113 void addmethod(Sym *sf, Type *t, int local, int nointerface); 1114 void addvar(Node *n, Type *t, int ctxt); 1115 NodeList* checkarglist(NodeList *all, int input); 1116 Node* colas(NodeList *left, NodeList *right, int32 lno); 1117 void colasdefn(NodeList *left, Node *defn); 1118 NodeList* constiter(NodeList *vl, Node *t, NodeList *cl); 1119 Node* dclname(Sym *s); 1120 void declare(Node *n, int ctxt); 1121 void dumpdcl(char *st); 1122 Node* embedded(Sym *s, Pkg *pkg); 1123 Node* fakethis(void); 1124 void funcbody(Node *n); 1125 void funccompile(Node *n, int isclosure); 1126 void funchdr(Node *n); 1127 Type* functype(Node *this, NodeList *in, NodeList *out); 1128 void ifacedcl(Node *n); 1129 int isifacemethod(Type *f); 1130 void markdcl(void); 1131 Node* methodname(Node *n, Type *t); 1132 Node* methodname1(Node *n, Node *t); 1133 Sym* methodsym(Sym *nsym, Type *t0, int iface); 1134 Node* newname(Sym *s); 1135 Node* oldname(Sym *s); 1136 void popdcl(void); 1137 void poptodcl(void); 1138 void redeclare(Sym *s, char *where); 1139 void testdclstack(void); 1140 Type* tointerface(NodeList *l); 1141 Type* tostruct(NodeList *l); 1142 Node* typedcl0(Sym *s); 1143 Node* typedcl1(Node *n, Node *t, int local); 1144 Node* typenod(Type *t); 1145 NodeList* variter(NodeList *vl, Node *t, NodeList *el); 1146 Sym* funcsym(Sym*); 1147 1148 /* 1149 * esc.c 1150 */ 1151 void escapes(NodeList*); 1152 1153 /* 1154 * export.c 1155 */ 1156 void autoexport(Node *n, int ctxt); 1157 void dumpexport(void); 1158 void dumpasmhdr(void); 1159 int exportname(char *s); 1160 void exportsym(Node *n); 1161 void importconst(Sym *s, Type *t, Node *n); 1162 void importimport(Sym *s, Strlit *z); 1163 Sym* importsym(Sym *s, int op); 1164 void importtype(Type *pt, Type *t); 1165 void importvar(Sym *s, Type *t); 1166 Type* pkgtype(Sym *s); 1167 1168 /* 1169 * fmt.c 1170 */ 1171 void fmtinstallgo(void); 1172 void dump(char *s, Node *n); 1173 void dumplist(char *s, NodeList *l); 1174 1175 /* 1176 * gen.c 1177 */ 1178 void addrescapes(Node *n); 1179 void cgen_as(Node *nl, Node *nr); 1180 void cgen_callmeth(Node *n, int proc); 1181 void cgen_eface(Node* n, Node* res); 1182 void cgen_slice(Node* n, Node* res); 1183 void clearlabels(void); 1184 void clearslim(Node*); 1185 void checklabels(void); 1186 int dotoffset(Node *n, int64 *oary, Node **nn); 1187 void gen(Node *n); 1188 void genlist(NodeList *l); 1189 Node* sysfunc(char *name); 1190 void tempname(Node *n, Type *t); 1191 Node* temp(Type*); 1192 1193 /* 1194 * init.c 1195 */ 1196 void fninit(NodeList *n); 1197 Sym* renameinit(void); 1198 1199 /* 1200 * inl.c 1201 */ 1202 void caninl(Node *fn); 1203 void inlcalls(Node *fn); 1204 void typecheckinl(Node *fn); 1205 1206 /* 1207 * lex.c 1208 */ 1209 void cannedimports(char *file, char *cp); 1210 void importfile(Val *f, int line); 1211 char* lexname(int lex); 1212 char* expstring(void); 1213 void mkpackage(char* pkgname); 1214 void unimportfile(void); 1215 int32 yylex(void); 1216 extern int yylast; 1217 extern int yyprev; 1218 1219 /* 1220 * mparith1.c 1221 */ 1222 int Bconv(Fmt *fp); 1223 int Fconv(Fmt *fp); 1224 void mpaddcfix(Mpint *a, vlong c); 1225 void mpaddcflt(Mpflt *a, double c); 1226 void mpatofix(Mpint *a, char *as); 1227 void mpatoflt(Mpflt *a, char *as); 1228 int mpcmpfixc(Mpint *b, vlong c); 1229 int mpcmpfixfix(Mpint *a, Mpint *b); 1230 int mpcmpfixflt(Mpint *a, Mpflt *b); 1231 int mpcmpfltc(Mpflt *b, double c); 1232 int mpcmpfltfix(Mpflt *a, Mpint *b); 1233 int mpcmpfltflt(Mpflt *a, Mpflt *b); 1234 void mpcomfix(Mpint *a); 1235 void mpdivfixfix(Mpint *a, Mpint *b); 1236 void mpmodfixfix(Mpint *a, Mpint *b); 1237 void mpmovefixfix(Mpint *a, Mpint *b); 1238 void mpmovefixflt(Mpflt *a, Mpint *b); 1239 int mpmovefltfix(Mpint *a, Mpflt *b); 1240 void mpmovefltflt(Mpflt *a, Mpflt *b); 1241 void mpmulcfix(Mpint *a, vlong c); 1242 void mpmulcflt(Mpflt *a, double c); 1243 void mpsubfixfix(Mpint *a, Mpint *b); 1244 void mpsubfltflt(Mpflt *a, Mpflt *b); 1245 1246 /* 1247 * mparith2.c 1248 */ 1249 void mpaddfixfix(Mpint *a, Mpint *b, int); 1250 void mpandfixfix(Mpint *a, Mpint *b); 1251 void mpandnotfixfix(Mpint *a, Mpint *b); 1252 void mpdivfract(Mpint *a, Mpint *b); 1253 void mpdivmodfixfix(Mpint *q, Mpint *r, Mpint *n, Mpint *d); 1254 vlong mpgetfix(Mpint *a); 1255 void mplshfixfix(Mpint *a, Mpint *b); 1256 void mpmovecfix(Mpint *a, vlong c); 1257 void mpmulfixfix(Mpint *a, Mpint *b); 1258 void mpmulfract(Mpint *a, Mpint *b); 1259 void mpnegfix(Mpint *a); 1260 void mporfixfix(Mpint *a, Mpint *b); 1261 void mprshfixfix(Mpint *a, Mpint *b); 1262 void mpshiftfix(Mpint *a, int s); 1263 int mptestfix(Mpint *a); 1264 void mpxorfixfix(Mpint *a, Mpint *b); 1265 1266 /* 1267 * mparith3.c 1268 */ 1269 void mpaddfltflt(Mpflt *a, Mpflt *b); 1270 void mpdivfltflt(Mpflt *a, Mpflt *b); 1271 double mpgetflt(Mpflt *a); 1272 double mpgetflt32(Mpflt *a); 1273 void mpmovecflt(Mpflt *a, double c); 1274 void mpmulfltflt(Mpflt *a, Mpflt *b); 1275 void mpnegflt(Mpflt *a); 1276 void mpnorm(Mpflt *a); 1277 void mpsetexp(Mpflt *a, int exp); 1278 int mptestflt(Mpflt *a); 1279 int sigfig(Mpflt *a); 1280 1281 /* 1282 * obj.c 1283 */ 1284 void Bputname(Biobuf *b, LSym *s); 1285 int duint16(Sym *s, int off, uint16 v); 1286 int duint32(Sym *s, int off, uint32 v); 1287 int duint64(Sym *s, int off, uint64 v); 1288 int duint8(Sym *s, int off, uint8 v); 1289 int duintptr(Sym *s, int off, uint64 v); 1290 int dsname(Sym *s, int off, char *dat, int ndat); 1291 void dumpobj(void); 1292 Sym* stringsym(char*, int); 1293 void slicebytes(Node*, char*, int); 1294 LSym* linksym(Sym*); 1295 1296 /* 1297 * order.c 1298 */ 1299 void order(Node *fn); 1300 void orderstmtinplace(Node **stmt); 1301 1302 /* 1303 * range.c 1304 */ 1305 void typecheckrange(Node *n); 1306 void walkrange(Node *n); 1307 1308 /* 1309 * reflect.c 1310 */ 1311 void dumptypestructs(void); 1312 Type* methodfunc(Type *f, Type*); 1313 Node* typename(Type *t); 1314 Sym* typesym(Type *t); 1315 Sym* typenamesym(Type *t); 1316 Sym* tracksym(Type *t); 1317 Sym* typesymprefix(char *prefix, Type *t); 1318 int haspointers(Type *t); 1319 Type* hiter(Type* t); 1320 1321 /* 1322 * select.c 1323 */ 1324 void typecheckselect(Node *sel); 1325 void walkselect(Node *sel); 1326 1327 /* 1328 * sinit.c 1329 */ 1330 void anylit(int, Node *n, Node *var, NodeList **init); 1331 int gen_as_init(Node *n); 1332 NodeList* initfix(NodeList *l); 1333 int oaslit(Node *n, NodeList **init); 1334 int stataddr(Node *nam, Node *n); 1335 1336 /* 1337 * subr.c 1338 */ 1339 Node* adddot(Node *n); 1340 int adddot1(Sym *s, Type *t, int d, Type **save, int ignorecase); 1341 void addinit(Node**, NodeList*); 1342 Type* aindex(Node *b, Type *t); 1343 int algtype(Type *t); 1344 int algtype1(Type *t, Type **bad); 1345 void argtype(Node *on, Type *t); 1346 Node* assignconv(Node *n, Type *t, char *context); 1347 int assignop(Type *src, Type *dst, char **why); 1348 void badtype(int o, Type *tl, Type *tr); 1349 int brcom(int a); 1350 int brrev(int a); 1351 NodeList* concat(NodeList *a, NodeList *b); 1352 int convertop(Type *src, Type *dst, char **why); 1353 Node* copyexpr(Node*, Type*, NodeList**); 1354 int count(NodeList *l); 1355 int cplxsubtype(int et); 1356 int eqtype(Type *t1, Type *t2); 1357 int eqtypenoname(Type *t1, Type *t2); 1358 void errorexit(void); 1359 void expandmeth(Type *t); 1360 void fatal(char *fmt, ...); 1361 void flusherrors(void); 1362 void frame(int context); 1363 Type* funcfirst(Iter *s, Type *t); 1364 Type* funcnext(Iter *s); 1365 void genwrapper(Type *rcvr, Type *method, Sym *newnam, int iface); 1366 void genhash(Sym *sym, Type *t); 1367 void geneq(Sym *sym, Type *t); 1368 Type** getinarg(Type *t); 1369 Type* getinargx(Type *t); 1370 Type** getoutarg(Type *t); 1371 Type* getoutargx(Type *t); 1372 Type** getthis(Type *t); 1373 Type* getthisx(Type *t); 1374 int implements(Type *t, Type *iface, Type **missing, Type **have, int *ptr); 1375 void importdot(Pkg *opkg, Node *pack); 1376 int is64(Type *t); 1377 int isbadimport(Strlit *s); 1378 int isblank(Node *n); 1379 int isblanksym(Sym *s); 1380 int isdirectiface(Type*); 1381 int isfixedarray(Type *t); 1382 int isideal(Type *t); 1383 int isinter(Type *t); 1384 int isnil(Node *n); 1385 int isnilinter(Type *t); 1386 int isptrto(Type *t, int et); 1387 int isslice(Type *t); 1388 int istype(Type *t, int et); 1389 int iszero(Node *n); 1390 void linehist(char *file, int32 off, int relative); 1391 NodeList* list(NodeList *l, Node *n); 1392 NodeList* list1(Node *n); 1393 void listsort(NodeList**, int(*f)(Node*, Node*)); 1394 Node* liststmt(NodeList *l); 1395 NodeList* listtreecopy(NodeList *l); 1396 Sym* lookup(char *name); 1397 void* mal(int32 n); 1398 Type* maptype(Type *key, Type *val); 1399 Type* methtype(Type *t, int mustname); 1400 Pkg* mkpkg(Strlit *path); 1401 Sym* ngotype(Node *n); 1402 int noconv(Type *t1, Type *t2); 1403 Node* nod(int op, Node *nleft, Node *nright); 1404 Node* nodbool(int b); 1405 void nodconst(Node *n, Type *t, int64 v); 1406 Node* nodintconst(int64 v); 1407 Node* nodfltconst(Mpflt *v); 1408 Node* nodnil(void); 1409 int parserline(void); 1410 Sym* pkglookup(char *name, Pkg *pkg); 1411 int powtwo(Node *n); 1412 Type* ptrto(Type *t); 1413 void* remal(void *p, int32 on, int32 n); 1414 Sym* restrictlookup(char *name, Pkg *pkg); 1415 Node* safeexpr(Node *n, NodeList **init); 1416 void saveerrors(void); 1417 Node* cheapexpr(Node *n, NodeList **init); 1418 Node* localexpr(Node *n, Type *t, NodeList **init); 1419 void saveorignode(Node *n); 1420 int32 setlineno(Node *n); 1421 void setmaxarg(Type *t, int32 extra); 1422 Type* shallow(Type *t); 1423 int simsimtype(Type *t); 1424 void smagic(Magic *m); 1425 Type* sortinter(Type *t); 1426 uint32 stringhash(char *p); 1427 Strlit* strlit(char *s); 1428 int structcount(Type *t); 1429 Type* structfirst(Iter *s, Type **nn); 1430 Type* structnext(Iter *s); 1431 Node* syslook(char *name, int copy); 1432 Type* tounsigned(Type *t); 1433 Node* treecopy(Node *n); 1434 Type* typ(int et); 1435 uint32 typehash(Type *t); 1436 void ullmancalc(Node *n); 1437 void umagic(Magic *m); 1438 void warn(char *fmt, ...); 1439 void warnl(int line, char *fmt, ...); 1440 void yyerror(char *fmt, ...); 1441 void yyerrorl(int line, char *fmt, ...); 1442 1443 /* 1444 * swt.c 1445 */ 1446 void typecheckswitch(Node *n); 1447 void walkswitch(Node *sw); 1448 1449 /* 1450 * typecheck.c 1451 */ 1452 int islvalue(Node *n); 1453 Node* typecheck(Node **np, int top); 1454 void typechecklist(NodeList *l, int top); 1455 Node* typecheckdef(Node *n); 1456 void copytype(Node *n, Type *t); 1457 void checkreturn(Node*); 1458 void queuemethod(Node *n); 1459 1460 /* 1461 * unsafe.c 1462 */ 1463 int isunsafebuiltin(Node *n); 1464 Node* unsafenmagic(Node *n); 1465 1466 /* 1467 * walk.c 1468 */ 1469 Node* callnew(Type *t); 1470 Node* chanfn(char *name, int n, Type *t); 1471 Node* mkcall(char *name, Type *t, NodeList **init, ...); 1472 Node* mkcall1(Node *fn, Type *t, NodeList **init, ...); 1473 int vmatch1(Node *l, Node *r); 1474 void walk(Node *fn); 1475 void walkexpr(Node **np, NodeList **init); 1476 void walkexprlist(NodeList *l, NodeList **init); 1477 void walkexprlistsafe(NodeList *l, NodeList **init); 1478 void walkexprlistcheap(NodeList *l, NodeList **init); 1479 void walkstmt(Node **np); 1480 void walkstmtlist(NodeList *l); 1481 Node* conv(Node*, Type*); 1482 int candiscard(Node*); 1483 int needwritebarrier(Node*, Node*); 1484 Node* outervalue(Node*); 1485 void usefield(Node*); 1486 1487 /* 1488 * arch-specific ggen.c/gsubr.c/gobj.c/pgen.c/plive.c 1489 */ 1490 #define P ((Prog*)0) 1491 1492 EXTERN Prog* continpc; 1493 EXTERN Prog* breakpc; 1494 EXTERN Prog* pc; 1495 EXTERN Prog* firstpc; 1496 1497 EXTERN Node* nodfp; 1498 EXTERN int disable_checknil; 1499 EXTERN vlong zerosize; 1500 1501 int anyregalloc(void); 1502 void betypeinit(void); 1503 void bgen(Node *n, int true, int likely, Prog *to); 1504 void checknil(Node*, NodeList**); 1505 void expandchecks(Prog*); 1506 void cgen(Node*, Node*); 1507 void cgen_asop(Node *n); 1508 void cgen_call(Node *n, int proc); 1509 void cgen_callinter(Node *n, Node *res, int proc); 1510 void cgen_checknil(Node*); 1511 void cgen_ret(Node *n); 1512 void clearfat(Node *n); 1513 void compile(Node*); 1514 void defframe(Prog*); 1515 int dgostringptr(Sym*, int off, char *str); 1516 int dgostrlitptr(Sym*, int off, Strlit*); 1517 int dstringptr(Sym *s, int off, char *str); 1518 int dsymptr(Sym *s, int off, Sym *x, int xoff); 1519 int duintxx(Sym *s, int off, uint64 v, int wid); 1520 void dumpdata(void); 1521 void fixautoused(Prog*); 1522 void gdata(Node*, Node*, int); 1523 void gdatacomplex(Node*, Mpcplx*); 1524 void gdatastring(Node*, Strlit*); 1525 void ggloblnod(Node *nam); 1526 void ggloblsym(Sym *s, int32 width, int8 flags); 1527 void gvardef(Node*); 1528 void gvarkill(Node*); 1529 Prog* gjmp(Prog*); 1530 void gused(Node*); 1531 void movelarge(NodeList*); 1532 int isfat(Type*); 1533 void linkarchinit(void); 1534 void liveness(Node*, Prog*, Sym*, Sym*); 1535 void twobitwalktype1(Type*, vlong*, Bvec*); 1536 void markautoused(Prog*); 1537 Plist* newplist(void); 1538 Node* nodarg(Type*, int); 1539 void nopout(Prog*); 1540 void patch(Prog*, Prog*); 1541 Prog* unpatch(Prog*); 1542 1543 #pragma varargck type "B" Mpint* 1544 #pragma varargck type "E" int 1545 #pragma varargck type "E" uint 1546 #pragma varargck type "F" Mpflt* 1547 #pragma varargck type "H" NodeList* 1548 #pragma varargck type "J" Node* 1549 #pragma varargck type "lL" int32 1550 #pragma varargck type "L" int32 1551 #pragma varargck type "N" Node* 1552 #pragma varargck type "lN" Node* 1553 #pragma varargck type "O" int 1554 #pragma varargck type "O" uint 1555 #pragma varargck type "Q" Bits 1556 #pragma varargck type "S" Sym* 1557 #pragma varargck type "lS" LSym* 1558 #pragma varargck type "T" Type* 1559 #pragma varargck type "lT" Type* 1560 #pragma varargck type "V" Val* 1561 #pragma varargck type "Z" Strlit* 1562 1563 /* 1564 * racewalk.c 1565 */ 1566 void racewalk(Node *fn);