From: Ian Lance Taylor Date: Sun, 14 Jan 2018 04:59:01 +0000 (+0000) Subject: go/types: implement SizesFor for gccgo X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ffad1c54d2e4b698bab8d198a65c6183e74449a8;p=gcc.git go/types: implement SizesFor for gccgo Move the architecture-specific settings out of configure.ac into a new shell script goarch.sh. Use the new script to collect the values for all architectures to make them available in go/types. Also fix cmd/vet to pass the right compiler when it calls SizesFor. This fixes cmd/vet for systems that are not implemented in the gc toolchain, such as alpha and ia64. Reviewed-on: https://go-review.googlesource.com/87635 From-SVN: r256655 --- diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 35bebbbf265..7d87aa8ab53 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -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. diff --git a/libgo/Makefile.am b/libgo/Makefile.am index c8b444c7fd8..32e1e4dd09e 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -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-libgo -fno-inline 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) diff --git a/libgo/Makefile.in b/libgo/Makefile.in index 99fbd8c7308..4c69dbd7f26 100644 --- a/libgo/Makefile.in +++ b/libgo/Makefile.in @@ -303,14 +303,6 @@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOARCH = @GOARCH@ -GOARCH_BIGENDIAN = @GOARCH_BIGENDIAN@ -GOARCH_CACHELINESIZE = @GOARCH_CACHELINESIZE@ -GOARCH_FAMILY = @GOARCH_FAMILY@ -GOARCH_HUGEPAGESIZE = @GOARCH_HUGEPAGESIZE@ -GOARCH_INT64ALIGN = @GOARCH_INT64ALIGN@ -GOARCH_MINFRAMESIZE = @GOARCH_MINFRAMESIZE@ -GOARCH_PCQUANTUM = @GOARCH_PCQUANTUM@ -GOARCH_PHYSPAGESIZE = @GOARCH_PHYSPAGESIZE@ GOC = @GOC@ GOCFLAGS = $(CFLAGS) GOOS = @GOOS@ @@ -1212,6 +1204,7 @@ runtime_internal_sys_lo_check_GOCFLAGS = -fgo-compiling-runtime # Also use -fno-inline to get better results from the memory profiler. runtime_pprof_check_GOCFLAGS = -static-libgo -fno-inline extra_go_files_runtime_internal_sys = version.go +extra_go_files_go_types = gccgosizes.go extra_go_files_cmd_internal_objabi = objabi.go extra_go_files_cmd_go_internal_cfg = zdefaultcc.go extra_go_files_cmd_go_internal_load = zstdpkglist.go @@ -3095,14 +3088,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 \ @@ -3137,6 +3130,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 @@ -3313,6 +3321,7 @@ $(foreach package,$(GOTOOL_PACKAGES),$(eval $(call PACKAGE_template,$(package))) runtime.lo.dep: $(extra_go_files_runtime) syscall.lo.dep: $(extra_go_files_syscall) runtime/internal/sys.lo.dep: $(extra_go_files_runtime_internal_sys) +go/types.lo.dep: $(extra_go_files_go_types) cmd/internal/objabi.lo.dep: $(extra_go_files_cmd_internal_objabi) cmd/go/internal/cfg.lo.dep: $(extra_go_files_cmd_go_internal_cfg) cmd/go/internal/load.lo.dep: $(extra_go_files_cmd_go_internal_load) diff --git a/libgo/configure b/libgo/configure index 28e283c6316..d0550c37c55 100755 --- a/libgo/configure +++ b/libgo/configure @@ -632,14 +632,6 @@ GO_LIBCALL_OS_ARCH_FILE GO_LIBCALL_OS_FILE ALLGOARCHFAMILY ALLGOARCH -GOARCH_MINFRAMESIZE -GOARCH_HUGEPAGESIZE -GOARCH_INT64ALIGN -GOARCH_PCQUANTUM -GOARCH_PHYSPAGESIZE -GOARCH_CACHELINESIZE -GOARCH_BIGENDIAN -GOARCH_FAMILY GOARCH USE_DEJAGNU ALLGOOS @@ -11114,7 +11106,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11118 "configure" +#line 11109 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11220,7 +11212,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11224 "configure" +#line 11215 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13644,46 +13636,41 @@ esac # 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 ;; @@ -13697,31 +13684,16 @@ case ${host} in _ACEOF if ac_fn_c_try_compile "$LINENO"; then : GOARCH=386 -GOARCH_FAMILY=I386 -GOARCH_INT64ALIGN=4 -GOARCH_HUGEPAGESIZE="1 << 21" - else GOARCH=amd64 -GOARCH_FAMILY=AMD64 -GOARCH_HUGEPAGESIZE="1 << 21" - fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; 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*-*-*) cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -13767,27 +13739,11 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext "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*-*-*) cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -13799,12 +13755,8 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext _ACEOF if ac_fn_c_try_compile "$LINENO"; then : GOARCH=ppc -GOARCH_FAMILY=PPC -GOARCH_BIGENDIAN=true - else -GOARCH_FAMILY=PPC64 cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -13814,18 +13766,12 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext _ACEOF if ac_fn_c_try_compile "$LINENO"; then : GOARCH=ppc64le - else GOARCH=ppc64 -GOARCH_BIGENDIAN=true - fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - GOARCH_PHYSPAGESIZE=65536 - GOARCH_PCQUANTUM=4 - GOARCH_MINFRAMESIZE=32 ;; s390*-*-*) cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -13837,49 +13783,16 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext _ACEOF if ac_fn_c_try_compile "$LINENO"; then : GOARCH=s390 -GOARCH_FAMILY=S390 -GOARCH_MINFRAMESIZE=4 - else GOARCH=s390x -GOARCH_FAMILY=S390X -GOARCH_MINFRAMESIZE=8 - fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - GOARCH_BIGENDIAN=true - GOARCH_CACHELINESIZE=256 - GOARCH_PCQUANTUM=2 ;; - sh3eb*-*-*) + sh3eb*-*-* | sh4eb*-*-*) GOARCH=shbe - GOARCH_FAMILY=SH - GOARCH_BIGENDIAN=true - GOARCH_CACHELINESIZE=16 - GOARCH_PCQUANTUM=2 - GOARCH_MINFRAMESIZE=4 ;; - sh3*-*-*) + sh3*-*-* | sh4*-*-*) GOARCH=sh - GOARCH_FAMILY=SH - GOARCH_CACHELINESIZE=16 - GOARCH_PCQUANTUM=2 - GOARCH_MINFRAMESIZE=4 - ;; - sh4eb*-*-*) - GOARCH=shbe - GOARCH_FAMILY=SH - GOARCH_BIGENDIAN=true - GOARCH_CACHELINESIZE=32 - GOARCH_PCQUANTUM=2 - GOARCH_MINFRAMESIZE=4 - ;; - sh4*-*-*) - GOARCH=sh - GOARCH_FAMILY=SH - GOARCH_CACHELINESIZE=32 - GOARCH_PCQUANTUM=2 - GOARCH_MINFRAMESIZE=4 ;; sparc*-*-*) cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -13891,31 +13804,16 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext _ACEOF if ac_fn_c_try_compile "$LINENO"; then : GOARCH=sparc -GOARCH_FAMILY=SPARC - else GOARCH=sparc64 -GOARCH_FAMILY=SPARC64 - fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - GOARCH_BIGENDIAN=true - GOARCH_PHYSPAGESIZE=8192 - GOARCH_PCQUANTUM=4 ;; esac - - - - - - - - GO_LIBCALL_OS_FILE= GO_LIBCALL_OS_ARCH_FILE= GO_SYSCALL_OS_FILE= diff --git a/libgo/configure.ac b/libgo/configure.ac index 1077c9e114d..c497e78c31a 100644 --- a/libgo/configure.ac +++ b/libgo/configure.ac @@ -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 +[GOARCH=s390], +[GOARCH=s390x]) ;; - sh3*-*-*) - GOARCH=sh - GOARCH_FAMILY=SH - GOARCH_CACHELINESIZE=16 - GOARCH_PCQUANTUM=2 - GOARCH_MINFRAMESIZE=4 - ;; - 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) diff --git a/libgo/go/cmd/vet/types.go b/libgo/go/cmd/vet/types.go index 799dc655e60..d83611b4da0 100644 --- a/libgo/go/cmd/vet/types.go +++ b/libgo/go/cmd/vet/types.go @@ -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, name string) bool { return ok } -var archSizes = types.SizesFor("gc", build.Default.GOARCH) +var archSizes = types.SizesFor(runtime.Compiler, build.Default.GOARCH) diff --git a/libgo/go/go/types/sizes.go b/libgo/go/go/types/sizes.go index 0821a61359d..05d14dae132 100644 --- a/libgo/go/go/types/sizes.go +++ b/libgo/go/go/types/sizes.go @@ -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 } diff --git a/libgo/goarch.sh b/libgo/goarch.sh new file mode 100755 index 00000000000..9165e6a19a3 --- /dev/null +++ b/libgo/goarch.sh @@ -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 " + 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 diff --git a/libgo/testsuite/Makefile.in b/libgo/testsuite/Makefile.in index 79da1c91ff6..fc02e093ef8 100644 --- a/libgo/testsuite/Makefile.in +++ b/libgo/testsuite/Makefile.in @@ -107,14 +107,6 @@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOARCH = @GOARCH@ -GOARCH_BIGENDIAN = @GOARCH_BIGENDIAN@ -GOARCH_CACHELINESIZE = @GOARCH_CACHELINESIZE@ -GOARCH_FAMILY = @GOARCH_FAMILY@ -GOARCH_HUGEPAGESIZE = @GOARCH_HUGEPAGESIZE@ -GOARCH_INT64ALIGN = @GOARCH_INT64ALIGN@ -GOARCH_MINFRAMESIZE = @GOARCH_MINFRAMESIZE@ -GOARCH_PCQUANTUM = @GOARCH_PCQUANTUM@ -GOARCH_PHYSPAGESIZE = @GOARCH_PHYSPAGESIZE@ GOC = @GOC@ GOCFLAGS = @GOCFLAGS@ GOOS = @GOOS@