github.com/aloncn/graphics-go@v0.0.1/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  	"os"
    10  	"strings"
    11  )
    12  
    13  // go-specific code shared across loaders (5l, 6l, 8l).
    14  
    15  var (
    16  	Framepointer_enabled int
    17  	Fieldtrack_enabled   int
    18  )
    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  func Nopout(p *Prog) {
    55  	p.As = ANOP
    56  	p.Scond = 0
    57  	p.From = Addr{}
    58  	p.From3 = nil
    59  	p.Reg = 0
    60  	p.To = Addr{}
    61  }
    62  
    63  func Nocache(p *Prog) {
    64  	p.Optab = 0
    65  	p.From.Class = 0
    66  	if p.From3 != nil {
    67  		p.From3.Class = 0
    68  	}
    69  	p.To.Class = 0
    70  }
    71  
    72  func Expstring() string {
    73  	buf := "X"
    74  	for i := range exper {
    75  		if *exper[i].val != 0 {
    76  			buf += "," + exper[i].name
    77  		}
    78  	}
    79  	if buf == "X" {
    80  		buf += ",none"
    81  	}
    82  	return "X:" + buf[2:]
    83  }