rsc.io/go@v0.0.0-20150416155037-e040fd465409/src/cmd/internal/obj/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 obj
     6  
     7  import (
     8  	"fmt"
     9  	"math"
    10  	"os"
    11  	"strings"
    12  )
    13  
    14  // go-specific code shared across loaders (5l, 6l, 8l).
    15  
    16  var Framepointer_enabled int
    17  
    18  var Fieldtrack_enabled int
    19  
    20  // Toolchain experiments.
    21  // These are controlled by the GOEXPERIMENT environment
    22  // variable recorded when the toolchain is built.
    23  // This list is also known to cmd/gc.
    24  var exper = []struct {
    25  	name string
    26  	val  *int
    27  }{
    28  	{"fieldtrack", &Fieldtrack_enabled},
    29  	{"framepointer", &Framepointer_enabled},
    30  }
    31  
    32  func addexp(s string) {
    33  	for i := 0; i < len(exper); i++ {
    34  		if exper[i].name == s {
    35  			if exper[i].val != nil {
    36  				*exper[i].val = 1
    37  			}
    38  			return
    39  		}
    40  	}
    41  
    42  	fmt.Printf("unknown experiment %s\n", s)
    43  	os.Exit(2)
    44  }
    45  
    46  func init() {
    47  	for _, f := range strings.Split(goexperiment, ",") {
    48  		if f != "" {
    49  			addexp(f)
    50  		}
    51  	}
    52  }
    53  
    54  // replace all "". with pkg.
    55  func Expandpkg(t0 string, pkg string) string {
    56  	return strings.Replace(t0, `"".`, pkg+".", -1)
    57  }
    58  
    59  func double2ieee(ieee *uint64, f float64) {
    60  	*ieee = math.Float64bits(f)
    61  }
    62  
    63  func Nopout(p *Prog) {
    64  	p.As = ANOP
    65  	p.Scond = 0
    66  	p.From = Addr{}
    67  	p.From3 = Addr{}
    68  	p.Reg = 0
    69  	p.To = Addr{}
    70  }
    71  
    72  func Nocache(p *Prog) {
    73  	p.Optab = 0
    74  	p.From.Class = 0
    75  	p.From3.Class = 0
    76  	p.To.Class = 0
    77  }
    78  
    79  /*
    80   *	bv.c
    81   */
    82  
    83  /*
    84   *	closure.c
    85   */
    86  
    87  /*
    88   *	const.c
    89   */
    90  
    91  /*
    92   *	cplx.c
    93   */
    94  
    95  /*
    96   *	dcl.c
    97   */
    98  
    99  /*
   100   *	esc.c
   101   */
   102  
   103  /*
   104   *	export.c
   105   */
   106  
   107  /*
   108   *	fmt.c
   109   */
   110  
   111  /*
   112   *	gen.c
   113   */
   114  
   115  /*
   116   *	init.c
   117   */
   118  
   119  /*
   120   *	inl.c
   121   */
   122  
   123  /*
   124   *	lex.c
   125   */
   126  func Expstring() string {
   127  	buf := "X"
   128  	for i := range exper {
   129  		if *exper[i].val != 0 {
   130  			buf += "," + exper[i].name
   131  		}
   132  	}
   133  	if buf == "X" {
   134  		buf += ",none"
   135  	}
   136  	return "X:" + buf[2:]
   137  }