Daily bump.
[official-gcc.git] / libgo / goarch.sh
blob11bca7bb18f041986878b77489f3c400a54f9115
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 | amd64p32)
61 family=AMD64
62 hugepagesize="1 << 21"
64 arm | armbe)
65 family=ARM
66 cachelinesize=32
67 minframesize=4
68 pcquantum=4
69 ptrsize=4
70 case $goarch in
71 *be)
72 bigendian=true
74 esac
76 arm64 | arm64be)
77 family=ARM64
78 cachelinesize=32
79 defaultphyspagesize=65536
80 minframesize=8
81 pcquantum=4
82 case $goarch in
83 *be)
84 bigendian=true
86 esac
88 ia64)
89 family=IA64
90 cachelinesize=128
91 defaultphyspagesize=65536
93 m68k)
94 family=M68K
95 bigendian=true
96 cachelinesize=16
97 int64align=2
98 maxalign=2
99 pcquantum=4
100 ptrsize=4
102 mips | mipsle | mips64p32 | mips64p32le)
103 family=MIPS
104 bigendian=true
105 cachelinesize=32
106 defaultphyspagesize=16384
107 minframesize=4
108 pcquantum=4
109 ptrsize=4
110 case $goarch in
111 *le)
112 bigendian=false
114 esac
116 mips64 | mips64le)
117 family=MIPS64
118 bigendian=true
119 cachelinesize=32
120 defaultphyspagesize=16384
121 minframesize=8
122 pcquantum=4
123 case $goarch in
124 *le)
125 bigendian=false
127 esac
129 nios2)
130 family=NIOS2
131 cachelinesize=32
132 minframesize=16
133 pcquantum=4
134 ptrsize=4
136 ppc)
137 family=PPC
138 bigendian=true
139 defaultphyspagesize=65536
140 minframesize=32
141 pcquantum=4
142 ptrsize=4
144 ppc64 | ppc64le)
145 family=PPC64
146 bigendian=true
147 defaultphyspagesize=65536
148 minframesize=32
149 pcquantum=4
150 case $goarch in
151 *le)
152 bigendian=false
154 esac
156 riscv64)
157 family=RISCV64
158 pcquantum=2
160 s390)
161 family=S390
162 bigendian=true
163 cachelinesize=256
164 minframesize=4
165 pcquantum=2
166 ptrsize=4
168 s390x)
169 family=S390X
170 bigendian=true
171 cachelinesize=256
172 minframesize=8
173 pcquantum=2
175 sh | shbe)
176 family=SH
177 cachelinesize=16
178 int64align=4
179 minframesize=4
180 pcquantum=2
181 ptrsize=4
182 case $goarch in
183 *be)
184 bigendian=true
186 esac
188 sparc)
189 family=SPARC
190 bigendian=true
191 defaultphyspagesize=8192
192 pcquantum=4
193 ptrsize=4
195 sparc64)
196 family=SPARC64
197 bigendian=true
198 defaultphyspagesize=8192
199 pcquantum=4
202 echo 1>&2 "unrecognized goarch value \"$goarch\""
203 exit 1
205 esac
207 if test "$family" = "unknown"; then
208 echo 1>&2 "internal error: no family for goarch value \"$goarch\""
209 exit 1
212 case $keyword in
213 bigendian)
214 echo $bigendian
216 cachelinesize)
217 echo $cachelinesize
219 defaultphyspagesize)
220 echo $defaultphyspagesize
222 family)
223 echo $family
225 hugepagesize)
226 echo $hugepagesize
228 int64align)
229 echo $int64align
231 maxalign)
232 echo $maxalign
234 minframesize)
235 echo $minframesize
237 pcquantum)
238 echo $pcquantum
240 ptrsize)
241 echo $ptrsize
244 echo 1>&2 "unrecognized keyword \"$keyword\""
245 exit 1
247 esac
249 exit 0