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