This libgo patch implements types.SizesFor for gccgo. This potentially corrects some type sizes, and fixes the vet tool for alpha, ia64, m68k, and possibly others. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline.
Ian
Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 256593) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -fe8481db9f5b37eb9a0c329673789eaaf1335598 +4aa531c1765bba52848c6d71b9f57b593063d3ba The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/Makefile.am =================================================================== --- libgo/Makefile.am (revision 256593) +++ libgo/Makefile.am (working copy) @@ -506,14 +506,14 @@ s-version: Makefile done echo >> version.go.tmp echo "const (" >> version.go.tmp - echo " ArchFamily = $(GOARCH_FAMILY)" >> version.go.tmp - echo " BigEndian = $(GOARCH_BIGENDIAN)" >> version.go.tmp - echo " CacheLineSize = $(GOARCH_CACHELINESIZE)" >> version.go.tmp - echo " PhysPageSize = $(GOARCH_PHYSPAGESIZE)" >> version.go.tmp - echo " PCQuantum = $(GOARCH_PCQUANTUM)" >> version.go.tmp - echo " Int64Align = $(GOARCH_INT64ALIGN)" >> version.go.tmp - echo " HugePageSize = $(GOARCH_HUGEPAGESIZE)" >> version.go.tmp - echo " MinFrameSize = $(GOARCH_MINFRAMESIZE)" >> version.go.tmp + echo " ArchFamily = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) family`" >> version.go.tmp + echo " BigEndian = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) bigendian`" >> version.go.tmp + echo " CacheLineSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) cachelinesize`" >> version.go.tmp + echo " DefaultPhysPageSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) defaultphyspagesize`" >> version.go.tmp + echo " HugePageSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) hugepagesize`" >> version.go.tmp + echo " Int64Align = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) int64align`" >> version.go.tmp + echo " MinFrameSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) minframesize`" >> version.go.tmp + echo " PCQuantum = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) pcquantum`" >> version.go.tmp echo ")" >> version.go.tmp echo >> version.go.tmp for a in $(ALLGOOS); do \ @@ -548,6 +548,21 @@ s-objabi: Makefile $(SHELL) $(srcdir)/mvifdiff.sh objabi.go.tmp objabi.go $(STAMP) $@ +gccgosizes.go: s-gccgosizes; @true +s-gccgosizes: Makefile goarch.sh + rm -f gccgosizes.go.tmp + echo "package types" > gccgosizes.go.tmp + echo >> gccgosizes.go.tmp + echo "var gccgoArchSizes = map[string]*StdSizes{" >> gccgosizes.go.tmp + for a in $(ALLGOARCH); do \ + ptrsize=`$(SHELL) $(srcdir)/goarch.sh $$a ptrsize`; \ + maxalign=`$(SHELL) $(srcdir)/goarch.sh $$a maxalign`; \ + echo " \"$$a\": {$${ptrsize}, $${maxalign}}," >> gccgosizes.go.tmp; \ + done + echo "}" >> gccgosizes.go.tmp + $(SHELL) $(srcdir)/mvifdiff.sh gccgosizes.go.tmp gccgosizes.go + $(STAMP) $@ + runtime_sysinfo.go: s-runtime_sysinfo; @true s-runtime_sysinfo: $(srcdir)/mkrsysinfo.sh gen-sysinfo.go GOARCH=$(GOARCH) GOOS=$(GOOS) $(SHELL) $(srcdir)/mkrsysinfo.sh @@ -1159,6 +1174,9 @@ runtime_pprof_check_GOCFLAGS = -static-l extra_go_files_runtime_internal_sys = version.go runtime/internal/sys.lo.dep: $(extra_go_files_runtime_internal_sys) +extra_go_files_go_types = gccgosizes.go +go/types.lo.dep: $(extra_go_files_go_types) + extra_go_files_cmd_internal_objabi = objabi.go cmd/internal/objabi.lo.dep: $(extra_go_files_cmd_internal_objabi) Index: libgo/configure.ac =================================================================== --- libgo/configure.ac (revision 256593) +++ libgo/configure.ac (working copy) @@ -207,46 +207,41 @@ AC_SUBST(USE_DEJAGNU) # All known GOARCH values. This is the union of all architectures # supported by the gofrontend and all architectures supported by the # gc toolchain. -# N.B. Keep in sync with gcc/testsuite/go.test/go-test.exp (go-set-goarch). +# To add a new architecture: +# - add it to this list +# - if appropriate, add an entry to ALLGOARCHFAMILY below +# - add an entry to the case on ${host} below to set GOARCH +# - update goarchList in libgo/go/go/build/syslist.go +# - update goarch.sh to report the values for this architecture +# - update go-set-goarch in gcc/testsuite/go.test/go-test.exp +# - update ptrSizeMap and intSizeMap in libgo/go/cmd/cgo/main.go +# - update arch lists in libgo/match.sh +# - update arch lists in libgo/testsuite/gotest +# - update +build lines in several places +# - libgo/go/runtime/lfstack_NNbit.go +# - libgo/go/runtime/hashNN.go +# - libgo/go/runtime/unalignedN.go +# - libgo/go/syscall/endian_XX.go +# - possibly others +# - possibly update files in libgo/go/internal/syscall/unix ALLGOARCH="386 alpha amd64 amd64p32 arm armbe arm64 arm64be ia64 m68k mips mipsle mips64 mips64le mips64p32 mips64p32le ppc ppc64 ppc64le s390 s390x sh shbe sparc sparc64" -# All known GOARCH_FAMILY values. +# All known GOARCH family values. ALLGOARCHFAMILY="I386 ALPHA AMD64 ARM ARM64 IA64 M68K MIPS MIPS64 PPC PPC64 S390 S390X SH SPARC SPARC64" GOARCH=unknown -GOARCH_FAMILY=unknown -GOARCH_BIGENDIAN=false -GOARCH_CACHELINESIZE=64 -GOARCH_PHYSPAGESIZE=4096 -GOARCH_PCQUANTUM=1 -GOARCH_INT64ALIGN=8 -GOARCH_HUGEPAGESIZE=0 -GOARCH_MINFRAMESIZE=0 case ${host} in alpha*-*-*) GOARCH=alpha - GOARCH_FAMILY=ALPHA - GOARCH_PHYSPAGESIZE=8192 - GOARCH_PCQUANTUM=4 ;; aarch64-*-*) GOARCH=arm64 - GOARCH_FAMILY=ARM64 - GOARCH_CACHELINESIZE=32 - GOARCH_PHYSPAGESIZE=65536 - GOARCH_PCQUANTUM=4 - GOARCH_MINFRAMESIZE=8 ;; arm*-*-* | strongarm*-*-* | ep9312*-*-* | xscale-*-*) GOARCH=arm - GOARCH_FAMILY=ARM - GOARCH_CACHELINESIZE=32 - GOARCH_PCQUANTUM=4 - GOARCH_MINFRAMESIZE=4 case ${host} in arm*b*-*-*) GOARCH=armbe - GOARCH_BIGENDIAN=true ;; esac ;; @@ -257,29 +252,14 @@ changequote([,])dnl #ifdef __x86_64__ #error 64-bit #endif], -[GOARCH=386 -GOARCH_FAMILY=I386 -GOARCH_INT64ALIGN=4 -GOARCH_HUGEPAGESIZE="1 << 21" -], -[GOARCH=amd64 -GOARCH_FAMILY=AMD64 -GOARCH_HUGEPAGESIZE="1 << 21" -]) +[GOARCH=386], +[GOARCH=amd64]) ;; ia64-*-*) GOARCH=ia64 - GOARCH_FAMILY=IA64 - GOARCH_CACHELINESIZE=128 - GOARCH_PHYSPAGESIZE=65536 ;; m68k*-*-*) GOARCH=m68k - GOARCH_FAMILY=M68K - GOARCH_BIGENDIAN=true - GOARCH_CACHELINESIZE=16 - GOARCH_PCQUANTUM=4 - GOARCH_INT64ALIGN=2 ;; mips*-*-*) AC_COMPILE_IFELSE([ @@ -304,123 +284,50 @@ GOARCH_HUGEPAGESIZE="1 << 21" "n32") GOARCH=mips64p32 ;; "n64") GOARCH=mips64 ;; esac - case "$mips_abi" in - "o32" | "n32") - GOARCH_FAMILY=MIPS - GOARCH_MINFRAMESIZE=4 - ;; - "n64") - GOARCH_FAMILY=MIPS64 - GOARCH_MINFRAMESIZE=8 - ;; - esac case "${host}" in mips*el-*-*) GOARCH="${GOARCH}le" ;; - *) - GOARCH_BIGENDIAN=true - ;; esac - GOARCH_CACHELINESIZE=32 - GOARCH_PHYSPAGESIZE=16384 - GOARCH_PCQUANTUM=4 ;; rs6000*-*-* | powerpc*-*-*) AC_COMPILE_IFELSE([ #ifdef _ARCH_PPC64 #error 64-bit #endif], -[GOARCH=ppc -GOARCH_FAMILY=PPC -GOARCH_BIGENDIAN=true -], +[GOARCH=ppc], [ -GOARCH_FAMILY=PPC64 AC_COMPILE_IFELSE([ #if defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__) #error 64be #endif], -[GOARCH=ppc64le -], -[GOARCH=ppc64 -GOARCH_BIGENDIAN=true -])]) - GOARCH_PHYSPAGESIZE=65536 - GOARCH_PCQUANTUM=4 - GOARCH_MINFRAMESIZE=32 +[GOARCH=ppc64le], +[GOARCH=ppc64])]) ;; s390*-*-*) AC_COMPILE_IFELSE([ #if defined(__s390x__) #error 64-bit #endif], -[GOARCH=s390 -GOARCH_FAMILY=S390 -GOARCH_MINFRAMESIZE=4 -], [GOARCH=s390x -GOARCH_FAMILY=S390X -GOARCH_MINFRAMESIZE=8 -]) - GOARCH_BIGENDIAN=true - GOARCH_CACHELINESIZE=256 - GOARCH_PCQUANTUM=2 - ;; - sh3eb*-*-*) - GOARCH=shbe - GOARCH_FAMILY=SH - GOARCH_BIGENDIAN=true - GOARCH_CACHELINESIZE=16 - GOARCH_PCQUANTUM=2 - GOARCH_MINFRAMESIZE=4 - ;; - sh3*-*-*) - GOARCH=sh - GOARCH_FAMILY=SH - GOARCH_CACHELINESIZE=16 - GOARCH_PCQUANTUM=2 - GOARCH_MINFRAMESIZE=4 +[GOARCH=s390], +[GOARCH=s390x]) ;; - sh4eb*-*-*) + sh3eb*-*-* | sh4eb*-*-*) GOARCH=shbe - GOARCH_FAMILY=SH - GOARCH_BIGENDIAN=true - GOARCH_CACHELINESIZE=32 - GOARCH_PCQUANTUM=2 - GOARCH_MINFRAMESIZE=4 ;; - sh4*-*-*) + sh3*-*-* | sh4*-*-*) GOARCH=sh - GOARCH_FAMILY=SH - GOARCH_CACHELINESIZE=32 - GOARCH_PCQUANTUM=2 - GOARCH_MINFRAMESIZE=4 ;; sparc*-*-*) AC_COMPILE_IFELSE([ #if defined(__sparcv9) || defined(__arch64__) #error 64-bit #endif], -[GOARCH=sparc -GOARCH_FAMILY=SPARC -], -[GOARCH=sparc64 -GOARCH_FAMILY=SPARC64 -]) - GOARCH_BIGENDIAN=true - GOARCH_PHYSPAGESIZE=8192 - GOARCH_PCQUANTUM=4 +[GOARCH=sparc], +[GOARCH=sparc64]) ;; esac AC_SUBST(GOARCH) -AC_SUBST(GOARCH_FAMILY) -AC_SUBST(GOARCH_BIGENDIAN) -AC_SUBST(GOARCH_CACHELINESIZE) -AC_SUBST(GOARCH_PHYSPAGESIZE) -AC_SUBST(GOARCH_PCQUANTUM) -AC_SUBST(GOARCH_INT64ALIGN) -AC_SUBST(GOARCH_HUGEPAGESIZE) -AC_SUBST(GOARCH_MINFRAMESIZE) AC_SUBST(ALLGOARCH) AC_SUBST(ALLGOARCHFAMILY) Index: libgo/go/cmd/vet/types.go =================================================================== --- libgo/go/cmd/vet/types.go (revision 256593) +++ libgo/go/cmd/vet/types.go (working copy) @@ -12,6 +12,7 @@ import ( "go/importer" "go/token" "go/types" + "runtime" ) // stdImporter is the importer we use to import packages. @@ -309,4 +310,4 @@ func (f *File) hasMethod(typ types.Type, return ok } -var archSizes = types.SizesFor("gc", build.Default.GOARCH) +var archSizes = types.SizesFor(runtime.Compiler, build.Default.GOARCH) Index: libgo/go/go/types/sizes.go =================================================================== --- libgo/go/go/types/sizes.go (revision 256593) +++ libgo/go/go/types/sizes.go (working copy) @@ -178,10 +178,16 @@ var gcArchSizes = map[string]*StdSizes{ // "386", "arm", "arm64", "amd64", "amd64p32", "mips", "mipsle", // "mips64", "mips64le", "ppc64", "ppc64le", "s390x". 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 } Index: libgo/goarch.sh =================================================================== --- libgo/goarch.sh (nonexistent) +++ libgo/goarch.sh (working copy) @@ -0,0 +1,238 @@ +#!/bin/sh + +# Copyright 2018 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. + +# Code in Makefile.am will invoke this script with two arguments. +# The first is a GOARCH value. The second is a keyword. +# The script will print the value of that keyword for that GOARCH. +# Keywords: +# - bigendian: true or false +# - cachelinesize: the cache line size in bytes +# (for performance only; it's not essential to get this right) +# - defaultphyspagesize: the default physical page size in bytes +# (not currently used, but maybe some day) +# - family: the processor family, from ALLGOARCHFAMILY in configure.ac +# - hugepagesize: size of a huge page in bytes +# (used only to decide when to use madvise with MADV_[NO]HUGEPAGE) +# (set to 0 if there are no huge pages) +# - int64align: alignment of int64 type in bytes +# - maxalign: maximum alignment of values of Go types in bytes +# - minframesize: size of smallest possible function frame in bytes +# (not currently used, may never be used) +# - pcquantum: minimum size of a single instruction in bytes +# - ptrsize: size of a pointer in bytes + +if test $# -ne 2; then + echo 1>&2 "usage: goarch <goarch> <keyword>" + exit 1 +fi + +goarch=$1 +keyword=$2 + +# Default values +bigendian=false +cachelinesize=64 +defaultphyspagesize=4096 +family=unknown +hugepagesize=0 +int64align=8 +maxalign=8 +minframesize=0 +pcquantum=1 +ptrsize=8 + +case $goarch in + 386) + family=I386 + hugepagesize="1 << 21" + int64align=4 + maxalign=4 + ptrsize=4 + ;; + alpha) + family=ALPHA + defaultphyspagesize=8192 + pcquantum=4 + ;; + amd64 | amd64p32) + family=AMD64 + hugepagesize="1 << 21" + ;; + arm | armbe) + family=ARM + cachelinesize=32 + minframesize=4 + pcquantum=4 + ptrsize=4 + case $goarch in + *be) + bigendian=true + ;; + esac + ;; + arm64 | arm64be) + family=ARM64 + cachelinesize=32 + defaultphyspagesize=65536 + minframesize=8 + pcquantum=4 + case $goarch in + *be) + bigendian=true + ;; + esac + ;; + ia64) + family=IA64 + cachelinesize=128 + defaultphyspagesize=65536 + ;; + m68k) + family=M68K + bigendian=true + cachelinesize=16 + int64align=2 + maxalign=2 + pcquantum=4 + ptrsize=4 + ;; + mips | mipsle | mips64p32 | mips64p32le) + family=MIPS + bigendian=true + cachelinesize=32 + defaultphyspagesize=16384 + minframesize=4 + pcquantum=4 + ptrsize=4 + case $goarch in + *le) + bigendian=false + ;; + esac + ;; + mips64 | mips64le) + family=MIPS64 + bigendian=true + cachelinesize=32 + defaultphyspagesize=16384 + minframesize=8 + pcquantum=4 + case $goarch in + *le) + bigendian=false + ;; + esac + ;; + ppc) + family=PPC + bigendian=true + defaultphyspagesize=65536 + minframesize=32 + pcquantum=4 + ptrsize=4 + ;; + ppc64 | ppc64le) + family=PPC64 + bigendian=true + defaultphyspagesize=65536 + minframesize=32 + pcquantum=4 + case $goarch in + *le) + bigendian=false + ;; + esac + ;; + s390) + family=S390 + bigendian=true + cachelinesize=256 + minframesize=4 + pcquantum=2 + ptrsize=4 + ;; + s390x) + family=S390X + bigendian=true + cachelinesize=256 + minframesize=8 + pcquantum=2 + ;; + sh | shbe) + family=SH + cachelinesize=16 + int64align=4 + minframesize=4 + pcquantum=2 + ptrsize=4 + case $goarch in + *be) + bigendian=true + ;; + esac + ;; + sparc) + family=SPARC + bigendian=true + defaultphyspagesize=8192 + pcquantum=4 + ptrsize=4 + ;; + sparc64) + family=SPARC64 + bigendian=true + defaultphyspagesize=8192 + pcquantum=4 + ;; + *) + echo 1>&2 "unrecognized goarch value \"$goarch\"" + exit 1 + ;; +esac + +if test "$family" = "unknown"; then + echo 1>&2 "internal error: no family for goarch value \"$goarch\"" + exit 1 +fi + +case $keyword in + bigendian) + echo $bigendian + ;; + cachelinesize) + echo $cachelinesize + ;; + defaultphyspagesize) + echo $defaultphyspagesize + ;; + family) + echo $family + ;; + hugepagesize) + echo $hugepagesize + ;; + int64align) + echo $int64align + ;; + maxalign) + echo $maxalign + ;; + minframesize) + echo $minframesize + ;; + pcquantum) + echo $pcquantum + ;; + ptrsize) + echo $ptrsize + ;; + *) + echo 1>&2 "unrecognized keyword \"$keyword\"" + exit 1 + ;; +esac + +exit 0 Property changes on: libgo/goarch.sh ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property