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