1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
|
#!/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
# - 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
int64align=8
maxalign=8
minframesize=0
pcquantum=1
ptrsize=8
stackalign=8
case $goarch in
386)
family=I386
int64align=4
maxalign=4
ptrsize=4
stackalign=4
;;
alpha)
family=ALPHA
defaultphyspagesize=8192
pcquantum=4
;;
amd64)
family=AMD64
;;
amd64p32)
family=AMD64
ptrsize=4
stackalign=4
;;
arm | armbe)
family=ARM
cachelinesize=32
minframesize=4
pcquantum=4
ptrsize=4
stackalign=4
case $goarch in
*be)
bigendian=true
;;
esac
;;
arm64 | arm64be)
family=ARM64
cachelinesize=32
defaultphyspagesize=65536
minframesize=8
pcquantum=4
stackalign=16
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
stackalign=4
;;
mips | mipsle | mips64p32 | mips64p32le)
family=MIPS
bigendian=true
cachelinesize=32
defaultphyspagesize=16384
minframesize=4
pcquantum=4
ptrsize=4
stackalign=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
;;
nios2)
family=NIOS2
cachelinesize=32
minframesize=16
pcquantum=4
ptrsize=4
stackalign=4
;;
ppc)
family=PPC
bigendian=true
defaultphyspagesize=65536
minframesize=32
pcquantum=4
ptrsize=4
stackalign=4
;;
ppc64 | ppc64le)
family=PPC64
bigendian=true
defaultphyspagesize=65536
minframesize=32
pcquantum=4
stackalign=16
case $goarch in
*le)
bigendian=false
;;
esac
;;
riscv)
family=RISCV
pcquantum=2
ptrsize=4
stackalign=4
;;
riscv64)
family=RISCV64
pcquantum=2
;;
s390)
family=S390
bigendian=true
cachelinesize=256
minframesize=4
pcquantum=2
ptrsize=4
stackalign=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
stackalign=4
case $goarch in
*be)
bigendian=true
;;
esac
;;
sparc)
family=SPARC
bigendian=true
defaultphyspagesize=8192
pcquantum=4
ptrsize=4
stackalign=4
;;
sparc64)
family=SPARC64
bigendian=true
defaultphyspagesize=8192
pcquantum=4
;;
wasm)
family=WASM
defaultphyspagesize=65536
;;
*)
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
;;
int64align)
echo $int64align
;;
maxalign)
echo $maxalign
;;
minframesize)
echo $minframesize
;;
pcquantum)
echo $pcquantum
;;
ptrsize)
echo $ptrsize
;;
stackalign)
echo $stackalign
;;
*)
echo 1>&2 "unrecognized keyword \"$keyword\""
exit 1
;;
esac
exit 0
|