Daily bump.
[official-gcc.git] / libgo / goarch.sh
blobf7aef9d7ddeb4f677dbcc7b18637a68477e9ed9c
1 #!/bin/sh
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.
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 # - hugepagesize: size of a huge page in bytes
18 # (used only to decide when to use madvise with MADV_[NO]HUGEPAGE)
19 # (set to 0 if there are no huge pages)
20 # - int64align: alignment of int64 type in bytes
21 # - maxalign: maximum alignment of values of Go types in bytes
22 # - minframesize: size of smallest possible function frame in bytes
23 # (not currently used, may never be used)
24 # - pcquantum: minimum size of a single instruction in bytes
25 # - ptrsize: size of a pointer in bytes
27 if test $# -ne 2; then
28 echo 1>&2 "usage: goarch <goarch> <keyword>"
29 exit 1
32 goarch=$1
33 keyword=$2
35 # Default values
36 bigendian=false
37 cachelinesize=64
38 defaultphyspagesize=4096
39 family=unknown
40 hugepagesize=0
41 int64align=8
42 maxalign=8
43 minframesize=0
44 pcquantum=1
45 ptrsize=8
47 case $goarch in
48 386)
49 family=I386
50 hugepagesize="1 << 21"
51 int64align=4
52 maxalign=4
53 ptrsize=4
55 alpha)
56 family=ALPHA
57 defaultphyspagesize=8192
58 pcquantum=4
60 amd64)
61 family=AMD64
62 hugepagesize="1 << 21"
64 amd64p32)
65 family=AMD64
66 hugepagesize="1 << 21"
67 ptrsize=4
69 arm | armbe)
70 family=ARM
71 cachelinesize=32
72 minframesize=4
73 pcquantum=4
74 ptrsize=4
75 case $goarch in
76 *be)
77 bigendian=true
79 esac
81 arm64 | arm64be)
82 family=ARM64
83 cachelinesize=32
84 defaultphyspagesize=65536
85 minframesize=8
86 pcquantum=4
87 case $goarch in
88 *be)
89 bigendian=true
91 esac
93 ia64)
94 family=IA64
95 cachelinesize=128
96 defaultphyspagesize=65536
98 m68k)
99 family=M68K
100 bigendian=true
101 cachelinesize=16
102 int64align=2
103 maxalign=2
104 pcquantum=4
105 ptrsize=4
107 mips | mipsle | mips64p32 | mips64p32le)
108 family=MIPS
109 bigendian=true
110 cachelinesize=32
111 defaultphyspagesize=16384
112 minframesize=4
113 pcquantum=4
114 ptrsize=4
115 case $goarch in
116 *le)
117 bigendian=false
119 esac
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
132 esac
134 nios2)
135 family=NIOS2
136 cachelinesize=32
137 minframesize=16
138 pcquantum=4
139 ptrsize=4
141 ppc)
142 family=PPC
143 bigendian=true
144 defaultphyspagesize=65536
145 minframesize=32
146 pcquantum=4
147 ptrsize=4
149 ppc64 | ppc64le)
150 family=PPC64
151 bigendian=true
152 defaultphyspagesize=65536
153 minframesize=32
154 pcquantum=4
155 case $goarch in
156 *le)
157 bigendian=false
159 esac
161 riscv)
162 family=RISCV
163 pcquantum=2
164 ptrsize=4
166 riscv64)
167 family=RISCV64
168 pcquantum=2
170 s390)
171 family=S390
172 bigendian=true
173 cachelinesize=256
174 minframesize=4
175 pcquantum=2
176 ptrsize=4
178 s390x)
179 family=S390X
180 bigendian=true
181 cachelinesize=256
182 minframesize=8
183 pcquantum=2
185 sh | shbe)
186 family=SH
187 cachelinesize=16
188 int64align=4
189 minframesize=4
190 pcquantum=2
191 ptrsize=4
192 case $goarch in
193 *be)
194 bigendian=true
196 esac
198 sparc)
199 family=SPARC
200 bigendian=true
201 defaultphyspagesize=8192
202 pcquantum=4
203 ptrsize=4
205 sparc64)
206 family=SPARC64
207 bigendian=true
208 defaultphyspagesize=8192
209 pcquantum=4
211 wasm)
212 family=WASM
213 defaultphyspagesize=65536
216 echo 1>&2 "unrecognized goarch value \"$goarch\""
217 exit 1
219 esac
221 if test "$family" = "unknown"; then
222 echo 1>&2 "internal error: no family for goarch value \"$goarch\""
223 exit 1
226 case $keyword in
227 bigendian)
228 echo $bigendian
230 cachelinesize)
231 echo $cachelinesize
233 defaultphyspagesize)
234 echo $defaultphyspagesize
236 family)
237 echo $family
239 hugepagesize)
240 echo $hugepagesize
242 int64align)
243 echo $int64align
245 maxalign)
246 echo $maxalign
248 minframesize)
249 echo $minframesize
251 pcquantum)
252 echo $pcquantum
254 ptrsize)
255 echo $ptrsize
258 echo 1>&2 "unrecognized keyword \"$keyword\""
259 exit 1
261 esac
263 exit 0