From 98cbf45cfc6a5a50cc6ac2367f9572cb198b57c7 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 22 Jan 2019 07:40:19 -0800 Subject: [PATCH] go/types: add gccgo sizes information This will need to be updated from time to time as new targets are added to gccgo. But that is better than always returning nil. Change-Id: I04b8c4d0f8efa38e2a148eb2e38b16b09f0351c3 Reviewed-on: https://go-review.googlesource.com/c/158844 Run-TryBot: Ian Lance Taylor Reviewed-by: Alan Donovan Reviewed-by: Robert Griesemer TryBot-Result: Gobot Gobot --- src/go/types/gccgosizes.go | 40 ++++++++++++++++++++++++++++++++++++++ src/go/types/sizes.go | 10 ++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 src/go/types/gccgosizes.go diff --git a/src/go/types/gccgosizes.go b/src/go/types/gccgosizes.go new file mode 100644 index 00000000000..d5c92c6d1dd --- /dev/null +++ b/src/go/types/gccgosizes.go @@ -0,0 +1,40 @@ +// Copyright 2019 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. + +// This is a copy of the file generated during the gccgo build process. +// Last update 2019-01-22. + +package types + +var gccgoArchSizes = map[string]*StdSizes{ + "386": {4, 4}, + "alpha": {8, 8}, + "amd64": {8, 8}, + "amd64p32": {4, 8}, + "arm": {4, 8}, + "armbe": {4, 8}, + "arm64": {8, 8}, + "arm64be": {8, 8}, + "ia64": {8, 8}, + "m68k": {4, 2}, + "mips": {4, 8}, + "mipsle": {4, 8}, + "mips64": {8, 8}, + "mips64le": {8, 8}, + "mips64p32": {4, 8}, + "mips64p32le": {4, 8}, + "nios2": {4, 8}, + "ppc": {4, 8}, + "ppc64": {8, 8}, + "ppc64le": {8, 8}, + "riscv": {4, 8}, + "riscv64": {8, 8}, + "s390": {4, 8}, + "s390x": {8, 8}, + "sh": {4, 8}, + "shbe": {4, 8}, + "sparc": {4, 8}, + "sparc64": {8, 8}, + "wasm": {8, 8}, +} diff --git a/src/go/types/sizes.go b/src/go/types/sizes.go index f890c303774..6ab6157b82d 100644 --- a/src/go/types/sizes.go +++ b/src/go/types/sizes.go @@ -182,10 +182,16 @@ var gcArchSizes = map[string]*StdSizes{ // "386", "arm", "arm64", "amd64", "amd64p32", "mips", "mipsle", // "mips64", "mips64le", "ppc64", "ppc64le", "riscv64", "s390x", "sparc64", "wasm". func SizesFor(compiler, arch string) Sizes { - if compiler != "gc" { + var m map[string]*StdSizes + switch compiler { + case "gc": + m = gcArchSizes + case "gccgo": + m = gccgoArchSizes + default: return nil } - s, ok := gcArchSizes[arch] + s, ok := m[arch] if !ok { return nil }