github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/src/cmd/5g/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 "../5l/5.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*	sym;
    27  	Sym*	gotype;
    28  	Node*	node;
    29  	int	width;
    30  	uchar	type;
    31  	char	name;
    32  	uchar	reg;
    33  	uchar	etype;
    34  };
    35  #define	A	((Addr*)0)
    36  
    37  struct	Prog
    38  {
    39  	uint32	loc;		// pc offset in this func
    40  	uint32	lineno;		// source line that generated this
    41  	Prog*	link;		// next instruction in this func
    42  	void*	regp;		// points to enclosing Reg struct
    43  	short	as;		// opcode
    44  	uchar	reg;		// doubles as width in DATA op
    45  	uchar	scond;
    46  	Addr	from;		// src address
    47  	Addr	to;		// dst address
    48  };
    49  
    50  #define TEXTFLAG reg
    51  
    52  #define REGALLOC_R0 0
    53  #define REGALLOC_RMAX REGEXT
    54  #define REGALLOC_F0 (REGALLOC_RMAX+1)
    55  #define REGALLOC_FMAX (REGALLOC_F0 + FREGEXT)
    56  
    57  EXTERN	int32	dynloc;
    58  EXTERN	uchar	reg[REGALLOC_FMAX+1];
    59  EXTERN	int32	pcloc;		// instruction counter
    60  EXTERN	Strlit	emptystring;
    61  extern	char*	anames[];
    62  EXTERN	Prog	zprog;
    63  EXTERN	Node*	newproc;
    64  EXTERN	Node*	deferproc;
    65  EXTERN	Node*	deferreturn;
    66  EXTERN	Node*	panicindex;
    67  EXTERN	Node*	panicslice;
    68  EXTERN	Node*	throwreturn;
    69  extern	long	unmappedzero;
    70  EXTERN	int	maxstksize;
    71  
    72  /*
    73   * gen.c
    74   */
    75  void	compile(Node*);
    76  void	proglist(void);
    77  void	gen(Node*);
    78  Node*	lookdot(Node*, Node*, int);
    79  void	cgen_as(Node*, Node*);
    80  void	cgen_callmeth(Node*, int);
    81  void	cgen_callinter(Node*, Node*, int);
    82  void	cgen_proc(Node*, int);
    83  void	cgen_callret(Node*, Node*);
    84  void	cgen_dcl(Node*);
    85  int	needconvert(Type*, Type*);
    86  void	genconv(Type*, Type*);
    87  void	allocparams(void);
    88  void	checklabels(void);
    89  void	ginscall(Node*, int);
    90  
    91  /*
    92   * cgen
    93   */
    94  void	agen(Node*, Node*);
    95  Prog* cgenindex(Node *, Node *, int);
    96  void	igen(Node*, Node*, Node*);
    97  void agenr(Node *n, Node *a, Node *res);
    98  vlong	fieldoffset(Type*, Node*);
    99  void	sgen(Node*, Node*, int64);
   100  void	gmove(Node*, Node*);
   101  Prog*	gins(int, Node*, Node*);
   102  int	samaddr(Node*, Node*);
   103  void	raddr(Node *n, Prog *p);
   104  Prog*	gcmp(int, Node*, Node*);
   105  Prog*	gshift(int as, Node *lhs, int32 stype, int32 sval, Node *rhs);
   106  Prog *	gregshift(int as, Node *lhs, int32 stype, Node *reg, Node *rhs);
   107  void	naddr(Node*, Addr*, int);
   108  void	cgen_aret(Node*, Node*);
   109  void	cgen_hmul(Node*, Node*, Node*);
   110  void	cgen_shift(int, int, Node*, Node*, Node*);
   111  int	componentgen(Node*, Node*);
   112  
   113  /*
   114   * cgen64.c
   115   */
   116  void	cmp64(Node*, Node*, int, int, Prog*);
   117  void	cgen64(Node*, Node*);
   118  
   119  /*
   120   * gsubr.c
   121   */
   122  void	clearp(Prog*);
   123  void	proglist(void);
   124  Prog*	gbranch(int, Type*, int);
   125  Prog*	prog(int);
   126  void	gconv(int, int);
   127  int	conv2pt(Type*);
   128  vlong	convvtox(vlong, int);
   129  void	fnparam(Type*, int, int);
   130  Prog*	gop(int, Node*, Node*, Node*);
   131  int	optoas(int, Type*);
   132  void	ginit(void);
   133  void	gclean(void);
   134  void	regalloc(Node*, Type*, Node*);
   135  void	regfree(Node*);
   136  Node*	nodarg(Type*, int);
   137  void	nodreg(Node*, Type*, int);
   138  void	nodindreg(Node*, Type*, int);
   139  void	buildtxt(void);
   140  Plist*	newplist(void);
   141  int	isfat(Type*);
   142  int	dotaddable(Node*, Node*);
   143  void	sudoclean(void);
   144  int	sudoaddable(int, Node*, Addr*, int*);
   145  void	afunclit(Addr*, Node*);
   146  void	datagostring(Strlit*, Addr*);
   147  void	split64(Node*, Node*, Node*);
   148  void	splitclean(void);
   149  Node*	ncon(uint32 i);
   150  void	gtrack(Sym*);
   151  
   152  /*
   153   * obj.c
   154   */
   155  void	datastring(char*, int, Addr*);
   156  
   157  /*
   158   * list.c
   159   */
   160  int	Aconv(Fmt*);
   161  int	Cconv(Fmt*);
   162  int	Dconv(Fmt*);
   163  int	Mconv(Fmt*);
   164  int	Pconv(Fmt*);
   165  int	Rconv(Fmt*);
   166  int	Yconv(Fmt*);
   167  void	listinit(void);
   168  
   169  void	zaddr(Biobuf*, Addr*, int, int);
   170  
   171  #pragma	varargck	type	"D"	Addr*
   172  #pragma	varargck	type	"M"	Addr*