Daily bump.
[official-gcc.git] / libgo / goarch.sh
blobc63cbbaa76b4d55d1007696303900e4443f9bb60
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 ppc)
130 family=PPC
131 bigendian=true
132 defaultphyspagesize=65536
133 minframesize=32
134 pcquantum=4
135 ptrsize=4
137 ppc64 | ppc64le)
138 family=PPC64
139 bigendian=true
140 defaultphyspagesize=65536
141 minframesize=32
142 pcquantum=4
143 case $goarch in
144 *le)
145 bigendian=false
147 esac
149 riscv64)
150 family=RISCV64
151 pcquantum=2
153 s390)
154 family=S390
155 bigendian=true
156 cachelinesize=256
157 minframesize=4
158 pcquantum=2
159 ptrsize=4
161 s390x)
162 family=S390X
163 bigendian=true
164 cachelinesize=256
165 minframesize=8
166 pcquantum=2
168 sh | shbe)
169 family=SH
170 cachelinesize=16
171 int64align=4
172 minframesize=4
173 pcquantum=2
174 ptrsize=4
175 case $goarch in
176 *be)
177 bigendian=true
179 esac
181 sparc)
182 family=SPARC
183 bigendian=true
184 defaultphyspagesize=8192
185 pcquantum=4
186 ptrsize=4
188 sparc64)
189 family=SPARC64
190 bigendian=true
191 defaultphyspagesize=8192
192 pcquantum=4
195 echo 1>&2 "unrecognized goarch value \"$goarch\""
196 exit 1
198 esac
200 if test "$family" = "unknown"; then
201 echo 1>&2 "internal error: no family for goarch value \"$goarch\""
202 exit 1
205 case $keyword in
206 bigendian)
207 echo $bigendian
209 cachelinesize)
210 echo $cachelinesize
212 defaultphyspagesize)
213 echo $defaultphyspagesize
215 family)
216 echo $family
218 hugepagesize)
219 echo $hugepagesize
221 int64align)
222 echo $int64align
224 maxalign)
225 echo $maxalign
227 minframesize)
228 echo $minframesize
230 pcquantum)
231 echo $pcquantum
233 ptrsize)
234 echo $ptrsize
237 echo 1>&2 "unrecognized keyword \"$keyword\""
238 exit 1
240 esac
242 exit 0