github.com/tidwall/go@v0.0.0-20170415222209-6694a6888b7d/src/cmd/compile/internal/gc/go.go (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  package gc
     6  
     7  import (
     8  	"cmd/compile/internal/ssa"
     9  	"cmd/compile/internal/types"
    10  	"cmd/internal/bio"
    11  	"cmd/internal/obj"
    12  	"cmd/internal/src"
    13  )
    14  
    15  const (
    16  	BADWIDTH        = types.BADWIDTH
    17  	MaxStackVarSize = 10 * 1024 * 1024
    18  )
    19  
    20  // isRuntimePkg reports whether p is package runtime.
    21  func isRuntimePkg(p *types.Pkg) bool {
    22  	if compiling_runtime && p == localpkg {
    23  		return true
    24  	}
    25  	return p.Path == "runtime"
    26  }
    27  
    28  // The Class of a variable/function describes the "storage class"
    29  // of a variable or function. During parsing, storage classes are
    30  // called declaration contexts.
    31  type Class uint8
    32  
    33  const (
    34  	Pxxx      Class = iota
    35  	PEXTERN         // global variable
    36  	PAUTO           // local variables
    37  	PAUTOHEAP       // local variable or parameter moved to heap
    38  	PPARAM          // input arguments
    39  	PPARAMOUT       // output results
    40  	PFUNC           // global function
    41  
    42  	PDISCARD // discard during parse of duplicate import
    43  )
    44  
    45  // note this is the runtime representation
    46  // of the compilers arrays.
    47  //
    48  // typedef	struct
    49  // {				// must not move anything
    50  // 	uchar	array[8];	// pointer to data
    51  // 	uchar	nel[4];		// number of elements
    52  // 	uchar	cap[4];		// allocated number of elements
    53  // } Array;
    54  var array_array int // runtime offsetof(Array,array) - same for String
    55  
    56  var array_nel int // runtime offsetof(Array,nel) - same for String
    57  
    58  var array_cap int // runtime offsetof(Array,cap)
    59  
    60  var sizeof_Array int // runtime sizeof(Array)
    61  
    62  // note this is the runtime representation
    63  // of the compilers strings.
    64  //
    65  // typedef	struct
    66  // {				// must not move anything
    67  // 	uchar	array[8];	// pointer to data
    68  // 	uchar	nel[4];		// number of elements
    69  // } String;
    70  var sizeof_String int // runtime sizeof(String)
    71  
    72  var pragcgobuf string
    73  
    74  var outfile string
    75  var linkobj string
    76  var dolinkobj bool
    77  
    78  var bout *bio.Writer
    79  
    80  // nerrors is the number of compiler errors reported
    81  // since the last call to saveerrors.
    82  var nerrors int
    83  
    84  // nsavederrors is the total number of compiler errors
    85  // reported before the last call to saveerrors.
    86  var nsavederrors int
    87  
    88  var nsyntaxerrors int
    89  
    90  var decldepth int32
    91  
    92  var safemode bool
    93  
    94  var nolocalimports bool
    95  
    96  var Debug [256]int
    97  
    98  var debugstr string
    99  
   100  var Debug_checknil int
   101  var Debug_typeassert int
   102  
   103  var localpkg *types.Pkg // package being compiled
   104  
   105  var inimport bool // set during import
   106  
   107  var itabpkg *types.Pkg // fake pkg for itab entries
   108  
   109  var itablinkpkg *types.Pkg // fake package for runtime itab entries
   110  
   111  var Runtimepkg *types.Pkg // fake package runtime
   112  
   113  var racepkg *types.Pkg // package runtime/race
   114  
   115  var msanpkg *types.Pkg // package runtime/msan
   116  
   117  var typepkg *types.Pkg // fake package for runtime type info (headers)
   118  
   119  var unsafepkg *types.Pkg // package unsafe
   120  
   121  var trackpkg *types.Pkg // fake package for field tracking
   122  
   123  var mappkg *types.Pkg // fake package for map zero value
   124  var zerosize int64
   125  
   126  var myimportpath string
   127  
   128  var localimport string
   129  
   130  var asmhdr string
   131  
   132  var simtype [NTYPE]types.EType
   133  
   134  var (
   135  	isforw    [NTYPE]bool
   136  	isInt     [NTYPE]bool
   137  	isFloat   [NTYPE]bool
   138  	isComplex [NTYPE]bool
   139  	issimple  [NTYPE]bool
   140  )
   141  
   142  var (
   143  	okforeq    [NTYPE]bool
   144  	okforadd   [NTYPE]bool
   145  	okforand   [NTYPE]bool
   146  	okfornone  [NTYPE]bool
   147  	okforcmp   [NTYPE]bool
   148  	okforbool  [NTYPE]bool
   149  	okforcap   [NTYPE]bool
   150  	okforlen   [NTYPE]bool
   151  	okforarith [NTYPE]bool
   152  	okforconst [NTYPE]bool
   153  )
   154  
   155  var (
   156  	okfor [OEND][]bool
   157  	iscmp [OEND]bool
   158  )
   159  
   160  var minintval [NTYPE]*Mpint
   161  
   162  var maxintval [NTYPE]*Mpint
   163  
   164  var minfltval [NTYPE]*Mpflt
   165  
   166  var maxfltval [NTYPE]*Mpflt
   167  
   168  var xtop []*Node
   169  
   170  var exportlist []*Node
   171  
   172  var importlist []*Node // imported functions and methods with inlinable bodies
   173  
   174  var funcsyms []*types.Sym
   175  
   176  var dclcontext Class // PEXTERN/PAUTO
   177  
   178  var Curfn *Node
   179  
   180  var Widthptr int
   181  
   182  var Widthint int
   183  
   184  var Widthreg int
   185  
   186  var nblank *Node
   187  
   188  var typecheckok bool
   189  
   190  var compiling_runtime bool
   191  
   192  var compiling_wrappers int
   193  
   194  var use_writebarrier bool
   195  
   196  var pure_go bool
   197  
   198  var flag_installsuffix string
   199  
   200  var flag_race bool
   201  
   202  var flag_msan bool
   203  
   204  var flag_largemodel bool
   205  
   206  // Whether we are adding any sort of code instrumentation, such as
   207  // when the race detector is enabled.
   208  var instrumenting bool
   209  
   210  var debuglive int
   211  
   212  var Ctxt *obj.Link
   213  
   214  var writearchive bool
   215  
   216  var Nacl bool
   217  
   218  var nodfp *Node
   219  
   220  var disable_checknil int
   221  
   222  var autogeneratedPos src.XPos
   223  
   224  // interface to back end
   225  
   226  type Arch struct {
   227  	LinkArch *obj.LinkArch
   228  
   229  	REGSP    int
   230  	MAXWIDTH int64
   231  	Use387   bool // should 386 backend use 387 FP instructions instead of sse2.
   232  
   233  	Defframe func(*Progs, *Node, int64)
   234  	Ginsnop  func(*Progs)
   235  
   236  	// SSAMarkMoves marks any MOVXconst ops that need to avoid clobbering flags.
   237  	SSAMarkMoves func(*SSAGenState, *ssa.Block)
   238  
   239  	// SSAGenValue emits Prog(s) for the Value.
   240  	SSAGenValue func(*SSAGenState, *ssa.Value)
   241  
   242  	// SSAGenBlock emits end-of-block Progs. SSAGenValue should be called
   243  	// for all values in the block before SSAGenBlock.
   244  	SSAGenBlock func(s *SSAGenState, b, next *ssa.Block)
   245  }
   246  
   247  var thearch Arch
   248  
   249  var (
   250  	staticbytes,
   251  	zerobase *Node
   252  
   253  	Newproc,
   254  	Deferproc,
   255  	Deferreturn,
   256  	Duffcopy,
   257  	Duffzero,
   258  	panicindex,
   259  	panicslice,
   260  	panicdivide,
   261  	growslice,
   262  	panicdottypeE,
   263  	panicdottypeI,
   264  	panicnildottype,
   265  	assertE2I,
   266  	assertE2I2,
   267  	assertI2I,
   268  	assertI2I2 *obj.LSym
   269  )