2018-02-17 Thomas Koenig <tkoenig@gcc.gnu.org>
[official-gcc.git] / libgo / goarch.sh
blob9165e6a19a3af2f9fedd743897c8870579f98b89
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 s390)
150 family=S390
151 bigendian=true
152 cachelinesize=256
153 minframesize=4
154 pcquantum=2
155 ptrsize=4
157 s390x)
158 family=S390X
159 bigendian=true
160 cachelinesize=256
161 minframesize=8
162 pcquantum=2
164 sh | shbe)
165 family=SH
166 cachelinesize=16
167 int64align=4
168 minframesize=4
169 pcquantum=2
170 ptrsize=4
171 case $goarch in
172 *be)
173 bigendian=true
175 esac
177 sparc)
178 family=SPARC
179 bigendian=true
180 defaultphyspagesize=8192
181 pcquantum=4
182 ptrsize=4
184 sparc64)
185 family=SPARC64
186 bigendian=true
187 defaultphyspagesize=8192
188 pcquantum=4
191 echo 1>&2 "unrecognized goarch value \"$goarch\""
192 exit 1
194 esac
196 if test "$family" = "unknown"; then
197 echo 1>&2 "internal error: no family for goarch value \"$goarch\""
198 exit 1
201 case $keyword in
202 bigendian)
203 echo $bigendian
205 cachelinesize)
206 echo $cachelinesize
208 defaultphyspagesize)
209 echo $defaultphyspagesize
211 family)
212 echo $family
214 hugepagesize)
215 echo $hugepagesize
217 int64align)
218 echo $int64align
220 maxalign)
221 echo $maxalign
223 minframesize)
224 echo $minframesize
226 pcquantum)
227 echo $pcquantum
229 ptrsize)
230 echo $ptrsize
233 echo 1>&2 "unrecognized keyword \"$keyword\""
234 exit 1
236 esac
238 exit 0