github.com/reiver/go@v0.0.0-20150109200633-1d0c7792f172/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 SymAlgGen = 1<<6, 388 }; 389 390 struct Sym 391 { 392 ushort lexical; 393 uchar flags; 394 uchar sym; // huffman encoding in object file 395 Sym* link; 396 int32 npkg; // number of imported packages with this name 397 uint32 uniqgen; 398 Pkg* importdef; // where imported definition was found 399 char* linkname; // link name 400 401 // saved and restored by dcopy 402 Pkg* pkg; 403 char* name; // variable name 404 Node* def; // definition: ONAME OTYPE OPACK or OLITERAL 405 Label* label; // corresponding label (ephemeral) 406 int32 block; // blocknumber to catch redeclaration 407 int32 lastlineno; // last declaration for diagnostic 408 Pkg* origpkg; // original package for . import 409 LSym* lsym; 410 }; 411 #define S ((Sym*)0) 412 413 EXTERN Sym* dclstack; 414 415 struct Pkg 416 { 417 char* name; // package name 418 Strlit* path; // string literal used in import statement 419 Sym* pathsym; 420 char* prefix; // escaped path for use in symbol table 421 Pkg* link; 422 uchar imported; // export data of this package was parsed 423 char exported; // import line written in export data 424 char direct; // imported directly 425 char safe; // whether the package is marked as safe 426 }; 427 428 typedef struct Iter Iter; 429 struct Iter 430 { 431 int done; 432 Type* tfunc; 433 Type* t; 434 Node** an; 435 Node* n; 436 }; 437 438 // Node ops. 439 enum 440 { 441 OXXX, 442 443 // names 444 ONAME, // var, const or func name 445 ONONAME, // unnamed arg or return value: f(int, string) (int, error) { etc } 446 OTYPE, // type name 447 OPACK, // import 448 OLITERAL, // literal 449 450 // expressions 451 OADD, // x + y 452 OSUB, // x - y 453 OOR, // x | y 454 OXOR, // x ^ y 455 OADDSTR, // s + "foo" 456 OADDR, // &x 457 OANDAND, // b0 && b1 458 OAPPEND, // append 459 OARRAYBYTESTR, // string(bytes) 460 OARRAYBYTESTRTMP, // string(bytes) ephemeral 461 OARRAYRUNESTR, // string(runes) 462 OSTRARRAYBYTE, // []byte(s) 463 OSTRARRAYRUNE, // []rune(s) 464 OAS, // x = y or x := y 465 OAS2, // x, y, z = xx, yy, zz 466 OAS2FUNC, // x, y = f() 467 OAS2RECV, // x, ok = <-c 468 OAS2MAPR, // x, ok = m["foo"] 469 OAS2DOTTYPE, // x, ok = I.(int) 470 OASOP, // x += y 471 OCALL, // function call, method call or type conversion, possibly preceded by defer or go. 472 OCALLFUNC, // f() 473 OCALLMETH, // t.Method() 474 OCALLINTER, // err.Error() 475 OCALLPART, // t.Method (without ()) 476 OCAP, // cap 477 OCLOSE, // close 478 OCLOSURE, // f = func() { etc } 479 OCMPIFACE, // err1 == err2 480 OCMPSTR, // s1 == s2 481 OCOMPLIT, // composite literal, typechecking may convert to a more specific OXXXLIT. 482 OMAPLIT, // M{"foo":3, "bar":4} 483 OSTRUCTLIT, // T{x:3, y:4} 484 OARRAYLIT, // [2]int{3, 4} 485 OPTRLIT, // &T{x:3, y:4} 486 OCONV, // var i int; var u uint; i = int(u) 487 OCONVIFACE, // I(t) 488 OCONVNOP, // type Int int; var i int; var j Int; i = int(j) 489 OCOPY, // copy 490 ODCL, // var x int 491 ODCLFUNC, // func f() or func (r) f() 492 ODCLFIELD, // struct field, interface field, or func/method argument/return value. 493 ODCLCONST, // const pi = 3.14 494 ODCLTYPE, // type Int int 495 ODELETE, // delete 496 ODOT, // t.x 497 ODOTPTR, // p.x that is implicitly (*p).x 498 ODOTMETH, // t.Method 499 ODOTINTER, // err.Error 500 OXDOT, // t.x, typechecking may convert to a more specific ODOTXXX. 501 ODOTTYPE, // e = err.(MyErr) 502 ODOTTYPE2, // e, ok = err.(MyErr) 503 OEQ, // x == y 504 ONE, // x != y 505 OLT, // x < y 506 OLE, // x <= y 507 OGE, // x >= y 508 OGT, // x > y 509 OIND, // *p 510 OINDEX, // a[i] 511 OINDEXMAP, // m[s] 512 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. 513 OPARAM, // The on-stack copy of a parameter or return value that escapes. 514 OLEN, // len 515 OMAKE, // make, typechecking may convert to a more specific OMAKEXXX. 516 OMAKECHAN, // make(chan int) 517 OMAKEMAP, // make(map[string]int) 518 OMAKESLICE, // make([]int, 0) 519 OMUL, // x * y 520 ODIV, // x / y 521 OMOD, // x % y 522 OLSH, // x << u 523 ORSH, // x >> u 524 OAND, // x & y 525 OANDNOT, // x &^ y 526 ONEW, // new 527 ONOT, // !b 528 OCOM, // ^x 529 OPLUS, // +x 530 OMINUS, // -y 531 OOROR, // b1 || b2 532 OPANIC, // panic 533 OPRINT, // print 534 OPRINTN, // println 535 OPAREN, // (x) 536 OSEND, // c <- x 537 OSLICE, // v[1:2], typechecking may convert to a more specific OSLICEXXX. 538 OSLICEARR, // a[1:2] 539 OSLICESTR, // s[1:2] 540 OSLICE3, // v[1:2:3], typechecking may convert to OSLICE3ARR. 541 OSLICE3ARR, // a[1:2:3] 542 ORECOVER, // recover 543 ORECV, // <-c 544 ORUNESTR, // string(i) 545 OSELRECV, // case x = <-c: 546 OSELRECV2, // case x, ok = <-c: 547 OIOTA, // iota 548 OREAL, // real 549 OIMAG, // imag 550 OCOMPLEX, // complex 551 552 // statements 553 OBLOCK, // block of code 554 OBREAK, // break 555 OCASE, // case, after being verified by swt.c's casebody. 556 OXCASE, // case, before verification. 557 OCONTINUE, // continue 558 ODEFER, // defer 559 OEMPTY, // no-op 560 OFALL, // fallthrough, after being verified by swt.c's casebody. 561 OXFALL, // fallthrough, before verification. 562 OFOR, // for 563 OGOTO, // goto 564 OIF, // if 565 OLABEL, // label: 566 OPROC, // go 567 ORANGE, // range 568 ORETURN, // return 569 OSELECT, // select 570 OSWITCH, // switch x 571 OTYPESW, // switch err.(type) 572 573 // types 574 OTCHAN, // chan int 575 OTMAP, // map[string]int 576 OTSTRUCT, // struct{} 577 OTINTER, // interface{} 578 OTFUNC, // func() 579 OTARRAY, // []int, [8]int, [N]int or [...]int 580 581 // misc 582 ODDD, // func f(args ...int) or f(l...) or var a = [...]int{0, 1, 2}. 583 ODDDARG, // func f(args ...int), introduced by escape analysis. 584 OINLCALL, // intermediary representation of an inlined call. 585 OEFACE, // itable and data words of an empty-interface value. 586 OITAB, // itable word of an interface value. 587 OSPTR, // base pointer of a slice or string. 588 OCLOSUREVAR, // variable reference at beginning of closure function 589 OCFUNC, // reference to c function pointer (not go func value) 590 OCHECKNIL, // emit code to ensure pointer/interface not nil 591 OVARKILL, // variable is dead 592 593 // arch-specific registers 594 OREGISTER, // a register, such as AX. 595 OINDREG, // offset plus indirect of a register, such as 8(SP). 596 597 // 386/amd64-specific opcodes 598 OCMP, // compare: ACMP. 599 ODEC, // decrement: ADEC. 600 OINC, // increment: AINC. 601 OEXTEND, // extend: ACWD/ACDQ/ACQO. 602 OHMUL, // high mul: AMUL/AIMUL for unsigned/signed (OMUL uses AIMUL for both). 603 OLROT, // left rotate: AROL. 604 ORROTC, // right rotate-carry: ARCR. 605 ORETJMP, // return to other function 606 607 OEND, 608 }; 609 610 enum 611 { 612 Txxx, // 0 613 614 TINT8, TUINT8, // 1 615 TINT16, TUINT16, 616 TINT32, TUINT32, 617 TINT64, TUINT64, 618 TINT, TUINT, TUINTPTR, 619 620 TCOMPLEX64, // 12 621 TCOMPLEX128, 622 623 TFLOAT32, // 14 624 TFLOAT64, 625 626 TBOOL, // 16 627 628 TPTR32, TPTR64, // 17 629 630 TFUNC, // 19 631 TARRAY, 632 T_old_DARRAY, 633 TSTRUCT, // 22 634 TCHAN, 635 TMAP, 636 TINTER, // 25 637 TFORW, 638 TFIELD, 639 TANY, 640 TSTRING, 641 TUNSAFEPTR, 642 643 // pseudo-types for literals 644 TIDEAL, // 31 645 TNIL, 646 TBLANK, 647 648 // pseudo-type for frame layout 649 TFUNCARGS, 650 TCHANARGS, 651 TINTERMETH, 652 653 NTYPE, 654 }; 655 656 enum 657 { 658 CTxxx, 659 660 CTINT, 661 CTRUNE, 662 CTFLT, 663 CTCPLX, 664 CTSTR, 665 CTBOOL, 666 CTNIL, 667 }; 668 669 enum 670 { 671 /* types of channel */ 672 /* must match ../../pkg/nreflect/type.go:/Chandir */ 673 Cxxx, 674 Crecv = 1<<0, 675 Csend = 1<<1, 676 Cboth = Crecv | Csend, 677 }; 678 679 // declaration context 680 enum 681 { 682 Pxxx, 683 684 PEXTERN, // global variable 685 PAUTO, // local variables 686 PPARAM, // input arguments 687 PPARAMOUT, // output results 688 PPARAMREF, // closure variable reference 689 PFUNC, // global function 690 691 PDISCARD, // discard during parse of duplicate import 692 693 PHEAP = 1<<7, // an extra bit to identify an escaped variable 694 }; 695 696 enum 697 { 698 Etop = 1<<1, // evaluated at statement level 699 Erv = 1<<2, // evaluated in value context 700 Etype = 1<<3, 701 Ecall = 1<<4, // call-only expressions are ok 702 Efnstruct = 1<<5, // multivalue function returns are ok 703 Eiota = 1<<6, // iota is ok 704 Easgn = 1<<7, // assigning to expression 705 Eindir = 1<<8, // indirecting through expression 706 Eaddr = 1<<9, // taking address of expression 707 Eproc = 1<<10, // inside a go statement 708 Ecomplit = 1<<11, // type in composite literal 709 }; 710 711 #define BITS 3 712 #define NVAR (BITS*sizeof(uint64)*8) 713 714 typedef struct Bits Bits; 715 struct Bits 716 { 717 uint64 b[BITS]; 718 }; 719 720 EXTERN Bits zbits; 721 722 struct Bvec 723 { 724 int32 n; // number of bits 725 uint32 b[]; 726 }; 727 728 typedef struct Var Var; 729 struct Var 730 { 731 vlong offset; 732 Node* node; 733 Var* nextinnode; 734 int width; 735 char name; 736 char etype; 737 char addr; 738 }; 739 740 EXTERN Var var[NVAR]; 741 742 typedef struct Typedef Typedef; 743 struct Typedef 744 { 745 char* name; 746 int etype; 747 int sameas; 748 }; 749 750 extern Typedef typedefs[]; 751 752 typedef struct Sig Sig; 753 struct Sig 754 { 755 char* name; 756 Pkg* pkg; 757 Sym* isym; 758 Sym* tsym; 759 Type* type; 760 Type* mtype; 761 int32 offset; 762 Sig* link; 763 }; 764 765 typedef struct Io Io; 766 struct Io 767 { 768 char* infile; 769 Biobuf* bin; 770 int32 ilineno; 771 int nlsemi; 772 int eofnl; 773 int last; 774 int peekc; 775 int peekc1; // second peekc for ... 776 char* cp; // used for content when bin==nil 777 int importsafe; 778 }; 779 780 typedef struct Dlist Dlist; 781 struct Dlist 782 { 783 Type* field; 784 }; 785 786 typedef struct Idir Idir; 787 struct Idir 788 { 789 Idir* link; 790 char* dir; 791 }; 792 793 /* 794 * argument passing to/from 795 * smagic and umagic 796 */ 797 typedef struct Magic Magic; 798 struct Magic 799 { 800 int w; // input for both - width 801 int s; // output for both - shift 802 int bad; // output for both - unexpected failure 803 804 // magic multiplier for signed literal divisors 805 int64 sd; // input - literal divisor 806 int64 sm; // output - multiplier 807 808 // magic multiplier for unsigned literal divisors 809 uint64 ud; // input - literal divisor 810 uint64 um; // output - multiplier 811 int ua; // output - adder 812 }; 813 814 struct Label 815 { 816 uchar used; 817 Sym* sym; 818 Node* def; 819 NodeList* use; 820 Label* link; 821 822 // for use during gen 823 Prog* gotopc; // pointer to unresolved gotos 824 Prog* labelpc; // pointer to code 825 Prog* breakpc; // pointer to code 826 Prog* continpc; // pointer to code 827 }; 828 #define L ((Label*)0) 829 830 /* 831 * note this is the runtime representation 832 * of the compilers arrays. 833 * 834 * typedef struct 835 * { // must not move anything 836 * uchar array[8]; // pointer to data 837 * uchar nel[4]; // number of elements 838 * uchar cap[4]; // allocated number of elements 839 * } Array; 840 */ 841 EXTERN int Array_array; // runtime offsetof(Array,array) - same for String 842 EXTERN int Array_nel; // runtime offsetof(Array,nel) - same for String 843 EXTERN int Array_cap; // runtime offsetof(Array,cap) 844 EXTERN int sizeof_Array; // runtime sizeof(Array) 845 846 847 /* 848 * note this is the runtime representation 849 * of the compilers strings. 850 * 851 * typedef struct 852 * { // must not move anything 853 * uchar array[8]; // pointer to data 854 * uchar nel[4]; // number of elements 855 * } String; 856 */ 857 EXTERN int sizeof_String; // runtime sizeof(String) 858 859 EXTERN Dlist dotlist[10]; // size is max depth of embeddeds 860 861 EXTERN Io curio; 862 EXTERN Io pushedio; 863 EXTERN int32 lexlineno; 864 EXTERN int32 lineno; 865 EXTERN int32 prevlineno; 866 867 EXTERN Fmt pragcgobuf; 868 869 EXTERN char* infile; 870 EXTERN char* outfile; 871 EXTERN Biobuf* bout; 872 EXTERN int nerrors; 873 EXTERN int nsavederrors; 874 EXTERN int nsyntaxerrors; 875 EXTERN int safemode; 876 EXTERN int nolocalimports; 877 EXTERN char namebuf[NSYMB]; 878 EXTERN char lexbuf[NSYMB]; 879 EXTERN char litbuf[NSYMB]; 880 EXTERN int debug[256]; 881 EXTERN char* debugstr; 882 EXTERN int debug_checknil; 883 EXTERN Sym* hash[NHASH]; 884 EXTERN Sym* importmyname; // my name for package 885 EXTERN Pkg* localpkg; // package being compiled 886 EXTERN Pkg* importpkg; // package being imported 887 EXTERN Pkg* structpkg; // package that declared struct, during import 888 EXTERN Pkg* builtinpkg; // fake package for builtins 889 EXTERN Pkg* gostringpkg; // fake pkg for Go strings 890 EXTERN Pkg* itabpkg; // fake pkg for itab cache 891 EXTERN Pkg* runtimepkg; // package runtime 892 EXTERN Pkg* racepkg; // package runtime/race 893 EXTERN Pkg* stringpkg; // fake package for C strings 894 EXTERN Pkg* typepkg; // fake package for runtime type info (headers) 895 EXTERN Pkg* typelinkpkg; // fake package for runtime type info (data) 896 EXTERN Pkg* weaktypepkg; // weak references to runtime type info 897 EXTERN Pkg* unsafepkg; // package unsafe 898 EXTERN Pkg* trackpkg; // fake package for field tracking 899 EXTERN Pkg* rawpkg; // fake package for raw symbol names 900 EXTERN Pkg* phash[128]; 901 EXTERN int tptr; // either TPTR32 or TPTR64 902 extern char* runtimeimport; 903 extern char* unsafeimport; 904 EXTERN char* myimportpath; 905 EXTERN Idir* idirs; 906 EXTERN char* localimport; 907 EXTERN char* asmhdr; 908 909 EXTERN Type* types[NTYPE]; 910 EXTERN Type* idealstring; 911 EXTERN Type* idealbool; 912 EXTERN Type* bytetype; 913 EXTERN Type* runetype; 914 EXTERN Type* errortype; 915 EXTERN uchar simtype[NTYPE]; 916 EXTERN uchar isptr[NTYPE]; 917 EXTERN uchar isforw[NTYPE]; 918 EXTERN uchar isint[NTYPE]; 919 EXTERN uchar isfloat[NTYPE]; 920 EXTERN uchar iscomplex[NTYPE]; 921 EXTERN uchar issigned[NTYPE]; 922 EXTERN uchar issimple[NTYPE]; 923 924 EXTERN uchar okforeq[NTYPE]; 925 EXTERN uchar okforadd[NTYPE]; 926 EXTERN uchar okforand[NTYPE]; 927 EXTERN uchar okfornone[NTYPE]; 928 EXTERN uchar okforcmp[NTYPE]; 929 EXTERN uchar okforbool[NTYPE]; 930 EXTERN uchar okforcap[NTYPE]; 931 EXTERN uchar okforlen[NTYPE]; 932 EXTERN uchar okforarith[NTYPE]; 933 EXTERN uchar okforconst[NTYPE]; 934 EXTERN uchar* okfor[OEND]; 935 EXTERN uchar iscmp[OEND]; 936 937 EXTERN Mpint* minintval[NTYPE]; 938 EXTERN Mpint* maxintval[NTYPE]; 939 EXTERN Mpflt* minfltval[NTYPE]; 940 EXTERN Mpflt* maxfltval[NTYPE]; 941 942 EXTERN NodeList* xtop; 943 EXTERN NodeList* externdcl; 944 EXTERN NodeList* closures; 945 EXTERN NodeList* exportlist; 946 EXTERN NodeList* importlist; // imported functions and methods with inlinable bodies 947 EXTERN NodeList* funcsyms; 948 EXTERN int dclcontext; // PEXTERN/PAUTO 949 EXTERN int incannedimport; 950 EXTERN int statuniqgen; // name generator for static temps 951 EXTERN int loophack; 952 953 EXTERN int32 iota; 954 EXTERN NodeList* lastconst; 955 EXTERN Node* lasttype; 956 EXTERN vlong maxarg; 957 EXTERN vlong stksize; // stack size for current frame 958 EXTERN vlong stkptrsize; // prefix of stack containing pointers 959 EXTERN int32 blockgen; // max block number 960 EXTERN int32 block; // current block number 961 EXTERN int hasdefer; // flag that curfn has defer statetment 962 963 EXTERN Node* curfn; 964 965 EXTERN int widthptr; 966 EXTERN int widthint; 967 EXTERN int widthreg; 968 969 EXTERN Node* typesw; 970 EXTERN Node* nblank; 971 972 extern int thechar; 973 extern char* thestring; 974 extern LinkArch* thelinkarch; 975 EXTERN int use_sse; 976 977 EXTERN char* hunk; 978 EXTERN int32 nhunk; 979 EXTERN int32 thunk; 980 981 EXTERN int funcdepth; 982 EXTERN int typecheckok; 983 EXTERN int compiling_runtime; 984 EXTERN int compiling_wrappers; 985 EXTERN int use_writebarrier; 986 EXTERN int pure_go; 987 EXTERN char* flag_installsuffix; 988 EXTERN int flag_race; 989 EXTERN int flag_largemodel; 990 EXTERN int noescape; 991 EXTERN int nosplit; 992 EXTERN int nowritebarrier; 993 EXTERN int debuglive; 994 EXTERN Link* ctxt; 995 996 EXTERN int nointerface; 997 EXTERN int fieldtrack_enabled; 998 EXTERN int precisestack_enabled; 999 EXTERN int writearchive; 1000 1001 EXTERN Biobuf bstdout; 1002 1003 EXTERN int nacl; 1004 1005 /* 1006 * y.tab.c 1007 */ 1008 int yyparse(void); 1009 1010 /* 1011 * align.c 1012 */ 1013 int argsize(Type *t); 1014 void checkwidth(Type *t); 1015 void defercheckwidth(void); 1016 void dowidth(Type *t); 1017 void resumecheckwidth(void); 1018 vlong rnd(vlong o, vlong r); 1019 void typeinit(void); 1020 1021 /* 1022 * array.c 1023 */ 1024 Array* arraynew(int32 capacity, int32 size); 1025 void arrayfree(Array *array); 1026 int32 arraylength(Array *array); 1027 void* arrayget(Array *array, int32 index); 1028 void arrayset(Array *array, int32 index, void *element); 1029 void arrayadd(Array *array, void *element); 1030 void arraysort(Array* array, int (*cmp)(const void*, const void*)); 1031 1032 /* 1033 * bits.c 1034 */ 1035 int Qconv(Fmt *fp); 1036 Bits band(Bits a, Bits b); 1037 int bany(Bits *a); 1038 int beq(Bits a, Bits b); 1039 int bitno(uint64 b); 1040 Bits blsh(uint n); 1041 Bits bnot(Bits a); 1042 int bnum(Bits a); 1043 Bits bor(Bits a, Bits b); 1044 int btest(Bits *a, uint n); 1045 void biset(Bits *a, uint n); 1046 void biclr(Bits *a, uint n); 1047 1048 /* 1049 * bv.c 1050 */ 1051 Bvec* bvalloc(int32 n); 1052 void bvandnot(Bvec *dst, Bvec *src1, Bvec *src2); 1053 int bvcmp(Bvec *bv1, Bvec *bv2); 1054 void bvcopy(Bvec *dst, Bvec *src); 1055 Bvec* bvconcat(Bvec *src1, Bvec *src2); 1056 int bvget(Bvec *bv, int32 i); 1057 int32 bvnext(Bvec *bv, int32 i); 1058 int bvisempty(Bvec *bv); 1059 void bvnot(Bvec *bv); 1060 void bvor(Bvec *dst, Bvec *src1, Bvec *src2); 1061 void bvand(Bvec *dst, Bvec *src1, Bvec *src2); 1062 void bvprint(Bvec *bv); 1063 void bvreset(Bvec *bv, int32 i); 1064 void bvresetall(Bvec *bv); 1065 void bvset(Bvec *bv, int32 i); 1066 1067 /* 1068 * closure.c 1069 */ 1070 Node* closurebody(NodeList *body); 1071 void closurehdr(Node *ntype); 1072 void typecheckclosure(Node *func, int top); 1073 Node* walkclosure(Node *func, NodeList **init); 1074 void typecheckpartialcall(Node*, Node*); 1075 Node* walkpartialcall(Node*, NodeList**); 1076 1077 /* 1078 * const.c 1079 */ 1080 int cmpslit(Node *l, Node *r); 1081 int consttype(Node *n); 1082 void convconst(Node *con, Type *t, Val *val); 1083 void convlit(Node **np, Type *t); 1084 void convlit1(Node **np, Type *t, int explicit); 1085 void defaultlit(Node **np, Type *t); 1086 void defaultlit2(Node **lp, Node **rp, int force); 1087 void evconst(Node *n); 1088 int isconst(Node *n, int ct); 1089 int isgoconst(Node *n); 1090 Node* nodcplxlit(Val r, Val i); 1091 Node* nodlit(Val v); 1092 long nonnegconst(Node *n); 1093 int doesoverflow(Val v, Type *t); 1094 void overflow(Val v, Type *t); 1095 int smallintconst(Node *n); 1096 Val toint(Val v); 1097 Mpflt* truncfltlit(Mpflt *oldv, Type *t); 1098 1099 /* 1100 * cplx.c 1101 */ 1102 void complexadd(int op, Node *nl, Node *nr, Node *res); 1103 void complexbool(int op, Node *nl, Node *nr, int true, int likely, Prog *to); 1104 void complexgen(Node *n, Node *res); 1105 void complexminus(Node *nl, Node *res); 1106 void complexmove(Node *f, Node *t); 1107 void complexmul(Node *nl, Node *nr, Node *res); 1108 int complexop(Node *n, Node *res); 1109 void nodfconst(Node *n, Type *t, Mpflt* fval); 1110 1111 /* 1112 * dcl.c 1113 */ 1114 void addmethod(Sym *sf, Type *t, int local, int nointerface); 1115 void addvar(Node *n, Type *t, int ctxt); 1116 NodeList* checkarglist(NodeList *all, int input); 1117 Node* colas(NodeList *left, NodeList *right, int32 lno); 1118 void colasdefn(NodeList *left, Node *defn); 1119 NodeList* constiter(NodeList *vl, Node *t, NodeList *cl); 1120 Node* dclname(Sym *s); 1121 void declare(Node *n, int ctxt); 1122 void dumpdcl(char *st); 1123 Node* embedded(Sym *s, Pkg *pkg); 1124 Node* fakethis(void); 1125 void funcbody(Node *n); 1126 void funccompile(Node *n, int isclosure); 1127 void funchdr(Node *n); 1128 Type* functype(Node *this, NodeList *in, NodeList *out); 1129 void ifacedcl(Node *n); 1130 int isifacemethod(Type *f); 1131 void markdcl(void); 1132 Node* methodname(Node *n, Type *t); 1133 Node* methodname1(Node *n, Node *t); 1134 Sym* methodsym(Sym *nsym, Type *t0, int iface); 1135 Node* newname(Sym *s); 1136 Node* oldname(Sym *s); 1137 void popdcl(void); 1138 void poptodcl(void); 1139 void redeclare(Sym *s, char *where); 1140 void testdclstack(void); 1141 Type* tointerface(NodeList *l); 1142 Type* tostruct(NodeList *l); 1143 Node* typedcl0(Sym *s); 1144 Node* typedcl1(Node *n, Node *t, int local); 1145 Node* typenod(Type *t); 1146 NodeList* variter(NodeList *vl, Node *t, NodeList *el); 1147 Sym* funcsym(Sym*); 1148 1149 /* 1150 * esc.c 1151 */ 1152 void escapes(NodeList*); 1153 1154 /* 1155 * export.c 1156 */ 1157 void autoexport(Node *n, int ctxt); 1158 void dumpexport(void); 1159 void dumpasmhdr(void); 1160 int exportname(char *s); 1161 void exportsym(Node *n); 1162 void importconst(Sym *s, Type *t, Node *n); 1163 void importimport(Sym *s, Strlit *z); 1164 Sym* importsym(Sym *s, int op); 1165 void importtype(Type *pt, Type *t); 1166 void importvar(Sym *s, Type *t); 1167 Type* pkgtype(Sym *s); 1168 1169 /* 1170 * fmt.c 1171 */ 1172 void fmtinstallgo(void); 1173 void dump(char *s, Node *n); 1174 void dumplist(char *s, NodeList *l); 1175 1176 /* 1177 * gen.c 1178 */ 1179 void addrescapes(Node *n); 1180 void cgen_as(Node *nl, Node *nr); 1181 void cgen_callmeth(Node *n, int proc); 1182 void cgen_eface(Node* n, Node* res); 1183 void cgen_slice(Node* n, Node* res); 1184 void clearlabels(void); 1185 void clearslim(Node*); 1186 void checklabels(void); 1187 int dotoffset(Node *n, int64 *oary, Node **nn); 1188 void gen(Node *n); 1189 void genlist(NodeList *l); 1190 Node* sysfunc(char *name); 1191 void tempname(Node *n, Type *t); 1192 Node* temp(Type*); 1193 1194 /* 1195 * init.c 1196 */ 1197 void fninit(NodeList *n); 1198 Sym* renameinit(void); 1199 1200 /* 1201 * inl.c 1202 */ 1203 void caninl(Node *fn); 1204 void inlcalls(Node *fn); 1205 void typecheckinl(Node *fn); 1206 1207 /* 1208 * lex.c 1209 */ 1210 void cannedimports(char *file, char *cp); 1211 void importfile(Val *f, int line); 1212 char* lexname(int lex); 1213 char* expstring(void); 1214 void mkpackage(char* pkgname); 1215 void unimportfile(void); 1216 int32 yylex(void); 1217 extern int yylast; 1218 extern int yyprev; 1219 1220 /* 1221 * mparith1.c 1222 */ 1223 int Bconv(Fmt *fp); 1224 int Fconv(Fmt *fp); 1225 void mpaddcfix(Mpint *a, vlong c); 1226 void mpaddcflt(Mpflt *a, double c); 1227 void mpatofix(Mpint *a, char *as); 1228 void mpatoflt(Mpflt *a, char *as); 1229 int mpcmpfixc(Mpint *b, vlong c); 1230 int mpcmpfixfix(Mpint *a, Mpint *b); 1231 int mpcmpfixflt(Mpint *a, Mpflt *b); 1232 int mpcmpfltc(Mpflt *b, double c); 1233 int mpcmpfltfix(Mpflt *a, Mpint *b); 1234 int mpcmpfltflt(Mpflt *a, Mpflt *b); 1235 void mpcomfix(Mpint *a); 1236 void mpdivfixfix(Mpint *a, Mpint *b); 1237 void mpmodfixfix(Mpint *a, Mpint *b); 1238 void mpmovefixfix(Mpint *a, Mpint *b); 1239 void mpmovefixflt(Mpflt *a, Mpint *b); 1240 int mpmovefltfix(Mpint *a, Mpflt *b); 1241 void mpmovefltflt(Mpflt *a, Mpflt *b); 1242 void mpmulcfix(Mpint *a, vlong c); 1243 void mpmulcflt(Mpflt *a, double c); 1244 void mpsubfixfix(Mpint *a, Mpint *b); 1245 void mpsubfltflt(Mpflt *a, Mpflt *b); 1246 1247 /* 1248 * mparith2.c 1249 */ 1250 void mpaddfixfix(Mpint *a, Mpint *b, int); 1251 void mpandfixfix(Mpint *a, Mpint *b); 1252 void mpandnotfixfix(Mpint *a, Mpint *b); 1253 void mpdivfract(Mpint *a, Mpint *b); 1254 void mpdivmodfixfix(Mpint *q, Mpint *r, Mpint *n, Mpint *d); 1255 vlong mpgetfix(Mpint *a); 1256 void mplshfixfix(Mpint *a, Mpint *b); 1257 void mpmovecfix(Mpint *a, vlong c); 1258 void mpmulfixfix(Mpint *a, Mpint *b); 1259 void mpmulfract(Mpint *a, Mpint *b); 1260 void mpnegfix(Mpint *a); 1261 void mporfixfix(Mpint *a, Mpint *b); 1262 void mprshfixfix(Mpint *a, Mpint *b); 1263 void mpshiftfix(Mpint *a, int s); 1264 int mptestfix(Mpint *a); 1265 void mpxorfixfix(Mpint *a, Mpint *b); 1266 1267 /* 1268 * mparith3.c 1269 */ 1270 void mpaddfltflt(Mpflt *a, Mpflt *b); 1271 void mpdivfltflt(Mpflt *a, Mpflt *b); 1272 double mpgetflt(Mpflt *a); 1273 double mpgetflt32(Mpflt *a); 1274 void mpmovecflt(Mpflt *a, double c); 1275 void mpmulfltflt(Mpflt *a, Mpflt *b); 1276 void mpnegflt(Mpflt *a); 1277 void mpnorm(Mpflt *a); 1278 void mpsetexp(Mpflt *a, int exp); 1279 int mptestflt(Mpflt *a); 1280 int sigfig(Mpflt *a); 1281 1282 /* 1283 * obj.c 1284 */ 1285 void Bputname(Biobuf *b, LSym *s); 1286 int duint16(Sym *s, int off, uint16 v); 1287 int duint32(Sym *s, int off, uint32 v); 1288 int duint64(Sym *s, int off, uint64 v); 1289 int duint8(Sym *s, int off, uint8 v); 1290 int duintptr(Sym *s, int off, uint64 v); 1291 int dsname(Sym *s, int off, char *dat, int ndat); 1292 void dumpobj(void); 1293 Sym* stringsym(char*, int); 1294 void slicebytes(Node*, char*, int); 1295 LSym* linksym(Sym*); 1296 1297 /* 1298 * order.c 1299 */ 1300 void order(Node *fn); 1301 void orderstmtinplace(Node **stmt); 1302 1303 /* 1304 * range.c 1305 */ 1306 void typecheckrange(Node *n); 1307 void walkrange(Node *n); 1308 1309 /* 1310 * reflect.c 1311 */ 1312 void dumptypestructs(void); 1313 Type* methodfunc(Type *f, Type*); 1314 Node* typename(Type *t); 1315 Sym* typesym(Type *t); 1316 Sym* typenamesym(Type *t); 1317 Sym* tracksym(Type *t); 1318 Sym* typesymprefix(char *prefix, Type *t); 1319 int haspointers(Type *t); 1320 Type* hiter(Type* t); 1321 1322 /* 1323 * select.c 1324 */ 1325 void typecheckselect(Node *sel); 1326 void walkselect(Node *sel); 1327 1328 /* 1329 * sinit.c 1330 */ 1331 void anylit(int, Node *n, Node *var, NodeList **init); 1332 int gen_as_init(Node *n); 1333 NodeList* initfix(NodeList *l); 1334 int oaslit(Node *n, NodeList **init); 1335 int stataddr(Node *nam, Node *n); 1336 1337 /* 1338 * subr.c 1339 */ 1340 Node* adddot(Node *n); 1341 int adddot1(Sym *s, Type *t, int d, Type **save, int ignorecase); 1342 void addinit(Node**, NodeList*); 1343 Type* aindex(Node *b, Type *t); 1344 int algtype(Type *t); 1345 int algtype1(Type *t, Type **bad); 1346 void argtype(Node *on, Type *t); 1347 Node* assignconv(Node *n, Type *t, char *context); 1348 int assignop(Type *src, Type *dst, char **why); 1349 void badtype(int o, Type *tl, Type *tr); 1350 int brcom(int a); 1351 int brrev(int a); 1352 NodeList* concat(NodeList *a, NodeList *b); 1353 int convertop(Type *src, Type *dst, char **why); 1354 Node* copyexpr(Node*, Type*, NodeList**); 1355 int count(NodeList *l); 1356 int cplxsubtype(int et); 1357 int eqtype(Type *t1, Type *t2); 1358 int eqtypenoname(Type *t1, Type *t2); 1359 void errorexit(void); 1360 void expandmeth(Type *t); 1361 void fatal(char *fmt, ...); 1362 void flusherrors(void); 1363 void frame(int context); 1364 Type* funcfirst(Iter *s, Type *t); 1365 Type* funcnext(Iter *s); 1366 void genwrapper(Type *rcvr, Type *method, Sym *newnam, int iface); 1367 void genhash(Sym *sym, Type *t); 1368 void geneq(Sym *sym, Type *t); 1369 Type** getinarg(Type *t); 1370 Type* getinargx(Type *t); 1371 Type** getoutarg(Type *t); 1372 Type* getoutargx(Type *t); 1373 Type** getthis(Type *t); 1374 Type* getthisx(Type *t); 1375 int implements(Type *t, Type *iface, Type **missing, Type **have, int *ptr); 1376 void importdot(Pkg *opkg, Node *pack); 1377 int is64(Type *t); 1378 int isbadimport(Strlit *s); 1379 int isblank(Node *n); 1380 int isblanksym(Sym *s); 1381 int isdirectiface(Type*); 1382 int isfixedarray(Type *t); 1383 int isideal(Type *t); 1384 int isinter(Type *t); 1385 int isnil(Node *n); 1386 int isnilinter(Type *t); 1387 int isptrto(Type *t, int et); 1388 int isslice(Type *t); 1389 int istype(Type *t, int et); 1390 int iszero(Node *n); 1391 void linehist(char *file, int32 off, int relative); 1392 NodeList* list(NodeList *l, Node *n); 1393 NodeList* list1(Node *n); 1394 void listsort(NodeList**, int(*f)(Node*, Node*)); 1395 Node* liststmt(NodeList *l); 1396 NodeList* listtreecopy(NodeList *l); 1397 Sym* lookup(char *name); 1398 void* mal(int32 n); 1399 Type* maptype(Type *key, Type *val); 1400 Type* methtype(Type *t, int mustname); 1401 Pkg* mkpkg(Strlit *path); 1402 Sym* ngotype(Node *n); 1403 int noconv(Type *t1, Type *t2); 1404 Node* nod(int op, Node *nleft, Node *nright); 1405 Node* nodbool(int b); 1406 void nodconst(Node *n, Type *t, int64 v); 1407 Node* nodintconst(int64 v); 1408 Node* nodfltconst(Mpflt *v); 1409 Node* nodnil(void); 1410 int parserline(void); 1411 Sym* pkglookup(char *name, Pkg *pkg); 1412 int powtwo(Node *n); 1413 Type* ptrto(Type *t); 1414 void* remal(void *p, int32 on, int32 n); 1415 Sym* restrictlookup(char *name, Pkg *pkg); 1416 Node* safeexpr(Node *n, NodeList **init); 1417 void saveerrors(void); 1418 Node* cheapexpr(Node *n, NodeList **init); 1419 Node* localexpr(Node *n, Type *t, NodeList **init); 1420 void saveorignode(Node *n); 1421 int32 setlineno(Node *n); 1422 void setmaxarg(Type *t, int32 extra); 1423 Type* shallow(Type *t); 1424 int simsimtype(Type *t); 1425 void smagic(Magic *m); 1426 Type* sortinter(Type *t); 1427 uint32 stringhash(char *p); 1428 Strlit* strlit(char *s); 1429 int structcount(Type *t); 1430 Type* structfirst(Iter *s, Type **nn); 1431 Type* structnext(Iter *s); 1432 Node* syslook(char *name, int copy); 1433 Type* tounsigned(Type *t); 1434 Node* treecopy(Node *n); 1435 Type* typ(int et); 1436 uint32 typehash(Type *t); 1437 void ullmancalc(Node *n); 1438 void umagic(Magic *m); 1439 void warn(char *fmt, ...); 1440 void warnl(int line, char *fmt, ...); 1441 void yyerror(char *fmt, ...); 1442 void yyerrorl(int line, char *fmt, ...); 1443 1444 /* 1445 * swt.c 1446 */ 1447 void typecheckswitch(Node *n); 1448 void walkswitch(Node *sw); 1449 1450 /* 1451 * typecheck.c 1452 */ 1453 int islvalue(Node *n); 1454 Node* typecheck(Node **np, int top); 1455 void typechecklist(NodeList *l, int top); 1456 Node* typecheckdef(Node *n); 1457 void copytype(Node *n, Type *t); 1458 void checkreturn(Node*); 1459 void queuemethod(Node *n); 1460 1461 /* 1462 * unsafe.c 1463 */ 1464 int isunsafebuiltin(Node *n); 1465 Node* unsafenmagic(Node *n); 1466 1467 /* 1468 * walk.c 1469 */ 1470 Node* callnew(Type *t); 1471 Node* chanfn(char *name, int n, Type *t); 1472 Node* mkcall(char *name, Type *t, NodeList **init, ...); 1473 Node* mkcall1(Node *fn, Type *t, NodeList **init, ...); 1474 int vmatch1(Node *l, Node *r); 1475 void walk(Node *fn); 1476 void walkexpr(Node **np, NodeList **init); 1477 void walkexprlist(NodeList *l, NodeList **init); 1478 void walkexprlistsafe(NodeList *l, NodeList **init); 1479 void walkexprlistcheap(NodeList *l, NodeList **init); 1480 void walkstmt(Node **np); 1481 void walkstmtlist(NodeList *l); 1482 Node* conv(Node*, Type*); 1483 int candiscard(Node*); 1484 int needwritebarrier(Node*, Node*); 1485 Node* outervalue(Node*); 1486 void usefield(Node*); 1487 1488 /* 1489 * arch-specific ggen.c/gsubr.c/gobj.c/pgen.c/plive.c 1490 */ 1491 #define P ((Prog*)0) 1492 1493 EXTERN Prog* continpc; 1494 EXTERN Prog* breakpc; 1495 EXTERN Prog* pc; 1496 EXTERN Prog* firstpc; 1497 1498 EXTERN Node* nodfp; 1499 EXTERN int disable_checknil; 1500 EXTERN vlong zerosize; 1501 1502 int anyregalloc(void); 1503 void betypeinit(void); 1504 void bgen(Node *n, int true, int likely, Prog *to); 1505 void checknil(Node*, NodeList**); 1506 void expandchecks(Prog*); 1507 void cgen(Node*, Node*); 1508 void cgen_asop(Node *n); 1509 void cgen_call(Node *n, int proc); 1510 void cgen_callinter(Node *n, Node *res, int proc); 1511 void cgen_checknil(Node*); 1512 void cgen_ret(Node *n); 1513 void clearfat(Node *n); 1514 void compile(Node*); 1515 void defframe(Prog*); 1516 int dgostringptr(Sym*, int off, char *str); 1517 int dgostrlitptr(Sym*, int off, Strlit*); 1518 int dstringptr(Sym *s, int off, char *str); 1519 int dsymptr(Sym *s, int off, Sym *x, int xoff); 1520 int duintxx(Sym *s, int off, uint64 v, int wid); 1521 void dumpdata(void); 1522 void fixautoused(Prog*); 1523 void gdata(Node*, Node*, int); 1524 void gdatacomplex(Node*, Mpcplx*); 1525 void gdatastring(Node*, Strlit*); 1526 void ggloblnod(Node *nam); 1527 void ggloblsym(Sym *s, int32 width, int8 flags); 1528 void gvardef(Node*); 1529 void gvarkill(Node*); 1530 Prog* gjmp(Prog*); 1531 void gused(Node*); 1532 void movelarge(NodeList*); 1533 int isfat(Type*); 1534 void linkarchinit(void); 1535 void liveness(Node*, Prog*, Sym*, Sym*); 1536 void twobitwalktype1(Type*, vlong*, Bvec*); 1537 void markautoused(Prog*); 1538 Plist* newplist(void); 1539 Node* nodarg(Type*, int); 1540 void nopout(Prog*); 1541 void patch(Prog*, Prog*); 1542 Prog* unpatch(Prog*); 1543 1544 #pragma varargck type "B" Mpint* 1545 #pragma varargck type "E" int 1546 #pragma varargck type "E" uint 1547 #pragma varargck type "F" Mpflt* 1548 #pragma varargck type "H" NodeList* 1549 #pragma varargck type "J" Node* 1550 #pragma varargck type "lL" int32 1551 #pragma varargck type "L" int32 1552 #pragma varargck type "N" Node* 1553 #pragma varargck type "lN" Node* 1554 #pragma varargck type "O" int 1555 #pragma varargck type "O" uint 1556 #pragma varargck type "Q" Bits 1557 #pragma varargck type "S" Sym* 1558 #pragma varargck type "lS" LSym* 1559 #pragma varargck type "T" Type* 1560 #pragma varargck type "lT" Type* 1561 #pragma varargck type "V" Val* 1562 #pragma varargck type "Z" Strlit* 1563 1564 /* 1565 * racewalk.c 1566 */ 1567 void racewalk(Node *fn);