Skip to content

Commit

Permalink
go/analysis/passes/asmdecl: add build tag for loong64
Browse files Browse the repository at this point in the history
The arch "loong64" doesn't exist before go 1.19 causing a "unknown
architecture" message printed to stderr when asmdecl is imported.

A build tag now prevents "loong64" from being checked in earlier
versions of go.

Fixes golang/go#52646

Change-Id: Ibc83ce02d92cfb709a773ca758b21a80516a399c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/403874
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
  • Loading branch information
leitzler committed May 4, 2022
1 parent b4c4500 commit 54c7ba5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
12 changes: 12 additions & 0 deletions go/analysis/passes/asmdecl/arches_go118.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !go1.19
// +build !go1.19

package asmdecl

func additionalArches() []*asmArch {
return nil
}
14 changes: 14 additions & 0 deletions go/analysis/passes/asmdecl/arches_go119.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build go1.19
// +build go1.19

package asmdecl

var asmArchLoong64 = asmArch{name: "loong64", bigEndian: false, stack: "R3", lr: true}

func additionalArches() []*asmArch {
return []*asmArch{&asmArchLoong64}
}
3 changes: 1 addition & 2 deletions go/analysis/passes/asmdecl/asmdecl.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ var (
asmArchArm = asmArch{name: "arm", bigEndian: false, stack: "R13", lr: true}
asmArchArm64 = asmArch{name: "arm64", bigEndian: false, stack: "RSP", lr: true, retRegs: []string{"R0", "F0"}}
asmArchAmd64 = asmArch{name: "amd64", bigEndian: false, stack: "SP", lr: false, retRegs: []string{"AX", "X0"}}
asmArchLoong64 = asmArch{name: "loong64", bigEndian: false, stack: "R3", lr: true}
asmArchMips = asmArch{name: "mips", bigEndian: true, stack: "R29", lr: true}
asmArchMipsLE = asmArch{name: "mipsle", bigEndian: false, stack: "R29", lr: true}
asmArchMips64 = asmArch{name: "mips64", bigEndian: true, stack: "R29", lr: true}
Expand All @@ -102,7 +101,6 @@ var (
&asmArchArm,
&asmArchArm64,
&asmArchAmd64,
&asmArchLoong64,
&asmArchMips,
&asmArchMipsLE,
&asmArchMips64,
Expand All @@ -116,6 +114,7 @@ var (
)

func init() {
arches = append(arches, additionalArches()...)
for _, arch := range arches {
arch.sizes = types.SizesFor("gc", arch.name)
if arch.sizes == nil {
Expand Down

0 comments on commit 54c7ba5

Please sign in to comment.