#include <bio.h>
#include <link.h>
#undef OAPPEND
#undef isblank
#define isblank goisblank
#ifndef EXTERN
#define EXTERN extern
#endif
#undef BUFSIZ
#define YYMAXDEPTH 500
enum
{
NHUNK = 50000,
BUFSIZ = 8192,
NSYMB = 500,
NHASH = 1024,
STRINGSZ = 200,
MAXALIGN = 7,
UINF = 100,
PRIME1 = 3,
AUNK = 100,
AMEM = 0,
AMEM0,
AMEM8,
AMEM16,
AMEM32,
AMEM64,
AMEM128,
ANOEQ,
ANOEQ0,
ANOEQ8,
ANOEQ16,
ANOEQ32,
ANOEQ64,
ANOEQ128,
ASTRING,
AINTER,
ANILINTER,
ASLICE,
AFLOAT32,
AFLOAT64,
ACPLX64,
ACPLX128,
BADWIDTH = -1000000000,
MaxStackVarSize = 10*1024*1024,
};
extern vlong MAXWIDTH;
typedef struct Strlit Strlit;
struct Strlit
{
int32 len;
char s[1];
};
enum
{
Mpscale = 29,
Mpprec = 16,
Mpnorm = Mpprec - 1,
Mpbase = 1L << Mpscale,
Mpsign = Mpbase >> 1,
Mpmask = Mpbase - 1,
Mpdebug = 0,
};
typedef struct Mpint Mpint;
struct Mpint
{
long a[Mpprec];
uchar neg;
uchar ovf;
};
typedef struct Mpflt Mpflt;
struct Mpflt
{
Mpint val;
short exp;
};
typedef struct Mpcplx Mpcplx;
struct Mpcplx
{
Mpflt real;
Mpflt imag;
};
typedef struct Val Val;
struct Val
{
short ctype;
union
{
short reg;
short bval;
Mpint* xval;
Mpflt* fval;
Mpcplx* cval;
Strlit* sval;
} u;
};
#pragma incomplete struct Array
typedef struct Array Array;
typedef struct Bvec Bvec;
typedef struct Pkg Pkg;
typedef struct Sym Sym;
typedef struct Node Node;
typedef struct NodeList NodeList;
typedef struct Type Type;
typedef struct Label Label;
struct Type
{
uchar etype;
uchar nointerface;
uchar noalg;
uchar chan;
uchar trecur;
uchar printed;
uchar embedded;
uchar siggen;
uchar funarg;
uchar copyany;
uchar local;
uchar deferwidth;
uchar broke;
uchar isddd;
uchar align;
uchar haspointers;
Node* nod;
Type* orig;
int lineno;
int thistuple;
int outtuple;
int intuple;
uchar outnamed;
Type* method;
Type* xmethod;
Sym* sym;
int32 vargen;
Node* nname;
vlong argwid;
Type* type;
vlong width;
Type* down;
Type* outer;
Strlit* note;
vlong bound;
Type* bucket;
Type* hmap;
Type* hiter;
Type* map;
int32 maplineno;
int32 embedlineno;
NodeList *copyto;
Node *lastfn;
};
#define T ((Type*)0)
typedef struct InitEntry InitEntry;
typedef struct InitPlan InitPlan;
struct InitEntry
{
vlong xoffset;
Node *key;
Node *expr;
};
struct InitPlan
{
vlong lit;
vlong zero;
vlong expr;
InitEntry *e;
int len;
int cap;
};
enum
{
EscUnknown,
EscHeap,
EscScope,
EscNone,
EscReturn,
EscNever,
EscBits = 3,
EscMask = (1<<EscBits) - 1,
EscContentEscapes = 1<<EscBits,
EscReturnBits = EscBits+1,
};
struct Node
{
Node* left;
Node* right;
Node* ntest;
Node* nincr;
NodeList* ninit;
NodeList* nbody;
NodeList* nelse;
NodeList* list;
NodeList* rlist;
uchar op;
uchar nointerface;
uchar ullman;
uchar addable;
uchar trecur;
uchar etype;
uchar bounded;
uchar class;
uchar method;
uchar embedded;
uchar colas;
uchar diag;
uchar noescape;
uchar builtin;
uchar walkdef;
uchar typecheck;
uchar local;
uchar dodata;
uchar initorder;
uchar used;
uchar isddd;
uchar readonly;
uchar implicit;
uchar addrtaken;
uchar dupok;
uchar wrapper;
schar likely;
uchar hasbreak;
uchar needzero;
uchar needctxt;
uint esc;
int funcdepth;
Type* type;
Node* orig;
Node* nname;
Node* shortname;
NodeList* enter;
NodeList* exit;
NodeList* cvars;
NodeList* dcl;
NodeList* inl;
NodeList* inldcl;
Val val;
Node* ntype;
Node* defn;
Node* pack;
Node* curfn;
Type* paramfld;
Node* heapaddr;
Node* stackparam;
Node* alloc;
Node* outer;
Node* closure;
Node* inlvar;
Pkg* pkg;
InitPlan* initplan;
NodeList* escflowsrc;
NodeList* escretval;
int escloopdepth;
Sym* sym;
int32 vargen;
int32 lineno;
int32 endlineno;
vlong xoffset;
vlong stkdelta;
int32 ostk;
int32 iota;
uint32 walkgen;
int32 esclevel;
void* opt;
};
#define N ((Node*)0)
EXTERN uint32 walkgen;
struct NodeList
{
Node* n;
NodeList* next;
NodeList* end;
};
enum
{
SymExport = 1<<0,
SymPackage = 1<<1,
SymExported = 1<<2,
SymUniq = 1<<3,
SymSiggen = 1<<4,
SymGcgen = 1<<5,
};
struct Sym
{
ushort lexical;
uchar flags;
uchar sym;
Sym* link;
int32 npkg;
uint32 uniqgen;
Pkg* importdef;
Pkg* pkg;
char* name;
Node* def;
Label* label;
int32 block;
int32 lastlineno;
Pkg* origpkg;
LSym* lsym;
};
#define S ((Sym*)0)
EXTERN Sym* dclstack;
struct Pkg
{
char* name;
Strlit* path;
Sym* pathsym;
char* prefix;
Pkg* link;
uchar imported;
char exported;
char direct;
char safe;
};
typedef struct Iter Iter;
struct Iter
{
int done;
Type* tfunc;
Type* t;
Node** an;
Node* n;
};
enum
{
OXXX,
ONAME,
ONONAME,
OTYPE,
OPACK,
OLITERAL,
OADD,
OSUB,
OOR,
OXOR,
OADDPTR,
OADDSTR,
OADDR,
OANDAND,
OAPPEND,
OARRAYBYTESTR,
OARRAYBYTESTRTMP,
OARRAYRUNESTR,
OSTRARRAYBYTE,
OSTRARRAYRUNE,
OAS,
OAS2,
OAS2FUNC,
OAS2RECV,
OAS2MAPR,
OAS2DOTTYPE,
OASOP,
OCALL,
OCALLFUNC,
OCALLMETH,
OCALLINTER,
OCALLPART,
OCAP,
OCLOSE,
OCLOSURE,
OCMPIFACE,
OCMPSTR,
OCOMPLIT,
OMAPLIT,
OSTRUCTLIT,
OARRAYLIT,
OPTRLIT,
OCONV,
OCONVIFACE,
OCONVNOP,
OCOPY,
ODCL,
ODCLFUNC,
ODCLFIELD,
ODCLCONST,
ODCLTYPE,
ODELETE,
ODOT,
ODOTPTR,
ODOTMETH,
ODOTINTER,
OXDOT,
ODOTTYPE,
ODOTTYPE2,
OEQ,
ONE,
OLT,
OLE,
OGE,
OGT,
OIND,
OINDEX,
OINDEXMAP,
OKEY,
OPARAM,
OLEN,
OMAKE,
OMAKECHAN,
OMAKEMAP,
OMAKESLICE,
OMUL,
ODIV,
OMOD,
OLSH,
ORSH,
OAND,
OANDNOT,
ONEW,
ONOT,
OCOM,
OPLUS,
OMINUS,
OOROR,
OPANIC,
OPRINT,
OPRINTN,
OPAREN,
OSEND,
OSLICE,
OSLICEARR,
OSLICESTR,
OSLICE3,
OSLICE3ARR,
ORECOVER,
ORECV,
ORUNESTR,
OSELRECV,
OSELRECV2,
OIOTA,
OREAL,
OIMAG,
OCOMPLEX,
OBLOCK,
OBREAK,
OCASE,
OXCASE,
OCONTINUE,
ODEFER,
OEMPTY,
OFALL,
OXFALL,
OFOR,
OGOTO,
OIF,
OLABEL,
OPROC,
ORANGE,
ORETURN,
OSELECT,
OSWITCH,
OTYPESW,
OTCHAN,
OTMAP,
OTSTRUCT,
OTINTER,
OTFUNC,
OTARRAY,
OTPAREN,
ODDD,
ODDDARG,
OINLCALL,
OEFACE,
OITAB,
OSPTR,
OCLOSUREVAR,
OCFUNC,
OCHECKNIL,
OVARKILL,
OREGISTER,
OINDREG,
OCMP,
ODEC,
OINC,
OEXTEND,
OHMUL,
OLROT,
ORROTC,
ORETJMP,
OEND,
};
enum
{
Txxx,
TINT8, TUINT8,
TINT16, TUINT16,
TINT32, TUINT32,
TINT64, TUINT64,
TINT, TUINT, TUINTPTR,
TCOMPLEX64,
TCOMPLEX128,
TFLOAT32,
TFLOAT64,
TBOOL,
TPTR32, TPTR64,
TFUNC,
TARRAY,
T_old_DARRAY,
TSTRUCT,
TCHAN,
TMAP,
TINTER,
TFORW,
TFIELD,
TANY,
TSTRING,
TUNSAFEPTR,
TIDEAL,
TNIL,
TBLANK,
TFUNCARGS,
TCHANARGS,
TINTERMETH,
NTYPE,
};
enum
{
CTxxx,
CTINT,
CTRUNE,
CTFLT,
CTCPLX,
CTSTR,
CTBOOL,
CTNIL,
};
enum
{
Cxxx,
Crecv = 1<<0,
Csend = 1<<1,
Cboth = Crecv | Csend,
};
enum
{
Pxxx,
PEXTERN,
PAUTO,
PPARAM,
PPARAMOUT,
PPARAMREF,
PFUNC,
PDISCARD,
PHEAP = 1<<7,
};
enum
{
Etop = 1<<1,
Erv = 1<<2,
Etype = 1<<3,
Ecall = 1<<4,
Efnstruct = 1<<5,
Eiota = 1<<6,
Easgn = 1<<7,
Eindir = 1<<8,
Eaddr = 1<<9,
Eproc = 1<<10,
Ecomplit = 1<<11,
};
#define BITS 5
#define NVAR (BITS*sizeof(uint32)*8)
typedef struct Bits Bits;
struct Bits
{
uint32 b[BITS];
};
EXTERN Bits zbits;
struct Bvec
{
int32 n;
uint32 b[];
};
typedef struct Var Var;
struct Var
{
vlong offset;
Node* node;
Var* nextinnode;
int width;
char name;
char etype;
char addr;
};
EXTERN Var var[NVAR];
typedef struct Typedef Typedef;
struct Typedef
{
char* name;
int etype;
int sameas;
};
extern Typedef typedefs[];
typedef struct Sig Sig;
struct Sig
{
char* name;
Pkg* pkg;
Sym* isym;
Sym* tsym;
Type* type;
Type* mtype;
int32 offset;
Sig* link;
};
typedef struct Io Io;
struct Io
{
char* infile;
Biobuf* bin;
int32 ilineno;
int nlsemi;
int eofnl;
int last;
int peekc;
int peekc1;
char* cp;
int importsafe;
};
typedef struct Dlist Dlist;
struct Dlist
{
Type* field;
};
typedef struct Idir Idir;
struct Idir
{
Idir* link;
char* dir;
};
typedef struct Magic Magic;
struct Magic
{
int w;
int s;
int bad;
int64 sd;
int64 sm;
uint64 ud;
uint64 um;
int ua;
};
struct Label
{
uchar used;
Sym* sym;
Node* def;
NodeList* use;
Label* link;
Prog* gotopc;
Prog* labelpc;
Prog* breakpc;
Prog* continpc;
};
#define L ((Label*)0)
EXTERN int Array_array;
EXTERN int Array_nel;
EXTERN int Array_cap;
EXTERN int sizeof_Array;
EXTERN int sizeof_String;
EXTERN Dlist dotlist[10];
EXTERN Io curio;
EXTERN Io pushedio;
EXTERN int32 lexlineno;
EXTERN int32 lineno;
EXTERN int32 prevlineno;
EXTERN char* infile;
EXTERN char* outfile;
EXTERN Biobuf* bout;
EXTERN int nerrors;
EXTERN int nsavederrors;
EXTERN int nsyntaxerrors;
EXTERN int safemode;
EXTERN int nolocalimports;
EXTERN char namebuf[NSYMB];
EXTERN char lexbuf[NSYMB];
EXTERN char litbuf[NSYMB];
EXTERN int debug[256];
EXTERN char* debugstr;
EXTERN int debug_checknil;
EXTERN Sym* hash[NHASH];
EXTERN Sym* importmyname;
EXTERN Pkg* localpkg;
EXTERN Pkg* importpkg;
EXTERN Pkg* structpkg;
EXTERN Pkg* builtinpkg;
EXTERN Pkg* gostringpkg;
EXTERN Pkg* itabpkg;
EXTERN Pkg* runtimepkg;
EXTERN Pkg* racepkg;
EXTERN Pkg* stringpkg;
EXTERN Pkg* typepkg;
EXTERN Pkg* typelinkpkg;
EXTERN Pkg* weaktypepkg;
EXTERN Pkg* unsafepkg;
EXTERN Pkg* trackpkg;
EXTERN Pkg* phash[128];
EXTERN int tptr;
extern char* runtimeimport;
extern char* unsafeimport;
EXTERN char* myimportpath;
EXTERN Idir* idirs;
EXTERN char* localimport;
EXTERN Type* types[NTYPE];
EXTERN Type* idealstring;
EXTERN Type* idealbool;
EXTERN Type* bytetype;
EXTERN Type* runetype;
EXTERN Type* errortype;
EXTERN uchar simtype[NTYPE];
EXTERN uchar isptr[NTYPE];
EXTERN uchar isforw[NTYPE];
EXTERN uchar isint[NTYPE];
EXTERN uchar isfloat[NTYPE];
EXTERN uchar iscomplex[NTYPE];
EXTERN uchar issigned[NTYPE];
EXTERN uchar issimple[NTYPE];
EXTERN uchar okforeq[NTYPE];
EXTERN uchar okforadd[NTYPE];
EXTERN uchar okforand[NTYPE];
EXTERN uchar okfornone[NTYPE];
EXTERN uchar okforcmp[NTYPE];
EXTERN uchar okforbool[NTYPE];
EXTERN uchar okforcap[NTYPE];
EXTERN uchar okforlen[NTYPE];
EXTERN uchar okforarith[NTYPE];
EXTERN uchar okforconst[NTYPE];
EXTERN uchar* okfor[OEND];
EXTERN uchar iscmp[OEND];
EXTERN Mpint* minintval[NTYPE];
EXTERN Mpint* maxintval[NTYPE];
EXTERN Mpflt* minfltval[NTYPE];
EXTERN Mpflt* maxfltval[NTYPE];
EXTERN NodeList* xtop;
EXTERN NodeList* externdcl;
EXTERN NodeList* closures;
EXTERN NodeList* exportlist;
EXTERN NodeList* importlist;
EXTERN NodeList* funcsyms;
EXTERN int dclcontext;
EXTERN int incannedimport;
EXTERN int statuniqgen;
EXTERN int loophack;
EXTERN int32 iota;
EXTERN NodeList* lastconst;
EXTERN Node* lasttype;
EXTERN vlong maxarg;
EXTERN vlong stksize;
EXTERN vlong stkptrsize;
EXTERN int32 blockgen;
EXTERN int32 block;
EXTERN int hasdefer;
EXTERN Node* curfn;
EXTERN int widthptr;
EXTERN int widthint;
EXTERN int widthreg;
EXTERN Node* typesw;
EXTERN Node* nblank;
extern int thechar;
extern char* thestring;
extern LinkArch* thelinkarch;
EXTERN int use_sse;
EXTERN char* hunk;
EXTERN int32 nhunk;
EXTERN int32 thunk;
EXTERN int funcdepth;
EXTERN int typecheckok;
EXTERN int compiling_runtime;
EXTERN int compiling_wrappers;
EXTERN int pure_go;
EXTERN char* flag_installsuffix;
EXTERN int flag_race;
EXTERN int flag_largemodel;
EXTERN int noescape;
EXTERN int debuglive;
EXTERN Link* ctxt;
EXTERN int nointerface;
EXTERN int fieldtrack_enabled;
EXTERN int precisestack_enabled;
EXTERN int writearchive;
EXTERN Biobuf bstdout;
EXTERN int nacl;
int yyparse(void);
int argsize(Type *t);
void checkwidth(Type *t);
void defercheckwidth(void);
void dowidth(Type *t);
void resumecheckwidth(void);
vlong rnd(vlong o, vlong r);
void typeinit(void);
Array* arraynew(int32 capacity, int32 size);
void arrayfree(Array *array);
int32 arraylength(Array *array);
void* arrayget(Array *array, int32 index);
void arrayset(Array *array, int32 index, void *element);
void arrayadd(Array *array, void *element);
int32 arrayindexof(Array* array, void *element);
void arraysort(Array* array, int (*cmp)(const void*, const void*));
int Qconv(Fmt *fp);
Bits band(Bits a, Bits b);
int bany(Bits *a);
int beq(Bits a, Bits b);
int bitno(int32 b);
Bits blsh(uint n);
Bits bnot(Bits a);
int bnum(Bits a);
Bits bor(Bits a, Bits b);
int bset(Bits a, uint n);
Bvec* bvalloc(int32 n);
void bvandnot(Bvec *dst, Bvec *src1, Bvec *src2);
int bvcmp(Bvec *bv1, Bvec *bv2);
void bvcopy(Bvec *dst, Bvec *src);
Bvec* bvconcat(Bvec *src1, Bvec *src2);
int bvget(Bvec *bv, int32 i);
int bvisempty(Bvec *bv);
void bvnot(Bvec *bv);
void bvor(Bvec *dst, Bvec *src1, Bvec *src2);
void bvand(Bvec *dst, Bvec *src1, Bvec *src2);
void bvprint(Bvec *bv);
void bvreset(Bvec *bv, int32 i);
void bvresetall(Bvec *bv);
void bvset(Bvec *bv, int32 i);
Node* closurebody(NodeList *body);
void closurehdr(Node *ntype);
void typecheckclosure(Node *func, int top);
Node* walkclosure(Node *func, NodeList **init);
void typecheckpartialcall(Node*, Node*);
Node* walkpartialcall(Node*, NodeList**);
int cmpslit(Node *l, Node *r);
int consttype(Node *n);
void convconst(Node *con, Type *t, Val *val);
void convlit(Node **np, Type *t);
void convlit1(Node **np, Type *t, int explicit);
void defaultlit(Node **np, Type *t);
void defaultlit2(Node **lp, Node **rp, int force);
void evconst(Node *n);
int isconst(Node *n, int ct);
int isgoconst(Node *n);
Node* nodcplxlit(Val r, Val i);
Node* nodlit(Val v);
long nonnegconst(Node *n);
int doesoverflow(Val v, Type *t);
void overflow(Val v, Type *t);
int smallintconst(Node *n);
Val toint(Val v);
Mpflt* truncfltlit(Mpflt *oldv, Type *t);
void complexadd(int op, Node *nl, Node *nr, Node *res);
void complexbool(int op, Node *nl, Node *nr, int true, int likely, Prog *to);
void complexgen(Node *n, Node *res);
void complexminus(Node *nl, Node *res);
void complexmove(Node *f, Node *t);
void complexmul(Node *nl, Node *nr, Node *res);
int complexop(Node *n, Node *res);
void nodfconst(Node *n, Type *t, Mpflt* fval);
void addmethod(Sym *sf, Type *t, int local, int nointerface);
void addvar(Node *n, Type *t, int ctxt);
NodeList* checkarglist(NodeList *all, int input);
Node* colas(NodeList *left, NodeList *right, int32 lno);
void colasdefn(NodeList *left, Node *defn);
NodeList* constiter(NodeList *vl, Node *t, NodeList *cl);
Node* dclname(Sym *s);
void declare(Node *n, int ctxt);
void dumpdcl(char *st);
Node* embedded(Sym *s, Pkg *pkg);
Node* fakethis(void);
void funcbody(Node *n);
void funccompile(Node *n, int isclosure);
void funchdr(Node *n);
Type* functype(Node *this, NodeList *in, NodeList *out);
void ifacedcl(Node *n);
int isifacemethod(Type *f);
void markdcl(void);
Node* methodname(Node *n, Type *t);
Node* methodname1(Node *n, Node *t);
Sym* methodsym(Sym *nsym, Type *t0, int iface);
Node* newname(Sym *s);
Node* oldname(Sym *s);
void popdcl(void);
void poptodcl(void);
void redeclare(Sym *s, char *where);
void testdclstack(void);
Type* tointerface(NodeList *l);
Type* tostruct(NodeList *l);
Node* typedcl0(Sym *s);
Node* typedcl1(Node *n, Node *t, int local);
Node* typenod(Type *t);
NodeList* variter(NodeList *vl, Node *t, NodeList *el);
Sym* funcsym(Sym*);
void escapes(NodeList*);
void autoexport(Node *n, int ctxt);
void dumpexport(void);
int exportname(char *s);
void exportsym(Node *n);
void importconst(Sym *s, Type *t, Node *n);
void importimport(Sym *s, Strlit *z);
Sym* importsym(Sym *s, int op);
void importtype(Type *pt, Type *t);
void importvar(Sym *s, Type *t);
Type* pkgtype(Sym *s);
void fmtinstallgo(void);
void dump(char *s, Node *n);
void dumplist(char *s, NodeList *l);
void addrescapes(Node *n);
void cgen_as(Node *nl, Node *nr);
void cgen_callmeth(Node *n, int proc);
void cgen_eface(Node* n, Node* res);
void cgen_slice(Node* n, Node* res);
void clearlabels(void);
void checklabels(void);
int dotoffset(Node *n, int64 *oary, Node **nn);
void gen(Node *n);
void genlist(NodeList *l);
Node* sysfunc(char *name);
void tempname(Node *n, Type *t);
Node* temp(Type*);
void fninit(NodeList *n);
Sym* renameinit(void);
void caninl(Node *fn);
void inlcalls(Node *fn);
void typecheckinl(Node *fn);
void cannedimports(char *file, char *cp);
void importfile(Val *f, int line);
char* lexname(int lex);
char* expstring(void);
void mkpackage(char* pkgname);
void unimportfile(void);
int32 yylex(void);
extern int yylast;
extern int yyprev;
int Bconv(Fmt *fp);
int Fconv(Fmt *fp);
void mpaddcfix(Mpint *a, vlong c);
void mpaddcflt(Mpflt *a, double c);
void mpatofix(Mpint *a, char *as);
void mpatoflt(Mpflt *a, char *as);
int mpcmpfixc(Mpint *b, vlong c);
int mpcmpfixfix(Mpint *a, Mpint *b);
int mpcmpfixflt(Mpint *a, Mpflt *b);
int mpcmpfltc(Mpflt *b, double c);
int mpcmpfltfix(Mpflt *a, Mpint *b);
int mpcmpfltflt(Mpflt *a, Mpflt *b);
void mpcomfix(Mpint *a);
void mpdivfixfix(Mpint *a, Mpint *b);
void mpmodfixfix(Mpint *a, Mpint *b);
void mpmovefixfix(Mpint *a, Mpint *b);
void mpmovefixflt(Mpflt *a, Mpint *b);
int mpmovefltfix(Mpint *a, Mpflt *b);
void mpmovefltflt(Mpflt *a, Mpflt *b);
void mpmulcfix(Mpint *a, vlong c);
void mpmulcflt(Mpflt *a, double c);
void mpsubfixfix(Mpint *a, Mpint *b);
void mpsubfltflt(Mpflt *a, Mpflt *b);
void mpaddfixfix(Mpint *a, Mpint *b, int);
void mpandfixfix(Mpint *a, Mpint *b);
void mpandnotfixfix(Mpint *a, Mpint *b);
void mpdivfract(Mpint *a, Mpint *b);
void mpdivmodfixfix(Mpint *q, Mpint *r, Mpint *n, Mpint *d);
vlong mpgetfix(Mpint *a);
void mplshfixfix(Mpint *a, Mpint *b);
void mpmovecfix(Mpint *a, vlong c);
void mpmulfixfix(Mpint *a, Mpint *b);
void mpmulfract(Mpint *a, Mpint *b);
void mpnegfix(Mpint *a);
void mporfixfix(Mpint *a, Mpint *b);
void mprshfixfix(Mpint *a, Mpint *b);
void mpshiftfix(Mpint *a, int s);
int mptestfix(Mpint *a);
void mpxorfixfix(Mpint *a, Mpint *b);
void mpaddfltflt(Mpflt *a, Mpflt *b);
void mpdivfltflt(Mpflt *a, Mpflt *b);
double mpgetflt(Mpflt *a);
double mpgetflt32(Mpflt *a);
void mpmovecflt(Mpflt *a, double c);
void mpmulfltflt(Mpflt *a, Mpflt *b);
void mpnegflt(Mpflt *a);
void mpnorm(Mpflt *a);
void mpsetexp(Mpflt *a, int exp);
int mptestflt(Mpflt *a);
int sigfig(Mpflt *a);
void Bputname(Biobuf *b, LSym *s);
int duint16(Sym *s, int off, uint16 v);
int duint32(Sym *s, int off, uint32 v);
int duint64(Sym *s, int off, uint64 v);
int duint8(Sym *s, int off, uint8 v);
int duintptr(Sym *s, int off, uint64 v);
int dsname(Sym *s, int off, char *dat, int ndat);
void dumpobj(void);
Sym* stringsym(char*, int);
void slicebytes(Node*, char*, int);
LSym* linksym(Sym*);
void order(Node *fn);
void typecheckrange(Node *n);
void walkrange(Node *n);
void dumptypestructs(void);
Type* methodfunc(Type *f, Type*);
Node* typename(Type *t);
Sym* typesym(Type *t);
Sym* typenamesym(Type *t);
Sym* tracksym(Type *t);
Sym* typesymprefix(char *prefix, Type *t);
int haspointers(Type *t);
void usefield(Node*);
Type* hiter(Type* t);
void typecheckselect(Node *sel);
void walkselect(Node *sel);
void anylit(int, Node *n, Node *var, NodeList **init);
int gen_as_init(Node *n);
NodeList* initfix(NodeList *l);
int oaslit(Node *n, NodeList **init);
int stataddr(Node *nam, Node *n);
Node* adddot(Node *n);
int adddot1(Sym *s, Type *t, int d, Type **save, int ignorecase);
void addinit(Node**, NodeList*);
Type* aindex(Node *b, Type *t);
int algtype(Type *t);
int algtype1(Type *t, Type **bad);
void argtype(Node *on, Type *t);
Node* assignconv(Node *n, Type *t, char *context);
int assignop(Type *src, Type *dst, char **why);
void badtype(int o, Type *tl, Type *tr);
int brcom(int a);
int brrev(int a);
NodeList* concat(NodeList *a, NodeList *b);
int convertop(Type *src, Type *dst, char **why);
Node* copyexpr(Node*, Type*, NodeList**);
int count(NodeList *l);
int cplxsubtype(int et);
int eqtype(Type *t1, Type *t2);
int eqtypenoname(Type *t1, Type *t2);
void errorexit(void);
void expandmeth(Type *t);
void fatal(char *fmt, ...);
void flusherrors(void);
void frame(int context);
Type* funcfirst(Iter *s, Type *t);
Type* funcnext(Iter *s);
void genwrapper(Type *rcvr, Type *method, Sym *newnam, int iface);
void genhash(Sym *sym, Type *t);
void geneq(Sym *sym, Type *t);
Type** getinarg(Type *t);
Type* getinargx(Type *t);
Type** getoutarg(Type *t);
Type* getoutargx(Type *t);
Type** getthis(Type *t);
Type* getthisx(Type *t);
int implements(Type *t, Type *iface, Type **missing, Type **have, int *ptr);
void importdot(Pkg *opkg, Node *pack);
int is64(Type *t);
int isbadimport(Strlit *s);
int isblank(Node *n);
int isblanksym(Sym *s);
int isfixedarray(Type *t);
int isideal(Type *t);
int isinter(Type *t);
int isnil(Node *n);
int isnilinter(Type *t);
int isptrto(Type *t, int et);
int isslice(Type *t);
int istype(Type *t, int et);
void linehist(char *file, int32 off, int relative);
NodeList* list(NodeList *l, Node *n);
NodeList* list1(Node *n);
void listsort(NodeList**, int(*f)(Node*, Node*));
Node* liststmt(NodeList *l);
NodeList* listtreecopy(NodeList *l);
Sym* lookup(char *name);
void* mal(int32 n);
Type* maptype(Type *key, Type *val);
Type* methtype(Type *t, int mustname);
Pkg* mkpkg(Strlit *path);
Sym* ngotype(Node *n);
int noconv(Type *t1, Type *t2);
Node* nod(int op, Node *nleft, Node *nright);
Node* nodbool(int b);
void nodconst(Node *n, Type *t, int64 v);
Node* nodintconst(int64 v);
Node* nodfltconst(Mpflt *v);
Node* nodnil(void);
int parserline(void);
Sym* pkglookup(char *name, Pkg *pkg);
int powtwo(Node *n);
Type* ptrto(Type *t);
void* remal(void *p, int32 on, int32 n);
Sym* restrictlookup(char *name, Pkg *pkg);
Node* safeexpr(Node *n, NodeList **init);
void saveerrors(void);
Node* cheapexpr(Node *n, NodeList **init);
Node* localexpr(Node *n, Type *t, NodeList **init);
void saveorignode(Node *n);
int32 setlineno(Node *n);
void setmaxarg(Type *t);
Type* shallow(Type *t);
int simsimtype(Type *t);
void smagic(Magic *m);
Type* sortinter(Type *t);
uint32 stringhash(char *p);
Strlit* strlit(char *s);
int structcount(Type *t);
Type* structfirst(Iter *s, Type **nn);
Type* structnext(Iter *s);
Node* syslook(char *name, int copy);
Type* tounsigned(Type *t);
Node* treecopy(Node *n);
Type* typ(int et);
uint32 typehash(Type *t);
void ullmancalc(Node *n);
void umagic(Magic *m);
void warn(char *fmt, ...);
void warnl(int line, char *fmt, ...);
void yyerror(char *fmt, ...);
void yyerrorl(int line, char *fmt, ...);
void typecheckswitch(Node *n);
void walkswitch(Node *sw);
int islvalue(Node *n);
Node* typecheck(Node **np, int top);
void typechecklist(NodeList *l, int top);
Node* typecheckdef(Node *n);
void copytype(Node *n, Type *t);
void checkreturn(Node*);
void queuemethod(Node *n);
int isunsafebuiltin(Node *n);
Node* unsafenmagic(Node *n);
Node* callnew(Type *t);
Node* chanfn(char *name, int n, Type *t);
Node* mkcall(char *name, Type *t, NodeList **init, ...);
Node* mkcall1(Node *fn, Type *t, NodeList **init, ...);
int vmatch1(Node *l, Node *r);
void walk(Node *fn);
void walkexpr(Node **np, NodeList **init);
void walkexprlist(NodeList *l, NodeList **init);
void walkexprlistsafe(NodeList *l, NodeList **init);
void walkstmt(Node **np);
void walkstmtlist(NodeList *l);
Node* conv(Node*, Type*);
int candiscard(Node*);
Node* outervalue(Node*);
#define P ((Prog*)0)
EXTERN Prog* continpc;
EXTERN Prog* breakpc;
EXTERN Prog* pc;
EXTERN Prog* firstpc;
EXTERN Node* nodfp;
EXTERN int disable_checknil;
EXTERN vlong zerosize;
int anyregalloc(void);
void betypeinit(void);
void bgen(Node *n, int true, int likely, Prog *to);
void checknil(Node*, NodeList**);
void expandchecks(Prog*);
void cgen(Node*, Node*);
void cgen_asop(Node *n);
void cgen_call(Node *n, int proc);
void cgen_callinter(Node *n, Node *res, int proc);
void cgen_checknil(Node*);
void cgen_ret(Node *n);
void clearfat(Node *n);
void compile(Node*);
void defframe(Prog*);
int dgostringptr(Sym*, int off, char *str);
int dgostrlitptr(Sym*, int off, Strlit*);
int dstringptr(Sym *s, int off, char *str);
int dsymptr(Sym *s, int off, Sym *x, int xoff);
int duintxx(Sym *s, int off, uint64 v, int wid);
void dumpdata(void);
void fixautoused(Prog*);
void gdata(Node*, Node*, int);
void gdatacomplex(Node*, Mpcplx*);
void gdatastring(Node*, Strlit*);
void ggloblnod(Node *nam);
void ggloblsym(Sym *s, int32 width, int dupok, int rodata);
void gvardef(Node*);
void gvarkill(Node*);
Prog* gjmp(Prog*);
void gused(Node*);
void movelarge(NodeList*);
int isfat(Type*);
void linkarchinit(void);
void liveness(Node*, Prog*, Sym*, Sym*);
void markautoused(Prog*);
Plist* newplist(void);
Node* nodarg(Type*, int);
void nopout(Prog*);
void patch(Prog*, Prog*);
Prog* unpatch(Prog*);
#pragma varargck type "B" Mpint*
#pragma varargck type "E" int
#pragma varargck type "E" uint
#pragma varargck type "F" Mpflt*
#pragma varargck type "H" NodeList*
#pragma varargck type "J" Node*
#pragma varargck type "lL" int32
#pragma varargck type "L" int32
#pragma varargck type "N" Node*
#pragma varargck type "lN" Node*
#pragma varargck type "O" int
#pragma varargck type "O" uint
#pragma varargck type "Q" Bits
#pragma varargck type "S" Sym*
#pragma varargck type "lS" LSym*
#pragma varargck type "T" Type*
#pragma varargck type "lT" Type*
#pragma varargck type "V" Val*
#pragma varargck type "Z" Strlit*
void racewalk(Node *fn);