github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/src/cmd/8g/gg.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  #ifndef	EXTERN
     6  #define	EXTERN	extern
     7  #endif
     8  
     9  #include "../gc/go.h"
    10  #include "../8l/8.out.h"
    11  
    12  typedef	struct	Addr	Addr;
    13  
    14  struct	Addr
    15  {
    16  	int32	offset;
    17  	int32	offset2;
    18  
    19  	union {
    20  		double	dval;
    21  		vlong	vval;
    22  		Prog*	branch;
    23  		char	sval[NSNAME];
    24  	} u;
    25  
    26  	Sym*	gotype;
    27  	Sym*	sym;
    28  	Node*	node;
    29  	int	width;
    30  	uchar	type;
    31  	uchar	index;
    32  	uchar	etype;
    33  	uchar	scale;	/* doubles as width in DATA op */
    34  };
    35  #define	A	((Addr*)0)
    36  
    37  struct	Prog
    38  {
    39  	short	as;		// opcode
    40  	uint32	loc;		// pc offset in this func
    41  	uint32	lineno;		// source line that generated this
    42  	Addr	from;		// src address
    43  	Addr	to;		// dst address
    44  	Prog*	link;		// next instruction in this func
    45  	void*	reg;		// pointer to containing Reg struct
    46  };
    47  
    48  #define TEXTFLAG from.scale
    49  
    50  // foptoas flags
    51  enum
    52  {
    53  	Frev = 1<<0,
    54  	Fpop = 1<<1,
    55  	Fpop2 = 1<<2,
    56  };
    57  
    58  EXTERN	int32	dynloc;
    59  EXTERN	uchar	reg[D_NONE];
    60  EXTERN	int32	pcloc;		// instruction counter
    61  EXTERN	Strlit	emptystring;
    62  extern	char*	anames[];
    63  EXTERN	Prog	zprog;
    64  EXTERN	Node*	newproc;
    65  EXTERN	Node*	deferproc;
    66  EXTERN	Node*	deferreturn;
    67  EXTERN	Node*	panicindex;
    68  EXTERN	Node*	panicslice;
    69  EXTERN	Node*	throwreturn;
    70  EXTERN	int	maxstksize;
    71  extern	uint32	unmappedzero;
    72  
    73  
    74  /*
    75   * ggen.c
    76   */
    77  void	compile(Node*);
    78  void	proglist(void);
    79  void	gen(Node*);
    80  Node*	lookdot(Node*, Node*, int);
    81  void	cgen_as(Node*, Node*);
    82  void	cgen_callmeth(Node*, int);
    83  void	cgen_callinter(Node*, Node*, int);
    84  void	cgen_proc(Node*, int);
    85  void	cgen_callret(Node*, Node*);
    86  void	cgen_div(int, Node*, Node*, Node*);
    87  void	cgen_bmul(int, Node*, Node*, Node*);
    88  void	cgen_hmul(Node*, Node*, Node*);
    89  void	cgen_shift(int, int, Node*, Node*, Node*);
    90  void	cgen_float(Node*, Node*);
    91  void	bgen_float(Node *n, int true, int likely, Prog *to);
    92  void	cgen_dcl(Node*);
    93  int	needconvert(Type*, Type*);
    94  void	genconv(Type*, Type*);
    95  void	allocparams(void);
    96  void	checklabels(void);
    97  void	ginscall(Node*, int);
    98  
    99  /*
   100   * cgen.c
   101   */
   102  void	agen(Node*, Node*);
   103  void	igen(Node*, Node*, Node*);
   104  vlong	fieldoffset(Type*, Node*);
   105  void	sgen(Node*, Node*, int64);
   106  void	gmove(Node*, Node*);
   107  Prog*	gins(int, Node*, Node*);
   108  int	samaddr(Node*, Node*);
   109  void	naddr(Node*, Addr*, int);
   110  void	cgen_aret(Node*, Node*);
   111  Node*	ncon(uint32);
   112  void	mgen(Node*, Node*, Node*);
   113  void	mfree(Node*);
   114  int	componentgen(Node*, Node*);
   115  
   116  /*
   117   * cgen64.c
   118   */
   119  void	cmp64(Node*, Node*, int, int, Prog*);
   120  void	cgen64(Node*, Node*);
   121  
   122  /*
   123   * gsubr.c
   124   */
   125  void	clearp(Prog*);
   126  void	proglist(void);
   127  Prog*	gbranch(int, Type*, int);
   128  Prog*	prog(int);
   129  void	gconv(int, int);
   130  int	conv2pt(Type*);
   131  vlong	convvtox(vlong, int);
   132  void	fnparam(Type*, int, int);
   133  Prog*	gop(int, Node*, Node*, Node*);
   134  int	optoas(int, Type*);
   135  int	foptoas(int, Type*, int);
   136  void	ginit(void);
   137  void	gclean(void);
   138  void	regalloc(Node*, Type*, Node*);
   139  void	regfree(Node*);
   140  Node*	nodarg(Type*, int);
   141  void	nodreg(Node*, Type*, int);
   142  void	nodindreg(Node*, Type*, int);
   143  void	nodconst(Node*, Type*, int64);
   144  void	gconreg(int, vlong, int);
   145  void	buildtxt(void);
   146  Plist*	newplist(void);
   147  int	isfat(Type*);
   148  void	sudoclean(void);
   149  int	sudoaddable(int, Node*, Addr*);
   150  int	dotaddable(Node*, Node*);
   151  void	afunclit(Addr*, Node*);
   152  void	split64(Node*, Node*, Node*);
   153  void	splitclean(void);
   154  void	nswap(Node*, Node*);
   155  void	gtrack(Sym*);
   156  
   157  /*
   158   * cplx.c
   159   */
   160  int	complexop(Node*, Node*);
   161  void	complexmove(Node*, Node*);
   162  void	complexgen(Node*, Node*);
   163  
   164  /*
   165   * gobj.c
   166   */
   167  void	datastring(char*, int, Addr*);
   168  void	datagostring(Strlit*, Addr*);
   169  
   170  /*
   171   * list.c
   172   */
   173  int	Aconv(Fmt*);
   174  int	Dconv(Fmt*);
   175  int	Pconv(Fmt*);
   176  int	Rconv(Fmt*);
   177  int	Yconv(Fmt*);
   178  void	listinit(void);
   179  
   180  void	zaddr(Biobuf*, Addr*, int, int);
   181  
   182  #pragma	varargck	type	"D"	Addr*
   183  #pragma	varargck	type	"lD"	Addr*