github.com/razvanm/vanadium-go-1.3@v0.0.0-20160721203343-4a65068e5915/src/cmd/gc/go.h (about)

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