github.com/golang/gofrontend@v0.0.0-20240429183944-60f985a78526/libgo/goarch.sh (about) 1 #!/bin/sh 2 3 # Copyright 2018 The Go Authors. All rights reserved. 4 # Use of this source code is governed by a BSD-style 5 # license that can be found in the LICENSE file. 6 7 # Code in Makefile.am will invoke this script with two arguments. 8 # The first is a GOARCH value. The second is a keyword. 9 # The script will print the value of that keyword for that GOARCH. 10 # Keywords: 11 # - bigendian: true or false 12 # - cachelinesize: the cache line size in bytes 13 # (for performance only; it's not essential to get this right) 14 # - defaultphyspagesize: the default physical page size in bytes 15 # (not currently used, but maybe some day) 16 # - family: the processor family, from ALLGOARCHFAMILY in configure.ac 17 # - int64align: alignment of int64 type in bytes 18 # - maxalign: maximum alignment of values of Go types in bytes 19 # - minframesize: size of smallest possible function frame in bytes 20 # (not currently used, may never be used) 21 # - pcquantum: minimum size of a single instruction in bytes 22 # - ptrsize: size of a pointer in bytes 23 24 if test $# -ne 2; then 25 echo 1>&2 "usage: goarch <goarch> <keyword>" 26 exit 1 27 fi 28 29 goarch=$1 30 keyword=$2 31 32 # Default values 33 bigendian=false 34 cachelinesize=64 35 defaultphyspagesize=4096 36 family=unknown 37 int64align=8 38 maxalign=8 39 minframesize=0 40 pcquantum=1 41 ptrsize=8 42 stackalign=8 43 44 case $goarch in 45 386) 46 family=I386 47 int64align=4 48 maxalign=4 49 ptrsize=4 50 stackalign=4 51 ;; 52 alpha) 53 family=ALPHA 54 defaultphyspagesize=8192 55 pcquantum=4 56 ;; 57 amd64) 58 family=AMD64 59 ;; 60 amd64p32) 61 family=AMD64 62 ptrsize=4 63 stackalign=4 64 ;; 65 arm | armbe) 66 family=ARM 67 cachelinesize=32 68 minframesize=4 69 pcquantum=4 70 ptrsize=4 71 stackalign=4 72 case $goarch in 73 *be) 74 bigendian=true 75 ;; 76 esac 77 ;; 78 arm64 | arm64be) 79 family=ARM64 80 cachelinesize=32 81 defaultphyspagesize=65536 82 minframesize=8 83 pcquantum=4 84 stackalign=16 85 case $goarch in 86 *be) 87 bigendian=true 88 ;; 89 esac 90 ;; 91 ia64) 92 family=IA64 93 cachelinesize=128 94 defaultphyspagesize=65536 95 ;; 96 m68k) 97 family=M68K 98 bigendian=true 99 cachelinesize=16 100 int64align=2 101 maxalign=2 102 pcquantum=4 103 ptrsize=4 104 stackalign=4 105 ;; 106 mips | mipsle | mips64p32 | mips64p32le) 107 family=MIPS 108 bigendian=true 109 cachelinesize=32 110 defaultphyspagesize=16384 111 minframesize=4 112 pcquantum=4 113 ptrsize=4 114 stackalign=4 115 case $goarch in 116 *le) 117 bigendian=false 118 ;; 119 esac 120 ;; 121 mips64 | mips64le) 122 family=MIPS64 123 bigendian=true 124 cachelinesize=32 125 defaultphyspagesize=16384 126 minframesize=8 127 pcquantum=4 128 case $goarch in 129 *le) 130 bigendian=false 131 ;; 132 esac 133 ;; 134 nios2) 135 family=NIOS2 136 cachelinesize=32 137 minframesize=16 138 pcquantum=4 139 ptrsize=4 140 stackalign=4 141 ;; 142 ppc) 143 family=PPC 144 bigendian=true 145 defaultphyspagesize=65536 146 minframesize=32 147 pcquantum=4 148 ptrsize=4 149 stackalign=4 150 ;; 151 ppc64 | ppc64le) 152 family=PPC64 153 bigendian=true 154 defaultphyspagesize=65536 155 minframesize=32 156 pcquantum=4 157 stackalign=16 158 case $goarch in 159 *le) 160 bigendian=false 161 ;; 162 esac 163 ;; 164 riscv) 165 family=RISCV 166 pcquantum=2 167 ptrsize=4 168 stackalign=4 169 ;; 170 riscv64) 171 family=RISCV64 172 pcquantum=2 173 ;; 174 s390) 175 family=S390 176 bigendian=true 177 cachelinesize=256 178 minframesize=4 179 pcquantum=2 180 ptrsize=4 181 stackalign=4 182 ;; 183 s390x) 184 family=S390X 185 bigendian=true 186 cachelinesize=256 187 minframesize=8 188 pcquantum=2 189 ;; 190 sh | shbe) 191 family=SH 192 cachelinesize=16 193 int64align=4 194 minframesize=4 195 pcquantum=2 196 ptrsize=4 197 stackalign=4 198 case $goarch in 199 *be) 200 bigendian=true 201 ;; 202 esac 203 ;; 204 sparc) 205 family=SPARC 206 bigendian=true 207 defaultphyspagesize=8192 208 pcquantum=4 209 ptrsize=4 210 stackalign=4 211 ;; 212 sparc64) 213 family=SPARC64 214 bigendian=true 215 defaultphyspagesize=8192 216 pcquantum=4 217 ;; 218 wasm) 219 family=WASM 220 defaultphyspagesize=65536 221 ;; 222 *) 223 echo 1>&2 "unrecognized goarch value \"$goarch\"" 224 exit 1 225 ;; 226 esac 227 228 if test "$family" = "unknown"; then 229 echo 1>&2 "internal error: no family for goarch value \"$goarch\"" 230 exit 1 231 fi 232 233 case $keyword in 234 bigendian) 235 echo $bigendian 236 ;; 237 cachelinesize) 238 echo $cachelinesize 239 ;; 240 defaultphyspagesize) 241 echo $defaultphyspagesize 242 ;; 243 family) 244 echo $family 245 ;; 246 int64align) 247 echo $int64align 248 ;; 249 maxalign) 250 echo $maxalign 251 ;; 252 minframesize) 253 echo $minframesize 254 ;; 255 pcquantum) 256 echo $pcquantum 257 ;; 258 ptrsize) 259 echo $ptrsize 260 ;; 261 stackalign) 262 echo $stackalign 263 ;; 264 *) 265 echo 1>&2 "unrecognized keyword \"$keyword\"" 266 exit 1 267 ;; 268 esac 269 270 exit 0