aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/asm
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2021-04-06 08:25:01 -0400
committerAustin Clements <austin@google.com>2021-04-08 02:17:16 +0000
commit6304b401e4bcfc1d61dd687bb5b7df13fd71033b (patch)
tree7f9e87d47b4a1baf3809f12e18bcc1d5a1248e9f /src/cmd/asm
parent0c4a08cb74abe026260a224a2b553c1f77a1172a (diff)
downloadgo-6304b401e4bcfc1d61dd687bb5b7df13fd71033b.tar.gz
go-6304b401e4bcfc1d61dd687bb5b7df13fd71033b.zip
internal/goexperiment,cmd: consolidate GOEXPERIMENTs into a new package
Currently there's knowledge about the list of GOEXPERIMENTs in a few different places. This CL introduces a new package and consolidates the list into one place: the internal/goexperiment.Flags struct type. This package gives us a central place to document the experiments as well as the GOEXPERIMENT environment variable itself. It will also give us a place to put built-time constants derived from the enabled experiments. Now the objabi package constructs experiment names by reflecting over this struct type rather than having a separate list of these names (this is similar to how the compiler handles command-line flags and debug options). We also expose a better-typed API to the toolchain for propagating enabled experiments. Change-Id: I06e026712b59fe2bd7cd11a869aedb48ffe5a4b7 Reviewed-on: https://go-review.googlesource.com/c/go/+/307817 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/asm')
-rw-r--r--src/cmd/asm/internal/lex/input.go23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/cmd/asm/internal/lex/input.go b/src/cmd/asm/internal/lex/input.go
index 8aa6becf55..aa03759c7d 100644
--- a/src/cmd/asm/internal/lex/input.go
+++ b/src/cmd/asm/internal/lex/input.go
@@ -46,31 +46,18 @@ func NewInput(name string) *Input {
func predefine(defines flags.MultiFlag) map[string]*Macro {
macros := make(map[string]*Macro)
- // Set macros for various GOEXPERIMENTs so we can easily
- // switch runtime assembly code based on them.
+ // Set macros for GOEXPERIMENTs so we can easily switch
+ // runtime assembly code based on them.
if *flags.CompilingRuntime {
- set := func(name string) {
+ for _, exp := range objabi.EnabledExperiments() {
+ // Define macro.
+ name := "GOEXPERIMENT_" + exp
macros[name] = &Macro{
name: name,
args: nil,
tokens: Tokenize("1"),
}
}
- if objabi.Experiment.RegabiWrappers {
- set("GOEXPERIMENT_regabiwrappers")
- }
- if objabi.Experiment.RegabiG {
- set("GOEXPERIMENT_regabig")
- }
- if objabi.Experiment.RegabiReflect {
- set("GOEXPERIMENT_regabireflect")
- }
- if objabi.Experiment.RegabiDefer {
- set("GOEXPERIMENT_regabidefer")
- }
- if objabi.Experiment.RegabiArgs {
- set("GOEXPERIMENT_regabiargs")
- }
}
for _, name := range defines {