github.com/bir3/gocompiler@v0.9.2202/src/cmd/compile/main.go (about)

     1  // Copyright 2015 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 compile
     6  
     7  import (
     8  	"github.com/bir3/gocompiler/src/cmd/compile/internal/amd64"
     9  	"github.com/bir3/gocompiler/src/cmd/compile/internal/arm"
    10  	"github.com/bir3/gocompiler/src/cmd/compile/internal/arm64"
    11  	"github.com/bir3/gocompiler/src/cmd/compile/internal/base"
    12  	"github.com/bir3/gocompiler/src/cmd/compile/internal/gc"
    13  	"github.com/bir3/gocompiler/src/cmd/compile/internal/loong64"
    14  	"github.com/bir3/gocompiler/src/cmd/compile/internal/mips"
    15  	"github.com/bir3/gocompiler/src/cmd/compile/internal/mips64"
    16  	"github.com/bir3/gocompiler/src/cmd/compile/internal/ppc64"
    17  	"github.com/bir3/gocompiler/src/cmd/compile/internal/riscv64"
    18  	"github.com/bir3/gocompiler/src/cmd/compile/internal/s390x"
    19  	"github.com/bir3/gocompiler/src/cmd/compile/internal/ssagen"
    20  	"github.com/bir3/gocompiler/src/cmd/compile/internal/wasm"
    21  	"github.com/bir3/gocompiler/src/cmd/compile/internal/x86"
    22  	"fmt"
    23  	"github.com/bir3/gocompiler/src/internal/buildcfg"
    24  	"log"
    25  	"os"
    26  )
    27  
    28  var archInits = map[string]func(*ssagen.ArchInfo){
    29  	"386":		x86.Init,
    30  	"amd64":	amd64.Init,
    31  	"arm":		arm.Init,
    32  	"arm64":	arm64.Init,
    33  	"loong64":	loong64.Init,
    34  	"mips":		mips.Init,
    35  	"mipsle":	mips.Init,
    36  	"mips64":	mips64.Init,
    37  	"mips64le":	mips64.Init,
    38  	"ppc64":	ppc64.Init,
    39  	"ppc64le":	ppc64.Init,
    40  	"riscv64":	riscv64.Init,
    41  	"s390x":	s390x.Init,
    42  	"wasm":		wasm.Init,
    43  }
    44  
    45  func Main() {
    46  	// disable timestamps for reproducible output
    47  	log.SetFlags(0)
    48  	log.SetPrefix("compile: ")
    49  
    50  	buildcfg.Check()
    51  	archInit, ok := archInits[buildcfg.GOARCH]
    52  	if !ok {
    53  		fmt.Fprintf(os.Stderr, "compile: unknown architecture %q\n", buildcfg.GOARCH)
    54  		os.Exit(2)
    55  	}
    56  
    57  	gc.Main(archInit)
    58  	base.Exit(0)
    59  }