Thu Apr 18 15:21:55 2024 UTC (34d)
Pull up following revision(s) (requested by riastradh in ticket #655):

	sys/modules/Makefile: revision 1.285
	share/mk/bsd.own.mk: revision 1.1365
	share/mk/bsd.own.mk: revision 1.1366
	sys/arch/aarch64/include/sljit_machdep.h: revision 1.4
	sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c: revision 1.5

sljit: Pacify -Wsign-compare.

If these sizes are negative, we're probably in trouble anyway, so
assert nonnegative here.
Needed to resolve PR 58103.

bsd.own.mk: Enable MKLSJIT on aarch64.

Make sure there's only one copy of the conditional, in bsd.own.mk;
just make sys/modules/Makefile conditional on MKSLJIT so we don't
have to keep these in sync.

As a workaround for PR 58106, tweak the conditional definition of
SLJIT_CACHE_FLUSH to use cpu_icache_sync_range only in _HARDKERNEL,
and use __builtin___clear_cache in userland and in rump kernels.

PR 58103: bpfjit.kmod is not built on aarch64
bsd.own.mk: No need for MKSLJIT to be set differently from others.
- Use ?=, not =, so mk.conf setting wins.
- Write out per-architecture tabular settings, not a conditional.
- Add comments for the architectures that look like they should have
  sljit but don't.  (XXX Missing comments about powerpc and mips --
  not sure why, is this because modules don't yet work on those
  architectures, or what?)

Tidying for PR 58103: bpfjit.kmod is not built on aarch64.


(martin)
diff -r1.1289.2.2 -r1.1289.2.3 src/share/mk/bsd.own.mk
diff -r1.3 -r1.3.18.1 src/sys/arch/aarch64/include/sljit_machdep.h
diff -r1.4 -r1.4.30.1 src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c
diff -r1.274.2.2 -r1.274.2.3 src/sys/modules/Makefile

cvs diff -r1.1289.2.2 -r1.1289.2.3 src/share/mk/bsd.own.mk (switch to unified diff)

--- src/share/mk/bsd.own.mk 2023/10/20 16:04:59 1.1289.2.2
+++ src/share/mk/bsd.own.mk 2024/04/18 15:21:55 1.1289.2.3
@@ -1,1769 +1,1778 @@ @@ -1,1769 +1,1778 @@
1# $NetBSD: bsd.own.mk,v 1.1289.2.2 2023/10/20 16:04:59 martin Exp $ 1# $NetBSD: bsd.own.mk,v 1.1289.2.3 2024/04/18 15:21:55 martin Exp $
2 2
3# This needs to be before bsd.init.mk 3# This needs to be before bsd.init.mk
4.if defined(BSD_MK_COMPAT_FILE) 4.if defined(BSD_MK_COMPAT_FILE)
5.include <${BSD_MK_COMPAT_FILE}> 5.include <${BSD_MK_COMPAT_FILE}>
6.endif 6.endif
7 7
8.if !defined(_BSD_OWN_MK_) 8.if !defined(_BSD_OWN_MK_)
9_BSD_OWN_MK_=1 9_BSD_OWN_MK_=1
10 10
11MAKECONF?= /etc/mk.conf 11MAKECONF?= /etc/mk.conf
12.-include "${MAKECONF}" 12.-include "${MAKECONF}"
13 13
14# 14#
15# CPU model, derived from MACHINE_ARCH 15# CPU model, derived from MACHINE_ARCH
16# 16#
17MACHINE_CPU= ${MACHINE_ARCH:C/mips.*e[bl]/mips/:C/sh3e[bl]/sh3/:S/coldfire/m68k/:S/m68000/m68k/:C/e?arm.*/arm/:S/powerpc64/powerpc/:S/aarch64eb/aarch64/:S/or1knd/or1k/:C/riscv../riscv/} 17MACHINE_CPU= ${MACHINE_ARCH:C/mips.*e[bl]/mips/:C/sh3e[bl]/sh3/:S/coldfire/m68k/:S/m68000/m68k/:C/e?arm.*/arm/:S/powerpc64/powerpc/:S/aarch64eb/aarch64/:S/or1knd/or1k/:C/riscv../riscv/}
18 18
19.if (${MACHINE_ARCH} == "mips64el" || \ 19.if (${MACHINE_ARCH} == "mips64el" || \
20 ${MACHINE_ARCH} == "mips64eb" || \ 20 ${MACHINE_ARCH} == "mips64eb" || \
21 ${MACHINE_ARCH} == "mipsn64el" || \ 21 ${MACHINE_ARCH} == "mipsn64el" || \
22 ${MACHINE_ARCH} == "mipsn64eb") 22 ${MACHINE_ARCH} == "mipsn64eb")
23MACHINE_MIPS64= 1 23MACHINE_MIPS64= 1
24.else 24.else
25MACHINE_MIPS64= 0 25MACHINE_MIPS64= 0
26.endif 26.endif
27 27
28# 28#
29# Subdirectory used below ${RELEASEDIR} when building a release 29# Subdirectory used below ${RELEASEDIR} when building a release
30# 30#
31.if !empty(MACHINE:Mevbarm) || !empty(MACHINE:Mevbmips) \ 31.if !empty(MACHINE:Mevbarm) || !empty(MACHINE:Mevbmips) \
32 || !empty(MACHINE:Mevbsh3) 32 || !empty(MACHINE:Mevbsh3)
33RELEASEMACHINEDIR?= ${MACHINE}-${MACHINE_ARCH} 33RELEASEMACHINEDIR?= ${MACHINE}-${MACHINE_ARCH}
34.else 34.else
35RELEASEMACHINEDIR?= ${MACHINE} 35RELEASEMACHINEDIR?= ${MACHINE}
36.endif 36.endif
37 37
38# 38#
39# Subdirectory or path component used for the following paths: 39# Subdirectory or path component used for the following paths:
40# distrib/${RELEASEMACHINE} 40# distrib/${RELEASEMACHINE}
41# distrib/notes/${RELEASEMACHINE} 41# distrib/notes/${RELEASEMACHINE}
42# etc/etc.${RELEASEMACHINE} 42# etc/etc.${RELEASEMACHINE}
43# Used when building a release. 43# Used when building a release.
44# 44#
45RELEASEMACHINE?= ${MACHINE} 45RELEASEMACHINE?= ${MACHINE}
46 46
47# 47#
48# NEED_OWN_INSTALL_TARGET is set to "no" by pkgsrc/mk/bsd.pkg.mk to 48# NEED_OWN_INSTALL_TARGET is set to "no" by pkgsrc/mk/bsd.pkg.mk to
49# ensure that things defined by <bsd.own.mk> (default targets, 49# ensure that things defined by <bsd.own.mk> (default targets,
50# INSTALL_FILE, etc.) are not conflicting with bsd.pkg.mk. 50# INSTALL_FILE, etc.) are not conflicting with bsd.pkg.mk.
51# 51#
52NEED_OWN_INSTALL_TARGET?= yes 52NEED_OWN_INSTALL_TARGET?= yes
53 53
54# 54#
55# This lists the platforms which do not have working in-tree toolchains. For 55# This lists the platforms which do not have working in-tree toolchains. For
56# the in-tree gcc toolchain, this list is empty. 56# the in-tree gcc toolchain, this list is empty.
57# 57#
58# If some future port is not supported by the in-tree toolchain, this should 58# If some future port is not supported by the in-tree toolchain, this should
59# be set to "yes" for that port only. 59# be set to "yes" for that port only.
60# 60#
61# .if ${MACHINE} == "playstation2" 61# .if ${MACHINE} == "playstation2"
62# TOOLCHAIN_MISSING?= yes 62# TOOLCHAIN_MISSING?= yes
63# .endif 63# .endif
64 64
65TOOLCHAIN_MISSING?= no 65TOOLCHAIN_MISSING?= no
66 66
67# 67#
68# GCC Using platforms. 68# GCC Using platforms.
69# 69#
70.if ${MKGCC:Uyes} != "no" 70.if ${MKGCC:Uyes} != "no"
71 71
72# 72#
73# What GCC is used? 73# What GCC is used?
74# 74#
75HAVE_GCC?= 10 75HAVE_GCC?= 10
76 76
77# 77#
78# Platforms that can't run a modern GCC natively 78# Platforms that can't run a modern GCC natively
79.if ${MACHINE_ARCH} == "m68000" 79.if ${MACHINE_ARCH} == "m68000"
80MKGCCCMDS?= no 80MKGCCCMDS?= no
81.endif 81.endif
82 82
83# 83#
84# We import the old gcc as "gcc.old" when upgrading. EXTERNAL_GCC_SUBDIR is 84# We import the old gcc as "gcc.old" when upgrading. EXTERNAL_GCC_SUBDIR is
85# set to the relevant subdirectory in src/external/gpl3 for his HAVE_GCC. 85# set to the relevant subdirectory in src/external/gpl3 for his HAVE_GCC.
86# 86#
87.if ${HAVE_GCC} == 9 87.if ${HAVE_GCC} == 9
88EXTERNAL_GCC_SUBDIR?= gcc.old 88EXTERNAL_GCC_SUBDIR?= gcc.old
89.elif ${HAVE_GCC} == 10 89.elif ${HAVE_GCC} == 10
90EXTERNAL_GCC_SUBDIR?= gcc 90EXTERNAL_GCC_SUBDIR?= gcc
91.else 91.else
92EXTERNAL_GCC_SUBDIR?= /does/not/exist 92EXTERNAL_GCC_SUBDIR?= /does/not/exist
93.endif 93.endif
94.else 94.else
95MKGCCCMDS?= no 95MKGCCCMDS?= no
96.endif 96.endif
97 97
98# 98#
99# What binutils is used? 99# What binutils is used?
100# 100#
101HAVE_BINUTILS?= 234 101HAVE_BINUTILS?= 234
102 102
103.if ${HAVE_BINUTILS} == 234 103.if ${HAVE_BINUTILS} == 234
104EXTERNAL_BINUTILS_SUBDIR= binutils 104EXTERNAL_BINUTILS_SUBDIR= binutils
105.elif ${HAVE_BINUTILS} == 231 105.elif ${HAVE_BINUTILS} == 231
106EXTERNAL_BINUTILS_SUBDIR= binutils.old 106EXTERNAL_BINUTILS_SUBDIR= binutils.old
107.else 107.else
108EXTERNAL_BINUTILS_SUBDIR= /does/not/exist 108EXTERNAL_BINUTILS_SUBDIR= /does/not/exist
109.endif 109.endif
110 110
111# 111#
112# What GDB is used? 112# What GDB is used?
113# 113#
114HAVE_GDB?= 1100 114HAVE_GDB?= 1100
115 115
116.if ${HAVE_GDB} == 1100 116.if ${HAVE_GDB} == 1100
117EXTERNAL_GDB_SUBDIR= gdb 117EXTERNAL_GDB_SUBDIR= gdb
118.elif ${HAVE_GDB} == 830 118.elif ${HAVE_GDB} == 830
119EXTERNAL_GDB_SUBDIR= gdb.old 119EXTERNAL_GDB_SUBDIR= gdb.old
120.else 120.else
121EXTERNAL_GDB_SUBDIR= /does/not/exist 121EXTERNAL_GDB_SUBDIR= /does/not/exist
122.endif 122.endif
123 123
124# 124#
125# What OpenSSL is used? 125# What OpenSSL is used?
126# 126#
127HAVE_OPENSSL?= 30 127HAVE_OPENSSL?= 30
128 128
129.if ${HAVE_OPENSSL} == 30 129.if ${HAVE_OPENSSL} == 30
130EXTERNAL_OPENSSL_SUBDIR=openssl 130EXTERNAL_OPENSSL_SUBDIR=openssl
131.elif ${HAVE_OPENSSL} == 11 131.elif ${HAVE_OPENSSL} == 11
132EXTERNAL_OPENSSL_SUBDIR=openssl.old 132EXTERNAL_OPENSSL_SUBDIR=openssl.old
133.else 133.else
134EXTERNAL_OPENSSL_SUBDIR=/does/not/exist 134EXTERNAL_OPENSSL_SUBDIR=/does/not/exist
135.endif 135.endif
136 136
137# 137#
138# Does the platform support ACPI? 138# Does the platform support ACPI?
139# 139#
140.if ${MACHINE} == "i386" || \ 140.if ${MACHINE} == "i386" || \
141 ${MACHINE} == "amd64" || \ 141 ${MACHINE} == "amd64" || \
142 ${MACHINE} == "ia64" || \ 142 ${MACHINE} == "ia64" || \
143 !empty(MACHINE_ARCH:Maarch64*) 143 !empty(MACHINE_ARCH:Maarch64*)
144HAVE_ACPI= yes 144HAVE_ACPI= yes
145.else 145.else
146HAVE_ACPI= no 146HAVE_ACPI= no
147.endif 147.endif
148 148
149# 149#
150# Does the platform support UEFI? 150# Does the platform support UEFI?
151# 151#
152.if ${MACHINE} == "i386" || \ 152.if ${MACHINE} == "i386" || \
153 ${MACHINE} == "amd64" || \ 153 ${MACHINE} == "amd64" || \
154 ${MACHINE} == "ia64" || \ 154 ${MACHINE} == "ia64" || \
155 !empty(MACHINE_ARCH:Mearmv7*) || \ 155 !empty(MACHINE_ARCH:Mearmv7*) || \
156 !empty(MACHINE_ARCH:Maarch64*) || \ 156 !empty(MACHINE_ARCH:Maarch64*) || \
157 ${MACHINE_ARCH} == "riscv64" 157 ${MACHINE_ARCH} == "riscv64"
158HAVE_UEFI= yes 158HAVE_UEFI= yes
159.else 159.else
160HAVE_UEFI= no 160HAVE_UEFI= no
161.endif 161.endif
162 162
163# 163#
164# Does the platform support NVMM? 164# Does the platform support NVMM?
165# 165#
166.if ${MACHINE_ARCH} == "x86_64" 166.if ${MACHINE_ARCH} == "x86_64"
167HAVE_NVMM= yes 167HAVE_NVMM= yes
168.else 168.else
169HAVE_NVMM= no 169HAVE_NVMM= no
170.endif 170.endif
171 171
172 172
173.if !empty(MACHINE_ARCH:Mearm*) 173.if !empty(MACHINE_ARCH:Mearm*)
174_LIBC_COMPILER_RT.${MACHINE_ARCH}= yes 174_LIBC_COMPILER_RT.${MACHINE_ARCH}= yes
175.endif 175.endif
176 176
177_LIBC_COMPILER_RT.aarch64= yes 177_LIBC_COMPILER_RT.aarch64= yes
178_LIBC_COMPILER_RT.aarch64eb= yes 178_LIBC_COMPILER_RT.aarch64eb= yes
179_LIBC_COMPILER_RT.i386= yes 179_LIBC_COMPILER_RT.i386= yes
180_LIBC_COMPILER_RT.powerpc= yes 180_LIBC_COMPILER_RT.powerpc= yes
181_LIBC_COMPILER_RT.powerpc64= yes 181_LIBC_COMPILER_RT.powerpc64= yes
182_LIBC_COMPILER_RT.sparc= yes 182_LIBC_COMPILER_RT.sparc= yes
183_LIBC_COMPILER_RT.sparc64= yes 183_LIBC_COMPILER_RT.sparc64= yes
184_LIBC_COMPILER_RT.x86_64= yes 184_LIBC_COMPILER_RT.x86_64= yes
185 185
186.if ${HAVE_LLVM:Uno} == "yes" && ${_LIBC_COMPILER_RT.${MACHINE_ARCH}:Uno} == "yes" 186.if ${HAVE_LLVM:Uno} == "yes" && ${_LIBC_COMPILER_RT.${MACHINE_ARCH}:Uno} == "yes"
187HAVE_LIBGCC?= no 187HAVE_LIBGCC?= no
188.else 188.else
189HAVE_LIBGCC?= yes 189HAVE_LIBGCC?= yes
190.endif 190.endif
191 191
192 192
193# Should libgcc have unwinding code? 193# Should libgcc have unwinding code?
194.if ${HAVE_LLVM:Uno} == "yes" || !empty(MACHINE_ARCH:Mearm*) 194.if ${HAVE_LLVM:Uno} == "yes" || !empty(MACHINE_ARCH:Mearm*)
195HAVE_LIBGCC_EH?= no 195HAVE_LIBGCC_EH?= no
196.else 196.else
197HAVE_LIBGCC_EH?= yes 197HAVE_LIBGCC_EH?= yes
198.endif 198.endif
199 199
200# Coverity does not like SSP 200# Coverity does not like SSP
201.if defined(COVERITY_TOP_CONFIG) || \ 201.if defined(COVERITY_TOP_CONFIG) || \
202 ${MACHINE} == "alpha" || \ 202 ${MACHINE} == "alpha" || \
203 ${MACHINE} == "hppa" || \ 203 ${MACHINE} == "hppa" || \
204 ${MACHINE} == "ia64" || \ 204 ${MACHINE} == "ia64" || \
205 ${MACHINE_CPU} == "mips" 205 ${MACHINE_CPU} == "mips"
206HAVE_SSP?= no 206HAVE_SSP?= no
207.else 207.else
208HAVE_SSP?= yes 208HAVE_SSP?= yes
209.if !defined(NOFORT) && ${USE_FORT:Uno} != "no" 209.if !defined(NOFORT) && ${USE_FORT:Uno} != "no"
210USE_SSP?= yes 210USE_SSP?= yes
211.endif 211.endif
212.endif 212.endif
213 213
214# 214#
215# What version of jemalloc we use (100 is the one 215# What version of jemalloc we use (100 is the one
216# built-in to libc from 2005 (pre version 3). 216# built-in to libc from 2005 (pre version 3).
217# 217#
218.if ${MACHINE_ARCH} == "vax" || ${MACHINE} == "sun2" 218.if ${MACHINE_ARCH} == "vax" || ${MACHINE} == "sun2"
219HAVE_JEMALLOC?= 100 219HAVE_JEMALLOC?= 100
220.else 220.else
221HAVE_JEMALLOC?= 510 221HAVE_JEMALLOC?= 510
222.endif 222.endif
223 223
224.if empty(.MAKEFLAGS:tW:M*-V .OBJDIR*) 224.if empty(.MAKEFLAGS:tW:M*-V .OBJDIR*)
225.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR) 225.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR)
226PRINTOBJDIR= ${MAKE} -r -V .OBJDIR -f /dev/null xxx 226PRINTOBJDIR= ${MAKE} -r -V .OBJDIR -f /dev/null xxx
227.else 227.else
228PRINTOBJDIR= ${MAKE} -V .OBJDIR 228PRINTOBJDIR= ${MAKE} -V .OBJDIR
229.endif 229.endif
230.else 230.else
231PRINTOBJDIR= echo /error/bsd.own.mk/PRINTOBJDIR # avoid infinite recursion 231PRINTOBJDIR= echo /error/bsd.own.mk/PRINTOBJDIR # avoid infinite recursion
232.endif 232.endif
233 233
234# 234#
235# Determine if running in the NetBSD source tree by checking for the 235# Determine if running in the NetBSD source tree by checking for the
236# existence of build.sh and tools/ in the current or a parent directory, 236# existence of build.sh and tools/ in the current or a parent directory,
237# and setting _SRC_TOP_ to the result. 237# and setting _SRC_TOP_ to the result.
238# 238#
239.if !defined(_SRC_TOP_) # { 239.if !defined(_SRC_TOP_) # {
240_SRC_TOP_!= cd "${.CURDIR}"; while :; do \ 240_SRC_TOP_!= cd "${.CURDIR}"; while :; do \
241 here=$$(pwd); \ 241 here=$$(pwd); \
242 [ -f build.sh ] && [ -d tools ] && { echo $$here; break; }; \ 242 [ -f build.sh ] && [ -d tools ] && { echo $$here; break; }; \
243 case $$here in /) echo ""; break;; esac; \ 243 case $$here in /) echo ""; break;; esac; \
244 cd ..; done 244 cd ..; done
245 245
246.MAKEOVERRIDES+= _SRC_TOP_ 246.MAKEOVERRIDES+= _SRC_TOP_
247 247
248.endif # } 248.endif # }
249 249
250# 250#
251# If _SRC_TOP_ != "", we're within the NetBSD source tree. 251# If _SRC_TOP_ != "", we're within the NetBSD source tree.
252# * Set defaults for NETBSDSRCDIR and _SRC_TOP_OBJ_. 252# * Set defaults for NETBSDSRCDIR and _SRC_TOP_OBJ_.
253# * Define _NETBSD_VERSION_DEPENDS. Targets that depend on the 253# * Define _NETBSD_VERSION_DEPENDS. Targets that depend on the
254# NetBSD version, or on variables defined at build time, can 254# NetBSD version, or on variables defined at build time, can
255# declare a dependency on ${_NETBSD_VERSION_DEPENDS}. 255# declare a dependency on ${_NETBSD_VERSION_DEPENDS}.
256# 256#
257.if (${_SRC_TOP_} != "") # { 257.if (${_SRC_TOP_} != "") # {
258 258
259NETBSDSRCDIR?= ${_SRC_TOP_} 259NETBSDSRCDIR?= ${_SRC_TOP_}
260 260
261.if !defined(_SRC_TOP_OBJ_) 261.if !defined(_SRC_TOP_OBJ_)
262_SRC_TOP_OBJ_!= cd "${_SRC_TOP_}" && ${PRINTOBJDIR} 262_SRC_TOP_OBJ_!= cd "${_SRC_TOP_}" && ${PRINTOBJDIR}
263.MAKEOVERRIDES+= _SRC_TOP_OBJ_ 263.MAKEOVERRIDES+= _SRC_TOP_OBJ_
264.endif 264.endif
265 265
266_NETBSD_VERSION_DEPENDS= ${_SRC_TOP_OBJ_}/params 266_NETBSD_VERSION_DEPENDS= ${_SRC_TOP_OBJ_}/params
267_NETBSD_VERSION_DEPENDS+= ${NETBSDSRCDIR}/sys/sys/param.h 267_NETBSD_VERSION_DEPENDS+= ${NETBSDSRCDIR}/sys/sys/param.h
268_NETBSD_VERSION_DEPENDS+= ${NETBSDSRCDIR}/sys/conf/newvers.sh 268_NETBSD_VERSION_DEPENDS+= ${NETBSDSRCDIR}/sys/conf/newvers.sh
269_NETBSD_VERSION_DEPENDS+= ${NETBSDSRCDIR}/sys/conf/osrelease.sh 269_NETBSD_VERSION_DEPENDS+= ${NETBSDSRCDIR}/sys/conf/osrelease.sh
270${_SRC_TOP_OBJ_}/params: .NOTMAIN .OPTIONAL # created by top level "make build" 270${_SRC_TOP_OBJ_}/params: .NOTMAIN .OPTIONAL # created by top level "make build"
271 271
272.endif # _SRC_TOP_ != "" # } 272.endif # _SRC_TOP_ != "" # }
273 273
274 274
275.if (${_SRC_TOP_} != "") && \ 275.if (${_SRC_TOP_} != "") && \
276 (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN)) 276 (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN))
277USETOOLS?= yes 277USETOOLS?= yes
278.endif 278.endif
279USETOOLS?= no 279USETOOLS?= no
280 280
281 281
282.if ${MACHINE_ARCH} == "mips" || ${MACHINE_ARCH} == "mips64" || \ 282.if ${MACHINE_ARCH} == "mips" || ${MACHINE_ARCH} == "mips64" || \
283 ${MACHINE_ARCH} == "sh3" 283 ${MACHINE_ARCH} == "sh3"
284.BEGIN: 284.BEGIN:
285 @echo "Must set MACHINE_ARCH to one of ${MACHINE_ARCH}eb or ${MACHINE_ARCH}el" 285 @echo "Must set MACHINE_ARCH to one of ${MACHINE_ARCH}eb or ${MACHINE_ARCH}el"
286 @false 286 @false
287.elif defined(REQUIRETOOLS) && \ 287.elif defined(REQUIRETOOLS) && \
288 (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN)) && \ 288 (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN)) && \
289 ${USETOOLS} == "no" 289 ${USETOOLS} == "no"
290.BEGIN: 290.BEGIN:
291 @echo "USETOOLS=no, but this component requires a version-specific host toolchain" 291 @echo "USETOOLS=no, but this component requires a version-specific host toolchain"
292 @false 292 @false
293.endif 293.endif
294 294
295# 295#
296# Host platform information; may be overridden 296# Host platform information; may be overridden
297# 297#
298.include <bsd.host.mk> 298.include <bsd.host.mk>
299 299
300.if ${USETOOLS} == "yes" # { 300.if ${USETOOLS} == "yes" # {
301 301
302# 302#
303# Provide a default for TOOLDIR. 303# Provide a default for TOOLDIR.
304# 304#
305.if !defined(TOOLDIR) 305.if !defined(TOOLDIR)
306TOOLDIR:= ${_SRC_TOP_OBJ_}/tooldir.${HOST_OSTYPE} 306TOOLDIR:= ${_SRC_TOP_OBJ_}/tooldir.${HOST_OSTYPE}
307.MAKEOVERRIDES+= TOOLDIR 307.MAKEOVERRIDES+= TOOLDIR
308.endif 308.endif
309 309
310# 310#
311# This is the prefix used for the NetBSD-sourced tools. 311# This is the prefix used for the NetBSD-sourced tools.
312# 312#
313_TOOL_PREFIX?= nb 313_TOOL_PREFIX?= nb
314 314
315# 315#
316# If an external toolchain base is specified, use it. 316# If an external toolchain base is specified, use it.
317# 317#
318.if defined(EXTERNAL_TOOLCHAIN) # { 318.if defined(EXTERNAL_TOOLCHAIN) # {
319AR= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ar 319AR= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ar
320AS= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-as 320AS= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-as
321LD= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ld 321LD= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ld
322NM= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-nm 322NM= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-nm
323OBJCOPY= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-objcopy 323OBJCOPY= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-objcopy
324OBJDUMP= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-objdump 324OBJDUMP= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-objdump
325RANLIB= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ranlib 325RANLIB= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ranlib
326READELF= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-readelf 326READELF= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-readelf
327SIZE= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-size 327SIZE= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-size
328STRINGS= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-strings 328STRINGS= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-strings
329STRIP= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-strip 329STRIP= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-strip
330 330
331TOOL_CC.gcc= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gcc 331TOOL_CC.gcc= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gcc
332TOOL_CPP.gcc= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-cpp 332TOOL_CPP.gcc= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-cpp
333TOOL_CXX.gcc= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-c++ 333TOOL_CXX.gcc= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-c++
334TOOL_FC.gcc= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gfortran 334TOOL_FC.gcc= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gfortran
335TOOL_OBJC.gcc= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gcc 335TOOL_OBJC.gcc= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gcc
336 336
337TOOL_CC.clang= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang 337TOOL_CC.clang= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang
338TOOL_CPP.clang= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang-cpp 338TOOL_CPP.clang= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang-cpp
339TOOL_CXX.clang= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang++ 339TOOL_CXX.clang= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang++
340TOOL_OBJC.clang= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang 340TOOL_OBJC.clang= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang
341.else # } { 341.else # } {
342# Define default locations for common tools. 342# Define default locations for common tools.
343.if ${USETOOLS_BINUTILS:Uyes} == "yes" # { 343.if ${USETOOLS_BINUTILS:Uyes} == "yes" # {
344AR= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ar 344AR= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ar
345AS= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-as 345AS= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-as
346LD= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ld 346LD= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ld
347NM= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-nm 347NM= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-nm
348OBJCOPY= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objcopy 348OBJCOPY= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objcopy
349OBJDUMP= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objdump 349OBJDUMP= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objdump
350RANLIB= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ranlib 350RANLIB= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ranlib
351READELF= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-readelf 351READELF= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-readelf
352SIZE= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-size 352SIZE= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-size
353STRINGS= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strings 353STRINGS= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strings
354STRIP= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strip 354STRIP= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strip
355 355
356# GCC supports C, C++, Fortran and Objective C 356# GCC supports C, C++, Fortran and Objective C
357TOOL_CC.gcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc 357TOOL_CC.gcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
358TOOL_CPP.gcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-cpp 358TOOL_CPP.gcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-cpp
359TOOL_CXX.gcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-c++ 359TOOL_CXX.gcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-c++
360TOOL_FC.gcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gfortran 360TOOL_FC.gcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gfortran
361TOOL_OBJC.gcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc 361TOOL_OBJC.gcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
362.endif # } 362.endif # }
363 363
364# Clang supports C, C++ and Objective C 364# Clang supports C, C++ and Objective C
365TOOL_CC.clang= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang 365TOOL_CC.clang= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang
366TOOL_CPP.clang= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang-cpp 366TOOL_CPP.clang= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang-cpp
367TOOL_CXX.clang= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang++ 367TOOL_CXX.clang= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang++
368TOOL_OBJC.clang= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang 368TOOL_OBJC.clang= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang
369 369
370# PCC supports C and Fortran 370# PCC supports C and Fortran
371TOOL_CC.pcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-pcc 371TOOL_CC.pcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-pcc
372TOOL_CPP.pcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-pcpp 372TOOL_CPP.pcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-pcpp
373TOOL_CXX.pcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-p++ 373TOOL_CXX.pcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-p++
374.endif # EXTERNAL_TOOLCHAIN # } 374.endif # EXTERNAL_TOOLCHAIN # }
375 375
376# 376#
377# Make sure DESTDIR is set, so that builds with these tools always 377# Make sure DESTDIR is set, so that builds with these tools always
378# get appropriate -nostdinc, -nostdlib, etc. handling. The default is 378# get appropriate -nostdinc, -nostdlib, etc. handling. The default is
379# <empty string>, meaning start from /, the root directory. 379# <empty string>, meaning start from /, the root directory.
380# 380#
381DESTDIR?= 381DESTDIR?=
382 382
383# Don't append another copy of sysroot (coming from COMPATCPPFLAGS etc.) 383# Don't append another copy of sysroot (coming from COMPATCPPFLAGS etc.)
384# because it confuses Coverity. Still we need to cov-configure specially 384# because it confuses Coverity. Still we need to cov-configure specially
385# for each specific sysroot argument. 385# for each specific sysroot argument.
386# Also don't add a sysroot at all if a rumpkernel build. 386# Also don't add a sysroot at all if a rumpkernel build.
387.if !defined(HOSTPROG) && !defined(HOSTLIB) && !defined(RUMPRUN) 387.if !defined(HOSTPROG) && !defined(HOSTLIB) && !defined(RUMPRUN)
388. if ${DESTDIR} != "" 388. if ${DESTDIR} != ""
389. if empty(CPPFLAGS:M*--sysroot=*) 389. if empty(CPPFLAGS:M*--sysroot=*)
390CPPFLAGS+= --sysroot=${DESTDIR} 390CPPFLAGS+= --sysroot=${DESTDIR}
391. endif 391. endif
392LDFLAGS+= --sysroot=${DESTDIR} 392LDFLAGS+= --sysroot=${DESTDIR}
393. else 393. else
394. if empty(CPPFLAGS:M*--sysroot=*) 394. if empty(CPPFLAGS:M*--sysroot=*)
395CPPFLAGS+= --sysroot=/ 395CPPFLAGS+= --sysroot=/
396. endif 396. endif
397LDFLAGS+= --sysroot=/ 397LDFLAGS+= --sysroot=/
398. endif 398. endif
399.endif 399.endif
400 400
401DBSYM= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-dbsym 401DBSYM= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-dbsym
402ARM_ELF2AOUT= ${TOOLDIR}/bin/${_TOOL_PREFIX}arm-elf2aout 402ARM_ELF2AOUT= ${TOOLDIR}/bin/${_TOOL_PREFIX}arm-elf2aout
403M68K_ELF2AOUT= ${TOOLDIR}/bin/${_TOOL_PREFIX}m68k-elf2aout 403M68K_ELF2AOUT= ${TOOLDIR}/bin/${_TOOL_PREFIX}m68k-elf2aout
404MIPS_ELF2ECOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}mips-elf2ecoff 404MIPS_ELF2ECOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}mips-elf2ecoff
405INSTALL= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-install 405INSTALL= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-install
406LEX= ${TOOLDIR}/bin/${_TOOL_PREFIX}lex 406LEX= ${TOOLDIR}/bin/${_TOOL_PREFIX}lex
407LINT= CC=${CC:Q} ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-lint 407LINT= CC=${CC:Q} ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-lint
408LORDER= NM=${NM:Q} MKTEMP=${TOOL_MKTEMP:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}lorder 408LORDER= NM=${NM:Q} MKTEMP=${TOOL_MKTEMP:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}lorder
409MKDEP= CC=${CC:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}mkdep 409MKDEP= CC=${CC:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}mkdep
410MKDEPCXX= CC=${CXX:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}mkdep 410MKDEPCXX= CC=${CXX:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}mkdep
411PAXCTL= ${TOOLDIR}/bin/${_TOOL_PREFIX}paxctl 411PAXCTL= ${TOOLDIR}/bin/${_TOOL_PREFIX}paxctl
412TSORT= ${TOOLDIR}/bin/${_TOOL_PREFIX}tsort -q 412TSORT= ${TOOLDIR}/bin/${_TOOL_PREFIX}tsort -q
413YACC= ${TOOLDIR}/bin/${_TOOL_PREFIX}yacc 413YACC= ${TOOLDIR}/bin/${_TOOL_PREFIX}yacc
414 414
415TOOL_AMIGAAOUT2BB= ${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-aout2bb 415TOOL_AMIGAAOUT2BB= ${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-aout2bb
416TOOL_AMIGAELF2BB= ${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-elf2bb 416TOOL_AMIGAELF2BB= ${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-elf2bb
417TOOL_AMIGATXLT= ${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-txlt 417TOOL_AMIGATXLT= ${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-txlt
418TOOL_ASN1_COMPILE= ${TOOLDIR}/bin/${_TOOL_PREFIX}asn1_compile 418TOOL_ASN1_COMPILE= ${TOOLDIR}/bin/${_TOOL_PREFIX}asn1_compile
419TOOL_AWK= ${TOOLDIR}/bin/${_TOOL_PREFIX}awk 419TOOL_AWK= ${TOOLDIR}/bin/${_TOOL_PREFIX}awk
420TOOL_CAP_MKDB= ${TOOLDIR}/bin/${_TOOL_PREFIX}cap_mkdb 420TOOL_CAP_MKDB= ${TOOLDIR}/bin/${_TOOL_PREFIX}cap_mkdb
421TOOL_CAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}cat 421TOOL_CAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}cat
422TOOL_CKSUM= ${TOOLDIR}/bin/${_TOOL_PREFIX}cksum 422TOOL_CKSUM= ${TOOLDIR}/bin/${_TOOL_PREFIX}cksum
423TOOL_CLANG_TBLGEN= ${TOOLDIR}/bin/${_TOOL_PREFIX}clang-tblgen 423TOOL_CLANG_TBLGEN= ${TOOLDIR}/bin/${_TOOL_PREFIX}clang-tblgen
424TOOL_COMPILE_ET= ${TOOLDIR}/bin/${_TOOL_PREFIX}compile_et 424TOOL_COMPILE_ET= ${TOOLDIR}/bin/${_TOOL_PREFIX}compile_et
425TOOL_CONFIG= ${TOOLDIR}/bin/${_TOOL_PREFIX}config 425TOOL_CONFIG= ${TOOLDIR}/bin/${_TOOL_PREFIX}config
426TOOL_CRUNCHGEN= MAKE=${.MAKE:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}crunchgen 426TOOL_CRUNCHGEN= MAKE=${.MAKE:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}crunchgen
427TOOL_CTAGS= ${TOOLDIR}/bin/${_TOOL_PREFIX}ctags 427TOOL_CTAGS= ${TOOLDIR}/bin/${_TOOL_PREFIX}ctags
428TOOL_CTFCONVERT= ${TOOLDIR}/bin/${_TOOL_PREFIX}ctfconvert 428TOOL_CTFCONVERT= ${TOOLDIR}/bin/${_TOOL_PREFIX}ctfconvert
429TOOL_CTFMERGE= ${TOOLDIR}/bin/${_TOOL_PREFIX}ctfmerge 429TOOL_CTFMERGE= ${TOOLDIR}/bin/${_TOOL_PREFIX}ctfmerge
430TOOL_CVSLATEST= ${TOOLDIR}/bin/${_TOOL_PREFIX}cvslatest 430TOOL_CVSLATEST= ${TOOLDIR}/bin/${_TOOL_PREFIX}cvslatest
431TOOL_DATE= ${TOOLDIR}/bin/${_TOOL_PREFIX}date 431TOOL_DATE= ${TOOLDIR}/bin/${_TOOL_PREFIX}date
432TOOL_DB= ${TOOLDIR}/bin/${_TOOL_PREFIX}db 432TOOL_DB= ${TOOLDIR}/bin/${_TOOL_PREFIX}db
433TOOL_DISKLABEL= ${TOOLDIR}/bin/${_TOOL_PREFIX}disklabel 433TOOL_DISKLABEL= ${TOOLDIR}/bin/${_TOOL_PREFIX}disklabel
434TOOL_DTC= ${TOOLDIR}/bin/${_TOOL_PREFIX}dtc 434TOOL_DTC= ${TOOLDIR}/bin/${_TOOL_PREFIX}dtc
435TOOL_EQN= ${TOOLDIR}/bin/${_TOOL_PREFIX}eqn 435TOOL_EQN= ${TOOLDIR}/bin/${_TOOL_PREFIX}eqn
436TOOL_FDISK= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-fdisk 436TOOL_FDISK= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-fdisk
437TOOL_FGEN= ${TOOLDIR}/bin/${_TOOL_PREFIX}fgen 437TOOL_FGEN= ${TOOLDIR}/bin/${_TOOL_PREFIX}fgen
438TOOL_GENASSYM= ${TOOLDIR}/bin/${_TOOL_PREFIX}genassym 438TOOL_GENASSYM= ${TOOLDIR}/bin/${_TOOL_PREFIX}genassym
439TOOL_GENCAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}gencat 439TOOL_GENCAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}gencat
440TOOL_GMAKE= ${TOOLDIR}/bin/${_TOOL_PREFIX}gmake 440TOOL_GMAKE= ${TOOLDIR}/bin/${_TOOL_PREFIX}gmake
441TOOL_GPT= ${TOOLDIR}/bin/${_TOOL_PREFIX}gpt 441TOOL_GPT= ${TOOLDIR}/bin/${_TOOL_PREFIX}gpt
442TOOL_GREP= ${TOOLDIR}/bin/${_TOOL_PREFIX}grep 442TOOL_GREP= ${TOOLDIR}/bin/${_TOOL_PREFIX}grep
443GROFF_SHARE_PATH= ${TOOLDIR}/share/groff 443GROFF_SHARE_PATH= ${TOOLDIR}/share/groff
444TOOL_GROFF_ENV= \ 444TOOL_GROFF_ENV= \
445 GROFF_ENCODING= \ 445 GROFF_ENCODING= \
446 GROFF_BIN_PATH=${TOOLDIR}/lib/groff \ 446 GROFF_BIN_PATH=${TOOLDIR}/lib/groff \
447 GROFF_FONT_PATH=${GROFF_SHARE_PATH}/site-font:${GROFF_SHARE_PATH}/font \ 447 GROFF_FONT_PATH=${GROFF_SHARE_PATH}/site-font:${GROFF_SHARE_PATH}/font \
448 GROFF_TMAC_PATH=${GROFF_SHARE_PATH}/site-tmac:${GROFF_SHARE_PATH}/tmac 448 GROFF_TMAC_PATH=${GROFF_SHARE_PATH}/site-tmac:${GROFF_SHARE_PATH}/tmac
449TOOL_GROFF= ${TOOL_GROFF_ENV} ${TOOLDIR}/bin/${_TOOL_PREFIX}groff ${GROFF_FLAGS} 449TOOL_GROFF= ${TOOL_GROFF_ENV} ${TOOLDIR}/bin/${_TOOL_PREFIX}groff ${GROFF_FLAGS}
450 450
451TOOL_HEXDUMP= ${TOOLDIR}/bin/${_TOOL_PREFIX}hexdump 451TOOL_HEXDUMP= ${TOOLDIR}/bin/${_TOOL_PREFIX}hexdump
452TOOL_HP300MKBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}hp300-mkboot 452TOOL_HP300MKBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}hp300-mkboot
453TOOL_HPPAMKBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}hppa-mkboot 453TOOL_HPPAMKBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}hppa-mkboot
454TOOL_INDXBIB= ${TOOLDIR}/bin/${_TOOL_PREFIX}indxbib 454TOOL_INDXBIB= ${TOOLDIR}/bin/${_TOOL_PREFIX}indxbib
455TOOL_INSTALLBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}installboot 455TOOL_INSTALLBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}installboot
456TOOL_INSTALL_INFO= ${TOOLDIR}/bin/${_TOOL_PREFIX}install-info 456TOOL_INSTALL_INFO= ${TOOLDIR}/bin/${_TOOL_PREFIX}install-info
457TOOL_JOIN= ${TOOLDIR}/bin/${_TOOL_PREFIX}join 457TOOL_JOIN= ${TOOLDIR}/bin/${_TOOL_PREFIX}join
458TOOL_LLVM_TBLGEN= ${TOOLDIR}/bin/${_TOOL_PREFIX}llvm-tblgen 458TOOL_LLVM_TBLGEN= ${TOOLDIR}/bin/${_TOOL_PREFIX}llvm-tblgen
459TOOL_M4= ${TOOLDIR}/bin/${_TOOL_PREFIX}m4 459TOOL_M4= ${TOOLDIR}/bin/${_TOOL_PREFIX}m4
460TOOL_MACPPCFIXCOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}macppc-fixcoff 460TOOL_MACPPCFIXCOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}macppc-fixcoff
461TOOL_MAKEFS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makefs 461TOOL_MAKEFS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makefs
462TOOL_MAKEINFO= ${TOOLDIR}/bin/${_TOOL_PREFIX}makeinfo 462TOOL_MAKEINFO= ${TOOLDIR}/bin/${_TOOL_PREFIX}makeinfo
463TOOL_MAKEKEYS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makekeys 463TOOL_MAKEKEYS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makekeys
464TOOL_MAKESTRS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makestrs 464TOOL_MAKESTRS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makestrs
465TOOL_MAKEWHATIS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makewhatis 465TOOL_MAKEWHATIS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makewhatis
466TOOL_MANDOC_ASCII= ${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Tascii 466TOOL_MANDOC_ASCII= ${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Tascii
467TOOL_MANDOC_HTML= ${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Thtml 467TOOL_MANDOC_HTML= ${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Thtml
468TOOL_MANDOC_LINT= ${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Tlint 468TOOL_MANDOC_LINT= ${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Tlint
469TOOL_MDSETIMAGE= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-mdsetimage 469TOOL_MDSETIMAGE= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-mdsetimage
470TOOL_MENUC= MENUDEF=${TOOLDIR}/share/misc ${TOOLDIR}/bin/${_TOOL_PREFIX}menuc 470TOOL_MENUC= MENUDEF=${TOOLDIR}/share/misc ${TOOLDIR}/bin/${_TOOL_PREFIX}menuc
471TOOL_ARMELF2AOUT= ${TOOLDIR}/bin/${_TOOL_PREFIX}arm-elf2aout 471TOOL_ARMELF2AOUT= ${TOOLDIR}/bin/${_TOOL_PREFIX}arm-elf2aout
472TOOL_M68KELF2AOUT= ${TOOLDIR}/bin/${_TOOL_PREFIX}m68k-elf2aout 472TOOL_M68KELF2AOUT= ${TOOLDIR}/bin/${_TOOL_PREFIX}m68k-elf2aout
473TOOL_MIPSELF2ECOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}mips-elf2ecoff 473TOOL_MIPSELF2ECOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}mips-elf2ecoff
474TOOL_MKCSMAPPER= ${TOOLDIR}/bin/${_TOOL_PREFIX}mkcsmapper 474TOOL_MKCSMAPPER= ${TOOLDIR}/bin/${_TOOL_PREFIX}mkcsmapper
475TOOL_MKESDB= ${TOOLDIR}/bin/${_TOOL_PREFIX}mkesdb 475TOOL_MKESDB= ${TOOLDIR}/bin/${_TOOL_PREFIX}mkesdb
476TOOL_MKLOCALE= ${TOOLDIR}/bin/${_TOOL_PREFIX}mklocale 476TOOL_MKLOCALE= ${TOOLDIR}/bin/${_TOOL_PREFIX}mklocale
477TOOL_MKMAGIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}file 477TOOL_MKMAGIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}file
478TOOL_MKNOD= ${TOOLDIR}/bin/${_TOOL_PREFIX}mknod 478TOOL_MKNOD= ${TOOLDIR}/bin/${_TOOL_PREFIX}mknod
479TOOL_MKTEMP= ${TOOLDIR}/bin/${_TOOL_PREFIX}mktemp 479TOOL_MKTEMP= ${TOOLDIR}/bin/${_TOOL_PREFIX}mktemp
480TOOL_MKUBOOTIMAGE= ${TOOLDIR}/bin/${_TOOL_PREFIX}mkubootimage 480TOOL_MKUBOOTIMAGE= ${TOOLDIR}/bin/${_TOOL_PREFIX}mkubootimage
481TOOL_ELFTOSB= ${TOOLDIR}/bin/${_TOOL_PREFIX}elftosb 481TOOL_ELFTOSB= ${TOOLDIR}/bin/${_TOOL_PREFIX}elftosb
482TOOL_MSGC= MSGDEF=${TOOLDIR}/share/misc ${TOOLDIR}/bin/${_TOOL_PREFIX}msgc 482TOOL_MSGC= MSGDEF=${TOOLDIR}/share/misc ${TOOLDIR}/bin/${_TOOL_PREFIX}msgc
483TOOL_MTREE= ${TOOLDIR}/bin/${_TOOL_PREFIX}mtree 483TOOL_MTREE= ${TOOLDIR}/bin/${_TOOL_PREFIX}mtree
484TOOL_MVME68KWRTVID= ${TOOLDIR}/bin/${_TOOL_PREFIX}mvme68k-wrtvid 484TOOL_MVME68KWRTVID= ${TOOLDIR}/bin/${_TOOL_PREFIX}mvme68k-wrtvid
485TOOL_NBPERF= ${TOOLDIR}/bin/${_TOOL_PREFIX}perf 485TOOL_NBPERF= ${TOOLDIR}/bin/${_TOOL_PREFIX}perf
486TOOL_NCDCS= ${TOOLDIR}/bin/${_TOOL_PREFIX}ibmnws-ncdcs 486TOOL_NCDCS= ${TOOLDIR}/bin/${_TOOL_PREFIX}ibmnws-ncdcs
487TOOL_PAX= ${TOOLDIR}/bin/${_TOOL_PREFIX}pax 487TOOL_PAX= ${TOOLDIR}/bin/${_TOOL_PREFIX}pax
488TOOL_PIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}pic 488TOOL_PIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}pic
489TOOL_PIGZ= ${TOOLDIR}/bin/${_TOOL_PREFIX}pigz 489TOOL_PIGZ= ${TOOLDIR}/bin/${_TOOL_PREFIX}pigz
490TOOL_XZ= ${TOOLDIR}/bin/${_TOOL_PREFIX}xz 490TOOL_XZ= ${TOOLDIR}/bin/${_TOOL_PREFIX}xz
491TOOL_PKG_CREATE= ${TOOLDIR}/bin/${_TOOL_PREFIX}pkg_create 491TOOL_PKG_CREATE= ${TOOLDIR}/bin/${_TOOL_PREFIX}pkg_create
492TOOL_POWERPCMKBOOTIMAGE=${TOOLDIR}/bin/${_TOOL_PREFIX}powerpc-mkbootimage 492TOOL_POWERPCMKBOOTIMAGE=${TOOLDIR}/bin/${_TOOL_PREFIX}powerpc-mkbootimage
493TOOL_PWD_MKDB= ${TOOLDIR}/bin/${_TOOL_PREFIX}pwd_mkdb 493TOOL_PWD_MKDB= ${TOOLDIR}/bin/${_TOOL_PREFIX}pwd_mkdb
494TOOL_REFER= ${TOOLDIR}/bin/${_TOOL_PREFIX}refer 494TOOL_REFER= ${TOOLDIR}/bin/${_TOOL_PREFIX}refer
495TOOL_ROFF_ASCII= ${TOOL_GROFF_ENV} ${TOOLDIR}/bin/${_TOOL_PREFIX}nroff 495TOOL_ROFF_ASCII= ${TOOL_GROFF_ENV} ${TOOLDIR}/bin/${_TOOL_PREFIX}nroff
496TOOL_ROFF_DOCASCII= ${TOOL_GROFF} -Tascii 496TOOL_ROFF_DOCASCII= ${TOOL_GROFF} -Tascii
497TOOL_ROFF_DOCHTML= ${TOOL_GROFF} -Thtml 497TOOL_ROFF_DOCHTML= ${TOOL_GROFF} -Thtml
498TOOL_ROFF_DVI= ${TOOL_GROFF} -Tdvi ${ROFF_PAGESIZE} 498TOOL_ROFF_DVI= ${TOOL_GROFF} -Tdvi ${ROFF_PAGESIZE}
499TOOL_ROFF_HTML= ${TOOL_GROFF} -Tlatin1 -mdoc2html 499TOOL_ROFF_HTML= ${TOOL_GROFF} -Tlatin1 -mdoc2html
500TOOL_ROFF_PS= ${TOOL_GROFF} -Tps ${ROFF_PAGESIZE} 500TOOL_ROFF_PS= ${TOOL_GROFF} -Tps ${ROFF_PAGESIZE}
501TOOL_ROFF_RAW= ${TOOL_GROFF} -Z 501TOOL_ROFF_RAW= ${TOOL_GROFF} -Z
502TOOL_RPCGEN= RPCGEN_CPP=${CPP:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}rpcgen 502TOOL_RPCGEN= RPCGEN_CPP=${CPP:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}rpcgen
503TOOL_SED= ${TOOLDIR}/bin/${_TOOL_PREFIX}sed 503TOOL_SED= ${TOOLDIR}/bin/${_TOOL_PREFIX}sed
504TOOL_SLC= ${TOOLDIR}/bin/${_TOOL_PREFIX}slc 504TOOL_SLC= ${TOOLDIR}/bin/${_TOOL_PREFIX}slc
505TOOL_SOELIM= ${TOOLDIR}/bin/${_TOOL_PREFIX}soelim 505TOOL_SOELIM= ${TOOLDIR}/bin/${_TOOL_PREFIX}soelim
506TOOL_SORTINFO= ${TOOLDIR}/bin/${_TOOL_PREFIX}sortinfo 506TOOL_SORTINFO= ${TOOLDIR}/bin/${_TOOL_PREFIX}sortinfo
507TOOL_SPARKCRC= ${TOOLDIR}/bin/${_TOOL_PREFIX}sparkcrc 507TOOL_SPARKCRC= ${TOOLDIR}/bin/${_TOOL_PREFIX}sparkcrc
508TOOL_STAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}stat 508TOOL_STAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}stat
509TOOL_STRFILE= ${TOOLDIR}/bin/${_TOOL_PREFIX}strfile 509TOOL_STRFILE= ${TOOLDIR}/bin/${_TOOL_PREFIX}strfile
510TOOL_SUNLABEL= ${TOOLDIR}/bin/${_TOOL_PREFIX}sunlabel 510TOOL_SUNLABEL= ${TOOLDIR}/bin/${_TOOL_PREFIX}sunlabel
511TOOL_TBL= ${TOOLDIR}/bin/${_TOOL_PREFIX}tbl 511TOOL_TBL= ${TOOLDIR}/bin/${_TOOL_PREFIX}tbl
512TOOL_TIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}tic 512TOOL_TIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}tic
513TOOL_UUDECODE= ${TOOLDIR}/bin/${_TOOL_PREFIX}uudecode 513TOOL_UUDECODE= ${TOOLDIR}/bin/${_TOOL_PREFIX}uudecode
514TOOL_VGRIND= ${TOOLDIR}/bin/${_TOOL_PREFIX}vgrind -f 514TOOL_VGRIND= ${TOOLDIR}/bin/${_TOOL_PREFIX}vgrind -f
515TOOL_VFONTEDPR= ${TOOLDIR}/libexec/${_TOOL_PREFIX}vfontedpr 515TOOL_VFONTEDPR= ${TOOLDIR}/libexec/${_TOOL_PREFIX}vfontedpr
516TOOL_ZIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}zic 516TOOL_ZIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}zic
517 517
518.else # USETOOLS != yes # } { 518.else # USETOOLS != yes # } {
519 519
520# Clang supports C, C++ and Objective C 520# Clang supports C, C++ and Objective C
521TOOL_CC.clang= clang 521TOOL_CC.clang= clang
522TOOL_CPP.clang= clang-cpp 522TOOL_CPP.clang= clang-cpp
523TOOL_CXX.clang= clang++ 523TOOL_CXX.clang= clang++
524TOOL_OBJC.clang= clang 524TOOL_OBJC.clang= clang
525 525
526# GCC supports C, C++, Fortran and Objective C 526# GCC supports C, C++, Fortran and Objective C
527TOOL_CC.gcc= gcc 527TOOL_CC.gcc= gcc
528TOOL_CPP.gcc= cpp 528TOOL_CPP.gcc= cpp
529TOOL_CXX.gcc= c++ 529TOOL_CXX.gcc= c++
530TOOL_FC.gcc= gfortran 530TOOL_FC.gcc= gfortran
531TOOL_OBJC.gcc= gcc 531TOOL_OBJC.gcc= gcc
532 532
533# PCC supports C and Fortran 533# PCC supports C and Fortran
534TOOL_CC.pcc= pcc 534TOOL_CC.pcc= pcc
535TOOL_CPP.pcc= pcpp 535TOOL_CPP.pcc= pcpp
536TOOL_CXX.pcc= p++ 536TOOL_CXX.pcc= p++
537 537
538TOOL_AMIGAAOUT2BB= amiga-aout2bb 538TOOL_AMIGAAOUT2BB= amiga-aout2bb
539TOOL_AMIGAELF2BB= amiga-elf2bb 539TOOL_AMIGAELF2BB= amiga-elf2bb
540TOOL_AMIGATXLT= amiga-txlt 540TOOL_AMIGATXLT= amiga-txlt
541TOOL_ASN1_COMPILE= asn1_compile 541TOOL_ASN1_COMPILE= asn1_compile
542TOOL_AWK= awk 542TOOL_AWK= awk
543TOOL_CAP_MKDB= cap_mkdb 543TOOL_CAP_MKDB= cap_mkdb
544TOOL_CAT= cat 544TOOL_CAT= cat
545TOOL_CKSUM= cksum 545TOOL_CKSUM= cksum
546TOOL_CLANG_TBLGEN= clang-tblgen 546TOOL_CLANG_TBLGEN= clang-tblgen
547TOOL_COMPILE_ET= compile_et 547TOOL_COMPILE_ET= compile_et
548TOOL_CONFIG= config 548TOOL_CONFIG= config
549TOOL_CRUNCHGEN= crunchgen 549TOOL_CRUNCHGEN= crunchgen
550TOOL_CTAGS= ctags 550TOOL_CTAGS= ctags
551TOOL_CTFCONVERT= ctfconvert 551TOOL_CTFCONVERT= ctfconvert
552TOOL_CTFMERGE= ctfmerge 552TOOL_CTFMERGE= ctfmerge
553TOOL_CVSLATEST= cvslatest 553TOOL_CVSLATEST= cvslatest
554TOOL_DATE= date 554TOOL_DATE= date
555TOOL_DB= db 555TOOL_DB= db
556TOOL_DISKLABEL= disklabel 556TOOL_DISKLABEL= disklabel
557TOOL_DTC= dtc 557TOOL_DTC= dtc
558TOOL_EQN= eqn 558TOOL_EQN= eqn
559TOOL_FDISK= fdisk 559TOOL_FDISK= fdisk
560TOOL_FGEN= fgen 560TOOL_FGEN= fgen
561TOOL_GENASSYM= genassym 561TOOL_GENASSYM= genassym
562TOOL_GENCAT= gencat 562TOOL_GENCAT= gencat
563TOOL_GMAKE= gmake 563TOOL_GMAKE= gmake
564TOOL_GPT= gpt 564TOOL_GPT= gpt
565TOOL_GREP= grep 565TOOL_GREP= grep
566TOOL_GROFF= groff 566TOOL_GROFF= groff
567TOOL_HEXDUMP= hexdump 567TOOL_HEXDUMP= hexdump
568TOOL_HP300MKBOOT= hp300-mkboot 568TOOL_HP300MKBOOT= hp300-mkboot
569TOOL_HPPAMKBOOT= hppa-mkboot 569TOOL_HPPAMKBOOT= hppa-mkboot
570TOOL_INDXBIB= indxbib 570TOOL_INDXBIB= indxbib
571TOOL_INSTALLBOOT= installboot 571TOOL_INSTALLBOOT= installboot
572TOOL_INSTALL_INFO= install-info 572TOOL_INSTALL_INFO= install-info
573TOOL_JOIN= join 573TOOL_JOIN= join
574TOOL_LLVM_TBLGEN= llvm-tblgen 574TOOL_LLVM_TBLGEN= llvm-tblgen
575TOOL_M4= m4 575TOOL_M4= m4
576TOOL_MACPPCFIXCOFF= macppc-fixcoff 576TOOL_MACPPCFIXCOFF= macppc-fixcoff
577TOOL_MAKEFS= makefs 577TOOL_MAKEFS= makefs
578TOOL_MAKEINFO= makeinfo 578TOOL_MAKEINFO= makeinfo
579TOOL_MAKEKEYS= makekeys 579TOOL_MAKEKEYS= makekeys
580TOOL_MAKESTRS= makestrs 580TOOL_MAKESTRS= makestrs
581TOOL_MAKEWHATIS= /usr/libexec/makewhatis 581TOOL_MAKEWHATIS= /usr/libexec/makewhatis
582TOOL_MANDOC_ASCII= mandoc -Tascii 582TOOL_MANDOC_ASCII= mandoc -Tascii
583TOOL_MANDOC_HTML= mandoc -Thtml 583TOOL_MANDOC_HTML= mandoc -Thtml
584TOOL_MANDOC_LINT= mandoc -Tlint 584TOOL_MANDOC_LINT= mandoc -Tlint
585TOOL_MDSETIMAGE= mdsetimage 585TOOL_MDSETIMAGE= mdsetimage
586TOOL_MENUC= menuc 586TOOL_MENUC= menuc
587TOOL_ARMELF2AOUT= arm-elf2aout 587TOOL_ARMELF2AOUT= arm-elf2aout
588TOOL_M68KELF2AOUT= m68k-elf2aout 588TOOL_M68KELF2AOUT= m68k-elf2aout
589TOOL_MIPSELF2ECOFF= mips-elf2ecoff 589TOOL_MIPSELF2ECOFF= mips-elf2ecoff
590TOOL_MKCSMAPPER= mkcsmapper 590TOOL_MKCSMAPPER= mkcsmapper
591TOOL_MKESDB= mkesdb 591TOOL_MKESDB= mkesdb
592TOOL_MKLOCALE= mklocale 592TOOL_MKLOCALE= mklocale
593TOOL_MKMAGIC= file 593TOOL_MKMAGIC= file
594TOOL_MKNOD= mknod 594TOOL_MKNOD= mknod
595TOOL_MKTEMP= mktemp 595TOOL_MKTEMP= mktemp
596TOOL_MKUBOOTIMAGE= mkubootimage 596TOOL_MKUBOOTIMAGE= mkubootimage
597TOOL_ELFTOSB= elftosb 597TOOL_ELFTOSB= elftosb
598TOOL_MSGC= msgc 598TOOL_MSGC= msgc
599TOOL_MTREE= mtree 599TOOL_MTREE= mtree
600TOOL_MVME68KWRTVID= wrtvid 600TOOL_MVME68KWRTVID= wrtvid
601TOOL_NBPERF= nbperf 601TOOL_NBPERF= nbperf
602TOOL_NCDCS= ncdcs 602TOOL_NCDCS= ncdcs
603TOOL_PAX= pax 603TOOL_PAX= pax
604TOOL_PIC= pic 604TOOL_PIC= pic
605TOOL_PIGZ= pigz 605TOOL_PIGZ= pigz
606TOOL_XZ= xz 606TOOL_XZ= xz
607TOOL_PKG_CREATE= pkg_create 607TOOL_PKG_CREATE= pkg_create
608TOOL_POWERPCMKBOOTIMAGE= powerpc-mkbootimage 608TOOL_POWERPCMKBOOTIMAGE= powerpc-mkbootimage
609TOOL_PWD_MKDB= pwd_mkdb 609TOOL_PWD_MKDB= pwd_mkdb
610TOOL_REFER= refer 610TOOL_REFER= refer
611TOOL_ROFF_ASCII= nroff 611TOOL_ROFF_ASCII= nroff
612TOOL_ROFF_DOCASCII= ${TOOL_GROFF} -Tascii 612TOOL_ROFF_DOCASCII= ${TOOL_GROFF} -Tascii
613TOOL_ROFF_DOCHTML= ${TOOL_GROFF} -Thtml 613TOOL_ROFF_DOCHTML= ${TOOL_GROFF} -Thtml
614TOOL_ROFF_DVI= ${TOOL_GROFF} -Tdvi ${ROFF_PAGESIZE} 614TOOL_ROFF_DVI= ${TOOL_GROFF} -Tdvi ${ROFF_PAGESIZE}
615TOOL_ROFF_HTML= ${TOOL_GROFF} -Tlatin1 -mdoc2html 615TOOL_ROFF_HTML= ${TOOL_GROFF} -Tlatin1 -mdoc2html
616TOOL_ROFF_PS= ${TOOL_GROFF} -Tps ${ROFF_PAGESIZE} 616TOOL_ROFF_PS= ${TOOL_GROFF} -Tps ${ROFF_PAGESIZE}
617TOOL_ROFF_RAW= ${TOOL_GROFF} -Z 617TOOL_ROFF_RAW= ${TOOL_GROFF} -Z
618TOOL_RPCGEN= rpcgen 618TOOL_RPCGEN= rpcgen
619TOOL_SED= sed 619TOOL_SED= sed
620TOOL_SOELIM= soelim 620TOOL_SOELIM= soelim
621TOOL_SORTINFO= sortinfo 621TOOL_SORTINFO= sortinfo
622TOOL_SPARKCRC= sparkcrc 622TOOL_SPARKCRC= sparkcrc
623TOOL_STAT= stat 623TOOL_STAT= stat
624TOOL_STRFILE= strfile 624TOOL_STRFILE= strfile
625TOOL_SUNLABEL= sunlabel 625TOOL_SUNLABEL= sunlabel
626TOOL_TBL= tbl 626TOOL_TBL= tbl
627TOOL_TIC= tic 627TOOL_TIC= tic
628TOOL_UUDECODE= uudecode 628TOOL_UUDECODE= uudecode
629TOOL_VGRIND= vgrind -f 629TOOL_VGRIND= vgrind -f
630TOOL_VFONTEDPR= /usr/libexec/vfontedpr 630TOOL_VFONTEDPR= /usr/libexec/vfontedpr
631TOOL_ZIC= zic 631TOOL_ZIC= zic
632 632
633.endif # USETOOLS != yes # } 633.endif # USETOOLS != yes # }
634 634
635# Standalone code should not be compiled with PIE or CTF 635# Standalone code should not be compiled with PIE or CTF
636# Should create a better test 636# Should create a better test
637.if defined(BINDIR) && ${BINDIR} == "/usr/mdec" 637.if defined(BINDIR) && ${BINDIR} == "/usr/mdec"
638NOPIE= # defined 638NOPIE= # defined
639NOCTF= # defined 639NOCTF= # defined
640.elif ${MACHINE} == "sun2" 640.elif ${MACHINE} == "sun2"
641NOPIE= # we don't have PIC, so no PIE 641NOPIE= # we don't have PIC, so no PIE
642.endif 642.endif
643 643
644# Fallback to ensure that all variables are defined to something 644# Fallback to ensure that all variables are defined to something
645TOOL_CC.false= false 645TOOL_CC.false= false
646TOOL_CPP.false= false 646TOOL_CPP.false= false
647TOOL_CXX.false= false 647TOOL_CXX.false= false
648TOOL_FC.false= false 648TOOL_FC.false= false
649TOOL_OBJC.false= false 649TOOL_OBJC.false= false
650 650
651AVAILABLE_COMPILER?= ${HAVE_PCC:Dpcc} ${HAVE_LLVM:Dclang} ${HAVE_GCC:Dgcc} false 651AVAILABLE_COMPILER?= ${HAVE_PCC:Dpcc} ${HAVE_LLVM:Dclang} ${HAVE_GCC:Dgcc} false
652 652
653.for _t in CC CPP CXX FC OBJC 653.for _t in CC CPP CXX FC OBJC
654ACTIVE_${_t}= ${AVAILABLE_COMPILER:@.c.@ ${ !defined(UNSUPPORTED_COMPILER.${.c.}) && defined(TOOL_${_t}.${.c.}) :? ${.c.} : }@:[1]} 654ACTIVE_${_t}= ${AVAILABLE_COMPILER:@.c.@ ${ !defined(UNSUPPORTED_COMPILER.${.c.}) && defined(TOOL_${_t}.${.c.}) :? ${.c.} : }@:[1]}
655SUPPORTED_${_t}=${AVAILABLE_COMPILER:Nfalse:@.c.@ ${ !defined(UNSUPPORTED_COMPILER.${.c.}) && defined(TOOL_${_t}.${.c.}) :? ${.c.} : }@} 655SUPPORTED_${_t}=${AVAILABLE_COMPILER:Nfalse:@.c.@ ${ !defined(UNSUPPORTED_COMPILER.${.c.}) && defined(TOOL_${_t}.${.c.}) :? ${.c.} : }@}
656.endfor 656.endfor
657# make bugs prevent moving this into the .for loop 657# make bugs prevent moving this into the .for loop
658CC= ${TOOL_CC.${ACTIVE_CC}} 658CC= ${TOOL_CC.${ACTIVE_CC}}
659CPP= ${TOOL_CPP.${ACTIVE_CPP}} 659CPP= ${TOOL_CPP.${ACTIVE_CPP}}
660CXX= ${TOOL_CXX.${ACTIVE_CXX}} 660CXX= ${TOOL_CXX.${ACTIVE_CXX}}
661FC= ${TOOL_FC.${ACTIVE_FC}} 661FC= ${TOOL_FC.${ACTIVE_FC}}
662OBJC= ${TOOL_OBJC.${ACTIVE_OBJC}} 662OBJC= ${TOOL_OBJC.${ACTIVE_OBJC}}
663 663
664# For each ${MACHINE_CPU}, list the ports that use it. 664# For each ${MACHINE_CPU}, list the ports that use it.
665MACHINES.aarch64= evbarm 665MACHINES.aarch64= evbarm
666MACHINES.alpha= alpha 666MACHINES.alpha= alpha
667MACHINES.arm= acorn32 cats epoc32 evbarm hpcarm \ 667MACHINES.arm= acorn32 cats epoc32 evbarm hpcarm \
668 iyonix netwinder shark zaurus 668 iyonix netwinder shark zaurus
669MACHINES.coldfire= evbcf 669MACHINES.coldfire= evbcf
670MACHINES.i386= i386 670MACHINES.i386= i386
671MACHINES.ia64= ia64 671MACHINES.ia64= ia64
672MACHINES.hppa= hppa 672MACHINES.hppa= hppa
673MACHINES.m68000= sun2 673MACHINES.m68000= sun2
674MACHINES.m68k= amiga atari cesfic hp300 luna68k mac68k \ 674MACHINES.m68k= amiga atari cesfic hp300 luna68k mac68k \
675 news68k next68k sun3 x68k 675 news68k next68k sun3 x68k
676MACHINES.mips= algor arc cobalt emips evbmips ews4800mips \ 676MACHINES.mips= algor arc cobalt emips evbmips ews4800mips \
677 hpcmips mipsco newsmips pmax sbmips sgimips 677 hpcmips mipsco newsmips pmax sbmips sgimips
678MACHINES.or1k= or1k 678MACHINES.or1k= or1k
679MACHINES.powerpc= amigappc bebox evbppc ibmnws macppc mvmeppc \ 679MACHINES.powerpc= amigappc bebox evbppc ibmnws macppc mvmeppc \
680 ofppc prep rs6000 sandpoint 680 ofppc prep rs6000 sandpoint
681MACHINES.riscv= riscv 681MACHINES.riscv= riscv
682MACHINES.sh3= dreamcast evbsh3 hpcsh landisk mmeye 682MACHINES.sh3= dreamcast evbsh3 hpcsh landisk mmeye
683MACHINES.sparc= sparc sparc64 683MACHINES.sparc= sparc sparc64
684MACHINES.sparc64= sparc64 684MACHINES.sparc64= sparc64
685MACHINES.vax= vax 685MACHINES.vax= vax
686MACHINES.x86_64= amd64 686MACHINES.x86_64= amd64
687 687
688# OBJCOPY flags to create a.out binaries for old firmware 688# OBJCOPY flags to create a.out binaries for old firmware
689# shared among src/distrib and ${MACHINE}/conf/Makefile.${MACHINE}.inc 689# shared among src/distrib and ${MACHINE}/conf/Makefile.${MACHINE}.inc
690.if ${MACHINE_CPU} == "arm" 690.if ${MACHINE_CPU} == "arm"
691OBJCOPY_ELF2AOUT_FLAGS?= \ 691OBJCOPY_ELF2AOUT_FLAGS?= \
692 -O a.out-arm-netbsd \ 692 -O a.out-arm-netbsd \
693 -R .ident \ 693 -R .ident \
694 -R .ARM.attributes \ 694 -R .ARM.attributes \
695 -R .ARM.exidx \ 695 -R .ARM.exidx \
696 -R .ARM.extab \ 696 -R .ARM.extab \
697 -R .SUNW_ctf \ 697 -R .SUNW_ctf \
698 -R .arm.atpcs \ 698 -R .arm.atpcs \
699 -R .comment \ 699 -R .comment \
700 -R .debug_abbrev \ 700 -R .debug_abbrev \
701 -R .debug_aranges \ 701 -R .debug_aranges \
702 -R .debug_info \ 702 -R .debug_info \
703 -R .debug_line \ 703 -R .debug_line \
704 -R .debug_frame \ 704 -R .debug_frame \
705 -R .debug_loc \ 705 -R .debug_loc \
706 -R .debug_pubnames \ 706 -R .debug_pubnames \
707 -R .debug_pubtypes \ 707 -R .debug_pubtypes \
708 -R .debug_ranges \ 708 -R .debug_ranges \
709 -R .debug_str \ 709 -R .debug_str \
710 -R .debug_macinfo \ 710 -R .debug_macinfo \
711 -R .eh_frame \ 711 -R .eh_frame \
712 -R .note.netbsd.ident 712 -R .note.netbsd.ident
713.endif 713.endif
714 714
715# 715#
716# Targets to check if DESTDIR or RELEASEDIR is provided 716# Targets to check if DESTDIR or RELEASEDIR is provided
717# 717#
718.if !target(check_DESTDIR) 718.if !target(check_DESTDIR)
719check_DESTDIR: .PHONY .NOTMAIN 719check_DESTDIR: .PHONY .NOTMAIN
720.if !defined(DESTDIR) 720.if !defined(DESTDIR)
721 @echo "setenv DESTDIR before doing that!" 721 @echo "setenv DESTDIR before doing that!"
722 @false 722 @false
723.else 723.else
724 @true 724 @true
725.endif 725.endif
726.endif 726.endif
727 727
728.if !target(check_RELEASEDIR) 728.if !target(check_RELEASEDIR)
729check_RELEASEDIR: .PHONY .NOTMAIN 729check_RELEASEDIR: .PHONY .NOTMAIN
730.if !defined(RELEASEDIR) 730.if !defined(RELEASEDIR)
731 @echo "setenv RELEASEDIR before doing that!" 731 @echo "setenv RELEASEDIR before doing that!"
732 @false 732 @false
733.else 733.else
734 @true 734 @true
735.endif 735.endif
736.endif 736.endif
737 737
738# 738#
739# Where the system object and source trees are kept; can be configurable 739# Where the system object and source trees are kept; can be configurable
740# by the user in case they want them in ~/foosrc and ~/fooobj (for example). 740# by the user in case they want them in ~/foosrc and ~/fooobj (for example).
741# 741#
742BSDSRCDIR?= /usr/src 742BSDSRCDIR?= /usr/src
743BSDOBJDIR?= /usr/obj 743BSDOBJDIR?= /usr/obj
744NETBSDSRCDIR?= ${BSDSRCDIR} 744NETBSDSRCDIR?= ${BSDSRCDIR}
745 745
746BINGRP?= wheel 746BINGRP?= wheel
747BINOWN?= root 747BINOWN?= root
748BINMODE?= 555 748BINMODE?= 555
749NONBINMODE?= 444 749NONBINMODE?= 444
750 750
751# These are here mainly because we don't want suid root in case 751# These are here mainly because we don't want suid root in case
752# a Makefile defines BINMODE. 752# a Makefile defines BINMODE.
753RUMPBINGRP?= wheel 753RUMPBINGRP?= wheel
754RUMPBINOWN?= root 754RUMPBINOWN?= root
755RUMPBINMODE?= 555 755RUMPBINMODE?= 555
756RUMPNONBINMODE?=444 756RUMPNONBINMODE?=444
757 757
758MANDIR?= /usr/share/man 758MANDIR?= /usr/share/man
759MANGRP?= wheel 759MANGRP?= wheel
760MANOWN?= root 760MANOWN?= root
761MANMODE?= ${NONBINMODE} 761MANMODE?= ${NONBINMODE}
762MANINSTALL?= ${_MANINSTALL} 762MANINSTALL?= ${_MANINSTALL}
763 763
764INFODIR?= /usr/share/info 764INFODIR?= /usr/share/info
765INFOGRP?= wheel 765INFOGRP?= wheel
766INFOOWN?= root 766INFOOWN?= root
767INFOMODE?= ${NONBINMODE} 767INFOMODE?= ${NONBINMODE}
768 768
769LIBDIR?= /usr/lib 769LIBDIR?= /usr/lib
770 770
771LINTLIBDIR?= /usr/libdata/lint 771LINTLIBDIR?= /usr/libdata/lint
772LIBGRP?= ${BINGRP} 772LIBGRP?= ${BINGRP}
773LIBOWN?= ${BINOWN} 773LIBOWN?= ${BINOWN}
774LIBMODE?= ${NONBINMODE} 774LIBMODE?= ${NONBINMODE}
775 775
776DOCDIR?= /usr/share/doc 776DOCDIR?= /usr/share/doc
777DOCGRP?= wheel 777DOCGRP?= wheel
778DOCOWN?= root 778DOCOWN?= root
779DOCMODE?= ${NONBINMODE} 779DOCMODE?= ${NONBINMODE}
780 780
781NLSDIR?= /usr/share/nls 781NLSDIR?= /usr/share/nls
782NLSGRP?= wheel 782NLSGRP?= wheel
783NLSOWN?= root 783NLSOWN?= root
784NLSMODE?= ${NONBINMODE} 784NLSMODE?= ${NONBINMODE}
785 785
786KMODULEGRP?= wheel 786KMODULEGRP?= wheel
787KMODULEOWN?= root 787KMODULEOWN?= root
788KMODULEMODE?= ${NONBINMODE} 788KMODULEMODE?= ${NONBINMODE}
789 789
790LOCALEDIR?= /usr/share/locale 790LOCALEDIR?= /usr/share/locale
791LOCALEGRP?= wheel 791LOCALEGRP?= wheel
792LOCALEOWN?= root 792LOCALEOWN?= root
793LOCALEMODE?= ${NONBINMODE} 793LOCALEMODE?= ${NONBINMODE}
794 794
795FIRMWAREDIR?= /libdata/firmware 795FIRMWAREDIR?= /libdata/firmware
796FIRMWAREGRP?= wheel 796FIRMWAREGRP?= wheel
797FIRMWAREOWN?= root 797FIRMWAREOWN?= root
798FIRMWAREMODE?= ${NONBINMODE} 798FIRMWAREMODE?= ${NONBINMODE}
799 799
800DEBUGDIR?= /usr/libdata/debug 800DEBUGDIR?= /usr/libdata/debug
801DEBUGGRP?= wheel 801DEBUGGRP?= wheel
802DEBUGOWN?= root 802DEBUGOWN?= root
803DEBUGMODE?= ${NONBINMODE} 803DEBUGMODE?= ${NONBINMODE}
804 804
805DTBDIR?= /boot/dtb 805DTBDIR?= /boot/dtb
806DTBGRP?= wheel 806DTBGRP?= wheel
807DTBOWN?= root 807DTBOWN?= root
808DTBMODE?= ${NONBINMODE} 808DTBMODE?= ${NONBINMODE}
809 809
810MKDIRMODE?= 0755 810MKDIRMODE?= 0755
811MKDIRPERM?= -m ${MKDIRMODE} 811MKDIRPERM?= -m ${MKDIRMODE}
812 812
813# 813#
814# Data-driven table using make variables to control how 814# Data-driven table using make variables to control how
815# toolchain-dependent targets and shared libraries are built 815# toolchain-dependent targets and shared libraries are built
816# for different platforms and object formats. 816# for different platforms and object formats.
817# 817#
818# OBJECT_FMT: currently either "ELF" or "a.out". 818# OBJECT_FMT: currently either "ELF" or "a.out".
819# 819#
820# All platforms are ELF. 820# All platforms are ELF.
821# 821#
822OBJECT_FMT= ELF 822OBJECT_FMT= ELF
823 823
824# 824#
825# If this platform's toolchain is missing, we obviously cannot build it. 825# If this platform's toolchain is missing, we obviously cannot build it.
826# 826#
827.if ${TOOLCHAIN_MISSING} != "no" 827.if ${TOOLCHAIN_MISSING} != "no"
828MKBINUTILS:= no 828MKBINUTILS:= no
829MKGDB:= no 829MKGDB:= no
830MKGCC:= no 830MKGCC:= no
831.endif 831.endif
832 832
833# 833#
834# If we are using an external toolchain, we can still build the target's 834# If we are using an external toolchain, we can still build the target's
835# binutils, but we cannot build GCC's support libraries, since those are 835# binutils, but we cannot build GCC's support libraries, since those are
836# tightly-coupled to the version of GCC being used. 836# tightly-coupled to the version of GCC being used.
837# 837#
838.if defined(EXTERNAL_TOOLCHAIN) 838.if defined(EXTERNAL_TOOLCHAIN)
839MKGCC:= no 839MKGCC:= no
840.endif 840.endif
841 841
842MKGDB.or1k= no 842MKGDB.or1k= no
843MKGDB.riscv32= no 843MKGDB.riscv32= no
844MKGDB.riscv64= no 844MKGDB.riscv64= no
845 845
846# No kernel modules for or1k or riscv (yet) 846# No kernel modules for or1k or riscv (yet)
847MKKMOD.or1k= no 847MKKMOD.or1k= no
848MKKMOD.riscv32= no 848MKKMOD.riscv32= no
849MKKMOD.riscv64= no 849MKKMOD.riscv64= no
850 850
851# No profiling for or1k (yet) 851# No profiling for or1k (yet)
852MKPROFILE.or1k= no 852MKPROFILE.or1k= no
853MKPROFILE.riscv32=no 853MKPROFILE.riscv32=no
854MKPROFILE.riscv64=no 854MKPROFILE.riscv64=no
855 855
856# 856#
857# The m68000 port is incomplete. 857# The m68000 port is incomplete.
858# 858#
859.if ${MACHINE_ARCH} == "m68000" 859.if ${MACHINE_ARCH} == "m68000"
860NOPIC= # defined 860NOPIC= # defined
861MKISCSI= no 861MKISCSI= no
862# XXX GCC 4 outputs mcount() calling sequences that try to load values 862# XXX GCC 4 outputs mcount() calling sequences that try to load values
863# from over 64KB away and this fails to assemble. 863# from over 64KB away and this fails to assemble.
864.if defined(HAVE_GCC) 864.if defined(HAVE_GCC)
865NOPROFILE= # defined 865NOPROFILE= # defined
866.endif 866.endif
867.endif 867.endif
868 868
869# 869#
870# GCC warnings with simple disables. Use these with eg 870# GCC warnings with simple disables. Use these with eg
871# COPTS.foo.c+= ${GCC_NO_STRINGOP_TRUNCATION}. 871# COPTS.foo.c+= ${GCC_NO_STRINGOP_TRUNCATION}.
872# 872#
873GCC_NO_FORMAT_TRUNCATION= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-format-truncation :} 873GCC_NO_FORMAT_TRUNCATION= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-format-truncation :}
874GCC_NO_FORMAT_OVERFLOW= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-format-overflow :} 874GCC_NO_FORMAT_OVERFLOW= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-format-overflow :}
875GCC_NO_STRINGOP_OVERFLOW= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-stringop-overflow :} 875GCC_NO_STRINGOP_OVERFLOW= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-stringop-overflow :}
876GCC_NO_IMPLICIT_FALLTHRU= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-implicit-fallthrough :} 876GCC_NO_IMPLICIT_FALLTHRU= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-implicit-fallthrough :}
877GCC_NO_STRINGOP_TRUNCATION= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 8:? -Wno-stringop-truncation :} 877GCC_NO_STRINGOP_TRUNCATION= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 8:? -Wno-stringop-truncation :}
878GCC_NO_CAST_FUNCTION_TYPE= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 8:? -Wno-cast-function-type :} 878GCC_NO_CAST_FUNCTION_TYPE= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 8:? -Wno-cast-function-type :}
879GCC_NO_ADDR_OF_PACKED_MEMBER= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 9:? -Wno-address-of-packed-member :} 879GCC_NO_ADDR_OF_PACKED_MEMBER= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 9:? -Wno-address-of-packed-member :}
880GCC_NO_MAYBE_UNINITIALIZED= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 10:? -Wno-maybe-uninitialized :} 880GCC_NO_MAYBE_UNINITIALIZED= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 10:? -Wno-maybe-uninitialized :}
881GCC_NO_RETURN_LOCAL_ADDR= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 10:? -Wno-return-local-addr :} 881GCC_NO_RETURN_LOCAL_ADDR= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 10:? -Wno-return-local-addr :}
882 882
883# 883#
884# Clang warnings 884# Clang warnings
885# 885#
886CLANG_NO_ADDR_OF_PACKED_MEMBER= ${${ACTIVE_CC} == "clang" :? -Wno-error=address-of-packed-member :} 886CLANG_NO_ADDR_OF_PACKED_MEMBER= ${${ACTIVE_CC} == "clang" :? -Wno-error=address-of-packed-member :}
887 887
888NO_ADDR_OF_PACKED_MEMBER= ${CLANG_NO_ADDR_OF_PACKED_MEMBER} ${GCC_NO_ADDR_OF_PACKED_MEMBER} 888NO_ADDR_OF_PACKED_MEMBER= ${CLANG_NO_ADDR_OF_PACKED_MEMBER} ${GCC_NO_ADDR_OF_PACKED_MEMBER}
889 889
890# 890#
891# The ia64 port is incomplete. 891# The ia64 port is incomplete.
892# 892#
893MKGDB.ia64= no 893MKGDB.ia64= no
894 894
895# 895#
896# On VAX using ELF, all objects are PIC, not just shared libraries, 896# On VAX using ELF, all objects are PIC, not just shared libraries,
897# so don't build the _pic version. VAX has no native TLS support either, 897# so don't build the _pic version. VAX has no native TLS support either,
898# so differences between TLS models are not relevant. 898# so differences between TLS models are not relevant.
899# 899#
900MKPICLIB.vax= no 900MKPICLIB.vax= no
901 901
902# 902#
903# Location of the file that contains the major and minor numbers of the 903# Location of the file that contains the major and minor numbers of the
904# version of a shared library. If this file exists a shared library 904# version of a shared library. If this file exists a shared library
905# will be built by <bsd.lib.mk>. 905# will be built by <bsd.lib.mk>.
906# 906#
907SHLIB_VERSION_FILE?= ${.CURDIR}/shlib_version 907SHLIB_VERSION_FILE?= ${.CURDIR}/shlib_version
908 908
909# 909#
910# GNU sources and packages sometimes see architecture names differently. 910# GNU sources and packages sometimes see architecture names differently.
911# 911#
912GNU_ARCH.aarch64eb=aarch64_be 912GNU_ARCH.aarch64eb=aarch64_be
913GNU_ARCH.coldfire=m5407 913GNU_ARCH.coldfire=m5407
914GNU_ARCH.earm=arm 914GNU_ARCH.earm=arm
915GNU_ARCH.earmhf=arm 915GNU_ARCH.earmhf=arm
916GNU_ARCH.earmeb=armeb 916GNU_ARCH.earmeb=armeb
917GNU_ARCH.earmhfeb=armeb 917GNU_ARCH.earmhfeb=armeb
918GNU_ARCH.earmv4=armv4 918GNU_ARCH.earmv4=armv4
919GNU_ARCH.earmv4eb=armv4eb 919GNU_ARCH.earmv4eb=armv4eb
920GNU_ARCH.earmv5=arm 920GNU_ARCH.earmv5=arm
921GNU_ARCH.earmv5hf=arm 921GNU_ARCH.earmv5hf=arm
922GNU_ARCH.earmv5eb=armeb 922GNU_ARCH.earmv5eb=armeb
923GNU_ARCH.earmv5hfeb=armeb 923GNU_ARCH.earmv5hfeb=armeb
924GNU_ARCH.earmv6=armv6 924GNU_ARCH.earmv6=armv6
925GNU_ARCH.earmv6hf=armv6 925GNU_ARCH.earmv6hf=armv6
926GNU_ARCH.earmv6eb=armv6eb 926GNU_ARCH.earmv6eb=armv6eb
927GNU_ARCH.earmv6hfeb=armv6eb 927GNU_ARCH.earmv6hfeb=armv6eb
928GNU_ARCH.earmv7=armv7 928GNU_ARCH.earmv7=armv7
929GNU_ARCH.earmv7hf=armv7 929GNU_ARCH.earmv7hf=armv7
930GNU_ARCH.earmv7eb=armv7eb 930GNU_ARCH.earmv7eb=armv7eb
931GNU_ARCH.earmv7hfeb=armv7eb 931GNU_ARCH.earmv7hfeb=armv7eb
932GNU_ARCH.i386=i486 932GNU_ARCH.i386=i486
933GCC_CONFIG_ARCH.i386=i486 933GCC_CONFIG_ARCH.i386=i486
934GCC_CONFIG_TUNE.i386=nocona 934GCC_CONFIG_TUNE.i386=nocona
935GCC_CONFIG_TUNE.x86_64=nocona 935GCC_CONFIG_TUNE.x86_64=nocona
936GNU_ARCH.m68000=m68010 936GNU_ARCH.m68000=m68010
937GNU_ARCH.sh3eb=sh 937GNU_ARCH.sh3eb=sh
938GNU_ARCH.sh3el=shle 938GNU_ARCH.sh3el=shle
939GNU_ARCH.mips64eb=mips64 939GNU_ARCH.mips64eb=mips64
940MACHINE_GNU_ARCH=${GNU_ARCH.${MACHINE_ARCH}:U${MACHINE_ARCH}} 940MACHINE_GNU_ARCH=${GNU_ARCH.${MACHINE_ARCH}:U${MACHINE_ARCH}}
941 941
942# 942#
943# In order to identify NetBSD to GNU packages, we sometimes need 943# In order to identify NetBSD to GNU packages, we sometimes need
944# an "elf" tag for historically a.out platforms. 944# an "elf" tag for historically a.out platforms.
945# 945#
946.if (!empty(MACHINE_ARCH:Mearm*)) 946.if (!empty(MACHINE_ARCH:Mearm*))
947MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsdelf-${MACHINE_ARCH:C/eb//:C/v[4-7]//:S/earm/eabi/} 947MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsdelf-${MACHINE_ARCH:C/eb//:C/v[4-7]//:S/earm/eabi/}
948.elif (${MACHINE_GNU_ARCH} == "arm" || \ 948.elif (${MACHINE_GNU_ARCH} == "arm" || \
949 ${MACHINE_GNU_ARCH} == "armeb" || \ 949 ${MACHINE_GNU_ARCH} == "armeb" || \
950 ${MACHINE_ARCH} == "i386" || \ 950 ${MACHINE_ARCH} == "i386" || \
951 ${MACHINE_CPU} == "m68k" || \ 951 ${MACHINE_CPU} == "m68k" || \
952 ${MACHINE_GNU_ARCH} == "sh" || \ 952 ${MACHINE_GNU_ARCH} == "sh" || \
953 ${MACHINE_GNU_ARCH} == "shle" || \ 953 ${MACHINE_GNU_ARCH} == "shle" || \
954 ${MACHINE_ARCH} == "sparc" || \ 954 ${MACHINE_ARCH} == "sparc" || \
955 ${MACHINE_ARCH} == "vax") 955 ${MACHINE_ARCH} == "vax")
956MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsdelf 956MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsdelf
957.else 957.else
958MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsd 958MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsd
959.endif 959.endif
960 960
961.if !empty(MACHINE_ARCH:M*arm*) 961.if !empty(MACHINE_ARCH:M*arm*)
962# Flags to pass to CC for using the old APCS ABI on ARM for compat or stand. 962# Flags to pass to CC for using the old APCS ABI on ARM for compat or stand.
963ARM_APCS_FLAGS= -mabi=apcs-gnu -mfloat-abi=soft -marm 963ARM_APCS_FLAGS= -mabi=apcs-gnu -mfloat-abi=soft -marm
964ARM_APCS_FLAGS+= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 8:? -mno-thumb-interwork :} 964ARM_APCS_FLAGS+= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 8:? -mno-thumb-interwork :}
965ARM_APCS_FLAGS+=${${ACTIVE_CC} == "clang":? -target ${MACHINE_GNU_ARCH}--netbsdelf -B ${TOOLDIR}/${MACHINE_GNU_PLATFORM}/bin :} 965ARM_APCS_FLAGS+=${${ACTIVE_CC} == "clang":? -target ${MACHINE_GNU_ARCH}--netbsdelf -B ${TOOLDIR}/${MACHINE_GNU_PLATFORM}/bin :}
966.endif 966.endif
967 967
968GENASSYM_CPPFLAGS+= ${${ACTIVE_CC} == "clang":? -no-integrated-as :} 968GENASSYM_CPPFLAGS+= ${${ACTIVE_CC} == "clang":? -no-integrated-as :}
969 969
970TARGETS+= all clean cleandir depend dependall includes \ 970TARGETS+= all clean cleandir depend dependall includes \
971 install lint obj regress tags html analyze describe \ 971 install lint obj regress tags html analyze describe \
972 rumpdescribe 972 rumpdescribe
973PHONY_NOTMAIN = all clean cleandir depend dependall distclean includes \ 973PHONY_NOTMAIN = all clean cleandir depend dependall distclean includes \
974 install lint obj regress beforedepend afterdepend \ 974 install lint obj regress beforedepend afterdepend \
975 beforeinstall afterinstall realinstall realdepend realall \ 975 beforeinstall afterinstall realinstall realdepend realall \
976 html subdir-all subdir-install subdir-depend analyze describe \ 976 html subdir-all subdir-install subdir-depend analyze describe \
977 rumpdescribe 977 rumpdescribe
978.PHONY: ${PHONY_NOTMAIN} 978.PHONY: ${PHONY_NOTMAIN}
979.NOTMAIN: ${PHONY_NOTMAIN} 979.NOTMAIN: ${PHONY_NOTMAIN}
980 980
981.if ${NEED_OWN_INSTALL_TARGET} != "no" 981.if ${NEED_OWN_INSTALL_TARGET} != "no"
982.if !target(install) 982.if !target(install)
983install: beforeinstall .WAIT subdir-install realinstall .WAIT afterinstall 983install: beforeinstall .WAIT subdir-install realinstall .WAIT afterinstall
984beforeinstall: 984beforeinstall:
985subdir-install: 985subdir-install:
986realinstall: 986realinstall:
987afterinstall: 987afterinstall:
988.endif 988.endif
989all: realall subdir-all 989all: realall subdir-all
990subdir-all: 990subdir-all:
991realall: 991realall:
992depend: realdepend subdir-depend 992depend: realdepend subdir-depend
993subdir-depend: 993subdir-depend:
994realdepend: 994realdepend:
995distclean: cleandir 995distclean: cleandir
996cleandir: clean 996cleandir: clean
997 997
998dependall: .NOTMAIN realdepend .MAKE 998dependall: .NOTMAIN realdepend .MAKE
999 @cd "${.CURDIR}"; ${MAKE} realall 999 @cd "${.CURDIR}"; ${MAKE} realall
1000.endif 1000.endif
1001 1001
1002# 1002#
1003# Define MKxxx variables (which are either yes or no) for users 1003# Define MKxxx variables (which are either yes or no) for users
1004# to set in /etc/mk.conf and override in the make environment. 1004# to set in /etc/mk.conf and override in the make environment.
1005# These should be tested with `== "no"' or `!= "no"'. 1005# These should be tested with `== "no"' or `!= "no"'.
1006# The NOxxx variables should only be set by Makefiles. 1006# The NOxxx variables should only be set by Makefiles.
1007# 1007#
1008# Please keep etc/Makefile and share/man/man5/mk.conf.5 in sync 1008# Please keep etc/Makefile and share/man/man5/mk.conf.5 in sync
1009# with changes to the MK* variables here. 1009# with changes to the MK* variables here.
1010# 1010#
1011 1011
1012# 1012#
1013# Supported NO* options (if defined, MK* will be forced to "no", 1013# Supported NO* options (if defined, MK* will be forced to "no",
1014# regardless of user's mk.conf setting). 1014# regardless of user's mk.conf setting).
1015# 1015#
1016# Source makefiles should set NO*, and not MK*, and must do so before 1016# Source makefiles should set NO*, and not MK*, and must do so before
1017# including bsd.own.mk. 1017# including bsd.own.mk.
1018# 1018#
1019.for var in \ 1019.for var in \
1020 NOCOMPAT NOCRYPTO NODOC NOHTML NOINFO NOLIBCSANITIZER NOLINKLIB \ 1020 NOCOMPAT NOCRYPTO NODOC NOHTML NOINFO NOLIBCSANITIZER NOLINKLIB \
1021 NOLINT NOMAN NONLS NOOBJ NOPIC NOPICINSTALL NOPROFILE NOSHARE \ 1021 NOLINT NOMAN NONLS NOOBJ NOPIC NOPICINSTALL NOPROFILE NOSHARE \
1022 NOSTATICLIB NODEBUGLIB NOSANITIZER NORELRO 1022 NOSTATICLIB NODEBUGLIB NOSANITIZER NORELRO
1023.if defined(${var}) 1023.if defined(${var})
1024MK${var:S/^NO//}:= no 1024MK${var:S/^NO//}:= no
1025.endif 1025.endif
1026.endfor 1026.endfor
1027 1027
1028# 1028#
1029# Older-style variables that enabled behaviour when set. 1029# Older-style variables that enabled behaviour when set.
1030# 1030#
1031.for var in MANZ UNPRIVED UPDATE 1031.for var in MANZ UNPRIVED UPDATE
1032.if defined(${var}) 1032.if defined(${var})
1033MK${var}:= yes 1033MK${var}:= yes
1034.endif 1034.endif
1035.endfor 1035.endfor
1036 1036
1037# 1037#
1038# MK* options which have variable defaults. 1038# MK* options which have variable defaults.
1039# 1039#
1040 1040
1041# 1041#
1042# aarch64eb is not yet supported for MKCOMPAT. 1042# aarch64eb is not yet supported for MKCOMPAT.
1043# 1043#
1044.if ${MACHINE_ARCH} == "x86_64" || \ 1044.if ${MACHINE_ARCH} == "x86_64" || \
1045 ${MACHINE_ARCH} == "sparc64" || \ 1045 ${MACHINE_ARCH} == "sparc64" || \
1046 ${MACHINE_MIPS64} || \ 1046 ${MACHINE_MIPS64} || \
1047 ${MACHINE_ARCH} == "powerpc64" || \ 1047 ${MACHINE_ARCH} == "powerpc64" || \
1048 (${MACHINE_ARCH} == "aarch64" && ${HAVE_GCC:U0} == 0) || \ 1048 (${MACHINE_ARCH} == "aarch64" && ${HAVE_GCC:U0} == 0) || \
1049 ${MACHINE_ARCH} == "riscv64" || \ 1049 ${MACHINE_ARCH} == "riscv64" || \
1050 !empty(MACHINE_ARCH:Mearm*) 1050 !empty(MACHINE_ARCH:Mearm*)
1051MKCOMPAT?= yes 1051MKCOMPAT?= yes
1052.else 1052.else
1053# Don't let this build where it really isn't supported. 1053# Don't let this build where it really isn't supported.
1054MKCOMPAT:= no 1054MKCOMPAT:= no
1055.endif 1055.endif
1056 1056
1057.if ${MKCOMPAT} == "no" 1057.if ${MKCOMPAT} == "no"
1058MKCOMPATTESTS:= no 1058MKCOMPATTESTS:= no
1059MKCOMPATX11:= no 1059MKCOMPATX11:= no
1060.endif 1060.endif
1061 1061
1062.if ${MACHINE_MIPS64} \ 1062.if ${MACHINE_MIPS64} \
1063 || (${MACHINE} == "evbppc" && ${MACHINE_ARCH} == "powerpc") 1063 || (${MACHINE} == "evbppc" && ${MACHINE_ARCH} == "powerpc")
1064MKCOMPATMODULES?= yes 1064MKCOMPATMODULES?= yes
1065.else 1065.else
1066MKCOMPATMODULES:= no 1066MKCOMPATMODULES:= no
1067.endif 1067.endif
1068 1068
1069# 1069#
1070# These platforms use softfloat by default. 1070# These platforms use softfloat by default.
1071# 1071#
1072.if ${MACHINE_MIPS64} 1072.if ${MACHINE_MIPS64}
1073MKSOFTFLOAT?= yes 1073MKSOFTFLOAT?= yes
1074.endif 1074.endif
1075 1075
1076# 1076#
1077# These platforms always use softfloat. 1077# These platforms always use softfloat.
1078# 1078#
1079.if (${MACHINE_CPU} == "arm" && ${MACHINE_ARCH:M*hf*} == "") || \ 1079.if (${MACHINE_CPU} == "arm" && ${MACHINE_ARCH:M*hf*} == "") || \
1080 ${MACHINE_ARCH} == "coldfire" || ${MACHINE_CPU} == "or1k" || \ 1080 ${MACHINE_ARCH} == "coldfire" || ${MACHINE_CPU} == "or1k" || \
1081 ${MACHINE} == "emips" || ${MACHINE_CPU} == "sh3" 1081 ${MACHINE} == "emips" || ${MACHINE_CPU} == "sh3"
1082MKSOFTFLOAT= yes 1082MKSOFTFLOAT= yes
1083.endif 1083.endif
1084 1084
1085.if ${MACHINE} == "emips" 1085.if ${MACHINE} == "emips"
1086SOFTFLOAT_BITS= 32 1086SOFTFLOAT_BITS= 32
1087.endif 1087.endif
1088 1088
1089# 1089#
1090# We want to build zfs only for amd64, aarch64 and sparc64 by default for now. 1090# We want to build zfs only for amd64, aarch64 and sparc64 by default for now.
1091# 1091#
1092.if ${MACHINE} == "amd64" || \ 1092.if ${MACHINE} == "amd64" || \
1093 ${MACHINE} == "sparc64" || \ 1093 ${MACHINE} == "sparc64" || \
1094 !empty(MACHINE_ARCH:Maarch64*) 1094 !empty(MACHINE_ARCH:Maarch64*)
1095MKZFS?= yes 1095MKZFS?= yes
1096.endif 1096.endif
1097 1097
1098# 1098#
1099# DTrace works on amd64, i386, aarch64, and earm* 1099# DTrace works on amd64, i386, aarch64, and earm*
1100# 1100#
1101.if ${MACHINE} == "i386" || \ 1101.if ${MACHINE} == "i386" || \
1102 ${MACHINE} == "amd64" || \ 1102 ${MACHINE} == "amd64" || \
1103 ${MACHINE_ARCH} == "aarch64" || \ 1103 ${MACHINE_ARCH} == "aarch64" || \
1104 !empty(MACHINE_ARCH:Mearm*) 1104 !empty(MACHINE_ARCH:Mearm*)
1105MKDTRACE?= yes 1105MKDTRACE?= yes
1106MKCTF?= yes 1106MKCTF?= yes
1107.endif 1107.endif
1108 1108
1109# 1109#
1110# PIE is enabled on many platforms by default. 1110# PIE is enabled on many platforms by default.
1111# 1111#
1112# Coverity does not like PIE 1112# Coverity does not like PIE
1113.if !defined(COVERITY_TOP_CONFIG) && \ 1113.if !defined(COVERITY_TOP_CONFIG) && \
1114 (${MACHINE_ARCH} == "i386" || \ 1114 (${MACHINE_ARCH} == "i386" || \
1115 ${MACHINE_ARCH} == "x86_64" || \ 1115 ${MACHINE_ARCH} == "x86_64" || \
1116 !empty(MACHINE_ARCH:Maarch64*) || \ 1116 !empty(MACHINE_ARCH:Maarch64*) || \
1117 ${MACHINE_CPU} == "arm" || \ 1117 ${MACHINE_CPU} == "arm" || \
1118 ${MACHINE_CPU} == "m68k" || \ 1118 ${MACHINE_CPU} == "m68k" || \
1119 ${MACHINE_CPU} == "mips" || \ 1119 ${MACHINE_CPU} == "mips" || \
1120 ${MACHINE_CPU} == "sh3" || \ 1120 ${MACHINE_CPU} == "sh3" || \
1121 ${MACHINE} == "sparc64") 1121 ${MACHINE} == "sparc64")
1122MKPIE?= yes 1122MKPIE?= yes
1123.else 1123.else
1124MKPIE?= no 1124MKPIE?= no
1125.endif 1125.endif
1126 1126
1127# 1127#
1128# RELRO is enabled on i386, amd64, and aarch64 by default 1128# RELRO is enabled on i386, amd64, and aarch64 by default
1129# 1129#
1130.if ${MACHINE} == "i386" || \ 1130.if ${MACHINE} == "i386" || \
1131 ${MACHINE} == "amd64" || \ 1131 ${MACHINE} == "amd64" || \
1132 !empty(MACHINE_ARCH:Maarch64*) 1132 !empty(MACHINE_ARCH:Maarch64*)
1133MKRELRO?= partial 1133MKRELRO?= partial
1134.else 1134.else
1135MKRELRO?= no 1135MKRELRO?= no
1136.endif 1136.endif
1137 1137
1138.if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "i386" 1138.if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "i386"
1139MKSTATICPIE?= yes 1139MKSTATICPIE?= yes
1140.else 1140.else
1141MKSTATICPIE?= no 1141MKSTATICPIE?= no
1142.endif 1142.endif
1143 1143
1144# 1144#
1145# MK* options which default to "yes". 1145# MK* options which default to "yes".
1146# 1146#
1147_MKVARS.yes= \ 1147_MKVARS.yes= \
1148 MKARGON2 \ 1148 MKARGON2 \
1149 MKATF \ 1149 MKATF \
1150 MKBINUTILS \ 1150 MKBINUTILS \
1151 MKBSDTAR \ 1151 MKBSDTAR \
1152 MKCOMPLEX MKCVS MKCXX \ 1152 MKCOMPLEX MKCVS MKCXX \
1153 MKDOC MKDTC \ 1153 MKDOC MKDTC \
1154 MKDYNAMICROOT \ 1154 MKDYNAMICROOT \
1155 MKGCC MKGDB MKGROFF \ 1155 MKGCC MKGDB MKGROFF \
1156 MKHESIOD MKHTML \ 1156 MKHESIOD MKHTML \
1157 MKIEEEFP MKINET6 MKINFO MKIPFILTER MKISCSI \ 1157 MKIEEEFP MKINET6 MKINFO MKIPFILTER MKISCSI \
1158 MKKERBEROS \ 1158 MKKERBEROS \
1159 MKKMOD \ 1159 MKKMOD \
1160 MKLDAP MKLIBSTDCXX MKLINKLIB MKLVM \ 1160 MKLDAP MKLIBSTDCXX MKLINKLIB MKLVM \
1161 MKMAN MKMANDOC \ 1161 MKMAN MKMANDOC \
1162 MKMDNS \ 1162 MKMDNS \
1163 MKMAKEMANDB \ 1163 MKMAKEMANDB \
1164 MKNLS \ 1164 MKNLS \
1165 MKNPF \ 1165 MKNPF \
1166 MKOBJ \ 1166 MKOBJ \
1167 MKPAM MKPERFUSE \ 1167 MKPAM MKPERFUSE \
1168 MKPF MKPIC MKPICLIB MKPOSTFIX MKPROFILE \ 1168 MKPF MKPIC MKPICLIB MKPOSTFIX MKPROFILE \
1169 MKRUMP \ 1169 MKRUMP \
1170 MKSHARE MKSKEY MKSTATICLIB \ 1170 MKSHARE MKSKEY MKSTATICLIB \
1171 MKUNBOUND \ 1171 MKUNBOUND \
1172 MKX11FONTS \ 1172 MKX11FONTS \
1173 MKYP 1173 MKYP
1174.for var in ${_MKVARS.yes} 1174.for var in ${_MKVARS.yes}
1175${var}?= ${${var}.${MACHINE_ARCH}:Uyes} 1175${var}?= ${${var}.${MACHINE_ARCH}:Uyes}
1176.endfor 1176.endfor
1177 1177
1178# 1178#
1179# MKGCCCMDS is only valid if we are building GCC so make it dependent on that. 1179# MKGCCCMDS is only valid if we are building GCC so make it dependent on that.
1180# 1180#
1181_MKVARS.yes += MKGCCCMDS 1181_MKVARS.yes += MKGCCCMDS
1182MKGCCCMDS?= ${MKGCC} 1182MKGCCCMDS?= ${MKGCC}
1183 1183
1184# 1184#
1185# Sanitizers, only "address" and "undefined" are supported by gcc 1185# Sanitizers, only "address" and "undefined" are supported by gcc
1186# 1186#
1187MKSANITIZER?= no 1187MKSANITIZER?= no
1188USE_SANITIZER?= address 1188USE_SANITIZER?= address
1189 1189
1190# 1190#
1191# Sanitizers implemented in libc, only "undefined" is supported 1191# Sanitizers implemented in libc, only "undefined" is supported
1192# 1192#
1193MKLIBCSANITIZER?= no 1193MKLIBCSANITIZER?= no
1194USE_LIBCSANITIZER?= undefined 1194USE_LIBCSANITIZER?= undefined
1195 1195
1196# 1196#
1197# Exceptions to the above: 1197# Exceptions to the above:
1198# 1198#
1199 1199
1200# RUMP uses -nostdinc which coverity does not like 1200# RUMP uses -nostdinc which coverity does not like
1201# It also does not use many new files, so disable it 1201# It also does not use many new files, so disable it
1202.if defined(COVERITY_TOP_CONFIG) 1202.if defined(COVERITY_TOP_CONFIG)
1203MKRUMP= no 1203MKRUMP= no
1204.endif 1204.endif
1205 1205
1206# 1206#
1207# Build a dynamically linked /bin and /sbin, with the necessary shared 1207# Build a dynamically linked /bin and /sbin, with the necessary shared
1208# libraries moved from /usr/lib to /lib and the shared linker moved 1208# libraries moved from /usr/lib to /lib and the shared linker moved
1209# from /usr/libexec to /lib 1209# from /usr/libexec to /lib
1210# 1210#
1211# Note that if the BINDIR is not /bin or /sbin, then we always use the 1211# Note that if the BINDIR is not /bin or /sbin, then we always use the
1212# non-DYNAMICROOT behavior (i.e. it is only enabled for programs in /bin 1212# non-DYNAMICROOT behavior (i.e. it is only enabled for programs in /bin
1213# and /sbin). See <bsd.shlib.mk>. 1213# and /sbin). See <bsd.shlib.mk>.
1214# 1214#
1215# For ia64, ld.elf_so not yet implemented 1215# For ia64, ld.elf_so not yet implemented
1216.if ${MACHINE_ARCH} == "ia64" 1216.if ${MACHINE_ARCH} == "ia64"
1217MKDYNAMICROOT= no 1217MKDYNAMICROOT= no
1218.endif 1218.endif
1219 1219
1220.if defined(MKREPRO) 1220.if defined(MKREPRO)
1221MKARZERO ?= ${MKREPRO} 1221MKARZERO ?= ${MKREPRO}
1222GROFF_FLAGS ?= -dpaper=letter 1222GROFF_FLAGS ?= -dpaper=letter
1223ROFF_PAGESIZE ?= -P-pletter 1223ROFF_PAGESIZE ?= -P-pletter
1224.endif 1224.endif
1225 1225
1226# 1226#
1227# Install the kernel as /netbsd/kernel and the modules in /netbsd/modules 1227# Install the kernel as /netbsd/kernel and the modules in /netbsd/modules
1228# 1228#
1229KERNEL_DIR?= no 1229KERNEL_DIR?= no
1230 1230
1231# Only install the general firmware on some systems 1231# Only install the general firmware on some systems
1232MKFIRMWARE.amd64= yes 1232MKFIRMWARE.amd64= yes
1233MKFIRMWARE.cobalt= yes 1233MKFIRMWARE.cobalt= yes
1234MKFIRMWARE.evbarm= yes 1234MKFIRMWARE.evbarm= yes
1235MKFIRMWARE.evbmips= yes 1235MKFIRMWARE.evbmips= yes
1236MKFIRMWARE.evbppc= yes 1236MKFIRMWARE.evbppc= yes
1237MKFIRMWARE.hpcarm= yes 1237MKFIRMWARE.hpcarm= yes
1238MKFIRMWARE.hppa= yes 1238MKFIRMWARE.hppa= yes
1239MKFIRMWARE.i386= yes 1239MKFIRMWARE.i386= yes
1240MKFIRMWARE.mac68k= yes 1240MKFIRMWARE.mac68k= yes
1241MKFIRMWARE.macppc= yes 1241MKFIRMWARE.macppc= yes
1242MKFIRMWARE.sandpoint= yes 1242MKFIRMWARE.sandpoint= yes
1243MKFIRMWARE.sparc64= yes 1243MKFIRMWARE.sparc64= yes
1244 1244
1245# Only install the GPU firmware on DRM-happy systems. 1245# Only install the GPU firmware on DRM-happy systems.
1246MKNOUVEAUFIRMWARE.x86_64= yes 1246MKNOUVEAUFIRMWARE.x86_64= yes
1247MKNOUVEAUFIRMWARE.i386= yes 1247MKNOUVEAUFIRMWARE.i386= yes
1248MKNOUVEAUFIRMWARE.aarch64= yes 1248MKNOUVEAUFIRMWARE.aarch64= yes
1249MKRADEONFIRMWARE.x86_64= yes 1249MKRADEONFIRMWARE.x86_64= yes
1250MKRADEONFIRMWARE.i386= yes 1250MKRADEONFIRMWARE.i386= yes
1251MKRADEONFIRMWARE.aarch64= yes 1251MKRADEONFIRMWARE.aarch64= yes
1252MKAMDGPUFIRMWARE.x86_64= yes 1252MKAMDGPUFIRMWARE.x86_64= yes
1253MKAMDGPUFIRMWARE.i386= yes 1253MKAMDGPUFIRMWARE.i386= yes
1254 1254
1255# Only install the tegra firmware on evbarm. 1255# Only install the tegra firmware on evbarm.
1256MKTEGRAFIRMWARE.evbarm= yes 1256MKTEGRAFIRMWARE.evbarm= yes
1257 1257
1258# Only build devicetree (dtb) files on armv6, armv7, and aarch64. 1258# Only build devicetree (dtb) files on armv6, armv7, and aarch64.
1259MKDTB.aarch64= yes 1259MKDTB.aarch64= yes
1260MKDTB.aarch64eb= yes 1260MKDTB.aarch64eb= yes
1261MKDTB.earmv6= yes 1261MKDTB.earmv6= yes
1262MKDTB.earmv6hf= yes 1262MKDTB.earmv6hf= yes
1263MKDTB.earmv6eb= yes 1263MKDTB.earmv6eb= yes
1264MKDTB.earmv6hfeb= yes 1264MKDTB.earmv6hfeb= yes
1265MKDTB.earmv7= yes 1265MKDTB.earmv7= yes
1266MKDTB.earmv7hf= yes 1266MKDTB.earmv7hf= yes
1267MKDTB.earmv7eb= yes 1267MKDTB.earmv7eb= yes
1268MKDTB.earmv7hfeb= yes 1268MKDTB.earmv7hfeb= yes
1269MKDTB.riscv32= yes 1269MKDTB.riscv32= yes
1270MKDTB.riscv64= yes 1270MKDTB.riscv64= yes
1271 1271
1272HAVE_MESA_VER?= 19 1272HAVE_MESA_VER?= 19
1273.if ${HAVE_MESA_VER} == 19 1273.if ${HAVE_MESA_VER} == 19
1274EXTERNAL_MESALIB_DIR?= MesaLib.old 1274EXTERNAL_MESALIB_DIR?= MesaLib.old
1275.elif ${HAVE_MESA_VER} == 21 1275.elif ${HAVE_MESA_VER} == 21
1276EXTERNAL_MESALIB_DIR?= MesaLib 1276EXTERNAL_MESALIB_DIR?= MesaLib
1277.endif 1277.endif
1278 1278
1279# Default to LLVM run-time if x86 or aarch64 and X11 and Mesa 18 or newer 1279# Default to LLVM run-time if x86 or aarch64 and X11 and Mesa 18 or newer
1280# XXX This knows that MKX11=no is default below, but would 1280# XXX This knows that MKX11=no is default below, but would
1281# require splitting the below loop in two parts. 1281# require splitting the below loop in two parts.
1282.if ${MKX11:Uno} != "no" && ${HAVE_MESA_VER} >= 19 1282.if ${MKX11:Uno} != "no" && ${HAVE_MESA_VER} >= 19
1283MKLLVMRT.amd64= yes 1283MKLLVMRT.amd64= yes
1284MKLLVMRT.i386= yes 1284MKLLVMRT.i386= yes
1285MKLLVMRT.aarch64= yes 1285MKLLVMRT.aarch64= yes
1286.endif 1286.endif
1287 1287
 1288# Just-in-time compiler for bpf, npf acceleration
 1289MKSLJIT.aarch64= yes
 1290MKSLJIT.i386= yes
 1291MKSLJIT.sparc= yes
 1292#MKSLJIT.sparc64= yes # not suppored in sljit (yet?)
 1293MKSLJIT.x86_64= yes
 1294#MKSLJIT.powerpc= yes # XXX
 1295#MKSLJIT.powerpc64= yes # XXX
 1296#MKSLJIT.mipsel= yes # XXX
 1297#MKSLJIT.mipseb= yes # XXX
 1298#MKSLJIT.mips64el= yes # XXX
 1299#MKSLJIT.mips64eb= yes # XXX
 1300#MKSLJIT.riscv32= yes # not until we update sljit
 1301#MKSLJIT.riscv64= yes # not until we update sljit
 1302
1288# compat with old names 1303# compat with old names
1289MKDEBUGKERNEL?=${MKKDEBUG:Uno} 1304MKDEBUGKERNEL?=${MKKDEBUG:Uno}
1290MKDEBUGTOOLS?=${MKTOOLSDEBUG:Uno} 1305MKDEBUGTOOLS?=${MKTOOLSDEBUG:Uno}
1291 1306
1292# 1307#
1293# MK* options which default to "no". Note that MKZFS has a different 1308# MK* options which default to "no". Note that MKZFS has a different
1294# default for some platforms, see above. Please keep alphabetically 1309# default for some platforms, see above. Please keep alphabetically
1295# sorted with at most one letter per line. 1310# sorted with at most one letter per line.
1296# 1311#
1297_MKVARS.no= \ 1312_MKVARS.no= \
1298 MKAMDGPUFIRMWARE \ 1313 MKAMDGPUFIRMWARE \
1299 MKARZERO \ 1314 MKARZERO \
1300 MKBSDGREP \ 1315 MKBSDGREP \
1301 MKCATPAGES MKCOMPATTESTS MKCOMPATX11 MKCTF \ 1316 MKCATPAGES MKCOMPATTESTS MKCOMPATX11 MKCTF \
1302 MKDEBUG MKDEBUGLIB MKDTB MKDTRACE \ 1317 MKDEBUG MKDEBUGLIB MKDTB MKDTRACE \
1303 MKFIRMWARE \ 1318 MKFIRMWARE \
1304 MKGROFFHTMLDOC \ 1319 MKGROFFHTMLDOC \
1305 MKKYUA \ 1320 MKKYUA \
1306 MKLIBCXX MKLLD MKLLDB MKLLVM MKLLVMRT MKLINT \ 1321 MKLIBCXX MKLLD MKLLDB MKLLVM MKLLVMRT MKLINT \
1307 MKMANZ MKMCLINKER \ 1322 MKMANZ MKMCLINKER \
1308 MKNOUVEAUFIRMWARE MKNSD \ 1323 MKNOUVEAUFIRMWARE MKNSD \
1309 MKOBJDIRS \ 1324 MKOBJDIRS \
1310 MKPCC MKPICINSTALL MKPIGZGZIP \ 1325 MKPCC MKPICINSTALL MKPIGZGZIP \
1311 MKRADEONFIRMWARE MKREPRO \ 1326 MKRADEONFIRMWARE MKREPRO \
1312 MKSLJIT MKSOFTFLOAT MKSTRIPIDENT \ 1327 MKSLJIT MKSOFTFLOAT MKSTRIPIDENT \
1313 MKTEGRAFIRMWARE MKTPM \ 1328 MKTEGRAFIRMWARE MKTPM \
1314 MKUNPRIVED MKUPDATE \ 1329 MKUNPRIVED MKUPDATE \
1315 MKX11 MKX11MOTIF MKXORG_SERVER \ 1330 MKX11 MKX11MOTIF MKXORG_SERVER \
1316 MKZFS 1331 MKZFS
1317.for var in ${_MKVARS.no} 1332.for var in ${_MKVARS.no}
1318${var}?= ${${var}.${MACHINE_ARCH}:U${${var}.${MACHINE}:Uno}} 1333${var}?= ${${var}.${MACHINE_ARCH}:U${${var}.${MACHINE}:Uno}}
1319.endfor 1334.endfor
1320 1335
1321.if ${MACHINE_ARCH} == "i386" || \ 
1322 ${MACHINE_ARCH} == "x86_64" || \ 
1323 ${MACHINE_ARCH} == "sparc" 
1324MKSLJIT= yes 
1325.endif 
1326 
1327# 1336#
1328# Which platforms build the xorg-server drivers (as opposed 1337# Which platforms build the xorg-server drivers (as opposed
1329# to just Xnest and Xvfb.) 1338# to just Xnest and Xvfb.)
1330# 1339#
1331.if ${MACHINE} == "alpha" || \ 1340.if ${MACHINE} == "alpha" || \
1332 ${MACHINE} == "amd64" || \ 1341 ${MACHINE} == "amd64" || \
1333 ${MACHINE} == "amiga" || \ 1342 ${MACHINE} == "amiga" || \
1334 ${MACHINE} == "bebox" || \ 1343 ${MACHINE} == "bebox" || \
1335 ${MACHINE} == "cats" || \ 1344 ${MACHINE} == "cats" || \
1336 ${MACHINE} == "dreamcast" || \ 1345 ${MACHINE} == "dreamcast" || \
1337 ${MACHINE} == "ews4800mips" || \ 1346 ${MACHINE} == "ews4800mips" || \
1338 ${MACHINE} == "evbarm" || \ 1347 ${MACHINE} == "evbarm" || \
1339 ${MACHINE} == "evbmips" || \ 1348 ${MACHINE} == "evbmips" || \
1340 ${MACHINE} == "evbppc" || \ 1349 ${MACHINE} == "evbppc" || \
1341 ${MACHINE} == "hp300" || \ 1350 ${MACHINE} == "hp300" || \
1342 ${MACHINE} == "hpcarm" || \ 1351 ${MACHINE} == "hpcarm" || \
1343 ${MACHINE} == "hpcmips" || \ 1352 ${MACHINE} == "hpcmips" || \
1344 ${MACHINE} == "hpcsh" || \ 1353 ${MACHINE} == "hpcsh" || \
1345 ${MACHINE} == "hppa" || \ 1354 ${MACHINE} == "hppa" || \
1346 ${MACHINE} == "i386" || \ 1355 ${MACHINE} == "i386" || \
1347 ${MACHINE} == "ibmnws" || \ 1356 ${MACHINE} == "ibmnws" || \
1348 ${MACHINE} == "iyonix" || \ 1357 ${MACHINE} == "iyonix" || \
1349 ${MACHINE} == "luna68k" || \ 1358 ${MACHINE} == "luna68k" || \
1350 ${MACHINE} == "mac68k" || \ 1359 ${MACHINE} == "mac68k" || \
1351 ${MACHINE} == "macppc" || \ 1360 ${MACHINE} == "macppc" || \
1352 ${MACHINE} == "netwinder" || \ 1361 ${MACHINE} == "netwinder" || \
1353 ${MACHINE} == "newsmips" || \ 1362 ${MACHINE} == "newsmips" || \
1354 ${MACHINE} == "pmax" || \ 1363 ${MACHINE} == "pmax" || \
1355 ${MACHINE} == "prep" || \ 1364 ${MACHINE} == "prep" || \
1356 ${MACHINE} == "ofppc" || \ 1365 ${MACHINE} == "ofppc" || \
1357 ${MACHINE} == "sgimips" || \ 1366 ${MACHINE} == "sgimips" || \
1358 ${MACHINE} == "shark" || \ 1367 ${MACHINE} == "shark" || \
1359 ${MACHINE} == "sparc" || \ 1368 ${MACHINE} == "sparc" || \
1360 ${MACHINE} == "sparc64" || \ 1369 ${MACHINE} == "sparc64" || \
1361 ${MACHINE} == "vax" || \ 1370 ${MACHINE} == "vax" || \
1362 ${MACHINE} == "zaurus" 1371 ${MACHINE} == "zaurus"
1363MKXORG_SERVER=yes 1372MKXORG_SERVER=yes
1364.endif 1373.endif
1365 1374
1366# 1375#
1367# Force some options off if their dependencies are off. 1376# Force some options off if their dependencies are off.
1368# 1377#
1369 1378
1370.if ${MKCXX} == "no" 1379.if ${MKCXX} == "no"
1371MKATF:= no 1380MKATF:= no
1372MKGCCCMDS:= no 1381MKGCCCMDS:= no
1373MKGDB:= no 1382MKGDB:= no
1374MKGROFF:= no 1383MKGROFF:= no
1375MKKYUA:= no 1384MKKYUA:= no
1376.endif 1385.endif
1377 1386
1378.if ${MKMAN} == "no" 1387.if ${MKMAN} == "no"
1379MKCATPAGES:= no 1388MKCATPAGES:= no
1380MKHTML:= no 1389MKHTML:= no
1381.endif 1390.endif
1382 1391
1383_MANINSTALL= maninstall 1392_MANINSTALL= maninstall
1384.if ${MKCATPAGES} != "no" 1393.if ${MKCATPAGES} != "no"
1385_MANINSTALL+= catinstall 1394_MANINSTALL+= catinstall
1386.endif 1395.endif
1387.if ${MKHTML} != "no" 1396.if ${MKHTML} != "no"
1388_MANINSTALL+= htmlinstall 1397_MANINSTALL+= htmlinstall
1389.endif 1398.endif
1390 1399
1391.if ${MKLINKLIB} == "no" 1400.if ${MKLINKLIB} == "no"
1392MKLINT:= no 1401MKLINT:= no
1393MKPICINSTALL:= no 1402MKPICINSTALL:= no
1394MKPROFILE:= no 1403MKPROFILE:= no
1395.endif 1404.endif
1396 1405
1397.if ${MKPIC} == "no" 1406.if ${MKPIC} == "no"
1398MKPICLIB:= no 1407MKPICLIB:= no
1399.endif 1408.endif
1400 1409
1401.if ${MKOBJ} == "no" 1410.if ${MKOBJ} == "no"
1402MKOBJDIRS:= no 1411MKOBJDIRS:= no
1403.endif 1412.endif
1404 1413
1405.if ${MKSHARE} == "no" 1414.if ${MKSHARE} == "no"
1406MKCATPAGES:= no 1415MKCATPAGES:= no
1407MKDOC:= no 1416MKDOC:= no
1408MKINFO:= no 1417MKINFO:= no
1409MKHTML:= no 1418MKHTML:= no
1410MKMAN:= no 1419MKMAN:= no
1411MKNLS:= no 1420MKNLS:= no
1412.endif 1421.endif
1413 1422
1414.if !empty(MACHINE_ARCH:Mearm*) 1423.if !empty(MACHINE_ARCH:Mearm*)
1415_NEEDS_LIBCXX.${MACHINE_ARCH}= yes 1424_NEEDS_LIBCXX.${MACHINE_ARCH}= yes
1416.endif 1425.endif
1417_NEEDS_LIBCXX.aarch64= yes 1426_NEEDS_LIBCXX.aarch64= yes
1418_NEEDS_LIBCXX.aarch64eb= yes 1427_NEEDS_LIBCXX.aarch64eb= yes
1419_NEEDS_LIBCXX.i386= yes 1428_NEEDS_LIBCXX.i386= yes
1420_NEEDS_LIBCXX.powerpc= yes 1429_NEEDS_LIBCXX.powerpc= yes
1421_NEEDS_LIBCXX.powerpc64= yes 1430_NEEDS_LIBCXX.powerpc64= yes
1422_NEEDS_LIBCXX.sparc= yes 1431_NEEDS_LIBCXX.sparc= yes
1423_NEEDS_LIBCXX.sparc64= yes 1432_NEEDS_LIBCXX.sparc64= yes
1424_NEEDS_LIBCXX.x86_64= yes 1433_NEEDS_LIBCXX.x86_64= yes
1425 1434
1426.if ${MKLLVM} == "yes" && ${_NEEDS_LIBCXX.${MACHINE_ARCH}:Uno} == "yes" 1435.if ${MKLLVM} == "yes" && ${_NEEDS_LIBCXX.${MACHINE_ARCH}:Uno} == "yes"
1427MKLIBCXX:= yes 1436MKLIBCXX:= yes
1428.endif 1437.endif
1429 1438
1430# 1439#
1431# Disable MKSTRIPSYM if MKDEBUG is enabled. 1440# Disable MKSTRIPSYM if MKDEBUG is enabled.
1432# 1441#
1433.if ${MKDEBUG} != "no" 1442.if ${MKDEBUG} != "no"
1434MKSTRIPSYM:= no 1443MKSTRIPSYM:= no
1435.endif 1444.endif
1436 1445
1437# 1446#
1438# install(1) parameters. 1447# install(1) parameters.
1439# 1448#
1440COPY?= -c 1449COPY?= -c
1441.if ${MKUPDATE} == "no" 1450.if ${MKUPDATE} == "no"
1442PRESERVE?= 1451PRESERVE?=
1443.else 1452.else
1444PRESERVE?= -p 1453PRESERVE?= -p
1445.endif 1454.endif
1446RENAME?= -r 1455RENAME?= -r
1447HRDLINK?= -l h 1456HRDLINK?= -l h
1448SYMLINK?= -l s 1457SYMLINK?= -l s
1449 1458
1450METALOG?= ${DESTDIR}/METALOG 1459METALOG?= ${DESTDIR}/METALOG
1451METALOG.add?= ${TOOL_CAT} -l >> ${METALOG} 1460METALOG.add?= ${TOOL_CAT} -l >> ${METALOG}
1452.if (${_SRC_TOP_} != "") # only set INSTPRIV if inside ${NETBSDSRCDIR} 1461.if (${_SRC_TOP_} != "") # only set INSTPRIV if inside ${NETBSDSRCDIR}
1453.if ${MKUNPRIVED} != "no" 1462.if ${MKUNPRIVED} != "no"
1454INSTPRIV.unpriv=-U -M ${METALOG} -D ${DESTDIR} -h sha256 1463INSTPRIV.unpriv=-U -M ${METALOG} -D ${DESTDIR} -h sha256
1455.else 1464.else
1456INSTPRIV.unpriv= 1465INSTPRIV.unpriv=
1457.endif 1466.endif
1458INSTPRIV?= ${INSTPRIV.unpriv} -N ${NETBSDSRCDIR}/etc 1467INSTPRIV?= ${INSTPRIV.unpriv} -N ${NETBSDSRCDIR}/etc
1459.endif 1468.endif
1460STRIPFLAG?= 1469STRIPFLAG?=
1461 1470
1462INSTALL_DIR?= ${INSTALL} ${INSTPRIV} -d 1471INSTALL_DIR?= ${INSTALL} ${INSTPRIV} -d
1463INSTALL_FILE?= ${INSTALL} ${INSTPRIV} ${COPY} ${PRESERVE} ${RENAME} 1472INSTALL_FILE?= ${INSTALL} ${INSTPRIV} ${COPY} ${PRESERVE} ${RENAME}
1464INSTALL_LINK?= ${INSTALL} ${INSTPRIV} ${HRDLINK} ${RENAME} 1473INSTALL_LINK?= ${INSTALL} ${INSTPRIV} ${HRDLINK} ${RENAME}
1465INSTALL_SYMLINK?= ${INSTALL} ${INSTPRIV} ${SYMLINK} ${RENAME} 1474INSTALL_SYMLINK?= ${INSTALL} ${INSTPRIV} ${SYMLINK} ${RENAME}
1466 1475
1467# for crunchide & ldd, define the OBJECT_FMTS used by a MACHINE_ARCH 1476# for crunchide & ldd, define the OBJECT_FMTS used by a MACHINE_ARCH
1468# 1477#
1469OBJECT_FMTS= 1478OBJECT_FMTS=
1470.if ${MACHINE_ARCH} != "alpha" && ${MACHINE_ARCH} != "ia64" 1479.if ${MACHINE_ARCH} != "alpha" && ${MACHINE_ARCH} != "ia64"
1471OBJECT_FMTS+= elf32 1480OBJECT_FMTS+= elf32
1472.endif 1481.endif
1473.if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH:M*64*} != "" 1482.if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH:M*64*} != ""
1474. if !(${MKCOMPAT:Uyes} == "no" && ${MACHINE_CPU} == "mips") 1483. if !(${MKCOMPAT:Uyes} == "no" && ${MACHINE_CPU} == "mips")
1475OBJECT_FMTS+= elf64 1484OBJECT_FMTS+= elf64
1476. endif 1485. endif
1477.endif 1486.endif
1478 1487
1479# 1488#
1480# Set defaults for the USE_xxx variables. 1489# Set defaults for the USE_xxx variables.
1481# 1490#
1482 1491
1483# 1492#
1484# USE_* options which default to "no" and will be forced to "no" if their 1493# USE_* options which default to "no" and will be forced to "no" if their
1485# corresponding MK* variable is set to "no". 1494# corresponding MK* variable is set to "no".
1486# 1495#
1487.for var in USE_SKEY 1496.for var in USE_SKEY
1488.if (${${var:S/USE_/MK/}} == "no") 1497.if (${${var:S/USE_/MK/}} == "no")
1489${var}:= no 1498${var}:= no
1490.else 1499.else
1491${var}?= no 1500${var}?= no
1492.endif 1501.endif
1493.endfor 1502.endfor
1494 1503
1495# 1504#
1496# USE_* options which default to "yes" unless their corresponding MK* 1505# USE_* options which default to "yes" unless their corresponding MK*
1497# variable is set to "no". 1506# variable is set to "no".
1498# 1507#
1499.for var in USE_HESIOD USE_INET6 USE_KERBEROS USE_LDAP USE_PAM USE_YP 1508.for var in USE_HESIOD USE_INET6 USE_KERBEROS USE_LDAP USE_PAM USE_YP
1500.if (${${var:S/USE_/MK/}} == "no") 1509.if (${${var:S/USE_/MK/}} == "no")
1501${var}:= no 1510${var}:= no
1502.else 1511.else
1503${var}?= yes 1512${var}?= yes
1504.endif 1513.endif
1505.endfor 1514.endfor
1506 1515
1507# 1516#
1508# USE_* options which default to "yes". 1517# USE_* options which default to "yes".
1509# 1518#
1510.for var in USE_JEMALLOC 1519.for var in USE_JEMALLOC
1511${var}?= yes 1520${var}?= yes
1512.endfor 1521.endfor
1513 1522
1514# 1523#
1515# USE_* options which default to "no". 1524# USE_* options which default to "no".
1516# 1525#
1517# For now, disable pigz as compressor by default 1526# For now, disable pigz as compressor by default
1518.for var in USE_PIGZGZIP 1527.for var in USE_PIGZGZIP
1519${var}?= no 1528${var}?= no
1520.endfor 1529.endfor
1521 1530
1522# Default to USE_XZ_SETS on some 64bit architectures where decompressor 1531# Default to USE_XZ_SETS on some 64bit architectures where decompressor
1523# memory will likely not be in short supply. 1532# memory will likely not be in short supply.
1524# Since pigz can not create .xz format files currently, disable .xz 1533# Since pigz can not create .xz format files currently, disable .xz
1525# format if USE_PIGZGZIP is enabled. 1534# format if USE_PIGZGZIP is enabled.
1526.if ${USE_PIGZGZIP} == "no" && \ 1535.if ${USE_PIGZGZIP} == "no" && \
1527 (${MACHINE} == "amd64" || \ 1536 (${MACHINE} == "amd64" || \
1528 ${MACHINE} == "sparc64" || \ 1537 ${MACHINE} == "sparc64" || \
1529 !empty(MACHINE_ARCH:Maarch64*)) 1538 !empty(MACHINE_ARCH:Maarch64*))
1530USE_XZ_SETS?= yes 1539USE_XZ_SETS?= yes
1531.else 1540.else
1532USE_XZ_SETS?= no 1541USE_XZ_SETS?= no
1533.endif 1542.endif
1534 1543
1535# 1544#
1536# TOOL_GZIP and friends. These might refer to TOOL_PIGZ or to the host gzip. 1545# TOOL_GZIP and friends. These might refer to TOOL_PIGZ or to the host gzip.
1537# 1546#
1538.if ${USE_PIGZGZIP} != "no" 1547.if ${USE_PIGZGZIP} != "no"
1539TOOL_GZIP= ${TOOL_PIGZ} 1548TOOL_GZIP= ${TOOL_PIGZ}
1540GZIP_N_FLAG?= -nT 1549GZIP_N_FLAG?= -nT
1541.else 1550.else
1542TOOL_GZIP= gzip 1551TOOL_GZIP= gzip
1543GZIP_N_FLAG?= -n 1552GZIP_N_FLAG?= -n
1544.endif 1553.endif
1545TOOL_GZIP_N= ${TOOL_GZIP} ${GZIP_N_FLAG} 1554TOOL_GZIP_N= ${TOOL_GZIP} ${GZIP_N_FLAG}
1546 1555
1547# 1556#
1548# Where X11 sources are and where it is installed to. 1557# Where X11 sources are and where it is installed to.
1549# 1558#
1550.if !defined(X11SRCDIR) 1559.if !defined(X11SRCDIR)
1551.if exists(${NETBSDSRCDIR}/../xsrc) 1560.if exists(${NETBSDSRCDIR}/../xsrc)
1552X11SRCDIR!= cd "${NETBSDSRCDIR}/../xsrc" && pwd 1561X11SRCDIR!= cd "${NETBSDSRCDIR}/../xsrc" && pwd
1553.else 1562.else
1554X11SRCDIR= /usr/xsrc 1563X11SRCDIR= /usr/xsrc
1555.endif 1564.endif
1556.endif # !defined(X11SRCDIR) 1565.endif # !defined(X11SRCDIR)
1557 1566
1558X11SRCDIR.local?= ${X11SRCDIR}/local 1567X11SRCDIR.local?= ${X11SRCDIR}/local
1559X11ROOTDIR?= /usr/X11R7 1568X11ROOTDIR?= /usr/X11R7
1560X11BINDIR?= ${X11ROOTDIR}/bin 1569X11BINDIR?= ${X11ROOTDIR}/bin
1561X11ETCDIR?= /etc/X11 1570X11ETCDIR?= /etc/X11
1562X11FONTDIR?= ${X11ROOTDIR}/lib/X11/fonts 1571X11FONTDIR?= ${X11ROOTDIR}/lib/X11/fonts
1563X11INCDIR?= ${X11ROOTDIR}/include 1572X11INCDIR?= ${X11ROOTDIR}/include
1564X11LIBDIR?= ${X11ROOTDIR}/lib/X11 1573X11LIBDIR?= ${X11ROOTDIR}/lib/X11
1565X11MANDIR?= ${X11ROOTDIR}/man 1574X11MANDIR?= ${X11ROOTDIR}/man
1566X11SHAREDIR?= ${X11ROOTDIR}/share 1575X11SHAREDIR?= ${X11ROOTDIR}/share
1567X11USRLIBDIR?= ${X11ROOTDIR}/lib${MLIBDIR:D/${MLIBDIR}} 1576X11USRLIBDIR?= ${X11ROOTDIR}/lib${MLIBDIR:D/${MLIBDIR}}
1568 1577
1569# 1578#
1570# New modular-xorg based builds 1579# New modular-xorg based builds
1571# 1580#
1572X11SRCDIRMIT?= ${X11SRCDIR}/external/mit 1581X11SRCDIRMIT?= ${X11SRCDIR}/external/mit
1573.for _lib in \ 1582.for _lib in \
1574 FS ICE SM X11 XScrnSaver XTrap Xau Xcomposite Xcursor Xdamage \ 1583 FS ICE SM X11 XScrnSaver XTrap Xau Xcomposite Xcursor Xdamage \
1575 Xdmcp Xevie Xext Xfixes Xfont Xfont2 Xft Xi Xinerama Xmu Xpresent Xpm \ 1584 Xdmcp Xevie Xext Xfixes Xfont Xfont2 Xft Xi Xinerama Xmu Xpresent Xpm \
1576 Xrandr Xrender Xres Xt Xtst Xv XvMC Xxf86dga Xxf86misc Xxf86vm drm \ 1585 Xrandr Xrender Xres Xt Xtst Xv XvMC Xxf86dga Xxf86misc Xxf86vm drm \
1577 epoxy fontenc vdpau xkbfile xkbui Xaw pciaccess xcb xshmfence \ 1586 epoxy fontenc vdpau xkbfile xkbui Xaw pciaccess xcb xshmfence \
1578 pthread-stubs xcvt 1587 pthread-stubs xcvt
1579X11SRCDIR.${_lib}?= ${X11SRCDIRMIT}/lib${_lib}/dist 1588X11SRCDIR.${_lib}?= ${X11SRCDIRMIT}/lib${_lib}/dist
1580.endfor 1589.endfor
1581 1590
1582.for _proto in \ 1591.for _proto in \
1583 xcb- xorg 1592 xcb- xorg
1584X11SRCDIR.${_proto}proto?= ${X11SRCDIRMIT}/${_proto}proto/dist 1593X11SRCDIR.${_proto}proto?= ${X11SRCDIRMIT}/${_proto}proto/dist
1585.endfor 1594.endfor
1586 1595
1587# During transition from xorg-server 1.10 to 1.20 1596# During transition from xorg-server 1.10 to 1.20
1588.if \ 1597.if \
1589 ${MACHINE} == "alpha" || \ 1598 ${MACHINE} == "alpha" || \
1590 ${MACHINE} == "netwinder" || \ 1599 ${MACHINE} == "netwinder" || \
1591 ${MACHINE} == "sgimips" || \ 1600 ${MACHINE} == "sgimips" || \
1592 ${MACHINE} == "vax" 1601 ${MACHINE} == "vax"
1593HAVE_XORG_SERVER_VER?=110 1602HAVE_XORG_SERVER_VER?=110
1594.else 1603.else
1595HAVE_XORG_SERVER_VER?=120 1604HAVE_XORG_SERVER_VER?=120
1596.endif 1605.endif
1597 1606
1598.if ${HAVE_XORG_SERVER_VER} == "120" 1607.if ${HAVE_XORG_SERVER_VER} == "120"
1599XORG_SERVER_SUBDIR?=xorg-server 1608XORG_SERVER_SUBDIR?=xorg-server
1600. if ${MACHINE} == "amd64" || ${MACHINE} == "i386" || ${MACHINE} == "evbarm" 1609. if ${MACHINE} == "amd64" || ${MACHINE} == "i386" || ${MACHINE} == "evbarm"
1601HAVE_XORG_GLAMOR?= yes 1610HAVE_XORG_GLAMOR?= yes
1602. endif 1611. endif
1603.else 1612.else
1604XORG_SERVER_SUBDIR?=xorg-server.old 1613XORG_SERVER_SUBDIR?=xorg-server.old
1605.endif 1614.endif
1606 1615
1607X11SRCDIR.xorg-server?= ${X11SRCDIRMIT}/${XORG_SERVER_SUBDIR}/dist 1616X11SRCDIR.xorg-server?= ${X11SRCDIRMIT}/${XORG_SERVER_SUBDIR}/dist
1608HAVE_XORG_GLAMOR?= no 1617HAVE_XORG_GLAMOR?= no
1609 1618
1610# Build glamor extension? 1619# Build glamor extension?
1611 1620
1612.for _dir in \ 1621.for _dir in \
1613 xtrans fontconfig freetype evieext mkfontscale bdftopcf \ 1622 xtrans fontconfig freetype evieext mkfontscale bdftopcf \
1614 xorg-cf-files imake xbiff xkeyboard-config \ 1623 xorg-cf-files imake xbiff xkeyboard-config \
1615 xcompmgr xbitmaps appres xeyes xev xedit sessreg pixman \ 1624 xcompmgr xbitmaps appres xeyes xev xedit sessreg pixman \
1616 beforelight bitmap editres makedepend fonttosfnt fslsfonts fstobdf \ 1625 beforelight bitmap editres makedepend fonttosfnt fslsfonts fstobdf \
1617 glu glw mesa-demos MesaGLUT MesaLib MesaLib.old MesaLib7 \ 1626 glu glw mesa-demos MesaGLUT MesaLib MesaLib.old MesaLib7 \
1618 ico iceauth listres lndir \ 1627 ico iceauth listres lndir \
1619 luit xproxymanagementprotocol mkfontdir oclock proxymngr rgb \ 1628 luit xproxymanagementprotocol mkfontdir oclock proxymngr rgb \
1620 rstart setxkbmap showfont smproxy transset twm viewres \ 1629 rstart setxkbmap showfont smproxy transset twm viewres \
1621 util-macros \ 1630 util-macros \
1622 x11perf xauth xcalc xclipboard \ 1631 x11perf xauth xcalc xclipboard \
1623 xclock xcmsdb xconsole xditview xdpyinfo xdriinfo xdm \ 1632 xclock xcmsdb xconsole xditview xdpyinfo xdriinfo xdm \
1624 xfd xf86dga xfindproxy xfontsel xfwp xgamma xgc xhost xinit \ 1633 xfd xf86dga xfindproxy xfontsel xfwp xgamma xgc xhost xinit \
1625 xkill xload xlogo xlsatoms xlsclients xlsfonts xmag xmessage \ 1634 xkill xload xlogo xlsatoms xlsclients xlsfonts xmag xmessage \
1626 xmh xmodmap xmore xman xprop xrandr xrdb xrefresh xset \ 1635 xmh xmodmap xmore xman xprop xrandr xrdb xrefresh xset \
1627 xsetmode xsetpointer xsetroot xsm xstdcmap xvidtune xvinfo \ 1636 xsetmode xsetpointer xsetroot xsm xstdcmap xvidtune xvinfo \
1628 xwininfo xwud xkbprint xkbevd \ 1637 xwininfo xwud xkbprint xkbevd \
1629 xterm xwd xfs xfsinfo xtrap xkbutils xkbcomp \ 1638 xterm xwd xfs xfsinfo xtrap xkbutils xkbcomp \
1630 xinput xcb-util xorg-docs \ 1639 xinput xcb-util xorg-docs \
1631 font-adobe-100dpi font-adobe-75dpi font-adobe-utopia-100dpi \ 1640 font-adobe-100dpi font-adobe-75dpi font-adobe-utopia-100dpi \
1632 font-adobe-utopia-75dpi font-adobe-utopia-type1 \ 1641 font-adobe-utopia-75dpi font-adobe-utopia-type1 \
1633 font-alias \ 1642 font-alias \
1634 font-bh-100dpi font-bh-75dpi font-bh-lucidatypewriter-100dpi \ 1643 font-bh-100dpi font-bh-75dpi font-bh-lucidatypewriter-100dpi \
1635 font-bh-lucidatypewriter-75dpi font-bh-ttf font-bh-type1 \ 1644 font-bh-lucidatypewriter-75dpi font-bh-ttf font-bh-type1 \
1636 font-bitstream-100dpi font-bitstream-75dpi font-bitstream-type1 \ 1645 font-bitstream-100dpi font-bitstream-75dpi font-bitstream-type1 \
1637 font-cursor-misc font-daewoo-misc font-dec-misc font-ibm-type1 \ 1646 font-cursor-misc font-daewoo-misc font-dec-misc font-ibm-type1 \
1638 font-isas-misc font-jis-misc font-misc-misc font-mutt-misc \ 1647 font-isas-misc font-jis-misc font-misc-misc font-mutt-misc \
1639 font-sony-misc font-util ttf-bitstream-vera encodings 1648 font-sony-misc font-util ttf-bitstream-vera encodings
1640X11SRCDIR.${_dir}?= ${X11SRCDIRMIT}/${_dir}/dist 1649X11SRCDIR.${_dir}?= ${X11SRCDIRMIT}/${_dir}/dist
1641.endfor 1650.endfor
1642 1651
1643# X11SRCDIR.Mesa points to the currently used Mesa sources 1652# X11SRCDIR.Mesa points to the currently used Mesa sources
1644X11SRCDIR.Mesa?= ${X11SRCDIRMIT}/${EXTERNAL_MESALIB_DIR}/dist 1653X11SRCDIR.Mesa?= ${X11SRCDIRMIT}/${EXTERNAL_MESALIB_DIR}/dist
1645 1654
1646.for _i in \ 1655.for _i in \
1647 elographics keyboard mouse synaptics vmmouse void ws 1656 elographics keyboard mouse synaptics vmmouse void ws
1648X11SRCDIR.xf86-input-${_i}?= ${X11SRCDIRMIT}/xf86-input-${_i}/dist 1657X11SRCDIR.xf86-input-${_i}?= ${X11SRCDIRMIT}/xf86-input-${_i}/dist
1649.endfor 1658.endfor
1650 1659
1651# xf86-video-modesetting move into the server build. 1660# xf86-video-modesetting move into the server build.
1652EXTRA_DRIVERS= 1661EXTRA_DRIVERS=
1653.if ${HAVE_XORG_SERVER_VER} == "120" 1662.if ${HAVE_XORG_SERVER_VER} == "120"
1654X11SRCDIR.xf86-video-modesetting=${X11SRCDIR.xorg-server}/hw/xfree86/drivers/modesetting 1663X11SRCDIR.xf86-video-modesetting=${X11SRCDIR.xorg-server}/hw/xfree86/drivers/modesetting
1655.else 1664.else
1656EXTRA_DRIVERS= modesetting 1665EXTRA_DRIVERS= modesetting
1657.endif 1666.endif
1658 1667
1659.for _v in \ 1668.for _v in \
1660 ag10e amdgpu apm ark ast ati ati-kms chips cirrus crime \ 1669 ag10e amdgpu apm ark ast ati ati-kms chips cirrus crime \
1661 geode glint i128 i740 igs imstt intel intel-old intel-2014 \ 1670 geode glint i128 i740 igs imstt intel intel-old intel-2014 \
1662 ${EXTRA_DRIVERS} mach64 mga \ 1671 ${EXTRA_DRIVERS} mach64 mga \
1663 neomagic newport nouveau nsc nv openchrome pnozz \ 1672 neomagic newport nouveau nsc nv openchrome pnozz \
1664 r128 rendition \ 1673 r128 rendition \
1665 s3 s3virge savage siliconmotion sis suncg14 \ 1674 s3 s3virge savage siliconmotion sis suncg14 \
1666 suncg6 sunffb sunleo suntcx \ 1675 suncg6 sunffb sunleo suntcx \
1667 tdfx tga trident tseng vboxvideo vesa vga vmware wsfb xgi 1676 tdfx tga trident tseng vboxvideo vesa vga vmware wsfb xgi
1668X11SRCDIR.xf86-video-${_v}?= ${X11SRCDIRMIT}/xf86-video-${_v}/dist 1677X11SRCDIR.xf86-video-${_v}?= ${X11SRCDIRMIT}/xf86-video-${_v}/dist
1669.endfor 1678.endfor
1670 1679
1671 1680
1672X11DRI?= yes 1681X11DRI?= yes
1673X11LOADABLE?= yes 1682X11LOADABLE?= yes
1674 1683
1675 1684
1676# 1685#
1677# MAKEDIRTARGET dir target [extra make(1) params] 1686# MAKEDIRTARGET dir target [extra make(1) params]
1678# run "cd $${dir} && ${MAKEDIRTARGETENV} ${MAKE} [params] $${target}", with a pretty message 1687# run "cd $${dir} && ${MAKEDIRTARGETENV} ${MAKE} [params] $${target}", with a pretty message
1679# 1688#
1680MAKEDIRTARGETENV?= 1689MAKEDIRTARGETENV?=
1681MAKEDIRTARGET=\ 1690MAKEDIRTARGET=\
1682 @_makedirtarget() { \ 1691 @_makedirtarget() { \
1683 dir="$$1"; shift; \ 1692 dir="$$1"; shift; \
1684 target="$$1"; shift; \ 1693 target="$$1"; shift; \
1685 case "$${dir}" in \ 1694 case "$${dir}" in \
1686 /*) this="$${dir}/"; \ 1695 /*) this="$${dir}/"; \
1687 real="$${dir}" ;; \ 1696 real="$${dir}" ;; \
1688 .) this="${_THISDIR_}"; \ 1697 .) this="${_THISDIR_}"; \
1689 real="${.CURDIR}" ;; \ 1698 real="${.CURDIR}" ;; \
1690 *) this="${_THISDIR_}$${dir}/"; \ 1699 *) this="${_THISDIR_}$${dir}/"; \
1691 real="${.CURDIR}/$${dir}" ;; \ 1700 real="${.CURDIR}/$${dir}" ;; \
1692 esac; \ 1701 esac; \
1693 show=$${this:-.}; \ 1702 show=$${this:-.}; \
1694 echo "$${target} ===> $${show%/}$${1:+ (with: $$@)}"; \ 1703 echo "$${target} ===> $${show%/}$${1:+ (with: $$@)}"; \
1695 cd "$${real}" \ 1704 cd "$${real}" \
1696 && ${MAKEDIRTARGETENV} ${MAKE} _THISDIR_="$${this}" "$$@" $${target}; \ 1705 && ${MAKEDIRTARGETENV} ${MAKE} _THISDIR_="$${this}" "$$@" $${target}; \
1697 }; \ 1706 }; \
1698 _makedirtarget 1707 _makedirtarget
1699 1708
1700# 1709#
1701# MAKEVERBOSE support. Levels are: 1710# MAKEVERBOSE support. Levels are:
1702# 0 Minimal output ("quiet") 1711# 0 Minimal output ("quiet")
1703# 1 Describe what is occurring 1712# 1 Describe what is occurring
1704# 2 Describe what is occurring and echo the actual command 1713# 2 Describe what is occurring and echo the actual command
1705# 3 Ignore the effect of the "@" prefix in make commands 1714# 3 Ignore the effect of the "@" prefix in make commands
1706# 4 Trace shell commands using the shell's -x flag 1715# 4 Trace shell commands using the shell's -x flag
1707# 1716#
1708MAKEVERBOSE?= 2 1717MAKEVERBOSE?= 2
1709 1718
1710.if ${MAKEVERBOSE} == 0 1719.if ${MAKEVERBOSE} == 0
1711_MKMSG?= @\# 1720_MKMSG?= @\#
1712_MKSHMSG?= : echo 1721_MKSHMSG?= : echo
1713_MKSHECHO?= : echo 1722_MKSHECHO?= : echo
1714.SILENT: 1723.SILENT:
1715.elif ${MAKEVERBOSE} == 1 1724.elif ${MAKEVERBOSE} == 1
1716_MKMSG?= @echo ' ' 1725_MKMSG?= @echo ' '
1717_MKSHMSG?= echo ' ' 1726_MKSHMSG?= echo ' '
1718_MKSHECHO?= : echo 1727_MKSHECHO?= : echo
1719.SILENT: 1728.SILENT:
1720.else # MAKEVERBOSE >= 2 1729.else # MAKEVERBOSE >= 2
1721_MKMSG?= @echo '\# ' 1730_MKMSG?= @echo '\# '
1722_MKSHMSG?= echo '\# ' 1731_MKSHMSG?= echo '\# '
1723_MKSHECHO?= echo 1732_MKSHECHO?= echo
1724.SILENT: __makeverbose_dummy_target__ 1733.SILENT: __makeverbose_dummy_target__
1725.endif # MAKEVERBOSE >= 2 1734.endif # MAKEVERBOSE >= 2
1726.if ${MAKEVERBOSE} >= 3 1735.if ${MAKEVERBOSE} >= 3
1727.MAKEFLAGS: -dl 1736.MAKEFLAGS: -dl
1728.endif # ${MAKEVERBOSE} >= 3 1737.endif # ${MAKEVERBOSE} >= 3
1729.if ${MAKEVERBOSE} >= 4 1738.if ${MAKEVERBOSE} >= 4
1730.MAKEFLAGS: -dx 1739.MAKEFLAGS: -dx
1731.endif # ${MAKEVERBOSE} >= 4 1740.endif # ${MAKEVERBOSE} >= 4
1732 1741
1733_MKMSG_BUILD?= ${_MKMSG} " build " 1742_MKMSG_BUILD?= ${_MKMSG} " build "
1734_MKMSG_CREATE?= ${_MKMSG} " create " 1743_MKMSG_CREATE?= ${_MKMSG} " create "
1735_MKMSG_COMPILE?= ${_MKMSG} "compile " 1744_MKMSG_COMPILE?= ${_MKMSG} "compile "
1736_MKMSG_FORMAT?= ${_MKMSG} " format " 1745_MKMSG_FORMAT?= ${_MKMSG} " format "
1737_MKMSG_INSTALL?= ${_MKMSG} "install " 1746_MKMSG_INSTALL?= ${_MKMSG} "install "
1738_MKMSG_LINK?= ${_MKMSG} " link " 1747_MKMSG_LINK?= ${_MKMSG} " link "
1739_MKMSG_LEX?= ${_MKMSG} " lex " 1748_MKMSG_LEX?= ${_MKMSG} " lex "
1740_MKMSG_REMOVE?= ${_MKMSG} " remove " 1749_MKMSG_REMOVE?= ${_MKMSG} " remove "
1741_MKMSG_YACC?= ${_MKMSG} " yacc " 1750_MKMSG_YACC?= ${_MKMSG} " yacc "
1742 1751
1743_MKSHMSG_CREATE?= ${_MKSHMSG} " create " 1752_MKSHMSG_CREATE?= ${_MKSHMSG} " create "
1744_MKSHMSG_INSTALL?= ${_MKSHMSG} "install " 1753_MKSHMSG_INSTALL?= ${_MKSHMSG} "install "
1745 1754
1746_MKTARGET_BUILD?= ${_MKMSG_BUILD} ${.CURDIR:T}/${.TARGET} 1755_MKTARGET_BUILD?= ${_MKMSG_BUILD} ${.CURDIR:T}/${.TARGET}
1747_MKTARGET_CREATE?= ${_MKMSG_CREATE} ${.CURDIR:T}/${.TARGET} 1756_MKTARGET_CREATE?= ${_MKMSG_CREATE} ${.CURDIR:T}/${.TARGET}
1748_MKTARGET_COMPILE?= ${_MKMSG_COMPILE} ${.CURDIR:T}/${.TARGET} 1757_MKTARGET_COMPILE?= ${_MKMSG_COMPILE} ${.CURDIR:T}/${.TARGET}
1749_MKTARGET_FORMAT?= ${_MKMSG_FORMAT} ${.CURDIR:T}/${.TARGET} 1758_MKTARGET_FORMAT?= ${_MKMSG_FORMAT} ${.CURDIR:T}/${.TARGET}
1750_MKTARGET_INSTALL?= ${_MKMSG_INSTALL} ${.TARGET} 1759_MKTARGET_INSTALL?= ${_MKMSG_INSTALL} ${.TARGET}
1751_MKTARGET_LINK?= ${_MKMSG_LINK} ${.CURDIR:T}/${.TARGET} 1760_MKTARGET_LINK?= ${_MKMSG_LINK} ${.CURDIR:T}/${.TARGET}
1752_MKTARGET_LEX?= ${_MKMSG_LEX} ${.CURDIR:T}/${.TARGET} 1761_MKTARGET_LEX?= ${_MKMSG_LEX} ${.CURDIR:T}/${.TARGET}
1753_MKTARGET_REMOVE?= ${_MKMSG_REMOVE} ${.TARGET} 1762_MKTARGET_REMOVE?= ${_MKMSG_REMOVE} ${.TARGET}
1754_MKTARGET_YACC?= ${_MKMSG_YACC} ${.CURDIR:T}/${.TARGET} 1763_MKTARGET_YACC?= ${_MKMSG_YACC} ${.CURDIR:T}/${.TARGET}
1755 1764
1756.if ${MKMANDOC} == "yes" 1765.if ${MKMANDOC} == "yes"
1757TARGETS+= lintmanpages 1766TARGETS+= lintmanpages
1758.endif 1767.endif
1759 1768
1760TESTSBASE= /usr/tests${MLIBDIR:D/${MLIBDIR}} 1769TESTSBASE= /usr/tests${MLIBDIR:D/${MLIBDIR}}
1761 1770
1762# Override with tools versions if needed 1771# Override with tools versions if needed
1763.if ${MKCTF:Uno} != "no" && !defined(NOCTF) && \ 1772.if ${MKCTF:Uno} != "no" && !defined(NOCTF) && \
1764 (exists(${TOOL_CTFCONVERT}) || exists(/usr/bin/${TOOL_CTFCONVERT})) 1773 (exists(${TOOL_CTFCONVERT}) || exists(/usr/bin/${TOOL_CTFCONVERT}))
1765CTFCONVERT= ${TOOL_CTFCONVERT} 1774CTFCONVERT= ${TOOL_CTFCONVERT}
1766CTFMERGE= ${TOOL_CTFMERGE} 1775CTFMERGE= ${TOOL_CTFMERGE}
1767.endif 1776.endif
1768 1777
1769.endif # !defined(_BSD_OWN_MK_) 1778.endif # !defined(_BSD_OWN_MK_)

cvs diff -r1.3 -r1.3.18.1 src/sys/arch/aarch64/include/sljit_machdep.h (switch to unified diff)

--- src/sys/arch/aarch64/include/sljit_machdep.h 2020/12/11 18:03:33 1.3
+++ src/sys/arch/aarch64/include/sljit_machdep.h 2024/04/18 15:21:55 1.3.18.1
@@ -1,54 +1,59 @@ @@ -1,54 +1,59 @@
1/* $NetBSD: sljit_machdep.h,v 1.3 2020/12/11 18:03:33 skrll Exp $ */ 1/* $NetBSD: sljit_machdep.h,v 1.3.18.1 2024/04/18 15:21:55 martin Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2014 Alexander Nasonov. 4 * Copyright (c) 2014 Alexander Nasonov.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#ifndef _AARCH64_SLJITARCH_H 29#ifndef _AARCH64_SLJITARCH_H
30#define _AARCH64_SLJITARCH_H 30#define _AARCH64_SLJITARCH_H
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33 33
34#ifdef _KERNEL 34#ifdef _KERNEL
35#include <machine/types.h> 35#include <machine/types.h>
36 36
37#include <arm/cpufunc.h> 37#include <arm/cpufunc.h>
38#else 38#else
39#include <stddef.h> 39#include <stddef.h>
40#include <stdint.h> 40#include <stdint.h>
41#include <aarch64/sysarch.h> 41#include <aarch64/sysarch.h>
42#endif 42#endif
43 43
44#define SLJIT_CONFIG_ARM_64 1 44#define SLJIT_CONFIG_ARM_64 1
45 45
46#ifdef _KERNEL 46#ifdef _HARDKERNEL
 47/*
 48 * XXX Currently sys/rump/include/machine/cpu.h doesn't have
 49 * ci_cpufuncs for cpu_icache_sync_range, so we do this only for
 50 * non-rump kernels for now.
 51 */
47#define SLJIT_CACHE_FLUSH(from, to) \ 52#define SLJIT_CACHE_FLUSH(from, to) \
48 cpu_icache_sync_range((vaddr_t)(from), (vsize_t)((to) - (from))) 53 cpu_icache_sync_range((vaddr_t)(from), (vsize_t)((to) - (from)))
49#else 54#else
50#define SLJIT_CACHE_FLUSH(from, to) \ 55#define SLJIT_CACHE_FLUSH(from, to) \
51 (void)__builtin___clear_cache((char *)(from), (char *)(to)) 56 (void)__builtin___clear_cache((char *)(from), (char *)(to))
52#endif 57#endif
53 58
54#endif 59#endif

cvs diff -r1.4 -r1.4.30.1 src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c (switch to unified diff)

--- src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c 2019/01/20 23:14:16 1.4
+++ src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c 2024/04/18 15:21:55 1.4.30.1
@@ -1,2056 +1,2060 @@ @@ -1,2056 +1,2060 @@
1/* $NetBSD: sljitNativeARM_64.c,v 1.4 2019/01/20 23:14:16 alnsn Exp $ */ 1/* $NetBSD: sljitNativeARM_64.c,v 1.4.30.1 2024/04/18 15:21:55 martin Exp $ */
2 2
3/* 3/*
4 * Stack-less Just-In-Time compiler 4 * Stack-less Just-In-Time compiler
5 * 5 *
6 * Copyright Zoltan Herczeg (hzmester@freemail.hu). All rights reserved. 6 * Copyright Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without modification, are 8 * Redistribution and use in source and binary forms, with or without modification, are
9 * permitted provided that the following conditions are met: 9 * permitted provided that the following conditions are met:
10 * 10 *
11 * 1. Redistributions of source code must retain the above copyright notice, this list of 11 * 1. Redistributions of source code must retain the above copyright notice, this list of
12 * conditions and the following disclaimer. 12 * conditions and the following disclaimer.
13 * 13 *
14 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 14 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
15 * of conditions and the following disclaimer in the documentation and/or other materials 15 * of conditions and the following disclaimer in the documentation and/or other materials
16 * provided with the distribution. 16 * provided with the distribution.
17 * 17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
21 * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
23 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29SLJIT_API_FUNC_ATTRIBUTE const char* sljit_get_platform_name(void) 29SLJIT_API_FUNC_ATTRIBUTE const char* sljit_get_platform_name(void)
30{ 30{
31 return "ARM-64" SLJIT_CPUINFO; 31 return "ARM-64" SLJIT_CPUINFO;
32} 32}
33 33
34/* Length of an instruction word */ 34/* Length of an instruction word */
35typedef sljit_u32 sljit_ins; 35typedef sljit_u32 sljit_ins;
36 36
37#define TMP_ZERO (0) 37#define TMP_ZERO (0)
38 38
39#define TMP_REG1 (SLJIT_NUMBER_OF_REGISTERS + 2) 39#define TMP_REG1 (SLJIT_NUMBER_OF_REGISTERS + 2)
40#define TMP_REG2 (SLJIT_NUMBER_OF_REGISTERS + 3) 40#define TMP_REG2 (SLJIT_NUMBER_OF_REGISTERS + 3)
41#define TMP_REG3 (SLJIT_NUMBER_OF_REGISTERS + 4) 41#define TMP_REG3 (SLJIT_NUMBER_OF_REGISTERS + 4)
42#define TMP_LR (SLJIT_NUMBER_OF_REGISTERS + 5) 42#define TMP_LR (SLJIT_NUMBER_OF_REGISTERS + 5)
43#define TMP_SP (SLJIT_NUMBER_OF_REGISTERS + 6) 43#define TMP_SP (SLJIT_NUMBER_OF_REGISTERS + 6)
44 44
45#define TMP_FREG1 (0) 45#define TMP_FREG1 (0)
46#define TMP_FREG2 (SLJIT_NUMBER_OF_FLOAT_REGISTERS + 1) 46#define TMP_FREG2 (SLJIT_NUMBER_OF_FLOAT_REGISTERS + 1)
47 47
48static const sljit_u8 reg_map[SLJIT_NUMBER_OF_REGISTERS + 8] = { 48static const sljit_u8 reg_map[SLJIT_NUMBER_OF_REGISTERS + 8] = {
49 31, 0, 1, 2, 3, 4, 5, 6, 7, 12, 13, 14, 15, 16, 17, 8, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 29, 9, 10, 11, 30, 31 49 31, 0, 1, 2, 3, 4, 5, 6, 7, 12, 13, 14, 15, 16, 17, 8, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 29, 9, 10, 11, 30, 31
50}; 50};
51 51
52#define W_OP (1 << 31) 52#define W_OP (1 << 31)
53#define RD(rd) (reg_map[rd]) 53#define RD(rd) (reg_map[rd])
54#define RT(rt) (reg_map[rt]) 54#define RT(rt) (reg_map[rt])
55#define RN(rn) (reg_map[rn] << 5) 55#define RN(rn) (reg_map[rn] << 5)
56#define RT2(rt2) (reg_map[rt2] << 10) 56#define RT2(rt2) (reg_map[rt2] << 10)
57#define RM(rm) (reg_map[rm] << 16) 57#define RM(rm) (reg_map[rm] << 16)
58#define VD(vd) (vd) 58#define VD(vd) (vd)
59#define VT(vt) (vt) 59#define VT(vt) (vt)
60#define VN(vn) ((vn) << 5) 60#define VN(vn) ((vn) << 5)
61#define VM(vm) ((vm) << 16) 61#define VM(vm) ((vm) << 16)
62 62
63/* --------------------------------------------------------------------- */ 63/* --------------------------------------------------------------------- */
64/* Instrucion forms */ 64/* Instrucion forms */
65/* --------------------------------------------------------------------- */ 65/* --------------------------------------------------------------------- */
66 66
67#define ADC 0x9a000000 67#define ADC 0x9a000000
68#define ADD 0x8b000000 68#define ADD 0x8b000000
69#define ADDI 0x91000000 69#define ADDI 0x91000000
70#define AND 0x8a000000 70#define AND 0x8a000000
71#define ANDI 0x92000000 71#define ANDI 0x92000000
72#define ASRV 0x9ac02800 72#define ASRV 0x9ac02800
73#define B 0x14000000 73#define B 0x14000000
74#define B_CC 0x54000000 74#define B_CC 0x54000000
75#define BL 0x94000000 75#define BL 0x94000000
76#define BLR 0xd63f0000 76#define BLR 0xd63f0000
77#define BR 0xd61f0000 77#define BR 0xd61f0000
78#define BRK 0xd4200000 78#define BRK 0xd4200000
79#define CBZ 0xb4000000 79#define CBZ 0xb4000000
80#define CLZ 0xdac01000 80#define CLZ 0xdac01000
81#define CSINC 0x9a800400 81#define CSINC 0x9a800400
82#define EOR 0xca000000 82#define EOR 0xca000000
83#define EORI 0xd2000000 83#define EORI 0xd2000000
84#define FABS 0x1e60c000 84#define FABS 0x1e60c000
85#define FADD 0x1e602800 85#define FADD 0x1e602800
86#define FCMP 0x1e602000 86#define FCMP 0x1e602000
87#define FCVT 0x1e224000 87#define FCVT 0x1e224000
88#define FCVTZS 0x9e780000 88#define FCVTZS 0x9e780000
89#define FDIV 0x1e601800 89#define FDIV 0x1e601800
90#define FMOV 0x1e604000 90#define FMOV 0x1e604000
91#define FMUL 0x1e600800 91#define FMUL 0x1e600800
92#define FNEG 0x1e614000 92#define FNEG 0x1e614000
93#define FSUB 0x1e603800 93#define FSUB 0x1e603800
94#define LDRI 0xf9400000 94#define LDRI 0xf9400000
95#define LDP 0xa9400000 95#define LDP 0xa9400000
96#define LDP_PST 0xa8c00000 96#define LDP_PST 0xa8c00000
97#define LSLV 0x9ac02000 97#define LSLV 0x9ac02000
98#define LSRV 0x9ac02400 98#define LSRV 0x9ac02400
99#define MADD 0x9b000000 99#define MADD 0x9b000000
100#define MOVK 0xf2800000 100#define MOVK 0xf2800000
101#define MOVN 0x92800000 101#define MOVN 0x92800000
102#define MOVZ 0xd2800000 102#define MOVZ 0xd2800000
103#define NOP 0xd503201f 103#define NOP 0xd503201f
104#define ORN 0xaa200000 104#define ORN 0xaa200000
105#define ORR 0xaa000000 105#define ORR 0xaa000000
106#define ORRI 0xb2000000 106#define ORRI 0xb2000000
107#define RET 0xd65f0000 107#define RET 0xd65f0000
108#define SBC 0xda000000 108#define SBC 0xda000000
109#define SBFM 0x93000000 109#define SBFM 0x93000000
110#define SCVTF 0x9e620000 110#define SCVTF 0x9e620000
111#define SDIV 0x9ac00c00 111#define SDIV 0x9ac00c00
112#define SMADDL 0x9b200000 112#define SMADDL 0x9b200000
113#define SMULH 0x9b403c00 113#define SMULH 0x9b403c00
114#define STP 0xa9000000 114#define STP 0xa9000000
115#define STP_PRE 0xa9800000 115#define STP_PRE 0xa9800000
116#define STRI 0xf9000000 116#define STRI 0xf9000000
117#define STR_FI 0x3d000000 117#define STR_FI 0x3d000000
118#define STR_FR 0x3c206800 118#define STR_FR 0x3c206800
119#define STUR_FI 0x3c000000 119#define STUR_FI 0x3c000000
120#define SUB 0xcb000000 120#define SUB 0xcb000000
121#define SUBI 0xd1000000 121#define SUBI 0xd1000000
122#define SUBS 0xeb000000 122#define SUBS 0xeb000000
123#define UBFM 0xd3000000 123#define UBFM 0xd3000000
124#define UDIV 0x9ac00800 124#define UDIV 0x9ac00800
125#define UMULH 0x9bc03c00 125#define UMULH 0x9bc03c00
126 126
127/* dest_reg is the absolute name of the register 127/* dest_reg is the absolute name of the register
128 Useful for reordering instructions in the delay slot. */ 128 Useful for reordering instructions in the delay slot. */
129static sljit_s32 push_inst(struct sljit_compiler *compiler, sljit_ins ins) 129static sljit_s32 push_inst(struct sljit_compiler *compiler, sljit_ins ins)
130{ 130{
131 sljit_ins *ptr = (sljit_ins*)ensure_buf(compiler, sizeof(sljit_ins)); 131 sljit_ins *ptr = (sljit_ins*)ensure_buf(compiler, sizeof(sljit_ins));
132 FAIL_IF(!ptr); 132 FAIL_IF(!ptr);
133 *ptr = ins; 133 *ptr = ins;
134 compiler->size++; 134 compiler->size++;
135 return SLJIT_SUCCESS; 135 return SLJIT_SUCCESS;
136} 136}
137 137
138static SLJIT_INLINE sljit_s32 emit_imm64_const(struct sljit_compiler *compiler, sljit_s32 dst, sljit_uw imm) 138static SLJIT_INLINE sljit_s32 emit_imm64_const(struct sljit_compiler *compiler, sljit_s32 dst, sljit_uw imm)
139{ 139{
140 FAIL_IF(push_inst(compiler, MOVZ | RD(dst) | ((imm & 0xffff) << 5))); 140 FAIL_IF(push_inst(compiler, MOVZ | RD(dst) | ((imm & 0xffff) << 5)));
141 FAIL_IF(push_inst(compiler, MOVK | RD(dst) | (((imm >> 16) & 0xffff) << 5) | (1 << 21))); 141 FAIL_IF(push_inst(compiler, MOVK | RD(dst) | (((imm >> 16) & 0xffff) << 5) | (1 << 21)));
142 FAIL_IF(push_inst(compiler, MOVK | RD(dst) | (((imm >> 32) & 0xffff) << 5) | (2 << 21))); 142 FAIL_IF(push_inst(compiler, MOVK | RD(dst) | (((imm >> 32) & 0xffff) << 5) | (2 << 21)));
143 return push_inst(compiler, MOVK | RD(dst) | ((imm >> 48) << 5) | (3 << 21)); 143 return push_inst(compiler, MOVK | RD(dst) | ((imm >> 48) << 5) | (3 << 21));
144} 144}
145 145
146static SLJIT_INLINE void modify_imm64_const(sljit_ins* inst, sljit_uw new_imm) 146static SLJIT_INLINE void modify_imm64_const(sljit_ins* inst, sljit_uw new_imm)
147{ 147{
148 sljit_s32 dst = inst[0] & 0x1f; 148 sljit_s32 dst = inst[0] & 0x1f;
149 SLJIT_ASSERT((inst[0] & 0xffe00000) == MOVZ && (inst[1] & 0xffe00000) == (MOVK | (1 << 21))); 149 SLJIT_ASSERT((inst[0] & 0xffe00000) == MOVZ && (inst[1] & 0xffe00000) == (MOVK | (1 << 21)));
150 inst[0] = MOVZ | dst | ((new_imm & 0xffff) << 5); 150 inst[0] = MOVZ | dst | ((new_imm & 0xffff) << 5);
151 inst[1] = MOVK | dst | (((new_imm >> 16) & 0xffff) << 5) | (1 << 21); 151 inst[1] = MOVK | dst | (((new_imm >> 16) & 0xffff) << 5) | (1 << 21);
152 inst[2] = MOVK | dst | (((new_imm >> 32) & 0xffff) << 5) | (2 << 21); 152 inst[2] = MOVK | dst | (((new_imm >> 32) & 0xffff) << 5) | (2 << 21);
153 inst[3] = MOVK | dst | ((new_imm >> 48) << 5) | (3 << 21); 153 inst[3] = MOVK | dst | ((new_imm >> 48) << 5) | (3 << 21);
154} 154}
155 155
156static SLJIT_INLINE sljit_s32 detect_jump_type(struct sljit_jump *jump, sljit_ins *code_ptr, sljit_ins *code, sljit_sw executable_offset) 156static SLJIT_INLINE sljit_s32 detect_jump_type(struct sljit_jump *jump, sljit_ins *code_ptr, sljit_ins *code, sljit_sw executable_offset)
157{ 157{
158 sljit_sw diff; 158 sljit_sw diff;
159 sljit_uw target_addr; 159 sljit_uw target_addr;
160 160
161 if (jump->flags & SLJIT_REWRITABLE_JUMP) { 161 if (jump->flags & SLJIT_REWRITABLE_JUMP) {
162 jump->flags |= PATCH_ABS64; 162 jump->flags |= PATCH_ABS64;
163 return 0; 163 return 0;
164 } 164 }
165 165
166 if (jump->flags & JUMP_ADDR) 166 if (jump->flags & JUMP_ADDR)
167 target_addr = jump->u.target; 167 target_addr = jump->u.target;
168 else { 168 else {
169 SLJIT_ASSERT(jump->flags & JUMP_LABEL); 169 SLJIT_ASSERT(jump->flags & JUMP_LABEL);
170 target_addr = (sljit_uw)(code + jump->u.label->size) + (sljit_uw)executable_offset; 170 target_addr = (sljit_uw)(code + jump->u.label->size) + (sljit_uw)executable_offset;
171 } 171 }
172 172
173 diff = (sljit_sw)target_addr - (sljit_sw)(code_ptr + 4) - executable_offset; 173 diff = (sljit_sw)target_addr - (sljit_sw)(code_ptr + 4) - executable_offset;
174 174
175 if (jump->flags & IS_COND) { 175 if (jump->flags & IS_COND) {
176 diff += sizeof(sljit_ins); 176 diff += sizeof(sljit_ins);
177 if (diff <= 0xfffff && diff >= -0x100000) { 177 if (diff <= 0xfffff && diff >= -0x100000) {
178 code_ptr[-5] ^= (jump->flags & IS_CBZ) ? (0x1 << 24) : 0x1; 178 code_ptr[-5] ^= (jump->flags & IS_CBZ) ? (0x1 << 24) : 0x1;
179 jump->addr -= sizeof(sljit_ins); 179 jump->addr -= sizeof(sljit_ins);
180 jump->flags |= PATCH_COND; 180 jump->flags |= PATCH_COND;
181 return 5; 181 return 5;
182 } 182 }
183 diff -= sizeof(sljit_ins); 183 diff -= sizeof(sljit_ins);
184 } 184 }
185 185
186 if (diff <= 0x7ffffff && diff >= -0x8000000) { 186 if (diff <= 0x7ffffff && diff >= -0x8000000) {
187 jump->flags |= PATCH_B; 187 jump->flags |= PATCH_B;
188 return 4; 188 return 4;
189 } 189 }
190 190
191 if (target_addr <= 0xffffffffl) { 191 if (target_addr <= 0xffffffffl) {
192 if (jump->flags & IS_COND) 192 if (jump->flags & IS_COND)
193 code_ptr[-5] -= (2 << 5); 193 code_ptr[-5] -= (2 << 5);
194 code_ptr[-2] = code_ptr[0]; 194 code_ptr[-2] = code_ptr[0];
195 return 2; 195 return 2;
196 } 196 }
197 if (target_addr <= 0xffffffffffffl) { 197 if (target_addr <= 0xffffffffffffl) {
198 if (jump->flags & IS_COND) 198 if (jump->flags & IS_COND)
199 code_ptr[-5] -= (1 << 5); 199 code_ptr[-5] -= (1 << 5);
200 jump->flags |= PATCH_ABS48; 200 jump->flags |= PATCH_ABS48;
201 code_ptr[-1] = code_ptr[0]; 201 code_ptr[-1] = code_ptr[0];
202 return 1; 202 return 1;
203 } 203 }
204 204
205 jump->flags |= PATCH_ABS64; 205 jump->flags |= PATCH_ABS64;
206 return 0; 206 return 0;
207} 207}
208 208
209SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) 209SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler)
210{ 210{
211 struct sljit_memory_fragment *buf; 211 struct sljit_memory_fragment *buf;
212 sljit_ins *code; 212 sljit_ins *code;
213 sljit_ins *code_ptr; 213 sljit_ins *code_ptr;
214 sljit_ins *buf_ptr; 214 sljit_ins *buf_ptr;
215 sljit_ins *buf_end; 215 sljit_ins *buf_end;
216 sljit_uw word_count; 216 sljit_uw word_count;
217 sljit_sw executable_offset; 217 sljit_sw executable_offset;
218 sljit_uw addr; 218 sljit_uw addr;
219 sljit_s32 dst; 219 sljit_s32 dst;
220 220
221 struct sljit_label *label; 221 struct sljit_label *label;
222 struct sljit_jump *jump; 222 struct sljit_jump *jump;
223 struct sljit_const *const_; 223 struct sljit_const *const_;
224 224
225 CHECK_ERROR_PTR(); 225 CHECK_ERROR_PTR();
226 CHECK_PTR(check_sljit_generate_code(compiler)); 226 CHECK_PTR(check_sljit_generate_code(compiler));
227 reverse_buf(compiler); 227 reverse_buf(compiler);
228 228
229 code = (sljit_ins*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins)); 229 code = (sljit_ins*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins));
230 PTR_FAIL_WITH_EXEC_IF(code); 230 PTR_FAIL_WITH_EXEC_IF(code);
231 buf = compiler->buf; 231 buf = compiler->buf;
232 232
233 code_ptr = code; 233 code_ptr = code;
234 word_count = 0; 234 word_count = 0;
235 executable_offset = SLJIT_EXEC_OFFSET(code); 235 executable_offset = SLJIT_EXEC_OFFSET(code);
236 236
237 label = compiler->labels; 237 label = compiler->labels;
238 jump = compiler->jumps; 238 jump = compiler->jumps;
239 const_ = compiler->consts; 239 const_ = compiler->consts;
240 240
241 do { 241 do {
242 buf_ptr = (sljit_ins*)buf->memory; 242 buf_ptr = (sljit_ins*)buf->memory;
243 buf_end = buf_ptr + (buf->used_size >> 2); 243 buf_end = buf_ptr + (buf->used_size >> 2);
244 do { 244 do {
245 *code_ptr = *buf_ptr++; 245 *code_ptr = *buf_ptr++;
246 /* These structures are ordered by their address. */ 246 /* These structures are ordered by their address. */
247 SLJIT_ASSERT(!label || label->size >= word_count); 247 SLJIT_ASSERT(!label || label->size >= word_count);
248 SLJIT_ASSERT(!jump || jump->addr >= word_count); 248 SLJIT_ASSERT(!jump || jump->addr >= word_count);
249 SLJIT_ASSERT(!const_ || const_->addr >= word_count); 249 SLJIT_ASSERT(!const_ || const_->addr >= word_count);
250 if (label && label->size == word_count) { 250 if (label && label->size == word_count) {
251 label->addr = (sljit_uw)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset); 251 label->addr = (sljit_uw)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset);
252 label->size = code_ptr - code; 252 label->size = code_ptr - code;
253 label = label->next; 253 label = label->next;
254 } 254 }
255 if (jump && jump->addr == word_count) { 255 if (jump && jump->addr == word_count) {
256 jump->addr = (sljit_uw)(code_ptr - 4); 256 jump->addr = (sljit_uw)(code_ptr - 4);
257 code_ptr -= detect_jump_type(jump, code_ptr, code, executable_offset); 257 code_ptr -= detect_jump_type(jump, code_ptr, code, executable_offset);
258 jump = jump->next; 258 jump = jump->next;
259 } 259 }
260 if (const_ && const_->addr == word_count) { 260 if (const_ && const_->addr == word_count) {
261 const_->addr = (sljit_uw)code_ptr; 261 const_->addr = (sljit_uw)code_ptr;
262 const_ = const_->next; 262 const_ = const_->next;
263 } 263 }
264 code_ptr ++; 264 code_ptr ++;
265 word_count ++; 265 word_count ++;
266 } while (buf_ptr < buf_end); 266 } while (buf_ptr < buf_end);
267 267
268 buf = buf->next; 268 buf = buf->next;
269 } while (buf); 269 } while (buf);
270 270
271 if (label && label->size == word_count) { 271 if (label && label->size == word_count) {
272 label->addr = (sljit_uw)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset); 272 label->addr = (sljit_uw)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset);
273 label->size = code_ptr - code; 273 label->size = code_ptr - code;
274 label = label->next; 274 label = label->next;
275 } 275 }
276 276
277 SLJIT_ASSERT(!label); 277 SLJIT_ASSERT(!label);
278 SLJIT_ASSERT(!jump); 278 SLJIT_ASSERT(!jump);
279 SLJIT_ASSERT(!const_); 279 SLJIT_ASSERT(!const_);
280 SLJIT_ASSERT(code_ptr - code <= (sljit_sw)compiler->size); 280 SLJIT_ASSERT(code_ptr - code <= (sljit_sw)compiler->size);
281 281
282 jump = compiler->jumps; 282 jump = compiler->jumps;
283 while (jump) { 283 while (jump) {
284 do { 284 do {
285 addr = (jump->flags & JUMP_LABEL) ? jump->u.label->addr : jump->u.target; 285 addr = (jump->flags & JUMP_LABEL) ? jump->u.label->addr : jump->u.target;
286 buf_ptr = (sljit_ins *)jump->addr; 286 buf_ptr = (sljit_ins *)jump->addr;
287 287
288 if (jump->flags & PATCH_B) { 288 if (jump->flags & PATCH_B) {
289 addr = (sljit_sw)(addr - (sljit_uw)SLJIT_ADD_EXEC_OFFSET(buf_ptr, executable_offset)) >> 2; 289 addr = (sljit_sw)(addr - (sljit_uw)SLJIT_ADD_EXEC_OFFSET(buf_ptr, executable_offset)) >> 2;
290 SLJIT_ASSERT((sljit_sw)addr <= 0x1ffffff && (sljit_sw)addr >= -0x2000000); 290 SLJIT_ASSERT((sljit_sw)addr <= 0x1ffffff && (sljit_sw)addr >= -0x2000000);
291 buf_ptr[0] = ((jump->flags & IS_BL) ? BL : B) | (addr & 0x3ffffff); 291 buf_ptr[0] = ((jump->flags & IS_BL) ? BL : B) | (addr & 0x3ffffff);
292 if (jump->flags & IS_COND) 292 if (jump->flags & IS_COND)
293 buf_ptr[-1] -= (4 << 5); 293 buf_ptr[-1] -= (4 << 5);
294 break; 294 break;
295 } 295 }
296 if (jump->flags & PATCH_COND) { 296 if (jump->flags & PATCH_COND) {
297 addr = (sljit_sw)(addr - (sljit_uw)SLJIT_ADD_EXEC_OFFSET(buf_ptr, executable_offset)) >> 2; 297 addr = (sljit_sw)(addr - (sljit_uw)SLJIT_ADD_EXEC_OFFSET(buf_ptr, executable_offset)) >> 2;
298 SLJIT_ASSERT((sljit_sw)addr <= 0x3ffff && (sljit_sw)addr >= -0x40000); 298 SLJIT_ASSERT((sljit_sw)addr <= 0x3ffff && (sljit_sw)addr >= -0x40000);
299 buf_ptr[0] = (buf_ptr[0] & ~0xffffe0) | ((addr & 0x7ffff) << 5); 299 buf_ptr[0] = (buf_ptr[0] & ~0xffffe0) | ((addr & 0x7ffff) << 5);
300 break; 300 break;
301 } 301 }
302 302
303 SLJIT_ASSERT((jump->flags & (PATCH_ABS48 | PATCH_ABS64)) || addr <= 0xffffffffl); 303 SLJIT_ASSERT((jump->flags & (PATCH_ABS48 | PATCH_ABS64)) || addr <= 0xffffffffl);
304 SLJIT_ASSERT((jump->flags & PATCH_ABS64) || addr <= 0xffffffffffffl); 304 SLJIT_ASSERT((jump->flags & PATCH_ABS64) || addr <= 0xffffffffffffl);
305 305
306 dst = buf_ptr[0] & 0x1f; 306 dst = buf_ptr[0] & 0x1f;
307 buf_ptr[0] = MOVZ | dst | ((addr & 0xffff) << 5); 307 buf_ptr[0] = MOVZ | dst | ((addr & 0xffff) << 5);
308 buf_ptr[1] = MOVK | dst | (((addr >> 16) & 0xffff) << 5) | (1 << 21); 308 buf_ptr[1] = MOVK | dst | (((addr >> 16) & 0xffff) << 5) | (1 << 21);
309 if (jump->flags & (PATCH_ABS48 | PATCH_ABS64)) 309 if (jump->flags & (PATCH_ABS48 | PATCH_ABS64))
310 buf_ptr[2] = MOVK | dst | (((addr >> 32) & 0xffff) << 5) | (2 << 21); 310 buf_ptr[2] = MOVK | dst | (((addr >> 32) & 0xffff) << 5) | (2 << 21);
311 if (jump->flags & PATCH_ABS64) 311 if (jump->flags & PATCH_ABS64)
312 buf_ptr[3] = MOVK | dst | (((addr >> 48) & 0xffff) << 5) | (3 << 21); 312 buf_ptr[3] = MOVK | dst | (((addr >> 48) & 0xffff) << 5) | (3 << 21);
313 } while (0); 313 } while (0);
314 jump = jump->next; 314 jump = jump->next;
315 } 315 }
316 316
317 compiler->error = SLJIT_ERR_COMPILED; 317 compiler->error = SLJIT_ERR_COMPILED;
318 compiler->executable_offset = executable_offset; 318 compiler->executable_offset = executable_offset;
319 compiler->executable_size = (code_ptr - code) * sizeof(sljit_ins); 319 compiler->executable_size = (code_ptr - code) * sizeof(sljit_ins);
320 320
321 code = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(code, executable_offset); 321 code = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(code, executable_offset);
322 code_ptr = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset); 322 code_ptr = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset);
323 323
324 SLJIT_CACHE_FLUSH(code, code_ptr); 324 SLJIT_CACHE_FLUSH(code, code_ptr);
325 return code; 325 return code;
326} 326}
327 327
328/* --------------------------------------------------------------------- */ 328/* --------------------------------------------------------------------- */
329/* Core code generator functions. */ 329/* Core code generator functions. */
330/* --------------------------------------------------------------------- */ 330/* --------------------------------------------------------------------- */
331 331
332#define COUNT_TRAILING_ZERO(value, result) \ 332#define COUNT_TRAILING_ZERO(value, result) \
333 result = 0; \ 333 result = 0; \
334 if (!(value & 0xffffffff)) { \ 334 if (!(value & 0xffffffff)) { \
335 result += 32; \ 335 result += 32; \
336 value >>= 32; \ 336 value >>= 32; \
337 } \ 337 } \
338 if (!(value & 0xffff)) { \ 338 if (!(value & 0xffff)) { \
339 result += 16; \ 339 result += 16; \
340 value >>= 16; \ 340 value >>= 16; \
341 } \ 341 } \
342 if (!(value & 0xff)) { \ 342 if (!(value & 0xff)) { \
343 result += 8; \ 343 result += 8; \
344 value >>= 8; \ 344 value >>= 8; \
345 } \ 345 } \
346 if (!(value & 0xf)) { \ 346 if (!(value & 0xf)) { \
347 result += 4; \ 347 result += 4; \
348 value >>= 4; \ 348 value >>= 4; \
349 } \ 349 } \
350 if (!(value & 0x3)) { \ 350 if (!(value & 0x3)) { \
351 result += 2; \ 351 result += 2; \
352 value >>= 2; \ 352 value >>= 2; \
353 } \ 353 } \
354 if (!(value & 0x1)) { \ 354 if (!(value & 0x1)) { \
355 result += 1; \ 355 result += 1; \
356 value >>= 1; \ 356 value >>= 1; \
357 } 357 }
358 358
359#define LOGICAL_IMM_CHECK 0x100 359#define LOGICAL_IMM_CHECK 0x100
360 360
361static sljit_ins logical_imm(sljit_sw imm, sljit_s32 len) 361static sljit_ins logical_imm(sljit_sw imm, sljit_s32 len)
362{ 362{
363 sljit_s32 negated, ones, right; 363 sljit_s32 negated, ones, right;
364 sljit_uw mask, uimm; 364 sljit_uw mask, uimm;
365 sljit_ins ins; 365 sljit_ins ins;
366 366
367 if (len & LOGICAL_IMM_CHECK) { 367 if (len & LOGICAL_IMM_CHECK) {
368 len &= ~LOGICAL_IMM_CHECK; 368 len &= ~LOGICAL_IMM_CHECK;
369 if (len == 32 && (imm == 0 || imm == -1)) 369 if (len == 32 && (imm == 0 || imm == -1))
370 return 0; 370 return 0;
371 if (len == 16 && ((sljit_s32)imm == 0 || (sljit_s32)imm == -1)) 371 if (len == 16 && ((sljit_s32)imm == 0 || (sljit_s32)imm == -1))
372 return 0; 372 return 0;
373 } 373 }
374 374
375 SLJIT_ASSERT((len == 32 && imm != 0 && imm != -1) 375 SLJIT_ASSERT((len == 32 && imm != 0 && imm != -1)
376 || (len == 16 && (sljit_s32)imm != 0 && (sljit_s32)imm != -1)); 376 || (len == 16 && (sljit_s32)imm != 0 && (sljit_s32)imm != -1));
377 uimm = (sljit_uw)imm; 377 uimm = (sljit_uw)imm;
378 while (1) { 378 while (1) {
379 if (len <= 0) { 379 if (len <= 0) {
380 SLJIT_UNREACHABLE(); 380 SLJIT_UNREACHABLE();
381 return 0; 381 return 0;
382 } 382 }
383 mask = ((sljit_uw)1 << len) - 1; 383 mask = ((sljit_uw)1 << len) - 1;
384 if ((uimm & mask) != ((uimm >> len) & mask)) 384 if ((uimm & mask) != ((uimm >> len) & mask))
385 break; 385 break;
386 len >>= 1; 386 len >>= 1;
387 } 387 }
388 388
389 len <<= 1; 389 len <<= 1;
390 390
391 negated = 0; 391 negated = 0;
392 if (uimm & 0x1) { 392 if (uimm & 0x1) {
393 negated = 1; 393 negated = 1;
394 uimm = ~uimm; 394 uimm = ~uimm;
395 } 395 }
396 396
397 if (len < 64) 397 if (len < 64)
398 uimm &= ((sljit_uw)1 << len) - 1; 398 uimm &= ((sljit_uw)1 << len) - 1;
399 399
400 /* Unsigned right shift. */ 400 /* Unsigned right shift. */
401 COUNT_TRAILING_ZERO(uimm, right); 401 COUNT_TRAILING_ZERO(uimm, right);
402 402
403 /* Signed shift. We also know that the highest bit is set. */ 403 /* Signed shift. We also know that the highest bit is set. */
404 imm = (sljit_sw)~uimm; 404 imm = (sljit_sw)~uimm;
405 SLJIT_ASSERT(imm < 0); 405 SLJIT_ASSERT(imm < 0);
406 406
407 COUNT_TRAILING_ZERO(imm, ones); 407 COUNT_TRAILING_ZERO(imm, ones);
408 408
409 if (~imm) 409 if (~imm)
410 return 0; 410 return 0;
411 411
412 if (len == 64) 412 if (len == 64)
413 ins = 1 << 22; 413 ins = 1 << 22;
414 else 414 else
415 ins = (0x3f - ((len << 1) - 1)) << 10; 415 ins = (0x3f - ((len << 1) - 1)) << 10;
416 416
417 if (negated) 417 if (negated)
418 return ins | ((len - ones - 1) << 10) | ((len - ones - right) << 16); 418 return ins | ((len - ones - 1) << 10) | ((len - ones - right) << 16);
419 419
420 return ins | ((ones - 1) << 10) | ((len - right) << 16); 420 return ins | ((ones - 1) << 10) | ((len - right) << 16);
421} 421}
422 422
423#undef COUNT_TRAILING_ZERO 423#undef COUNT_TRAILING_ZERO
424 424
425static sljit_s32 load_immediate(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw simm) 425static sljit_s32 load_immediate(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw simm)
426{ 426{
427 sljit_uw imm = (sljit_uw)simm; 427 sljit_uw imm = (sljit_uw)simm;
428 sljit_s32 i, zeros, ones, first; 428 sljit_s32 i, zeros, ones, first;
429 sljit_ins bitmask; 429 sljit_ins bitmask;
430 430
431 if (imm <= 0xffff) 431 if (imm <= 0xffff)
432 return push_inst(compiler, MOVZ | RD(dst) | (imm << 5)); 432 return push_inst(compiler, MOVZ | RD(dst) | (imm << 5));
433 433
434 if (simm >= -0x10000 && simm < 0) 434 if (simm >= -0x10000 && simm < 0)
435 return push_inst(compiler, MOVN | RD(dst) | ((~imm & 0xffff) << 5)); 435 return push_inst(compiler, MOVN | RD(dst) | ((~imm & 0xffff) << 5));
436 436
437 if (imm <= 0xffffffffl) { 437 if (imm <= 0xffffffffl) {
438 if ((imm & 0xffff0000l) == 0xffff0000) 438 if ((imm & 0xffff0000l) == 0xffff0000)
439 return push_inst(compiler, (MOVN ^ W_OP) | RD(dst) | ((~imm & 0xffff) << 5)); 439 return push_inst(compiler, (MOVN ^ W_OP) | RD(dst) | ((~imm & 0xffff) << 5));
440 if ((imm & 0xffff) == 0xffff) 440 if ((imm & 0xffff) == 0xffff)
441 return push_inst(compiler, (MOVN ^ W_OP) | RD(dst) | ((~imm & 0xffff0000l) >> (16 - 5)) | (1 << 21)); 441 return push_inst(compiler, (MOVN ^ W_OP) | RD(dst) | ((~imm & 0xffff0000l) >> (16 - 5)) | (1 << 21));
442 bitmask = logical_imm(simm, 16); 442 bitmask = logical_imm(simm, 16);
443 if (bitmask != 0) 443 if (bitmask != 0)
444 return push_inst(compiler, (ORRI ^ W_OP) | RD(dst) | RN(TMP_ZERO) | bitmask); 444 return push_inst(compiler, (ORRI ^ W_OP) | RD(dst) | RN(TMP_ZERO) | bitmask);
445 } 445 }
446 else { 446 else {
447 bitmask = logical_imm(simm, 32); 447 bitmask = logical_imm(simm, 32);
448 if (bitmask != 0) 448 if (bitmask != 0)
449 return push_inst(compiler, ORRI | RD(dst) | RN(TMP_ZERO) | bitmask); 449 return push_inst(compiler, ORRI | RD(dst) | RN(TMP_ZERO) | bitmask);
450 } 450 }
451 451
452 if (imm <= 0xffffffffl) { 452 if (imm <= 0xffffffffl) {
453 FAIL_IF(push_inst(compiler, MOVZ | RD(dst) | ((imm & 0xffff) << 5))); 453 FAIL_IF(push_inst(compiler, MOVZ | RD(dst) | ((imm & 0xffff) << 5)));
454 return push_inst(compiler, MOVK | RD(dst) | ((imm & 0xffff0000l) >> (16 - 5)) | (1 << 21)); 454 return push_inst(compiler, MOVK | RD(dst) | ((imm & 0xffff0000l) >> (16 - 5)) | (1 << 21));
455 } 455 }
456 456
457 if (simm >= -0x100000000l && simm < 0) { 457 if (simm >= -0x100000000l && simm < 0) {
458 FAIL_IF(push_inst(compiler, MOVN | RD(dst) | ((~imm & 0xffff) << 5))); 458 FAIL_IF(push_inst(compiler, MOVN | RD(dst) | ((~imm & 0xffff) << 5)));
459 return push_inst(compiler, MOVK | RD(dst) | ((imm & 0xffff0000l) >> (16 - 5)) | (1 << 21)); 459 return push_inst(compiler, MOVK | RD(dst) | ((imm & 0xffff0000l) >> (16 - 5)) | (1 << 21));
460 } 460 }
461 461
462 /* A large amount of number can be constructed from ORR and MOVx, 462 /* A large amount of number can be constructed from ORR and MOVx,
463 but computing them is costly. We don't */ 463 but computing them is costly. We don't */
464 464
465 zeros = 0; 465 zeros = 0;
466 ones = 0; 466 ones = 0;
467 for (i = 4; i > 0; i--) { 467 for (i = 4; i > 0; i--) {
468 if ((simm & 0xffff) == 0) 468 if ((simm & 0xffff) == 0)
469 zeros++; 469 zeros++;
470 if ((simm & 0xffff) == 0xffff) 470 if ((simm & 0xffff) == 0xffff)
471 ones++; 471 ones++;
472 simm >>= 16; 472 simm >>= 16;
473 } 473 }
474 474
475 simm = (sljit_sw)imm; 475 simm = (sljit_sw)imm;
476 first = 1; 476 first = 1;
477 if (ones > zeros) { 477 if (ones > zeros) {
478 simm = ~simm; 478 simm = ~simm;
479 for (i = 0; i < 4; i++) { 479 for (i = 0; i < 4; i++) {
480 if (!(simm & 0xffff)) { 480 if (!(simm & 0xffff)) {
481 simm >>= 16; 481 simm >>= 16;
482 continue; 482 continue;
483 } 483 }
484 if (first) { 484 if (first) {
485 first = 0; 485 first = 0;
486 FAIL_IF(push_inst(compiler, MOVN | RD(dst) | ((simm & 0xffff) << 5) | (i << 21))); 486 FAIL_IF(push_inst(compiler, MOVN | RD(dst) | ((simm & 0xffff) << 5) | (i << 21)));
487 } 487 }
488 else 488 else
489 FAIL_IF(push_inst(compiler, MOVK | RD(dst) | ((~simm & 0xffff) << 5) | (i << 21))); 489 FAIL_IF(push_inst(compiler, MOVK | RD(dst) | ((~simm & 0xffff) << 5) | (i << 21)));
490 simm >>= 16; 490 simm >>= 16;
491 } 491 }
492 return SLJIT_SUCCESS; 492 return SLJIT_SUCCESS;
493 } 493 }
494 494
495 for (i = 0; i < 4; i++) { 495 for (i = 0; i < 4; i++) {
496 if (!(simm & 0xffff)) { 496 if (!(simm & 0xffff)) {
497 simm >>= 16; 497 simm >>= 16;
498 continue; 498 continue;
499 } 499 }
500 if (first) { 500 if (first) {
501 first = 0; 501 first = 0;
502 FAIL_IF(push_inst(compiler, MOVZ | RD(dst) | ((simm & 0xffff) << 5) | (i << 21))); 502 FAIL_IF(push_inst(compiler, MOVZ | RD(dst) | ((simm & 0xffff) << 5) | (i << 21)));
503 } 503 }
504 else 504 else
505 FAIL_IF(push_inst(compiler, MOVK | RD(dst) | ((simm & 0xffff) << 5) | (i << 21))); 505 FAIL_IF(push_inst(compiler, MOVK | RD(dst) | ((simm & 0xffff) << 5) | (i << 21)));
506 simm >>= 16; 506 simm >>= 16;
507 } 507 }
508 return SLJIT_SUCCESS; 508 return SLJIT_SUCCESS;
509} 509}
510 510
511#define ARG1_IMM 0x0010000 511#define ARG1_IMM 0x0010000
512#define ARG2_IMM 0x0020000 512#define ARG2_IMM 0x0020000
513#define INT_OP 0x0040000 513#define INT_OP 0x0040000
514#define SET_FLAGS 0x0080000 514#define SET_FLAGS 0x0080000
515#define UNUSED_RETURN 0x0100000 515#define UNUSED_RETURN 0x0100000
516#define SLOW_DEST 0x0200000 516#define SLOW_DEST 0x0200000
517#define SLOW_SRC1 0x0400000 517#define SLOW_SRC1 0x0400000
518#define SLOW_SRC2 0x0800000 518#define SLOW_SRC2 0x0800000
519 519
520#define CHECK_FLAGS(flag_bits) \ 520#define CHECK_FLAGS(flag_bits) \
521 if (flags & SET_FLAGS) { \ 521 if (flags & SET_FLAGS) { \
522 inv_bits |= flag_bits; \ 522 inv_bits |= flag_bits; \
523 if (flags & UNUSED_RETURN) \ 523 if (flags & UNUSED_RETURN) \
524 dst = TMP_ZERO; \ 524 dst = TMP_ZERO; \
525 } 525 }
526 526
527static sljit_s32 emit_op_imm(struct sljit_compiler *compiler, sljit_s32 flags, sljit_s32 dst, sljit_sw arg1, sljit_sw arg2) 527static sljit_s32 emit_op_imm(struct sljit_compiler *compiler, sljit_s32 flags, sljit_s32 dst, sljit_sw arg1, sljit_sw arg2)
528{ 528{
529 /* dst must be register, TMP_REG1 529 /* dst must be register, TMP_REG1
530 arg1 must be register, TMP_REG1, imm 530 arg1 must be register, TMP_REG1, imm
531 arg2 must be register, TMP_REG2, imm */ 531 arg2 must be register, TMP_REG2, imm */
532 sljit_ins inv_bits = (flags & INT_OP) ? (1 << 31) : 0; 532 sljit_ins inv_bits = (flags & INT_OP) ? (1 << 31) : 0;
533 sljit_ins inst_bits; 533 sljit_ins inst_bits;
534 sljit_s32 op = (flags & 0xffff); 534 sljit_s32 op = (flags & 0xffff);
535 sljit_s32 reg; 535 sljit_s32 reg;
536 sljit_sw imm, nimm; 536 sljit_sw imm, nimm;
537 537
538 if (SLJIT_UNLIKELY((flags & (ARG1_IMM | ARG2_IMM)) == (ARG1_IMM | ARG2_IMM))) { 538 if (SLJIT_UNLIKELY((flags & (ARG1_IMM | ARG2_IMM)) == (ARG1_IMM | ARG2_IMM))) {
539 /* Both are immediates. */ 539 /* Both are immediates. */
540 flags &= ~ARG1_IMM; 540 flags &= ~ARG1_IMM;
541 if (arg1 == 0 && op != SLJIT_ADD && op != SLJIT_SUB) 541 if (arg1 == 0 && op != SLJIT_ADD && op != SLJIT_SUB)
542 arg1 = TMP_ZERO; 542 arg1 = TMP_ZERO;
543 else { 543 else {
544 FAIL_IF(load_immediate(compiler, TMP_REG1, arg1)); 544 FAIL_IF(load_immediate(compiler, TMP_REG1, arg1));
545 arg1 = TMP_REG1; 545 arg1 = TMP_REG1;
546 } 546 }
547 } 547 }
548 548
549 if (flags & (ARG1_IMM | ARG2_IMM)) { 549 if (flags & (ARG1_IMM | ARG2_IMM)) {
550 reg = (flags & ARG2_IMM) ? arg1 : arg2; 550 reg = (flags & ARG2_IMM) ? arg1 : arg2;
551 imm = (flags & ARG2_IMM) ? arg2 : arg1; 551 imm = (flags & ARG2_IMM) ? arg2 : arg1;
552 552
553 switch (op) { 553 switch (op) {
554 case SLJIT_MUL: 554 case SLJIT_MUL:
555 case SLJIT_NEG: 555 case SLJIT_NEG:
556 case SLJIT_CLZ: 556 case SLJIT_CLZ:
557 case SLJIT_ADDC: 557 case SLJIT_ADDC:
558 case SLJIT_SUBC: 558 case SLJIT_SUBC:
559 /* No form with immediate operand (except imm 0, which 559 /* No form with immediate operand (except imm 0, which
560 is represented by a ZERO register). */ 560 is represented by a ZERO register). */
561 break; 561 break;
562 case SLJIT_MOV: 562 case SLJIT_MOV:
563 SLJIT_ASSERT(!(flags & SET_FLAGS) && (flags & ARG2_IMM) && arg1 == TMP_REG1); 563 SLJIT_ASSERT(!(flags & SET_FLAGS) && (flags & ARG2_IMM) && arg1 == TMP_REG1);
564 return load_immediate(compiler, dst, imm); 564 return load_immediate(compiler, dst, imm);
565 case SLJIT_NOT: 565 case SLJIT_NOT:
566 SLJIT_ASSERT(flags & ARG2_IMM); 566 SLJIT_ASSERT(flags & ARG2_IMM);
567 FAIL_IF(load_immediate(compiler, dst, (flags & INT_OP) ? (~imm & 0xffffffff) : ~imm)); 567 FAIL_IF(load_immediate(compiler, dst, (flags & INT_OP) ? (~imm & 0xffffffff) : ~imm));
568 goto set_flags; 568 goto set_flags;
569 case SLJIT_SUB: 569 case SLJIT_SUB:
570 if (flags & ARG1_IMM) 570 if (flags & ARG1_IMM)
571 break; 571 break;
572 imm = -imm; 572 imm = -imm;
573 /* Fall through. */ 573 /* Fall through. */
574 case SLJIT_ADD: 574 case SLJIT_ADD:
575 if (imm == 0) { 575 if (imm == 0) {
576 CHECK_FLAGS(1 << 29); 576 CHECK_FLAGS(1 << 29);
577 return push_inst(compiler, ((op == SLJIT_ADD ? ADDI : SUBI) ^ inv_bits) | RD(dst) | RN(reg)); 577 return push_inst(compiler, ((op == SLJIT_ADD ? ADDI : SUBI) ^ inv_bits) | RD(dst) | RN(reg));
578 } 578 }
579 if (imm > 0 && imm <= 0xfff) { 579 if (imm > 0 && imm <= 0xfff) {
580 CHECK_FLAGS(1 << 29); 580 CHECK_FLAGS(1 << 29);
581 return push_inst(compiler, (ADDI ^ inv_bits) | RD(dst) | RN(reg) | (imm << 10)); 581 return push_inst(compiler, (ADDI ^ inv_bits) | RD(dst) | RN(reg) | (imm << 10));
582 } 582 }
583 nimm = -imm; 583 nimm = -imm;
584 if (nimm > 0 && nimm <= 0xfff) { 584 if (nimm > 0 && nimm <= 0xfff) {
585 CHECK_FLAGS(1 << 29); 585 CHECK_FLAGS(1 << 29);
586 return push_inst(compiler, (SUBI ^ inv_bits) | RD(dst) | RN(reg) | (nimm << 10)); 586 return push_inst(compiler, (SUBI ^ inv_bits) | RD(dst) | RN(reg) | (nimm << 10));
587 } 587 }
588 if (imm > 0 && imm <= 0xffffff && !(imm & 0xfff)) { 588 if (imm > 0 && imm <= 0xffffff && !(imm & 0xfff)) {
589 CHECK_FLAGS(1 << 29); 589 CHECK_FLAGS(1 << 29);
590 return push_inst(compiler, (ADDI ^ inv_bits) | RD(dst) | RN(reg) | ((imm >> 12) << 10) | (1 << 22)); 590 return push_inst(compiler, (ADDI ^ inv_bits) | RD(dst) | RN(reg) | ((imm >> 12) << 10) | (1 << 22));
591 } 591 }
592 if (nimm > 0 && nimm <= 0xffffff && !(nimm & 0xfff)) { 592 if (nimm > 0 && nimm <= 0xffffff && !(nimm & 0xfff)) {
593 CHECK_FLAGS(1 << 29); 593 CHECK_FLAGS(1 << 29);
594 return push_inst(compiler, (SUBI ^ inv_bits) | RD(dst) | RN(reg) | ((nimm >> 12) << 10) | (1 << 22)); 594 return push_inst(compiler, (SUBI ^ inv_bits) | RD(dst) | RN(reg) | ((nimm >> 12) << 10) | (1 << 22));
595 } 595 }
596 if (imm > 0 && imm <= 0xffffff && !(flags & SET_FLAGS)) { 596 if (imm > 0 && imm <= 0xffffff && !(flags & SET_FLAGS)) {
597 FAIL_IF(push_inst(compiler, (ADDI ^ inv_bits) | RD(dst) | RN(reg) | ((imm >> 12) << 10) | (1 << 22))); 597 FAIL_IF(push_inst(compiler, (ADDI ^ inv_bits) | RD(dst) | RN(reg) | ((imm >> 12) << 10) | (1 << 22)));
598 return push_inst(compiler, (ADDI ^ inv_bits) | RD(dst) | RN(dst) | ((imm & 0xfff) << 10)); 598 return push_inst(compiler, (ADDI ^ inv_bits) | RD(dst) | RN(dst) | ((imm & 0xfff) << 10));
599 } 599 }
600 if (nimm > 0 && nimm <= 0xffffff && !(flags & SET_FLAGS)) { 600 if (nimm > 0 && nimm <= 0xffffff && !(flags & SET_FLAGS)) {
601 FAIL_IF(push_inst(compiler, (SUBI ^ inv_bits) | RD(dst) | RN(reg) | ((nimm >> 12) << 10) | (1 << 22))); 601 FAIL_IF(push_inst(compiler, (SUBI ^ inv_bits) | RD(dst) | RN(reg) | ((nimm >> 12) << 10) | (1 << 22)));
602 return push_inst(compiler, (SUBI ^ inv_bits) | RD(dst) | RN(dst) | ((nimm & 0xfff) << 10)); 602 return push_inst(compiler, (SUBI ^ inv_bits) | RD(dst) | RN(dst) | ((nimm & 0xfff) << 10));
603 } 603 }
604 break; 604 break;
605 case SLJIT_AND: 605 case SLJIT_AND:
606 inst_bits = logical_imm(imm, LOGICAL_IMM_CHECK | ((flags & INT_OP) ? 16 : 32)); 606 inst_bits = logical_imm(imm, LOGICAL_IMM_CHECK | ((flags & INT_OP) ? 16 : 32));
607 if (!inst_bits) 607 if (!inst_bits)
608 break; 608 break;
609 CHECK_FLAGS(3 << 29); 609 CHECK_FLAGS(3 << 29);
610 return push_inst(compiler, (ANDI ^ inv_bits) | RD(dst) | RN(reg) | inst_bits); 610 return push_inst(compiler, (ANDI ^ inv_bits) | RD(dst) | RN(reg) | inst_bits);
611 case SLJIT_OR: 611 case SLJIT_OR:
612 case SLJIT_XOR: 612 case SLJIT_XOR:
613 inst_bits = logical_imm(imm, LOGICAL_IMM_CHECK | ((flags & INT_OP) ? 16 : 32)); 613 inst_bits = logical_imm(imm, LOGICAL_IMM_CHECK | ((flags & INT_OP) ? 16 : 32));
614 if (!inst_bits) 614 if (!inst_bits)
615 break; 615 break;
616 if (op == SLJIT_OR) 616 if (op == SLJIT_OR)
617 inst_bits |= ORRI; 617 inst_bits |= ORRI;
618 else 618 else
619 inst_bits |= EORI; 619 inst_bits |= EORI;
620 FAIL_IF(push_inst(compiler, (inst_bits ^ inv_bits) | RD(dst) | RN(reg))); 620 FAIL_IF(push_inst(compiler, (inst_bits ^ inv_bits) | RD(dst) | RN(reg)));
621 goto set_flags; 621 goto set_flags;
622 case SLJIT_SHL: 622 case SLJIT_SHL:
623 if (flags & ARG1_IMM) 623 if (flags & ARG1_IMM)
624 break; 624 break;
625 if (flags & INT_OP) { 625 if (flags & INT_OP) {
626 imm &= 0x1f; 626 imm &= 0x1f;
627 FAIL_IF(push_inst(compiler, (UBFM ^ inv_bits) | RD(dst) | RN(arg1) | ((-imm & 0x1f) << 16) | ((31 - imm) << 10))); 627 FAIL_IF(push_inst(compiler, (UBFM ^ inv_bits) | RD(dst) | RN(arg1) | ((-imm & 0x1f) << 16) | ((31 - imm) << 10)));
628 } 628 }
629 else { 629 else {
630 imm &= 0x3f; 630 imm &= 0x3f;
631 FAIL_IF(push_inst(compiler, (UBFM ^ inv_bits) | RD(dst) | RN(arg1) | (1 << 22) | ((-imm & 0x3f) << 16) | ((63 - imm) << 10))); 631 FAIL_IF(push_inst(compiler, (UBFM ^ inv_bits) | RD(dst) | RN(arg1) | (1 << 22) | ((-imm & 0x3f) << 16) | ((63 - imm) << 10)));
632 } 632 }
633 goto set_flags; 633 goto set_flags;
634 case SLJIT_LSHR: 634 case SLJIT_LSHR:
635 case SLJIT_ASHR: 635 case SLJIT_ASHR:
636 if (flags & ARG1_IMM) 636 if (flags & ARG1_IMM)
637 break; 637 break;
638 if (op == SLJIT_ASHR) 638 if (op == SLJIT_ASHR)
639 inv_bits |= 1 << 30; 639 inv_bits |= 1 << 30;
640 if (flags & INT_OP) { 640 if (flags & INT_OP) {
641 imm &= 0x1f; 641 imm &= 0x1f;
642 FAIL_IF(push_inst(compiler, (UBFM ^ inv_bits) | RD(dst) | RN(arg1) | (imm << 16) | (31 << 10))); 642 FAIL_IF(push_inst(compiler, (UBFM ^ inv_bits) | RD(dst) | RN(arg1) | (imm << 16) | (31 << 10)));
643 } 643 }
644 else { 644 else {
645 imm &= 0x3f; 645 imm &= 0x3f;
646 FAIL_IF(push_inst(compiler, (UBFM ^ inv_bits) | RD(dst) | RN(arg1) | (1 << 22) | (imm << 16) | (63 << 10))); 646 FAIL_IF(push_inst(compiler, (UBFM ^ inv_bits) | RD(dst) | RN(arg1) | (1 << 22) | (imm << 16) | (63 << 10)));
647 } 647 }
648 goto set_flags; 648 goto set_flags;
649 default: 649 default:
650 SLJIT_UNREACHABLE(); 650 SLJIT_UNREACHABLE();
651 break; 651 break;
652 } 652 }
653 653
654 if (flags & ARG2_IMM) { 654 if (flags & ARG2_IMM) {
655 if (arg2 == 0) 655 if (arg2 == 0)
656 arg2 = TMP_ZERO; 656 arg2 = TMP_ZERO;
657 else { 657 else {
658 FAIL_IF(load_immediate(compiler, TMP_REG2, arg2)); 658 FAIL_IF(load_immediate(compiler, TMP_REG2, arg2));
659 arg2 = TMP_REG2; 659 arg2 = TMP_REG2;
660 } 660 }
661 } 661 }
662 else { 662 else {
663 if (arg1 == 0) 663 if (arg1 == 0)
664 arg1 = TMP_ZERO; 664 arg1 = TMP_ZERO;
665 else { 665 else {
666 FAIL_IF(load_immediate(compiler, TMP_REG1, arg1)); 666 FAIL_IF(load_immediate(compiler, TMP_REG1, arg1));
667 arg1 = TMP_REG1; 667 arg1 = TMP_REG1;
668 } 668 }
669 } 669 }
670 } 670 }
671 671
672 /* Both arguments are registers. */ 672 /* Both arguments are registers. */
673 switch (op) { 673 switch (op) {
674 case SLJIT_MOV: 674 case SLJIT_MOV:
675 case SLJIT_MOV_P: 675 case SLJIT_MOV_P:
676 case SLJIT_MOVU: 676 case SLJIT_MOVU:
677 case SLJIT_MOVU_P: 677 case SLJIT_MOVU_P:
678 SLJIT_ASSERT(!(flags & SET_FLAGS) && arg1 == TMP_REG1); 678 SLJIT_ASSERT(!(flags & SET_FLAGS) && arg1 == TMP_REG1);
679 if (dst == arg2) 679 if (dst == arg2)
680 return SLJIT_SUCCESS; 680 return SLJIT_SUCCESS;
681 return push_inst(compiler, ORR | RD(dst) | RN(TMP_ZERO) | RM(arg2)); 681 return push_inst(compiler, ORR | RD(dst) | RN(TMP_ZERO) | RM(arg2));
682 case SLJIT_MOV_U8: 682 case SLJIT_MOV_U8:
683 case SLJIT_MOVU_U8: 683 case SLJIT_MOVU_U8:
684 SLJIT_ASSERT(!(flags & SET_FLAGS) && arg1 == TMP_REG1); 684 SLJIT_ASSERT(!(flags & SET_FLAGS) && arg1 == TMP_REG1);
685 return push_inst(compiler, (UBFM ^ (1 << 31)) | RD(dst) | RN(arg2) | (7 << 10)); 685 return push_inst(compiler, (UBFM ^ (1 << 31)) | RD(dst) | RN(arg2) | (7 << 10));
686 case SLJIT_MOV_S8: 686 case SLJIT_MOV_S8:
687 case SLJIT_MOVU_S8: 687 case SLJIT_MOVU_S8:
688 SLJIT_ASSERT(!(flags & SET_FLAGS) && arg1 == TMP_REG1); 688 SLJIT_ASSERT(!(flags & SET_FLAGS) && arg1 == TMP_REG1);
689 if (!(flags & INT_OP)) 689 if (!(flags & INT_OP))
690 inv_bits |= 1 << 22; 690 inv_bits |= 1 << 22;
691 return push_inst(compiler, (SBFM ^ inv_bits) | RD(dst) | RN(arg2) | (7 << 10)); 691 return push_inst(compiler, (SBFM ^ inv_bits) | RD(dst) | RN(arg2) | (7 << 10));
692 case SLJIT_MOV_U16: 692 case SLJIT_MOV_U16:
693 case SLJIT_MOVU_U16: 693 case SLJIT_MOVU_U16:
694 SLJIT_ASSERT(!(flags & SET_FLAGS) && arg1 == TMP_REG1); 694 SLJIT_ASSERT(!(flags & SET_FLAGS) && arg1 == TMP_REG1);
695 return push_inst(compiler, (UBFM ^ (1 << 31)) | RD(dst) | RN(arg2) | (15 << 10)); 695 return push_inst(compiler, (UBFM ^ (1 << 31)) | RD(dst) | RN(arg2) | (15 << 10));
696 case SLJIT_MOV_S16: 696 case SLJIT_MOV_S16:
697 case SLJIT_MOVU_S16: 697 case SLJIT_MOVU_S16:
698 SLJIT_ASSERT(!(flags & SET_FLAGS) && arg1 == TMP_REG1); 698 SLJIT_ASSERT(!(flags & SET_FLAGS) && arg1 == TMP_REG1);
699 if (!(flags & INT_OP)) 699 if (!(flags & INT_OP))
700 inv_bits |= 1 << 22; 700 inv_bits |= 1 << 22;
701 return push_inst(compiler, (SBFM ^ inv_bits) | RD(dst) | RN(arg2) | (15 << 10)); 701 return push_inst(compiler, (SBFM ^ inv_bits) | RD(dst) | RN(arg2) | (15 << 10));
702 case SLJIT_MOV_U32: 702 case SLJIT_MOV_U32:
703 case SLJIT_MOVU_U32: 703 case SLJIT_MOVU_U32:
704 SLJIT_ASSERT(!(flags & SET_FLAGS) && arg1 == TMP_REG1); 704 SLJIT_ASSERT(!(flags & SET_FLAGS) && arg1 == TMP_REG1);
705 if ((flags & INT_OP) && dst == arg2) 705 if ((flags & INT_OP) && dst == arg2)
706 return SLJIT_SUCCESS; 706 return SLJIT_SUCCESS;
707 return push_inst(compiler, (ORR ^ (1 << 31)) | RD(dst) | RN(TMP_ZERO) | RM(arg2)); 707 return push_inst(compiler, (ORR ^ (1 << 31)) | RD(dst) | RN(TMP_ZERO) | RM(arg2));
708 case SLJIT_MOV_S32: 708 case SLJIT_MOV_S32:
709 case SLJIT_MOVU_S32: 709 case SLJIT_MOVU_S32:
710 SLJIT_ASSERT(!(flags & SET_FLAGS) && arg1 == TMP_REG1); 710 SLJIT_ASSERT(!(flags & SET_FLAGS) && arg1 == TMP_REG1);
711 if ((flags & INT_OP) && dst == arg2) 711 if ((flags & INT_OP) && dst == arg2)
712 return SLJIT_SUCCESS; 712 return SLJIT_SUCCESS;
713 return push_inst(compiler, SBFM | (1 << 22) | RD(dst) | RN(arg2) | (31 << 10)); 713 return push_inst(compiler, SBFM | (1 << 22) | RD(dst) | RN(arg2) | (31 << 10));
714 case SLJIT_NOT: 714 case SLJIT_NOT:
715 SLJIT_ASSERT(arg1 == TMP_REG1); 715 SLJIT_ASSERT(arg1 == TMP_REG1);
716 FAIL_IF(push_inst(compiler, (ORN ^ inv_bits) | RD(dst) | RN(TMP_ZERO) | RM(arg2))); 716 FAIL_IF(push_inst(compiler, (ORN ^ inv_bits) | RD(dst) | RN(TMP_ZERO) | RM(arg2)));
717 goto set_flags; 717 goto set_flags;
718 case SLJIT_NEG: 718 case SLJIT_NEG:
719 SLJIT_ASSERT(arg1 == TMP_REG1); 719 SLJIT_ASSERT(arg1 == TMP_REG1);
720 if (flags & SET_FLAGS) 720 if (flags & SET_FLAGS)
721 inv_bits |= 1 << 29; 721 inv_bits |= 1 << 29;
722 return push_inst(compiler, (SUB ^ inv_bits) | RD(dst) | RN(TMP_ZERO) | RM(arg2)); 722 return push_inst(compiler, (SUB ^ inv_bits) | RD(dst) | RN(TMP_ZERO) | RM(arg2));
723 case SLJIT_CLZ: 723 case SLJIT_CLZ:
724 SLJIT_ASSERT(arg1 == TMP_REG1); 724 SLJIT_ASSERT(arg1 == TMP_REG1);
725 FAIL_IF(push_inst(compiler, (CLZ ^ inv_bits) | RD(dst) | RN(arg2))); 725 FAIL_IF(push_inst(compiler, (CLZ ^ inv_bits) | RD(dst) | RN(arg2)));
726 goto set_flags; 726 goto set_flags;
727 case SLJIT_ADD: 727 case SLJIT_ADD:
728 CHECK_FLAGS(1 << 29); 728 CHECK_FLAGS(1 << 29);
729 return push_inst(compiler, (ADD ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); 729 return push_inst(compiler, (ADD ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2));
730 case SLJIT_ADDC: 730 case SLJIT_ADDC:
731 CHECK_FLAGS(1 << 29); 731 CHECK_FLAGS(1 << 29);
732 return push_inst(compiler, (ADC ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); 732 return push_inst(compiler, (ADC ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2));
733 case SLJIT_SUB: 733 case SLJIT_SUB:
734 CHECK_FLAGS(1 << 29); 734 CHECK_FLAGS(1 << 29);
735 return push_inst(compiler, (SUB ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); 735 return push_inst(compiler, (SUB ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2));
736 case SLJIT_SUBC: 736 case SLJIT_SUBC:
737 CHECK_FLAGS(1 << 29); 737 CHECK_FLAGS(1 << 29);
738 return push_inst(compiler, (SBC ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); 738 return push_inst(compiler, (SBC ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2));
739 case SLJIT_MUL: 739 case SLJIT_MUL:
740 if (!(flags & SET_FLAGS)) 740 if (!(flags & SET_FLAGS))
741 return push_inst(compiler, (MADD ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2) | RT2(TMP_ZERO)); 741 return push_inst(compiler, (MADD ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2) | RT2(TMP_ZERO));
742 if (flags & INT_OP) { 742 if (flags & INT_OP) {
743 FAIL_IF(push_inst(compiler, SMADDL | RD(dst) | RN(arg1) | RM(arg2) | (31 << 10))); 743 FAIL_IF(push_inst(compiler, SMADDL | RD(dst) | RN(arg1) | RM(arg2) | (31 << 10)));
744 FAIL_IF(push_inst(compiler, ADD | RD(TMP_LR) | RN(TMP_ZERO) | RM(dst) | (2 << 22) | (31 << 10))); 744 FAIL_IF(push_inst(compiler, ADD | RD(TMP_LR) | RN(TMP_ZERO) | RM(dst) | (2 << 22) | (31 << 10)));
745 return push_inst(compiler, SUBS | RD(TMP_ZERO) | RN(TMP_LR) | RM(dst) | (2 << 22) | (63 << 10)); 745 return push_inst(compiler, SUBS | RD(TMP_ZERO) | RN(TMP_LR) | RM(dst) | (2 << 22) | (63 << 10));
746 } 746 }
747 FAIL_IF(push_inst(compiler, SMULH | RD(TMP_LR) | RN(arg1) | RM(arg2))); 747 FAIL_IF(push_inst(compiler, SMULH | RD(TMP_LR) | RN(arg1) | RM(arg2)));
748 FAIL_IF(push_inst(compiler, MADD | RD(dst) | RN(arg1) | RM(arg2) | RT2(TMP_ZERO))); 748 FAIL_IF(push_inst(compiler, MADD | RD(dst) | RN(arg1) | RM(arg2) | RT2(TMP_ZERO)));
749 return push_inst(compiler, SUBS | RD(TMP_ZERO) | RN(TMP_LR) | RM(dst) | (2 << 22) | (63 << 10)); 749 return push_inst(compiler, SUBS | RD(TMP_ZERO) | RN(TMP_LR) | RM(dst) | (2 << 22) | (63 << 10));
750 case SLJIT_AND: 750 case SLJIT_AND:
751 CHECK_FLAGS(3 << 29); 751 CHECK_FLAGS(3 << 29);
752 return push_inst(compiler, (AND ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); 752 return push_inst(compiler, (AND ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2));
753 case SLJIT_OR: 753 case SLJIT_OR:
754 FAIL_IF(push_inst(compiler, (ORR ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2))); 754 FAIL_IF(push_inst(compiler, (ORR ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)));
755 goto set_flags; 755 goto set_flags;
756 case SLJIT_XOR: 756 case SLJIT_XOR:
757 FAIL_IF(push_inst(compiler, (EOR ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2))); 757 FAIL_IF(push_inst(compiler, (EOR ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)));
758 goto set_flags; 758 goto set_flags;
759 case SLJIT_SHL: 759 case SLJIT_SHL:
760 FAIL_IF(push_inst(compiler, (LSLV ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2))); 760 FAIL_IF(push_inst(compiler, (LSLV ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)));
761 goto set_flags; 761 goto set_flags;
762 case SLJIT_LSHR: 762 case SLJIT_LSHR:
763 FAIL_IF(push_inst(compiler, (LSRV ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2))); 763 FAIL_IF(push_inst(compiler, (LSRV ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)));
764 goto set_flags; 764 goto set_flags;
765 case SLJIT_ASHR: 765 case SLJIT_ASHR:
766 FAIL_IF(push_inst(compiler, (ASRV ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2))); 766 FAIL_IF(push_inst(compiler, (ASRV ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)));
767 goto set_flags; 767 goto set_flags;
768 } 768 }
769 769
770 SLJIT_UNREACHABLE(); 770 SLJIT_UNREACHABLE();
771 return SLJIT_SUCCESS; 771 return SLJIT_SUCCESS;
772 772
773set_flags: 773set_flags:
774 if (flags & SET_FLAGS) 774 if (flags & SET_FLAGS)
775 return push_inst(compiler, (SUBS ^ inv_bits) | RD(TMP_ZERO) | RN(dst) | RM(TMP_ZERO)); 775 return push_inst(compiler, (SUBS ^ inv_bits) | RD(TMP_ZERO) | RN(dst) | RM(TMP_ZERO));
776 return SLJIT_SUCCESS; 776 return SLJIT_SUCCESS;
777} 777}
778 778
779#define STORE 0x01 779#define STORE 0x01
780#define SIGNED 0x02 780#define SIGNED 0x02
781 781
782#define UPDATE 0x04 782#define UPDATE 0x04
783#define ARG_TEST 0x08 783#define ARG_TEST 0x08
784 784
785#define BYTE_SIZE 0x000 785#define BYTE_SIZE 0x000
786#define HALF_SIZE 0x100 786#define HALF_SIZE 0x100
787#define INT_SIZE 0x200 787#define INT_SIZE 0x200
788#define WORD_SIZE 0x300 788#define WORD_SIZE 0x300
789 789
790#define MEM_SIZE_SHIFT(flags) ((flags) >> 8) 790#define MEM_SIZE_SHIFT(flags) ((flags) >> 8)
791 791
792static const sljit_ins sljit_mem_imm[4] = { 792static const sljit_ins sljit_mem_imm[4] = {
793/* u l */ 0x39400000 /* ldrb [reg,imm] */, 793/* u l */ 0x39400000 /* ldrb [reg,imm] */,
794/* u s */ 0x39000000 /* strb [reg,imm] */, 794/* u s */ 0x39000000 /* strb [reg,imm] */,
795/* s l */ 0x39800000 /* ldrsb [reg,imm] */, 795/* s l */ 0x39800000 /* ldrsb [reg,imm] */,
796/* s s */ 0x39000000 /* strb [reg,imm] */, 796/* s s */ 0x39000000 /* strb [reg,imm] */,
797}; 797};
798 798
799static const sljit_ins sljit_mem_simm[4] = { 799static const sljit_ins sljit_mem_simm[4] = {
800/* u l */ 0x38400000 /* ldurb [reg,imm] */, 800/* u l */ 0x38400000 /* ldurb [reg,imm] */,
801/* u s */ 0x38000000 /* sturb [reg,imm] */, 801/* u s */ 0x38000000 /* sturb [reg,imm] */,
802/* s l */ 0x38800000 /* ldursb [reg,imm] */, 802/* s l */ 0x38800000 /* ldursb [reg,imm] */,
803/* s s */ 0x38000000 /* sturb [reg,imm] */, 803/* s s */ 0x38000000 /* sturb [reg,imm] */,
804}; 804};
805 805
806static const sljit_ins sljit_mem_pre_simm[4] = { 806static const sljit_ins sljit_mem_pre_simm[4] = {
807/* u l */ 0x38400c00 /* ldrb [reg,imm]! */, 807/* u l */ 0x38400c00 /* ldrb [reg,imm]! */,
808/* u s */ 0x38000c00 /* strb [reg,imm]! */, 808/* u s */ 0x38000c00 /* strb [reg,imm]! */,
809/* s l */ 0x38800c00 /* ldrsb [reg,imm]! */, 809/* s l */ 0x38800c00 /* ldrsb [reg,imm]! */,
810/* s s */ 0x38000c00 /* strb [reg,imm]! */, 810/* s s */ 0x38000c00 /* strb [reg,imm]! */,
811}; 811};
812 812
813static const sljit_ins sljit_mem_reg[4] = { 813static const sljit_ins sljit_mem_reg[4] = {
814/* u l */ 0x38606800 /* ldrb [reg,reg] */, 814/* u l */ 0x38606800 /* ldrb [reg,reg] */,
815/* u s */ 0x38206800 /* strb [reg,reg] */, 815/* u s */ 0x38206800 /* strb [reg,reg] */,
816/* s l */ 0x38a06800 /* ldrsb [reg,reg] */, 816/* s l */ 0x38a06800 /* ldrsb [reg,reg] */,
817/* s s */ 0x38206800 /* strb [reg,reg] */, 817/* s s */ 0x38206800 /* strb [reg,reg] */,
818}; 818};
819 819
820/* Helper function. Dst should be reg + value, using at most 1 instruction, flags does not set. */ 820/* Helper function. Dst should be reg + value, using at most 1 instruction, flags does not set. */
821static sljit_s32 emit_set_delta(struct sljit_compiler *compiler, sljit_s32 dst, sljit_s32 reg, sljit_sw value) 821static sljit_s32 emit_set_delta(struct sljit_compiler *compiler, sljit_s32 dst, sljit_s32 reg, sljit_sw value)
822{ 822{
823 if (value >= 0) { 823 if (value >= 0) {
824 if (value <= 0xfff) 824 if (value <= 0xfff)
825 return push_inst(compiler, ADDI | RD(dst) | RN(reg) | (value << 10)); 825 return push_inst(compiler, ADDI | RD(dst) | RN(reg) | (value << 10));
826 if (value <= 0xffffff && !(value & 0xfff)) 826 if (value <= 0xffffff && !(value & 0xfff))
827 return push_inst(compiler, ADDI | (1 << 22) | RD(dst) | RN(reg) | (value >> 2)); 827 return push_inst(compiler, ADDI | (1 << 22) | RD(dst) | RN(reg) | (value >> 2));
828 } 828 }
829 else { 829 else {
830 value = -value; 830 value = -value;
831 if (value <= 0xfff) 831 if (value <= 0xfff)
832 return push_inst(compiler, SUBI | RD(dst) | RN(reg) | (value << 10)); 832 return push_inst(compiler, SUBI | RD(dst) | RN(reg) | (value << 10));
833 if (value <= 0xffffff && !(value & 0xfff)) 833 if (value <= 0xffffff && !(value & 0xfff))
834 return push_inst(compiler, SUBI | (1 << 22) | RD(dst) | RN(reg) | (value >> 2)); 834 return push_inst(compiler, SUBI | (1 << 22) | RD(dst) | RN(reg) | (value >> 2));
835 } 835 }
836 return SLJIT_ERR_UNSUPPORTED; 836 return SLJIT_ERR_UNSUPPORTED;
837} 837}
838 838
839/* Can perform an operation using at most 1 instruction. */ 839/* Can perform an operation using at most 1 instruction. */
840static sljit_s32 getput_arg_fast(struct sljit_compiler *compiler, sljit_s32 flags, sljit_s32 reg, sljit_s32 arg, sljit_sw argw) 840static sljit_s32 getput_arg_fast(struct sljit_compiler *compiler, sljit_s32 flags, sljit_s32 reg, sljit_s32 arg, sljit_sw argw)
841{ 841{
842 sljit_u32 shift = MEM_SIZE_SHIFT(flags); 842 sljit_u32 shift = MEM_SIZE_SHIFT(flags);
843 843
844 SLJIT_ASSERT(arg & SLJIT_MEM); 844 SLJIT_ASSERT(arg & SLJIT_MEM);
845 845
846 if (SLJIT_UNLIKELY(flags & UPDATE)) { 846 if (SLJIT_UNLIKELY(flags & UPDATE)) {
847 if ((arg & REG_MASK) && !(arg & OFFS_REG_MASK) && argw <= 255 && argw >= -256) { 847 if ((arg & REG_MASK) && !(arg & OFFS_REG_MASK) && argw <= 255 && argw >= -256) {
848 if (SLJIT_UNLIKELY(flags & ARG_TEST)) 848 if (SLJIT_UNLIKELY(flags & ARG_TEST))
849 return 1; 849 return 1;
850 850
851 arg &= REG_MASK; 851 arg &= REG_MASK;
852 argw &= 0x1ff; 852 argw &= 0x1ff;
853 FAIL_IF(push_inst(compiler, sljit_mem_pre_simm[flags & 0x3] 853 FAIL_IF(push_inst(compiler, sljit_mem_pre_simm[flags & 0x3]
854 | (shift << 30) | RT(reg) | RN(arg) | (argw << 12))); 854 | (shift << 30) | RT(reg) | RN(arg) | (argw << 12)));
855 return -1; 855 return -1;
856 } 856 }
857 return 0; 857 return 0;
858 } 858 }
859 859
860 if (SLJIT_UNLIKELY(arg & OFFS_REG_MASK)) { 860 if (SLJIT_UNLIKELY(arg & OFFS_REG_MASK)) {
861 argw &= 0x3; 861 argw &= 0x3;
862 if (argw && argw != shift) 862 if (argw && argw != shift)
863 return 0; 863 return 0;
864 864
865 if (SLJIT_UNLIKELY(flags & ARG_TEST)) 865 if (SLJIT_UNLIKELY(flags & ARG_TEST))
866 return 1; 866 return 1;
867 867
868 FAIL_IF(push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg) 868 FAIL_IF(push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg)
869 | RN(arg & REG_MASK) | RM(OFFS_REG(arg)) | (argw ? (1 << 12) : 0))); 869 | RN(arg & REG_MASK) | RM(OFFS_REG(arg)) | (argw ? (1 << 12) : 0)));
870 return -1; 870 return -1;
871 } 871 }
872 872
873 arg &= REG_MASK; 873 arg &= REG_MASK;
874 if (argw >= 0 && (argw >> shift) <= 0xfff && (argw & ((1 << shift) - 1)) == 0) { 874 if (argw >= 0 && (argw >> shift) <= 0xfff && (argw & ((1 << shift) - 1)) == 0) {
875 if (SLJIT_UNLIKELY(flags & ARG_TEST)) 875 if (SLJIT_UNLIKELY(flags & ARG_TEST))
876 return 1; 876 return 1;
877 877
878 FAIL_IF(push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) 878 FAIL_IF(push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30)
879 | RT(reg) | RN(arg) | (argw << (10 - shift)))); 879 | RT(reg) | RN(arg) | (argw << (10 - shift))));
880 return -1; 880 return -1;
881 } 881 }
882 882
883 if (argw > 255 || argw < -256) 883 if (argw > 255 || argw < -256)
884 return 0; 884 return 0;
885 885
886 if (SLJIT_UNLIKELY(flags & ARG_TEST)) 886 if (SLJIT_UNLIKELY(flags & ARG_TEST))
887 return 1; 887 return 1;
888 888
889 FAIL_IF(push_inst(compiler, sljit_mem_simm[flags & 0x3] | (shift << 30) 889 FAIL_IF(push_inst(compiler, sljit_mem_simm[flags & 0x3] | (shift << 30)
890 | RT(reg) | RN(arg) | ((argw & 0x1ff) << 12))); 890 | RT(reg) | RN(arg) | ((argw & 0x1ff) << 12)));
891 return -1; 891 return -1;
892} 892}
893 893
894/* see getput_arg below. 894/* see getput_arg below.
895 Note: can_cache is called only for binary operators. Those 895 Note: can_cache is called only for binary operators. Those
896 operators always uses word arguments without write back. */ 896 operators always uses word arguments without write back. */
897static sljit_s32 can_cache(sljit_s32 arg, sljit_sw argw, sljit_s32 next_arg, sljit_sw next_argw) 897static sljit_s32 can_cache(sljit_s32 arg, sljit_sw argw, sljit_s32 next_arg, sljit_sw next_argw)
898{ 898{
899 sljit_sw diff; 899 sljit_sw diff;
900 if ((arg & OFFS_REG_MASK) || !(next_arg & SLJIT_MEM)) 900 if ((arg & OFFS_REG_MASK) || !(next_arg & SLJIT_MEM))
901 return 0; 901 return 0;
902 902
903 if (!(arg & REG_MASK)) { 903 if (!(arg & REG_MASK)) {
904 diff = argw - next_argw; 904 diff = argw - next_argw;
905 if (diff <= 0xfff && diff >= -0xfff) 905 if (diff <= 0xfff && diff >= -0xfff)
906 return 1; 906 return 1;
907 return 0; 907 return 0;
908 } 908 }
909 909
910 if (argw == next_argw) 910 if (argw == next_argw)
911 return 1; 911 return 1;
912 912
913 diff = argw - next_argw; 913 diff = argw - next_argw;
914 if (arg == next_arg && diff <= 0xfff && diff >= -0xfff) 914 if (arg == next_arg && diff <= 0xfff && diff >= -0xfff)
915 return 1; 915 return 1;
916 916
917 return 0; 917 return 0;
918} 918}
919 919
920/* Emit the necessary instructions. See can_cache above. */ 920/* Emit the necessary instructions. See can_cache above. */
921static sljit_s32 getput_arg(struct sljit_compiler *compiler, sljit_s32 flags, sljit_s32 reg, 921static sljit_s32 getput_arg(struct sljit_compiler *compiler, sljit_s32 flags, sljit_s32 reg,
922 sljit_s32 arg, sljit_sw argw, sljit_s32 next_arg, sljit_sw next_argw) 922 sljit_s32 arg, sljit_sw argw, sljit_s32 next_arg, sljit_sw next_argw)
923{ 923{
924 sljit_u32 shift = MEM_SIZE_SHIFT(flags); 924 sljit_u32 shift = MEM_SIZE_SHIFT(flags);
925 sljit_s32 tmp_r, other_r; 925 sljit_s32 tmp_r, other_r;
926 sljit_sw diff; 926 sljit_sw diff;
927 927
928 SLJIT_ASSERT(arg & SLJIT_MEM); 928 SLJIT_ASSERT(arg & SLJIT_MEM);
929 if (!(next_arg & SLJIT_MEM)) { 929 if (!(next_arg & SLJIT_MEM)) {
930 next_arg = 0; 930 next_arg = 0;
931 next_argw = 0; 931 next_argw = 0;
932 } 932 }
933 933
934 tmp_r = (flags & STORE) ? TMP_REG3 : reg; 934 tmp_r = (flags & STORE) ? TMP_REG3 : reg;
935 935
936 if (SLJIT_UNLIKELY((flags & UPDATE) && (arg & REG_MASK))) { 936 if (SLJIT_UNLIKELY((flags & UPDATE) && (arg & REG_MASK))) {
937 /* Update only applies if a base register exists. */ 937 /* Update only applies if a base register exists. */
938 other_r = OFFS_REG(arg); 938 other_r = OFFS_REG(arg);
939 if (!other_r) { 939 if (!other_r) {
940 other_r = arg & REG_MASK; 940 other_r = arg & REG_MASK;
941 SLJIT_ASSERT(other_r != reg); 941 SLJIT_ASSERT(other_r != reg);
942 942
943 if (argw >= 0 && argw <= 0xffffff) { 943 if (argw >= 0 && argw <= 0xffffff) {
944 if ((argw & 0xfff) != 0) 944 if ((argw & 0xfff) != 0)
945 FAIL_IF(push_inst(compiler, ADDI | RD(other_r) | RN(other_r) | ((argw & 0xfff) << 10))); 945 FAIL_IF(push_inst(compiler, ADDI | RD(other_r) | RN(other_r) | ((argw & 0xfff) << 10)));
946 if (argw >> 12) 946 if (argw >> 12)
947 FAIL_IF(push_inst(compiler, ADDI | (1 << 22) | RD(other_r) | RN(other_r) | ((argw >> 12) << 10))); 947 FAIL_IF(push_inst(compiler, ADDI | (1 << 22) | RD(other_r) | RN(other_r) | ((argw >> 12) << 10)));
948 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(other_r)); 948 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(other_r));
949 } 949 }
950 else if (argw < 0 && argw >= -0xffffff) { 950 else if (argw < 0 && argw >= -0xffffff) {
951 argw = -argw; 951 argw = -argw;
952 if ((argw & 0xfff) != 0) 952 if ((argw & 0xfff) != 0)
953 FAIL_IF(push_inst(compiler, SUBI | RD(other_r) | RN(other_r) | ((argw & 0xfff) << 10))); 953 FAIL_IF(push_inst(compiler, SUBI | RD(other_r) | RN(other_r) | ((argw & 0xfff) << 10)));
954 if (argw >> 12) 954 if (argw >> 12)
955 FAIL_IF(push_inst(compiler, SUBI | (1 << 22) | RD(other_r) | RN(other_r) | ((argw >> 12) << 10))); 955 FAIL_IF(push_inst(compiler, SUBI | (1 << 22) | RD(other_r) | RN(other_r) | ((argw >> 12) << 10)));
956 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(other_r)); 956 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(other_r));
957 } 957 }
958 958
959 if (compiler->cache_arg == SLJIT_MEM) { 959 if (compiler->cache_arg == SLJIT_MEM) {
960 if (argw == compiler->cache_argw) { 960 if (argw == compiler->cache_argw) {
961 other_r = TMP_REG3; 961 other_r = TMP_REG3;
962 argw = 0; 962 argw = 0;
963 } 963 }
964 else if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, argw - compiler->cache_argw) != SLJIT_ERR_UNSUPPORTED) { 964 else if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, argw - compiler->cache_argw) != SLJIT_ERR_UNSUPPORTED) {
965 FAIL_IF(compiler->error); 965 FAIL_IF(compiler->error);
966 compiler->cache_argw = argw; 966 compiler->cache_argw = argw;
967 other_r = TMP_REG3; 967 other_r = TMP_REG3;
968 argw = 0; 968 argw = 0;
969 } 969 }
970 } 970 }
971 971
972 if (argw) { 972 if (argw) {
973 FAIL_IF(load_immediate(compiler, TMP_REG3, argw)); 973 FAIL_IF(load_immediate(compiler, TMP_REG3, argw));
974 compiler->cache_arg = SLJIT_MEM; 974 compiler->cache_arg = SLJIT_MEM;
975 compiler->cache_argw = argw; 975 compiler->cache_argw = argw;
976 other_r = TMP_REG3; 976 other_r = TMP_REG3;
977 argw = 0; 977 argw = 0;
978 } 978 }
979 } 979 }
980 980
981 /* No caching here. */ 981 /* No caching here. */
982 arg &= REG_MASK; 982 arg &= REG_MASK;
983 FAIL_IF(push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg) | RM(other_r))); 983 FAIL_IF(push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg) | RM(other_r)));
984 return push_inst(compiler, ADD | RD(arg) | RN(arg) | RM(other_r)); 984 return push_inst(compiler, ADD | RD(arg) | RN(arg) | RM(other_r));
985 } 985 }
986 986
987 if (arg & OFFS_REG_MASK) { 987 if (arg & OFFS_REG_MASK) {
988 other_r = OFFS_REG(arg); 988 other_r = OFFS_REG(arg);
989 arg &= REG_MASK; 989 arg &= REG_MASK;
990 FAIL_IF(push_inst(compiler, ADD | RD(tmp_r) | RN(arg) | RM(other_r) | ((argw & 0x3) << 10))); 990 FAIL_IF(push_inst(compiler, ADD | RD(tmp_r) | RN(arg) | RM(other_r) | ((argw & 0x3) << 10)));
991 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(tmp_r)); 991 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(tmp_r));
992 } 992 }
993 993
994 if (compiler->cache_arg == arg) { 994 if (compiler->cache_arg == arg) {
995 diff = argw - compiler->cache_argw; 995 diff = argw - compiler->cache_argw;
996 if (diff <= 255 && diff >= -256) 996 if (diff <= 255 && diff >= -256)
997 return push_inst(compiler, sljit_mem_simm[flags & 0x3] | (shift << 30) 997 return push_inst(compiler, sljit_mem_simm[flags & 0x3] | (shift << 30)
998 | RT(reg) | RN(TMP_REG3) | ((diff & 0x1ff) << 12)); 998 | RT(reg) | RN(TMP_REG3) | ((diff & 0x1ff) << 12));
999 if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, diff) != SLJIT_ERR_UNSUPPORTED) { 999 if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, diff) != SLJIT_ERR_UNSUPPORTED) {
1000 FAIL_IF(compiler->error); 1000 FAIL_IF(compiler->error);
1001 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg)); 1001 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg));
1002 } 1002 }
1003 } 1003 }
1004 1004
1005 if (argw >= 0 && argw <= 0xffffff && (argw & ((1 << shift) - 1)) == 0) { 1005 if (argw >= 0 && argw <= 0xffffff && (argw & ((1 << shift) - 1)) == 0) {
1006 FAIL_IF(push_inst(compiler, ADDI | (1 << 22) | RD(tmp_r) | RN(arg & REG_MASK) | ((argw >> 12) << 10))); 1006 FAIL_IF(push_inst(compiler, ADDI | (1 << 22) | RD(tmp_r) | RN(arg & REG_MASK) | ((argw >> 12) << 10)));
1007 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) 1007 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30)
1008 | RT(reg) | RN(tmp_r) | ((argw & 0xfff) << (10 - shift))); 1008 | RT(reg) | RN(tmp_r) | ((argw & 0xfff) << (10 - shift)));
1009 } 1009 }
1010 1010
1011 diff = argw - next_argw; 1011 diff = argw - next_argw;
1012 next_arg = (arg & REG_MASK) && (arg == next_arg) && diff <= 0xfff && diff >= -0xfff && diff != 0; 1012 next_arg = (arg & REG_MASK) && (arg == next_arg) && diff <= 0xfff && diff >= -0xfff && diff != 0;
1013 arg &= REG_MASK; 1013 arg &= REG_MASK;
1014 1014
1015 if (arg && compiler->cache_arg == SLJIT_MEM) { 1015 if (arg && compiler->cache_arg == SLJIT_MEM) {
1016 if (compiler->cache_argw == argw) 1016 if (compiler->cache_argw == argw)
1017 return push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg) | RM(TMP_REG3)); 1017 return push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg) | RM(TMP_REG3));
1018 if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, argw - compiler->cache_argw) != SLJIT_ERR_UNSUPPORTED) { 1018 if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, argw - compiler->cache_argw) != SLJIT_ERR_UNSUPPORTED) {
1019 FAIL_IF(compiler->error); 1019 FAIL_IF(compiler->error);
1020 compiler->cache_argw = argw; 1020 compiler->cache_argw = argw;
1021 return push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg) | RM(TMP_REG3)); 1021 return push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg) | RM(TMP_REG3));
1022 } 1022 }
1023 } 1023 }
1024 1024
1025 compiler->cache_argw = argw; 1025 compiler->cache_argw = argw;
1026 if (next_arg && emit_set_delta(compiler, TMP_REG3, arg, argw) != SLJIT_ERR_UNSUPPORTED) { 1026 if (next_arg && emit_set_delta(compiler, TMP_REG3, arg, argw) != SLJIT_ERR_UNSUPPORTED) {
1027 FAIL_IF(compiler->error); 1027 FAIL_IF(compiler->error);
1028 compiler->cache_arg = SLJIT_MEM | arg; 1028 compiler->cache_arg = SLJIT_MEM | arg;
1029 arg = 0; 1029 arg = 0;
1030 } 1030 }
1031 else { 1031 else {
1032 FAIL_IF(load_immediate(compiler, TMP_REG3, argw)); 1032 FAIL_IF(load_immediate(compiler, TMP_REG3, argw));
1033 compiler->cache_arg = SLJIT_MEM; 1033 compiler->cache_arg = SLJIT_MEM;
1034 1034
1035 if (next_arg) { 1035 if (next_arg) {
1036 FAIL_IF(push_inst(compiler, ADD | RD(TMP_REG3) | RN(TMP_REG3) | RM(arg))); 1036 FAIL_IF(push_inst(compiler, ADD | RD(TMP_REG3) | RN(TMP_REG3) | RM(arg)));
1037 compiler->cache_arg = SLJIT_MEM | arg; 1037 compiler->cache_arg = SLJIT_MEM | arg;
1038 arg = 0; 1038 arg = 0;
1039 } 1039 }
1040 } 1040 }
1041 1041
1042 if (arg) 1042 if (arg)
1043 return push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg) | RM(TMP_REG3)); 1043 return push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg) | RM(TMP_REG3));
1044 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(TMP_REG3)); 1044 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(TMP_REG3));
1045} 1045}
1046 1046
1047static SLJIT_INLINE sljit_s32 emit_op_mem(struct sljit_compiler *compiler, sljit_s32 flags, sljit_s32 reg, sljit_s32 arg, sljit_sw argw) 1047static SLJIT_INLINE sljit_s32 emit_op_mem(struct sljit_compiler *compiler, sljit_s32 flags, sljit_s32 reg, sljit_s32 arg, sljit_sw argw)
1048{ 1048{
1049 if (getput_arg_fast(compiler, flags, reg, arg, argw)) 1049 if (getput_arg_fast(compiler, flags, reg, arg, argw))
1050 return compiler->error; 1050 return compiler->error;
1051 compiler->cache_arg = 0; 1051 compiler->cache_arg = 0;
1052 compiler->cache_argw = 0; 1052 compiler->cache_argw = 0;
1053 return getput_arg(compiler, flags, reg, arg, argw, 0, 0); 1053 return getput_arg(compiler, flags, reg, arg, argw, 0, 0);
1054} 1054}
1055 1055
1056static SLJIT_INLINE sljit_s32 emit_op_mem2(struct sljit_compiler *compiler, sljit_s32 flags, sljit_s32 reg, sljit_s32 arg1, sljit_sw arg1w, sljit_s32 arg2, sljit_sw arg2w) 1056static SLJIT_INLINE sljit_s32 emit_op_mem2(struct sljit_compiler *compiler, sljit_s32 flags, sljit_s32 reg, sljit_s32 arg1, sljit_sw arg1w, sljit_s32 arg2, sljit_sw arg2w)
1057{ 1057{
1058 if (getput_arg_fast(compiler, flags, reg, arg1, arg1w)) 1058 if (getput_arg_fast(compiler, flags, reg, arg1, arg1w))
1059 return compiler->error; 1059 return compiler->error;
1060 return getput_arg(compiler, flags, reg, arg1, arg1w, arg2, arg2w); 1060 return getput_arg(compiler, flags, reg, arg1, arg1w, arg2, arg2w);
1061} 1061}
1062 1062
1063/* --------------------------------------------------------------------- */ 1063/* --------------------------------------------------------------------- */
1064/* Entry, exit */ 1064/* Entry, exit */
1065/* --------------------------------------------------------------------- */ 1065/* --------------------------------------------------------------------- */
1066 1066
1067SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_enter(struct sljit_compiler *compiler, 1067SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_enter(struct sljit_compiler *compiler,
1068 sljit_s32 options, sljit_s32 args, sljit_s32 scratches, sljit_s32 saveds, 1068 sljit_s32 options, sljit_s32 args, sljit_s32 scratches, sljit_s32 saveds,
1069 sljit_s32 fscratches, sljit_s32 fsaveds, sljit_s32 local_size) 1069 sljit_s32 fscratches, sljit_s32 fsaveds, sljit_s32 local_size)
1070{ 1070{
1071 sljit_s32 i, tmp, offs, prev, saved_regs_size; 1071 sljit_s32 i, tmp, offs, prev, saved_regs_size;
1072 1072
1073 CHECK_ERROR(); 1073 CHECK_ERROR();
1074 CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size)); 1074 CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
1075 set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size); 1075 set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
1076 1076
1077 saved_regs_size = GET_SAVED_REGISTERS_SIZE(scratches, saveds, 0); 1077 saved_regs_size = GET_SAVED_REGISTERS_SIZE(scratches, saveds, 0);
1078 local_size += saved_regs_size + SLJIT_LOCALS_OFFSET; 1078 local_size += saved_regs_size + SLJIT_LOCALS_OFFSET;
1079 local_size = (local_size + 15) & ~0xf; 1079 local_size = (local_size + 15) & ~0xf;
1080 compiler->local_size = local_size; 1080 compiler->local_size = local_size;
1081 1081
1082 if (local_size <= (63 * sizeof(sljit_sw))) { 1082 SLJIT_ASSERT(local_size >= 0);
 1083 if ((size_t)local_size <= (63 * sizeof(sljit_sw))) {
1083 FAIL_IF(push_inst(compiler, STP_PRE | 29 | RT2(TMP_LR) 1084 FAIL_IF(push_inst(compiler, STP_PRE | 29 | RT2(TMP_LR)
1084 | RN(TMP_SP) | ((-(local_size >> 3) & 0x7f) << 15))); 1085 | RN(TMP_SP) | ((-(local_size >> 3) & 0x7f) << 15)));
1085 FAIL_IF(push_inst(compiler, ADDI | RD(SLJIT_SP) | RN(TMP_SP) | (0 << 10))); 1086 FAIL_IF(push_inst(compiler, ADDI | RD(SLJIT_SP) | RN(TMP_SP) | (0 << 10)));
1086 offs = (local_size - saved_regs_size) << (15 - 3); 1087 offs = (local_size - saved_regs_size) << (15 - 3);
1087 } else { 1088 } else {
1088 offs = 0 << 15; 1089 offs = 0 << 15;
1089 if (saved_regs_size & 0x8) { 1090 if (saved_regs_size & 0x8) {
1090 offs = 1 << 15; 1091 offs = 1 << 15;
1091 saved_regs_size += sizeof(sljit_sw); 1092 saved_regs_size += sizeof(sljit_sw);
1092 } 1093 }
1093 local_size -= saved_regs_size + SLJIT_LOCALS_OFFSET; 1094 local_size -= saved_regs_size + SLJIT_LOCALS_OFFSET;
1094 if (saved_regs_size > 0) 1095 if (saved_regs_size > 0)
1095 FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10))); 1096 FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10)));
1096 } 1097 }
1097 1098
1098 tmp = saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - saveds) : SLJIT_FIRST_SAVED_REG; 1099 tmp = saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - saveds) : SLJIT_FIRST_SAVED_REG;
1099 prev = -1; 1100 prev = -1;
1100 for (i = SLJIT_S0; i >= tmp; i--) { 1101 for (i = SLJIT_S0; i >= tmp; i--) {
1101 if (prev == -1) { 1102 if (prev == -1) {
1102 if (!(offs & (1 << 15))) { 1103 if (!(offs & (1 << 15))) {
1103 prev = i; 1104 prev = i;
1104 continue; 1105 continue;
1105 } 1106 }
1106 FAIL_IF(push_inst(compiler, STRI | RT(i) | RN(TMP_SP) | (offs >> 5))); 1107 FAIL_IF(push_inst(compiler, STRI | RT(i) | RN(TMP_SP) | (offs >> 5)));
1107 offs += 1 << 15; 1108 offs += 1 << 15;
1108 continue; 1109 continue;
1109 } 1110 }
1110 FAIL_IF(push_inst(compiler, STP | RT(prev) | RT2(i) | RN(TMP_SP) | offs)); 1111 FAIL_IF(push_inst(compiler, STP | RT(prev) | RT2(i) | RN(TMP_SP) | offs));
1111 offs += 2 << 15; 1112 offs += 2 << 15;
1112 prev = -1; 1113 prev = -1;
1113 } 1114 }
1114 1115
1115 for (i = scratches; i >= SLJIT_FIRST_SAVED_REG; i--) { 1116 for (i = scratches; i >= SLJIT_FIRST_SAVED_REG; i--) {
1116 if (prev == -1) { 1117 if (prev == -1) {
1117 if (!(offs & (1 << 15))) { 1118 if (!(offs & (1 << 15))) {
1118 prev = i; 1119 prev = i;
1119 continue; 1120 continue;
1120 } 1121 }
1121 FAIL_IF(push_inst(compiler, STRI | RT(i) | RN(TMP_SP) | (offs >> 5))); 1122 FAIL_IF(push_inst(compiler, STRI | RT(i) | RN(TMP_SP) | (offs >> 5)));
1122 offs += 1 << 15; 1123 offs += 1 << 15;
1123 continue; 1124 continue;
1124 } 1125 }
1125 FAIL_IF(push_inst(compiler, STP | RT(prev) | RT2(i) | RN(TMP_SP) | offs)); 1126 FAIL_IF(push_inst(compiler, STP | RT(prev) | RT2(i) | RN(TMP_SP) | offs));
1126 offs += 2 << 15; 1127 offs += 2 << 15;
1127 prev = -1; 1128 prev = -1;
1128 } 1129 }
1129 1130
1130 SLJIT_ASSERT(prev == -1); 1131 SLJIT_ASSERT(prev == -1);
1131 1132
1132 if (compiler->local_size > (63 * sizeof(sljit_sw))) { 1133 SLJIT_ASSERT(compiler->local_size >= 0);
 1134 if ((size_t)compiler->local_size > (63 * sizeof(sljit_sw))) {
1133 /* The local_size is already adjusted by the saved registers. */ 1135 /* The local_size is already adjusted by the saved registers. */
1134 if (local_size > 0xfff) { 1136 if (local_size > 0xfff) {
1135 FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | ((local_size >> 12) << 10) | (1 << 22))); 1137 FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | ((local_size >> 12) << 10) | (1 << 22)));
1136 local_size &= 0xfff; 1138 local_size &= 0xfff;
1137 } 1139 }
1138 if (local_size) 1140 if (local_size)
1139 FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (local_size << 10))); 1141 FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (local_size << 10)));
1140 FAIL_IF(push_inst(compiler, STP_PRE | 29 | RT2(TMP_LR) 1142 FAIL_IF(push_inst(compiler, STP_PRE | 29 | RT2(TMP_LR)
1141 | RN(TMP_SP) | ((-(16 >> 3) & 0x7f) << 15))); 1143 | RN(TMP_SP) | ((-(16 >> 3) & 0x7f) << 15)));
1142 FAIL_IF(push_inst(compiler, ADDI | RD(SLJIT_SP) | RN(TMP_SP) | (0 << 10))); 1144 FAIL_IF(push_inst(compiler, ADDI | RD(SLJIT_SP) | RN(TMP_SP) | (0 << 10)));
1143 } 1145 }
1144 1146
1145 if (args >= 1) 1147 if (args >= 1)
1146 FAIL_IF(push_inst(compiler, ORR | RD(SLJIT_S0) | RN(TMP_ZERO) | RM(SLJIT_R0))); 1148 FAIL_IF(push_inst(compiler, ORR | RD(SLJIT_S0) | RN(TMP_ZERO) | RM(SLJIT_R0)));
1147 if (args >= 2) 1149 if (args >= 2)
1148 FAIL_IF(push_inst(compiler, ORR | RD(SLJIT_S1) | RN(TMP_ZERO) | RM(SLJIT_R1))); 1150 FAIL_IF(push_inst(compiler, ORR | RD(SLJIT_S1) | RN(TMP_ZERO) | RM(SLJIT_R1)));
1149 if (args >= 3) 1151 if (args >= 3)
1150 FAIL_IF(push_inst(compiler, ORR | RD(SLJIT_S2) | RN(TMP_ZERO) | RM(SLJIT_R2))); 1152 FAIL_IF(push_inst(compiler, ORR | RD(SLJIT_S2) | RN(TMP_ZERO) | RM(SLJIT_R2)));
1151 1153
1152 return SLJIT_SUCCESS; 1154 return SLJIT_SUCCESS;
1153} 1155}
1154 1156
1155SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_set_context(struct sljit_compiler *compiler, 1157SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_set_context(struct sljit_compiler *compiler,
1156 sljit_s32 options, sljit_s32 args, sljit_s32 scratches, sljit_s32 saveds, 1158 sljit_s32 options, sljit_s32 args, sljit_s32 scratches, sljit_s32 saveds,
1157 sljit_s32 fscratches, sljit_s32 fsaveds, sljit_s32 local_size) 1159 sljit_s32 fscratches, sljit_s32 fsaveds, sljit_s32 local_size)
1158{ 1160{
1159 CHECK_ERROR(); 1161 CHECK_ERROR();
1160 CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size)); 1162 CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
1161 set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size); 1163 set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
1162 1164
1163 local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 0) + SLJIT_LOCALS_OFFSET; 1165 local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 0) + SLJIT_LOCALS_OFFSET;
1164 local_size = (local_size + 15) & ~0xf; 1166 local_size = (local_size + 15) & ~0xf;
1165 compiler->local_size = local_size; 1167 compiler->local_size = local_size;
1166 return SLJIT_SUCCESS; 1168 return SLJIT_SUCCESS;
1167} 1169}
1168 1170
1169SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_return(struct sljit_compiler *compiler, sljit_s32 op, sljit_s32 src, sljit_sw srcw) 1171SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_return(struct sljit_compiler *compiler, sljit_s32 op, sljit_s32 src, sljit_sw srcw)
1170{ 1172{
1171 sljit_s32 local_size; 1173 sljit_s32 local_size;
1172 sljit_s32 i, tmp, offs, prev, saved_regs_size; 1174 sljit_s32 i, tmp, offs, prev, saved_regs_size;
1173 1175
1174 CHECK_ERROR(); 1176 CHECK_ERROR();
1175 CHECK(check_sljit_emit_return(compiler, op, src, srcw)); 1177 CHECK(check_sljit_emit_return(compiler, op, src, srcw));
1176 1178
1177 FAIL_IF(emit_mov_before_return(compiler, op, src, srcw)); 1179 FAIL_IF(emit_mov_before_return(compiler, op, src, srcw));
1178 1180
1179 local_size = compiler->local_size; 1181 local_size = compiler->local_size;
1180 1182
1181 saved_regs_size = GET_SAVED_REGISTERS_SIZE(compiler->scratches, compiler->saveds, 0); 1183 saved_regs_size = GET_SAVED_REGISTERS_SIZE(compiler->scratches, compiler->saveds, 0);
1182 if (local_size <= (63 * sizeof(sljit_sw))) 1184 SLJIT_ASSERT(local_size >= 0);
 1185 if ((size_t)local_size <= (63 * sizeof(sljit_sw)))
1183 offs = (local_size - saved_regs_size) << (15 - 3); 1186 offs = (local_size - saved_regs_size) << (15 - 3);
1184 else { 1187 else {
1185 FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR) 1188 FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR)
1186 | RN(TMP_SP) | (((16 >> 3) & 0x7f) << 15))); 1189 | RN(TMP_SP) | (((16 >> 3) & 0x7f) << 15)));
1187 offs = 0 << 15; 1190 offs = 0 << 15;
1188 if (saved_regs_size & 0x8) { 1191 if (saved_regs_size & 0x8) {
1189 offs = 1 << 15; 1192 offs = 1 << 15;
1190 saved_regs_size += sizeof(sljit_sw); 1193 saved_regs_size += sizeof(sljit_sw);
1191 } 1194 }
1192 local_size -= saved_regs_size + SLJIT_LOCALS_OFFSET; 1195 local_size -= saved_regs_size + SLJIT_LOCALS_OFFSET;
1193 if (local_size > 0xfff) { 1196 if (local_size > 0xfff) {
1194 FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | ((local_size >> 12) << 10) | (1 << 22))); 1197 FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | ((local_size >> 12) << 10) | (1 << 22)));
1195 local_size &= 0xfff; 1198 local_size &= 0xfff;
1196 } 1199 }
1197 if (local_size) 1200 if (local_size)
1198 FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | (local_size << 10))); 1201 FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | (local_size << 10)));
1199 } 1202 }
1200 1203
1201 tmp = compiler->saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - compiler->saveds) : SLJIT_FIRST_SAVED_REG; 1204 tmp = compiler->saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - compiler->saveds) : SLJIT_FIRST_SAVED_REG;
1202 prev = -1; 1205 prev = -1;
1203 for (i = SLJIT_S0; i >= tmp; i--) { 1206 for (i = SLJIT_S0; i >= tmp; i--) {
1204 if (prev == -1) { 1207 if (prev == -1) {
1205 if (!(offs & (1 << 15))) { 1208 if (!(offs & (1 << 15))) {
1206 prev = i; 1209 prev = i;
1207 continue; 1210 continue;
1208 } 1211 }
1209 FAIL_IF(push_inst(compiler, LDRI | RT(i) | RN(TMP_SP) | (offs >> 5))); 1212 FAIL_IF(push_inst(compiler, LDRI | RT(i) | RN(TMP_SP) | (offs >> 5)));
1210 offs += 1 << 15; 1213 offs += 1 << 15;
1211 continue; 1214 continue;
1212 } 1215 }
1213 FAIL_IF(push_inst(compiler, LDP | RT(prev) | RT2(i) | RN(TMP_SP) | offs)); 1216 FAIL_IF(push_inst(compiler, LDP | RT(prev) | RT2(i) | RN(TMP_SP) | offs));
1214 offs += 2 << 15; 1217 offs += 2 << 15;
1215 prev = -1; 1218 prev = -1;
1216 } 1219 }
1217 1220
1218 for (i = compiler->scratches; i >= SLJIT_FIRST_SAVED_REG; i--) { 1221 for (i = compiler->scratches; i >= SLJIT_FIRST_SAVED_REG; i--) {
1219 if (prev == -1) { 1222 if (prev == -1) {
1220 if (!(offs & (1 << 15))) { 1223 if (!(offs & (1 << 15))) {
1221 prev = i; 1224 prev = i;
1222 continue; 1225 continue;
1223 } 1226 }
1224 FAIL_IF(push_inst(compiler, LDRI | RT(i) | RN(TMP_SP) | (offs >> 5))); 1227 FAIL_IF(push_inst(compiler, LDRI | RT(i) | RN(TMP_SP) | (offs >> 5)));
1225 offs += 1 << 15; 1228 offs += 1 << 15;
1226 continue; 1229 continue;
1227 } 1230 }
1228 FAIL_IF(push_inst(compiler, LDP | RT(prev) | RT2(i) | RN(TMP_SP) | offs)); 1231 FAIL_IF(push_inst(compiler, LDP | RT(prev) | RT2(i) | RN(TMP_SP) | offs));
1229 offs += 2 << 15; 1232 offs += 2 << 15;
1230 prev = -1; 1233 prev = -1;
1231 } 1234 }
1232 1235
1233 SLJIT_ASSERT(prev == -1); 1236 SLJIT_ASSERT(prev == -1);
1234 1237
1235 if (compiler->local_size <= (63 * sizeof(sljit_sw))) { 1238 SLJIT_ASSERT(compiler->local_size >= 0);
 1239 if ((size_t)compiler->local_size <= (63 * sizeof(sljit_sw))) {
1236 FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR) 1240 FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR)
1237 | RN(TMP_SP) | (((local_size >> 3) & 0x7f) << 15))); 1241 | RN(TMP_SP) | (((local_size >> 3) & 0x7f) << 15)));
1238 } else if (saved_regs_size > 0) { 1242 } else if (saved_regs_size > 0) {
1239 FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10))); 1243 FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10)));
1240 } 1244 }
1241 1245
1242 FAIL_IF(push_inst(compiler, RET | RN(TMP_LR))); 1246 FAIL_IF(push_inst(compiler, RET | RN(TMP_LR)));
1243 return SLJIT_SUCCESS; 1247 return SLJIT_SUCCESS;
1244} 1248}
1245 1249
1246/* --------------------------------------------------------------------- */ 1250/* --------------------------------------------------------------------- */
1247/* Operators */ 1251/* Operators */
1248/* --------------------------------------------------------------------- */ 1252/* --------------------------------------------------------------------- */
1249 1253
1250SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op0(struct sljit_compiler *compiler, sljit_s32 op) 1254SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op0(struct sljit_compiler *compiler, sljit_s32 op)
1251{ 1255{
1252 sljit_ins inv_bits = (op & SLJIT_I32_OP) ? (1 << 31) : 0; 1256 sljit_ins inv_bits = (op & SLJIT_I32_OP) ? (1 << 31) : 0;
1253 1257
1254 CHECK_ERROR(); 1258 CHECK_ERROR();
1255 CHECK(check_sljit_emit_op0(compiler, op)); 1259 CHECK(check_sljit_emit_op0(compiler, op));
1256 1260
1257 op = GET_OPCODE(op); 1261 op = GET_OPCODE(op);
1258 switch (op) { 1262 switch (op) {
1259 case SLJIT_BREAKPOINT: 1263 case SLJIT_BREAKPOINT:
1260 return push_inst(compiler, BRK); 1264 return push_inst(compiler, BRK);
1261 case SLJIT_NOP: 1265 case SLJIT_NOP:
1262 return push_inst(compiler, NOP); 1266 return push_inst(compiler, NOP);
1263 case SLJIT_LMUL_UW: 1267 case SLJIT_LMUL_UW:
1264 case SLJIT_LMUL_SW: 1268 case SLJIT_LMUL_SW:
1265 FAIL_IF(push_inst(compiler, ORR | RD(TMP_REG1) | RN(TMP_ZERO) | RM(SLJIT_R0))); 1269 FAIL_IF(push_inst(compiler, ORR | RD(TMP_REG1) | RN(TMP_ZERO) | RM(SLJIT_R0)));
1266 FAIL_IF(push_inst(compiler, MADD | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1) | RT2(TMP_ZERO))); 1270 FAIL_IF(push_inst(compiler, MADD | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1) | RT2(TMP_ZERO)));
1267 return push_inst(compiler, (op == SLJIT_LMUL_UW ? UMULH : SMULH) | RD(SLJIT_R1) | RN(TMP_REG1) | RM(SLJIT_R1)); 1271 return push_inst(compiler, (op == SLJIT_LMUL_UW ? UMULH : SMULH) | RD(SLJIT_R1) | RN(TMP_REG1) | RM(SLJIT_R1));
1268 case SLJIT_DIVMOD_UW: 1272 case SLJIT_DIVMOD_UW:
1269 case SLJIT_DIVMOD_SW: 1273 case SLJIT_DIVMOD_SW:
1270 FAIL_IF(push_inst(compiler, (ORR ^ inv_bits) | RD(TMP_REG1) | RN(TMP_ZERO) | RM(SLJIT_R0))); 1274 FAIL_IF(push_inst(compiler, (ORR ^ inv_bits) | RD(TMP_REG1) | RN(TMP_ZERO) | RM(SLJIT_R0)));
1271 FAIL_IF(push_inst(compiler, ((op == SLJIT_DIVMOD_UW ? UDIV : SDIV) ^ inv_bits) | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1))); 1275 FAIL_IF(push_inst(compiler, ((op == SLJIT_DIVMOD_UW ? UDIV : SDIV) ^ inv_bits) | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1)));
1272 FAIL_IF(push_inst(compiler, (MADD ^ inv_bits) | RD(SLJIT_R1) | RN(SLJIT_R0) | RM(SLJIT_R1) | RT2(TMP_ZERO))); 1276 FAIL_IF(push_inst(compiler, (MADD ^ inv_bits) | RD(SLJIT_R1) | RN(SLJIT_R0) | RM(SLJIT_R1) | RT2(TMP_ZERO)));
1273 return push_inst(compiler, (SUB ^ inv_bits) | RD(SLJIT_R1) | RN(TMP_REG1) | RM(SLJIT_R1)); 1277 return push_inst(compiler, (SUB ^ inv_bits) | RD(SLJIT_R1) | RN(TMP_REG1) | RM(SLJIT_R1));
1274 case SLJIT_DIV_UW: 1278 case SLJIT_DIV_UW:
1275 case SLJIT_DIV_SW: 1279 case SLJIT_DIV_SW:
1276 return push_inst(compiler, ((op == SLJIT_DIV_UW ? UDIV : SDIV) ^ inv_bits) | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1)); 1280 return push_inst(compiler, ((op == SLJIT_DIV_UW ? UDIV : SDIV) ^ inv_bits) | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1));
1277 } 1281 }
1278 1282
1279 return SLJIT_SUCCESS; 1283 return SLJIT_SUCCESS;
1280} 1284}
1281 1285
1282SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compiler, sljit_s32 op, 1286SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compiler, sljit_s32 op,
1283 sljit_s32 dst, sljit_sw dstw, 1287 sljit_s32 dst, sljit_sw dstw,
1284 sljit_s32 src, sljit_sw srcw) 1288 sljit_s32 src, sljit_sw srcw)
1285{ 1289{
1286 sljit_s32 dst_r, flags, mem_flags; 1290 sljit_s32 dst_r, flags, mem_flags;
1287 sljit_s32 op_flags = GET_ALL_FLAGS(op); 1291 sljit_s32 op_flags = GET_ALL_FLAGS(op);
1288 1292
1289 CHECK_ERROR(); 1293 CHECK_ERROR();
1290 CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw)); 1294 CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw));
1291 ADJUST_LOCAL_OFFSET(dst, dstw); 1295 ADJUST_LOCAL_OFFSET(dst, dstw);
1292 ADJUST_LOCAL_OFFSET(src, srcw); 1296 ADJUST_LOCAL_OFFSET(src, srcw);
1293 1297
1294 compiler->cache_arg = 0; 1298 compiler->cache_arg = 0;
1295 compiler->cache_argw = 0; 1299 compiler->cache_argw = 0;
1296 1300
1297 dst_r = SLOW_IS_REG(dst) ? dst : TMP_REG1; 1301 dst_r = SLOW_IS_REG(dst) ? dst : TMP_REG1;
1298 1302
1299 op = GET_OPCODE(op); 1303 op = GET_OPCODE(op);
1300 if (op >= SLJIT_MOV && op <= SLJIT_MOVU_P) { 1304 if (op >= SLJIT_MOV && op <= SLJIT_MOVU_P) {
1301 switch (op) { 1305 switch (op) {
1302 case SLJIT_MOV: 1306 case SLJIT_MOV:
1303 case SLJIT_MOV_P: 1307 case SLJIT_MOV_P:
1304 flags = WORD_SIZE; 1308 flags = WORD_SIZE;
1305 break; 1309 break;
1306 case SLJIT_MOV_U8: 1310 case SLJIT_MOV_U8:
1307 flags = BYTE_SIZE; 1311 flags = BYTE_SIZE;
1308 if (src & SLJIT_IMM) 1312 if (src & SLJIT_IMM)
1309 srcw = (sljit_u8)srcw; 1313 srcw = (sljit_u8)srcw;
1310 break; 1314 break;
1311 case SLJIT_MOV_S8: 1315 case SLJIT_MOV_S8:
1312 flags = BYTE_SIZE | SIGNED; 1316 flags = BYTE_SIZE | SIGNED;
1313 if (src & SLJIT_IMM) 1317 if (src & SLJIT_IMM)
1314 srcw = (sljit_s8)srcw; 1318 srcw = (sljit_s8)srcw;
1315 break; 1319 break;
1316 case SLJIT_MOV_U16: 1320 case SLJIT_MOV_U16:
1317 flags = HALF_SIZE; 1321 flags = HALF_SIZE;
1318 if (src & SLJIT_IMM) 1322 if (src & SLJIT_IMM)
1319 srcw = (sljit_u16)srcw; 1323 srcw = (sljit_u16)srcw;
1320 break; 1324 break;
1321 case SLJIT_MOV_S16: 1325 case SLJIT_MOV_S16:
1322 flags = HALF_SIZE | SIGNED; 1326 flags = HALF_SIZE | SIGNED;
1323 if (src & SLJIT_IMM) 1327 if (src & SLJIT_IMM)
1324 srcw = (sljit_s16)srcw; 1328 srcw = (sljit_s16)srcw;
1325 break; 1329 break;
1326 case SLJIT_MOV_U32: 1330 case SLJIT_MOV_U32:
1327 flags = INT_SIZE; 1331 flags = INT_SIZE;
1328 if (src & SLJIT_IMM) 1332 if (src & SLJIT_IMM)
1329 srcw = (sljit_u32)srcw; 1333 srcw = (sljit_u32)srcw;
1330 break; 1334 break;
1331 case SLJIT_MOV_S32: 1335 case SLJIT_MOV_S32:
1332 flags = INT_SIZE | SIGNED; 1336 flags = INT_SIZE | SIGNED;
1333 if (src & SLJIT_IMM) 1337 if (src & SLJIT_IMM)
1334 srcw = (sljit_s32)srcw; 1338 srcw = (sljit_s32)srcw;
1335 break; 1339 break;
1336 case SLJIT_MOVU: 1340 case SLJIT_MOVU:
1337 case SLJIT_MOVU_P: 1341 case SLJIT_MOVU_P:
1338 flags = WORD_SIZE | UPDATE; 1342 flags = WORD_SIZE | UPDATE;
1339 break; 1343 break;
1340 case SLJIT_MOVU_U8: 1344 case SLJIT_MOVU_U8:
1341 flags = BYTE_SIZE | UPDATE; 1345 flags = BYTE_SIZE | UPDATE;
1342 if (src & SLJIT_IMM) 1346 if (src & SLJIT_IMM)
1343 srcw = (sljit_u8)srcw; 1347 srcw = (sljit_u8)srcw;
1344 break; 1348 break;
1345 case SLJIT_MOVU_S8: 1349 case SLJIT_MOVU_S8:
1346 flags = BYTE_SIZE | SIGNED | UPDATE; 1350 flags = BYTE_SIZE | SIGNED | UPDATE;
1347 if (src & SLJIT_IMM) 1351 if (src & SLJIT_IMM)
1348 srcw = (sljit_s8)srcw; 1352 srcw = (sljit_s8)srcw;
1349 break; 1353 break;
1350 case SLJIT_MOVU_U16: 1354 case SLJIT_MOVU_U16:
1351 flags = HALF_SIZE | UPDATE; 1355 flags = HALF_SIZE | UPDATE;
1352 if (src & SLJIT_IMM) 1356 if (src & SLJIT_IMM)
1353 srcw = (sljit_u16)srcw; 1357 srcw = (sljit_u16)srcw;
1354 break; 1358 break;
1355 case SLJIT_MOVU_S16: 1359 case SLJIT_MOVU_S16:
1356 flags = HALF_SIZE | SIGNED | UPDATE; 1360 flags = HALF_SIZE | SIGNED | UPDATE;
1357 if (src & SLJIT_IMM) 1361 if (src & SLJIT_IMM)
1358 srcw = (sljit_s16)srcw; 1362 srcw = (sljit_s16)srcw;
1359 break; 1363 break;
1360 case SLJIT_MOVU_U32: 1364 case SLJIT_MOVU_U32:
1361 flags = INT_SIZE | UPDATE; 1365 flags = INT_SIZE | UPDATE;
1362 if (src & SLJIT_IMM) 1366 if (src & SLJIT_IMM)
1363 srcw = (sljit_u32)srcw; 1367 srcw = (sljit_u32)srcw;
1364 break; 1368 break;
1365 case SLJIT_MOVU_S32: 1369 case SLJIT_MOVU_S32:
1366 flags = INT_SIZE | SIGNED | UPDATE; 1370 flags = INT_SIZE | SIGNED | UPDATE;
1367 if (src & SLJIT_IMM) 1371 if (src & SLJIT_IMM)
1368 srcw = (sljit_s32)srcw; 1372 srcw = (sljit_s32)srcw;
1369 break; 1373 break;
1370 default: 1374 default:
1371 SLJIT_UNREACHABLE(); 1375 SLJIT_UNREACHABLE();
1372 flags = 0; 1376 flags = 0;
1373 break; 1377 break;
1374 } 1378 }
1375 1379
1376 if (src & SLJIT_IMM) 1380 if (src & SLJIT_IMM)
1377 FAIL_IF(emit_op_imm(compiler, SLJIT_MOV | ARG2_IMM, dst_r, TMP_REG1, srcw)); 1381 FAIL_IF(emit_op_imm(compiler, SLJIT_MOV | ARG2_IMM, dst_r, TMP_REG1, srcw));
1378 else if (src & SLJIT_MEM) { 1382 else if (src & SLJIT_MEM) {
1379 if (getput_arg_fast(compiler, flags, dst_r, src, srcw)) 1383 if (getput_arg_fast(compiler, flags, dst_r, src, srcw))
1380 FAIL_IF(compiler->error); 1384 FAIL_IF(compiler->error);
1381 else 1385 else
1382 FAIL_IF(getput_arg(compiler, flags, dst_r, src, srcw, dst, dstw)); 1386 FAIL_IF(getput_arg(compiler, flags, dst_r, src, srcw, dst, dstw));
1383 } else { 1387 } else {
1384 if (dst_r != TMP_REG1) 1388 if (dst_r != TMP_REG1)
1385 return emit_op_imm(compiler, op | ((op_flags & SLJIT_I32_OP) ? INT_OP : 0), dst_r, TMP_REG1, src); 1389 return emit_op_imm(compiler, op | ((op_flags & SLJIT_I32_OP) ? INT_OP : 0), dst_r, TMP_REG1, src);
1386 dst_r = src; 1390 dst_r = src;
1387 } 1391 }
1388 1392
1389 if (dst & SLJIT_MEM) { 1393 if (dst & SLJIT_MEM) {
1390 if (getput_arg_fast(compiler, flags | STORE, dst_r, dst, dstw)) 1394 if (getput_arg_fast(compiler, flags | STORE, dst_r, dst, dstw))
1391 return compiler->error; 1395 return compiler->error;
1392 else 1396 else
1393 return getput_arg(compiler, flags | STORE, dst_r, dst, dstw, 0, 0); 1397 return getput_arg(compiler, flags | STORE, dst_r, dst, dstw, 0, 0);
1394 } 1398 }
1395 return SLJIT_SUCCESS; 1399 return SLJIT_SUCCESS;
1396 } 1400 }
1397 1401
1398 flags = HAS_FLAGS(op_flags) ? SET_FLAGS : 0; 1402 flags = HAS_FLAGS(op_flags) ? SET_FLAGS : 0;
1399 mem_flags = WORD_SIZE; 1403 mem_flags = WORD_SIZE;
1400 if (op_flags & SLJIT_I32_OP) { 1404 if (op_flags & SLJIT_I32_OP) {
1401 flags |= INT_OP; 1405 flags |= INT_OP;
1402 mem_flags = INT_SIZE; 1406 mem_flags = INT_SIZE;
1403 } 1407 }
1404 1408
1405 if (dst == SLJIT_UNUSED) 1409 if (dst == SLJIT_UNUSED)
1406 flags |= UNUSED_RETURN; 1410 flags |= UNUSED_RETURN;
1407 1411
1408 if (src & SLJIT_MEM) { 1412 if (src & SLJIT_MEM) {
1409 if (getput_arg_fast(compiler, mem_flags, TMP_REG2, src, srcw)) 1413 if (getput_arg_fast(compiler, mem_flags, TMP_REG2, src, srcw))
1410 FAIL_IF(compiler->error); 1414 FAIL_IF(compiler->error);
1411 else 1415 else
1412 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src, srcw, dst, dstw)); 1416 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src, srcw, dst, dstw));
1413 src = TMP_REG2; 1417 src = TMP_REG2;
1414 } 1418 }
1415 1419
1416 if (src & SLJIT_IMM) { 1420 if (src & SLJIT_IMM) {
1417 flags |= ARG2_IMM; 1421 flags |= ARG2_IMM;
1418 if (op_flags & SLJIT_I32_OP) 1422 if (op_flags & SLJIT_I32_OP)
1419 srcw = (sljit_s32)srcw; 1423 srcw = (sljit_s32)srcw;
1420 } else 1424 } else
1421 srcw = src; 1425 srcw = src;
1422 1426
1423 emit_op_imm(compiler, flags | op, dst_r, TMP_REG1, srcw); 1427 emit_op_imm(compiler, flags | op, dst_r, TMP_REG1, srcw);
1424 1428
1425 if (dst & SLJIT_MEM) { 1429 if (dst & SLJIT_MEM) {
1426 if (getput_arg_fast(compiler, mem_flags | STORE, dst_r, dst, dstw)) 1430 if (getput_arg_fast(compiler, mem_flags | STORE, dst_r, dst, dstw))
1427 return compiler->error; 1431 return compiler->error;
1428 else 1432 else
1429 return getput_arg(compiler, mem_flags | STORE, dst_r, dst, dstw, 0, 0); 1433 return getput_arg(compiler, mem_flags | STORE, dst_r, dst, dstw, 0, 0);
1430 } 1434 }
1431 return SLJIT_SUCCESS; 1435 return SLJIT_SUCCESS;
1432} 1436}
1433 1437
1434SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2(struct sljit_compiler *compiler, sljit_s32 op, 1438SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2(struct sljit_compiler *compiler, sljit_s32 op,
1435 sljit_s32 dst, sljit_sw dstw, 1439 sljit_s32 dst, sljit_sw dstw,
1436 sljit_s32 src1, sljit_sw src1w, 1440 sljit_s32 src1, sljit_sw src1w,
1437 sljit_s32 src2, sljit_sw src2w) 1441 sljit_s32 src2, sljit_sw src2w)
1438{ 1442{
1439 sljit_s32 dst_r, flags, mem_flags; 1443 sljit_s32 dst_r, flags, mem_flags;
1440 1444
1441 CHECK_ERROR(); 1445 CHECK_ERROR();
1442 CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w)); 1446 CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
1443 ADJUST_LOCAL_OFFSET(dst, dstw); 1447 ADJUST_LOCAL_OFFSET(dst, dstw);
1444 ADJUST_LOCAL_OFFSET(src1, src1w); 1448 ADJUST_LOCAL_OFFSET(src1, src1w);
1445 ADJUST_LOCAL_OFFSET(src2, src2w); 1449 ADJUST_LOCAL_OFFSET(src2, src2w);
1446 1450
1447 compiler->cache_arg = 0; 1451 compiler->cache_arg = 0;
1448 compiler->cache_argw = 0; 1452 compiler->cache_argw = 0;
1449 1453
1450 dst_r = SLOW_IS_REG(dst) ? dst : TMP_REG1; 1454 dst_r = SLOW_IS_REG(dst) ? dst : TMP_REG1;
1451 flags = HAS_FLAGS(op) ? SET_FLAGS : 0; 1455 flags = HAS_FLAGS(op) ? SET_FLAGS : 0;
1452 mem_flags = WORD_SIZE; 1456 mem_flags = WORD_SIZE;
1453 if (op & SLJIT_I32_OP) { 1457 if (op & SLJIT_I32_OP) {
1454 flags |= INT_OP; 1458 flags |= INT_OP;
1455 mem_flags = INT_SIZE; 1459 mem_flags = INT_SIZE;
1456 } 1460 }
1457 1461
1458 if (dst == SLJIT_UNUSED) 1462 if (dst == SLJIT_UNUSED)
1459 flags |= UNUSED_RETURN; 1463 flags |= UNUSED_RETURN;
1460 1464
1461 if ((dst & SLJIT_MEM) && !getput_arg_fast(compiler, mem_flags | STORE | ARG_TEST, TMP_REG1, dst, dstw)) 1465 if ((dst & SLJIT_MEM) && !getput_arg_fast(compiler, mem_flags | STORE | ARG_TEST, TMP_REG1, dst, dstw))
1462 flags |= SLOW_DEST; 1466 flags |= SLOW_DEST;
1463 1467
1464 if (src1 & SLJIT_MEM) { 1468 if (src1 & SLJIT_MEM) {
1465 if (getput_arg_fast(compiler, mem_flags, TMP_REG1, src1, src1w)) 1469 if (getput_arg_fast(compiler, mem_flags, TMP_REG1, src1, src1w))
1466 FAIL_IF(compiler->error); 1470 FAIL_IF(compiler->error);
1467 else 1471 else
1468 flags |= SLOW_SRC1; 1472 flags |= SLOW_SRC1;
1469 } 1473 }
1470 if (src2 & SLJIT_MEM) { 1474 if (src2 & SLJIT_MEM) {
1471 if (getput_arg_fast(compiler, mem_flags, TMP_REG2, src2, src2w)) 1475 if (getput_arg_fast(compiler, mem_flags, TMP_REG2, src2, src2w))
1472 FAIL_IF(compiler->error); 1476 FAIL_IF(compiler->error);
1473 else 1477 else
1474 flags |= SLOW_SRC2; 1478 flags |= SLOW_SRC2;
1475 } 1479 }
1476 1480
1477 if ((flags & (SLOW_SRC1 | SLOW_SRC2)) == (SLOW_SRC1 | SLOW_SRC2)) { 1481 if ((flags & (SLOW_SRC1 | SLOW_SRC2)) == (SLOW_SRC1 | SLOW_SRC2)) {
1478 if (!can_cache(src1, src1w, src2, src2w) && can_cache(src1, src1w, dst, dstw)) { 1482 if (!can_cache(src1, src1w, src2, src2w) && can_cache(src1, src1w, dst, dstw)) {
1479 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src2, src2w, src1, src1w)); 1483 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src2, src2w, src1, src1w));
1480 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG1, src1, src1w, dst, dstw)); 1484 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG1, src1, src1w, dst, dstw));
1481 } 1485 }
1482 else { 1486 else {
1483 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG1, src1, src1w, src2, src2w)); 1487 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG1, src1, src1w, src2, src2w));
1484 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src2, src2w, dst, dstw)); 1488 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src2, src2w, dst, dstw));
1485 } 1489 }
1486 } 1490 }
1487 else if (flags & SLOW_SRC1) 1491 else if (flags & SLOW_SRC1)
1488 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG1, src1, src1w, dst, dstw)); 1492 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG1, src1, src1w, dst, dstw));
1489 else if (flags & SLOW_SRC2) 1493 else if (flags & SLOW_SRC2)
1490 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src2, src2w, dst, dstw)); 1494 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src2, src2w, dst, dstw));
1491 1495
1492 if (src1 & SLJIT_MEM) 1496 if (src1 & SLJIT_MEM)
1493 src1 = TMP_REG1; 1497 src1 = TMP_REG1;
1494 if (src2 & SLJIT_MEM) 1498 if (src2 & SLJIT_MEM)
1495 src2 = TMP_REG2; 1499 src2 = TMP_REG2;
1496 1500
1497 if (src1 & SLJIT_IMM) 1501 if (src1 & SLJIT_IMM)
1498 flags |= ARG1_IMM; 1502 flags |= ARG1_IMM;
1499 else 1503 else
1500 src1w = src1; 1504 src1w = src1;
1501 if (src2 & SLJIT_IMM) 1505 if (src2 & SLJIT_IMM)
1502 flags |= ARG2_IMM; 1506 flags |= ARG2_IMM;
1503 else 1507 else
1504 src2w = src2; 1508 src2w = src2;
1505 1509
1506 emit_op_imm(compiler, flags | GET_OPCODE(op), dst_r, src1w, src2w); 1510 emit_op_imm(compiler, flags | GET_OPCODE(op), dst_r, src1w, src2w);
1507 1511
1508 if (dst & SLJIT_MEM) { 1512 if (dst & SLJIT_MEM) {
1509 if (!(flags & SLOW_DEST)) { 1513 if (!(flags & SLOW_DEST)) {
1510 getput_arg_fast(compiler, mem_flags | STORE, dst_r, dst, dstw); 1514 getput_arg_fast(compiler, mem_flags | STORE, dst_r, dst, dstw);
1511 return compiler->error; 1515 return compiler->error;
1512 } 1516 }
1513 return getput_arg(compiler, mem_flags | STORE, TMP_REG1, dst, dstw, 0, 0); 1517 return getput_arg(compiler, mem_flags | STORE, TMP_REG1, dst, dstw, 0, 0);
1514 } 1518 }
1515 1519
1516 return SLJIT_SUCCESS; 1520 return SLJIT_SUCCESS;
1517} 1521}
1518 1522
1519SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_register_index(sljit_s32 reg) 1523SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_register_index(sljit_s32 reg)
1520{ 1524{
1521 CHECK_REG_INDEX(check_sljit_get_register_index(reg)); 1525 CHECK_REG_INDEX(check_sljit_get_register_index(reg));
1522 return reg_map[reg]; 1526 return reg_map[reg];
1523} 1527}
1524 1528
1525SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_float_register_index(sljit_s32 reg) 1529SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_float_register_index(sljit_s32 reg)
1526{ 1530{
1527 CHECK_REG_INDEX(check_sljit_get_float_register_index(reg)); 1531 CHECK_REG_INDEX(check_sljit_get_float_register_index(reg));
1528 return reg; 1532 return reg;
1529} 1533}
1530 1534
1531SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_custom(struct sljit_compiler *compiler, 1535SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_custom(struct sljit_compiler *compiler,
1532 void *instruction, sljit_s32 size) 1536 void *instruction, sljit_s32 size)
1533{ 1537{
1534 CHECK_ERROR(); 1538 CHECK_ERROR();
1535 CHECK(check_sljit_emit_op_custom(compiler, instruction, size)); 1539 CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
1536 1540
1537 return push_inst(compiler, *(sljit_ins*)instruction); 1541 return push_inst(compiler, *(sljit_ins*)instruction);
1538} 1542}
1539 1543
1540/* --------------------------------------------------------------------- */ 1544/* --------------------------------------------------------------------- */
1541/* Floating point operators */ 1545/* Floating point operators */
1542/* --------------------------------------------------------------------- */ 1546/* --------------------------------------------------------------------- */
1543 1547
1544SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_is_fpu_available(void) 1548SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_is_fpu_available(void)
1545{ 1549{
1546#ifdef SLJIT_IS_FPU_AVAILABLE 1550#ifdef SLJIT_IS_FPU_AVAILABLE
1547 return SLJIT_IS_FPU_AVAILABLE; 1551 return SLJIT_IS_FPU_AVAILABLE;
1548#else 1552#else
1549 /* Available by default. */ 1553 /* Available by default. */
1550 return 1; 1554 return 1;
1551#endif 1555#endif
1552} 1556}
1553 1557
1554static sljit_s32 emit_fop_mem(struct sljit_compiler *compiler, sljit_s32 flags, sljit_s32 reg, sljit_s32 arg, sljit_sw argw) 1558static sljit_s32 emit_fop_mem(struct sljit_compiler *compiler, sljit_s32 flags, sljit_s32 reg, sljit_s32 arg, sljit_sw argw)
1555{ 1559{
1556 sljit_u32 shift = MEM_SIZE_SHIFT(flags); 1560 sljit_u32 shift = MEM_SIZE_SHIFT(flags);
1557 sljit_ins ins_bits = (shift << 30); 1561 sljit_ins ins_bits = (shift << 30);
1558 sljit_s32 other_r; 1562 sljit_s32 other_r;
1559 sljit_sw diff; 1563 sljit_sw diff;
1560 1564
1561 SLJIT_ASSERT(arg & SLJIT_MEM); 1565 SLJIT_ASSERT(arg & SLJIT_MEM);
1562 1566
1563 if (!(flags & STORE)) 1567 if (!(flags & STORE))
1564 ins_bits |= 1 << 22; 1568 ins_bits |= 1 << 22;
1565 1569
1566 if (arg & OFFS_REG_MASK) { 1570 if (arg & OFFS_REG_MASK) {
1567 argw &= 3; 1571 argw &= 3;
1568 if (!argw || argw == shift) 1572 if (!argw || argw == shift)
1569 return push_inst(compiler, STR_FR | ins_bits | VT(reg) 1573 return push_inst(compiler, STR_FR | ins_bits | VT(reg)
1570 | RN(arg & REG_MASK) | RM(OFFS_REG(arg)) | (argw ? (1 << 12) : 0)); 1574 | RN(arg & REG_MASK) | RM(OFFS_REG(arg)) | (argw ? (1 << 12) : 0));
1571 other_r = OFFS_REG(arg); 1575 other_r = OFFS_REG(arg);
1572 arg &= REG_MASK; 1576 arg &= REG_MASK;
1573 FAIL_IF(push_inst(compiler, ADD | RD(TMP_REG1) | RN(arg) | RM(other_r) | (argw << 10))); 1577 FAIL_IF(push_inst(compiler, ADD | RD(TMP_REG1) | RN(arg) | RM(other_r) | (argw << 10)));
1574 arg = TMP_REG1; 1578 arg = TMP_REG1;
1575 argw = 0; 1579 argw = 0;
1576 } 1580 }
1577 1581
1578 arg &= REG_MASK; 1582 arg &= REG_MASK;
1579 if (arg && argw >= 0 && ((argw >> shift) <= 0xfff) && (argw & ((1 << shift) - 1)) == 0) 1583 if (arg && argw >= 0 && ((argw >> shift) <= 0xfff) && (argw & ((1 << shift) - 1)) == 0)
1580 return push_inst(compiler, STR_FI | ins_bits | VT(reg) | RN(arg) | (argw << (10 - shift))); 1584 return push_inst(compiler, STR_FI | ins_bits | VT(reg) | RN(arg) | (argw << (10 - shift)));
1581 1585
1582 if (arg && argw <= 255 && argw >= -256) 1586 if (arg && argw <= 255 && argw >= -256)
1583 return push_inst(compiler, STUR_FI | ins_bits | VT(reg) | RN(arg) | ((argw & 0x1ff) << 12)); 1587 return push_inst(compiler, STUR_FI | ins_bits | VT(reg) | RN(arg) | ((argw & 0x1ff) << 12));
1584 1588
1585 /* Slow cases */ 1589 /* Slow cases */
1586 if (compiler->cache_arg == SLJIT_MEM && argw != compiler->cache_argw) { 1590 if (compiler->cache_arg == SLJIT_MEM && argw != compiler->cache_argw) {
1587 diff = argw - compiler->cache_argw; 1591 diff = argw - compiler->cache_argw;
1588 if (!arg && diff <= 255 && diff >= -256) 1592 if (!arg && diff <= 255 && diff >= -256)
1589 return push_inst(compiler, STUR_FI | ins_bits | VT(reg) | RN(TMP_REG3) | ((diff & 0x1ff) << 12)); 1593 return push_inst(compiler, STUR_FI | ins_bits | VT(reg) | RN(TMP_REG3) | ((diff & 0x1ff) << 12));
1590 if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, argw - compiler->cache_argw) != SLJIT_ERR_UNSUPPORTED) { 1594 if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, argw - compiler->cache_argw) != SLJIT_ERR_UNSUPPORTED) {
1591 FAIL_IF(compiler->error); 1595 FAIL_IF(compiler->error);
1592 compiler->cache_argw = argw; 1596 compiler->cache_argw = argw;
1593 } 1597 }
1594 } 1598 }
1595 1599
1596 if (compiler->cache_arg != SLJIT_MEM || argw != compiler->cache_argw) { 1600 if (compiler->cache_arg != SLJIT_MEM || argw != compiler->cache_argw) {
1597 compiler->cache_arg = SLJIT_MEM; 1601 compiler->cache_arg = SLJIT_MEM;
1598 compiler->cache_argw = argw; 1602 compiler->cache_argw = argw;
1599 FAIL_IF(load_immediate(compiler, TMP_REG3, argw)); 1603 FAIL_IF(load_immediate(compiler, TMP_REG3, argw));
1600 } 1604 }
1601 1605
1602 if (arg & REG_MASK) 1606 if (arg & REG_MASK)
1603 return push_inst(compiler, STR_FR | ins_bits | VT(reg) | RN(arg) | RM(TMP_REG3)); 1607 return push_inst(compiler, STR_FR | ins_bits | VT(reg) | RN(arg) | RM(TMP_REG3));
1604 return push_inst(compiler, STR_FI | ins_bits | VT(reg) | RN(TMP_REG3)); 1608 return push_inst(compiler, STR_FI | ins_bits | VT(reg) | RN(TMP_REG3));
1605} 1609}
1606 1610
1607static SLJIT_INLINE sljit_s32 sljit_emit_fop1_conv_sw_from_f64(struct sljit_compiler *compiler, sljit_s32 op, 1611static SLJIT_INLINE sljit_s32 sljit_emit_fop1_conv_sw_from_f64(struct sljit_compiler *compiler, sljit_s32 op,
1608 sljit_s32 dst, sljit_sw dstw, 1612 sljit_s32 dst, sljit_sw dstw,
1609 sljit_s32 src, sljit_sw srcw) 1613 sljit_s32 src, sljit_sw srcw)
1610{ 1614{
1611 sljit_s32 dst_r = SLOW_IS_REG(dst) ? dst : TMP_REG1; 1615 sljit_s32 dst_r = SLOW_IS_REG(dst) ? dst : TMP_REG1;
1612 sljit_ins inv_bits = (op & SLJIT_F32_OP) ? (1 << 22) : 0; 1616 sljit_ins inv_bits = (op & SLJIT_F32_OP) ? (1 << 22) : 0;
1613 1617
1614 if (GET_OPCODE(op) == SLJIT_CONV_S32_FROM_F64) 1618 if (GET_OPCODE(op) == SLJIT_CONV_S32_FROM_F64)
1615 inv_bits |= (1 << 31); 1619 inv_bits |= (1 << 31);
1616 1620
1617 if (src & SLJIT_MEM) { 1621 if (src & SLJIT_MEM) {
1618 emit_fop_mem(compiler, (op & SLJIT_F32_OP) ? INT_SIZE : WORD_SIZE, TMP_FREG1, src, srcw); 1622 emit_fop_mem(compiler, (op & SLJIT_F32_OP) ? INT_SIZE : WORD_SIZE, TMP_FREG1, src, srcw);
1619 src = TMP_FREG1; 1623 src = TMP_FREG1;
1620 } 1624 }
1621 1625
1622 FAIL_IF(push_inst(compiler, (FCVTZS ^ inv_bits) | RD(dst_r) | VN(src))); 1626 FAIL_IF(push_inst(compiler, (FCVTZS ^ inv_bits) | RD(dst_r) | VN(src)));
1623 1627
1624 if (dst_r == TMP_REG1 && dst != SLJIT_UNUSED) 1628 if (dst_r == TMP_REG1 && dst != SLJIT_UNUSED)
1625 return emit_op_mem(compiler, ((GET_OPCODE(op) == SLJIT_CONV_S32_FROM_F64) ? INT_SIZE : WORD_SIZE) | STORE, TMP_REG1, dst, dstw); 1629 return emit_op_mem(compiler, ((GET_OPCODE(op) == SLJIT_CONV_S32_FROM_F64) ? INT_SIZE : WORD_SIZE) | STORE, TMP_REG1, dst, dstw);
1626 return SLJIT_SUCCESS; 1630 return SLJIT_SUCCESS;
1627} 1631}
1628 1632
1629static SLJIT_INLINE sljit_s32 sljit_emit_fop1_conv_f64_from_sw(struct sljit_compiler *compiler, sljit_s32 op, 1633static SLJIT_INLINE sljit_s32 sljit_emit_fop1_conv_f64_from_sw(struct sljit_compiler *compiler, sljit_s32 op,
1630 sljit_s32 dst, sljit_sw dstw, 1634 sljit_s32 dst, sljit_sw dstw,
1631 sljit_s32 src, sljit_sw srcw) 1635 sljit_s32 src, sljit_sw srcw)
1632{ 1636{
1633 sljit_s32 dst_r = FAST_IS_REG(dst) ? dst : TMP_FREG1; 1637 sljit_s32 dst_r = FAST_IS_REG(dst) ? dst : TMP_FREG1;
1634 sljit_ins inv_bits = (op & SLJIT_F32_OP) ? (1 << 22) : 0; 1638 sljit_ins inv_bits = (op & SLJIT_F32_OP) ? (1 << 22) : 0;
1635 1639
1636 if (GET_OPCODE(op) == SLJIT_CONV_F64_FROM_S32) 1640 if (GET_OPCODE(op) == SLJIT_CONV_F64_FROM_S32)
1637 inv_bits |= (1 << 31); 1641 inv_bits |= (1 << 31);
1638 1642
1639 if (src & SLJIT_MEM) { 1643 if (src & SLJIT_MEM) {
1640 emit_op_mem(compiler, ((GET_OPCODE(op) == SLJIT_CONV_F64_FROM_S32) ? INT_SIZE : WORD_SIZE), TMP_REG1, src, srcw); 1644 emit_op_mem(compiler, ((GET_OPCODE(op) == SLJIT_CONV_F64_FROM_S32) ? INT_SIZE : WORD_SIZE), TMP_REG1, src, srcw);
1641 src = TMP_REG1; 1645 src = TMP_REG1;
1642 } else if (src & SLJIT_IMM) { 1646 } else if (src & SLJIT_IMM) {
1643#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) 1647#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
1644 if (GET_OPCODE(op) == SLJIT_CONV_F64_FROM_S32) 1648 if (GET_OPCODE(op) == SLJIT_CONV_F64_FROM_S32)
1645 srcw = (sljit_s32)srcw; 1649 srcw = (sljit_s32)srcw;
1646#endif 1650#endif
1647 FAIL_IF(load_immediate(compiler, TMP_REG1, srcw)); 1651 FAIL_IF(load_immediate(compiler, TMP_REG1, srcw));
1648 src = TMP_REG1; 1652 src = TMP_REG1;
1649 } 1653 }
1650 1654
1651 FAIL_IF(push_inst(compiler, (SCVTF ^ inv_bits) | VD(dst_r) | RN(src))); 1655 FAIL_IF(push_inst(compiler, (SCVTF ^ inv_bits) | VD(dst_r) | RN(src)));
1652 1656
1653 if (dst & SLJIT_MEM) 1657 if (dst & SLJIT_MEM)
1654 return emit_fop_mem(compiler, ((op & SLJIT_F32_OP) ? INT_SIZE : WORD_SIZE) | STORE, TMP_FREG1, dst, dstw); 1658 return emit_fop_mem(compiler, ((op & SLJIT_F32_OP) ? INT_SIZE : WORD_SIZE) | STORE, TMP_FREG1, dst, dstw);
1655 return SLJIT_SUCCESS; 1659 return SLJIT_SUCCESS;
1656} 1660}
1657 1661
1658static SLJIT_INLINE sljit_s32 sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_s32 op, 1662static SLJIT_INLINE sljit_s32 sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_s32 op,
1659 sljit_s32 src1, sljit_sw src1w, 1663 sljit_s32 src1, sljit_sw src1w,
1660 sljit_s32 src2, sljit_sw src2w) 1664 sljit_s32 src2, sljit_sw src2w)
1661{ 1665{
1662 sljit_s32 mem_flags = (op & SLJIT_F32_OP) ? INT_SIZE : WORD_SIZE; 1666 sljit_s32 mem_flags = (op & SLJIT_F32_OP) ? INT_SIZE : WORD_SIZE;
1663 sljit_ins inv_bits = (op & SLJIT_F32_OP) ? (1 << 22) : 0; 1667 sljit_ins inv_bits = (op & SLJIT_F32_OP) ? (1 << 22) : 0;
1664 1668
1665 if (src1 & SLJIT_MEM) { 1669 if (src1 & SLJIT_MEM) {
1666 emit_fop_mem(compiler, mem_flags, TMP_FREG1, src1, src1w); 1670 emit_fop_mem(compiler, mem_flags, TMP_FREG1, src1, src1w);
1667 src1 = TMP_FREG1; 1671 src1 = TMP_FREG1;
1668 } 1672 }
1669 1673
1670 if (src2 & SLJIT_MEM) { 1674 if (src2 & SLJIT_MEM) {
1671 emit_fop_mem(compiler, mem_flags, TMP_FREG2, src2, src2w); 1675 emit_fop_mem(compiler, mem_flags, TMP_FREG2, src2, src2w);
1672 src2 = TMP_FREG2; 1676 src2 = TMP_FREG2;
1673 } 1677 }
1674 1678
1675 return push_inst(compiler, (FCMP ^ inv_bits) | VN(src1) | VM(src2)); 1679 return push_inst(compiler, (FCMP ^ inv_bits) | VN(src1) | VM(src2));
1676} 1680}
1677 1681
1678SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop1(struct sljit_compiler *compiler, sljit_s32 op, 1682SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop1(struct sljit_compiler *compiler, sljit_s32 op,
1679 sljit_s32 dst, sljit_sw dstw, 1683 sljit_s32 dst, sljit_sw dstw,
1680 sljit_s32 src, sljit_sw srcw) 1684 sljit_s32 src, sljit_sw srcw)
1681{ 1685{
1682 sljit_s32 dst_r, mem_flags = (op & SLJIT_F32_OP) ? INT_SIZE : WORD_SIZE; 1686 sljit_s32 dst_r, mem_flags = (op & SLJIT_F32_OP) ? INT_SIZE : WORD_SIZE;
1683 sljit_ins inv_bits; 1687 sljit_ins inv_bits;
1684 1688
1685 CHECK_ERROR(); 1689 CHECK_ERROR();
1686 compiler->cache_arg = 0; 1690 compiler->cache_arg = 0;
1687 compiler->cache_argw = 0; 1691 compiler->cache_argw = 0;
1688 1692
1689 SLJIT_COMPILE_ASSERT((INT_SIZE ^ 0x100) == WORD_SIZE, must_be_one_bit_difference); 1693 SLJIT_COMPILE_ASSERT((INT_SIZE ^ 0x100) == WORD_SIZE, must_be_one_bit_difference);
1690 SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw); 1694 SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw);
1691 1695
1692 inv_bits = (op & SLJIT_F32_OP) ? (1 << 22) : 0; 1696 inv_bits = (op & SLJIT_F32_OP) ? (1 << 22) : 0;
1693 dst_r = FAST_IS_REG(dst) ? dst : TMP_FREG1; 1697 dst_r = FAST_IS_REG(dst) ? dst : TMP_FREG1;
1694 1698
1695 if (src & SLJIT_MEM) { 1699 if (src & SLJIT_MEM) {
1696 emit_fop_mem(compiler, (GET_OPCODE(op) == SLJIT_CONV_F64_FROM_F32) ? (mem_flags ^ 0x100) : mem_flags, dst_r, src, srcw); 1700 emit_fop_mem(compiler, (GET_OPCODE(op) == SLJIT_CONV_F64_FROM_F32) ? (mem_flags ^ 0x100) : mem_flags, dst_r, src, srcw);
1697 src = dst_r; 1701 src = dst_r;
1698 } 1702 }
1699 1703
1700 switch (GET_OPCODE(op)) { 1704 switch (GET_OPCODE(op)) {
1701 case SLJIT_MOV_F64: 1705 case SLJIT_MOV_F64:
1702 if (src != dst_r) { 1706 if (src != dst_r) {
1703 if (dst_r != TMP_FREG1) 1707 if (dst_r != TMP_FREG1)
1704 FAIL_IF(push_inst(compiler, (FMOV ^ inv_bits) | VD(dst_r) | VN(src))); 1708 FAIL_IF(push_inst(compiler, (FMOV ^ inv_bits) | VD(dst_r) | VN(src)));
1705 else 1709 else
1706 dst_r = src; 1710 dst_r = src;
1707 } 1711 }
1708 break; 1712 break;
1709 case SLJIT_NEG_F64: 1713 case SLJIT_NEG_F64:
1710 FAIL_IF(push_inst(compiler, (FNEG ^ inv_bits) | VD(dst_r) | VN(src))); 1714 FAIL_IF(push_inst(compiler, (FNEG ^ inv_bits) | VD(dst_r) | VN(src)));
1711 break; 1715 break;
1712 case SLJIT_ABS_F64: 1716 case SLJIT_ABS_F64:
1713 FAIL_IF(push_inst(compiler, (FABS ^ inv_bits) | VD(dst_r) | VN(src))); 1717 FAIL_IF(push_inst(compiler, (FABS ^ inv_bits) | VD(dst_r) | VN(src)));
1714 break; 1718 break;
1715 case SLJIT_CONV_F64_FROM_F32: 1719 case SLJIT_CONV_F64_FROM_F32:
1716 FAIL_IF(push_inst(compiler, FCVT | ((op & SLJIT_F32_OP) ? (1 << 22) : (1 << 15)) | VD(dst_r) | VN(src))); 1720 FAIL_IF(push_inst(compiler, FCVT | ((op & SLJIT_F32_OP) ? (1 << 22) : (1 << 15)) | VD(dst_r) | VN(src)));
1717 break; 1721 break;
1718 } 1722 }
1719 1723
1720 if (dst & SLJIT_MEM) 1724 if (dst & SLJIT_MEM)
1721 return emit_fop_mem(compiler, mem_flags | STORE, dst_r, dst, dstw); 1725 return emit_fop_mem(compiler, mem_flags | STORE, dst_r, dst, dstw);
1722 return SLJIT_SUCCESS; 1726 return SLJIT_SUCCESS;
1723} 1727}
1724 1728
1725SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop2(struct sljit_compiler *compiler, sljit_s32 op, 1729SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop2(struct sljit_compiler *compiler, sljit_s32 op,
1726 sljit_s32 dst, sljit_sw dstw, 1730 sljit_s32 dst, sljit_sw dstw,
1727 sljit_s32 src1, sljit_sw src1w, 1731 sljit_s32 src1, sljit_sw src1w,
1728 sljit_s32 src2, sljit_sw src2w) 1732 sljit_s32 src2, sljit_sw src2w)
1729{ 1733{
1730 sljit_s32 dst_r, mem_flags = (op & SLJIT_F32_OP) ? INT_SIZE : WORD_SIZE; 1734 sljit_s32 dst_r, mem_flags = (op & SLJIT_F32_OP) ? INT_SIZE : WORD_SIZE;
1731 sljit_ins inv_bits = (op & SLJIT_F32_OP) ? (1 << 22) : 0; 1735 sljit_ins inv_bits = (op & SLJIT_F32_OP) ? (1 << 22) : 0;
1732 1736
1733 CHECK_ERROR(); 1737 CHECK_ERROR();
1734 CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w)); 1738 CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
1735 ADJUST_LOCAL_OFFSET(dst, dstw); 1739 ADJUST_LOCAL_OFFSET(dst, dstw);
1736 ADJUST_LOCAL_OFFSET(src1, src1w); 1740 ADJUST_LOCAL_OFFSET(src1, src1w);
1737 ADJUST_LOCAL_OFFSET(src2, src2w); 1741 ADJUST_LOCAL_OFFSET(src2, src2w);
1738 1742
1739 compiler->cache_arg = 0; 1743 compiler->cache_arg = 0;
1740 compiler->cache_argw = 0; 1744 compiler->cache_argw = 0;
1741 1745
1742 dst_r = FAST_IS_REG(dst) ? dst : TMP_FREG1; 1746 dst_r = FAST_IS_REG(dst) ? dst : TMP_FREG1;
1743 if (src1 & SLJIT_MEM) { 1747 if (src1 & SLJIT_MEM) {
1744 emit_fop_mem(compiler, mem_flags, TMP_FREG1, src1, src1w); 1748 emit_fop_mem(compiler, mem_flags, TMP_FREG1, src1, src1w);
1745 src1 = TMP_FREG1; 1749 src1 = TMP_FREG1;
1746 } 1750 }
1747 if (src2 & SLJIT_MEM) { 1751 if (src2 & SLJIT_MEM) {
1748 emit_fop_mem(compiler, mem_flags, TMP_FREG2, src2, src2w); 1752 emit_fop_mem(compiler, mem_flags, TMP_FREG2, src2, src2w);
1749 src2 = TMP_FREG2; 1753 src2 = TMP_FREG2;
1750 } 1754 }
1751 1755
1752 switch (GET_OPCODE(op)) { 1756 switch (GET_OPCODE(op)) {
1753 case SLJIT_ADD_F64: 1757 case SLJIT_ADD_F64:
1754 FAIL_IF(push_inst(compiler, (FADD ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2))); 1758 FAIL_IF(push_inst(compiler, (FADD ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2)));
1755 break; 1759 break;
1756 case SLJIT_SUB_F64: 1760 case SLJIT_SUB_F64:
1757 FAIL_IF(push_inst(compiler, (FSUB ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2))); 1761 FAIL_IF(push_inst(compiler, (FSUB ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2)));
1758 break; 1762 break;
1759 case SLJIT_MUL_F64: 1763 case SLJIT_MUL_F64:
1760 FAIL_IF(push_inst(compiler, (FMUL ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2))); 1764 FAIL_IF(push_inst(compiler, (FMUL ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2)));
1761 break; 1765 break;
1762 case SLJIT_DIV_F64: 1766 case SLJIT_DIV_F64:
1763 FAIL_IF(push_inst(compiler, (FDIV ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2))); 1767 FAIL_IF(push_inst(compiler, (FDIV ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2)));
1764 break; 1768 break;
1765 } 1769 }
1766 1770
1767 if (!(dst & SLJIT_MEM)) 1771 if (!(dst & SLJIT_MEM))
1768 return SLJIT_SUCCESS; 1772 return SLJIT_SUCCESS;
1769 return emit_fop_mem(compiler, mem_flags | STORE, TMP_FREG1, dst, dstw); 1773 return emit_fop_mem(compiler, mem_flags | STORE, TMP_FREG1, dst, dstw);
1770} 1774}
1771 1775
1772/* --------------------------------------------------------------------- */ 1776/* --------------------------------------------------------------------- */
1773/* Other instructions */ 1777/* Other instructions */
1774/* --------------------------------------------------------------------- */ 1778/* --------------------------------------------------------------------- */
1775 1779
1776SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw) 1780SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw)
1777{ 1781{
1778 CHECK_ERROR(); 1782 CHECK_ERROR();
1779 CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw)); 1783 CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
1780 ADJUST_LOCAL_OFFSET(dst, dstw); 1784 ADJUST_LOCAL_OFFSET(dst, dstw);
1781 1785
1782 /* For UNUSED dst. Uncommon, but possible. */ 1786 /* For UNUSED dst. Uncommon, but possible. */
1783 if (dst == SLJIT_UNUSED) 1787 if (dst == SLJIT_UNUSED)
1784 return SLJIT_SUCCESS; 1788 return SLJIT_SUCCESS;
1785 1789
1786 if (FAST_IS_REG(dst)) 1790 if (FAST_IS_REG(dst))
1787 return push_inst(compiler, ORR | RD(dst) | RN(TMP_ZERO) | RM(TMP_LR)); 1791 return push_inst(compiler, ORR | RD(dst) | RN(TMP_ZERO) | RM(TMP_LR));
1788 1792
1789 /* Memory. */ 1793 /* Memory. */
1790 return emit_op_mem(compiler, WORD_SIZE | STORE, TMP_LR, dst, dstw); 1794 return emit_op_mem(compiler, WORD_SIZE | STORE, TMP_LR, dst, dstw);
1791} 1795}
1792 1796
1793SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_s32 src, sljit_sw srcw) 1797SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_s32 src, sljit_sw srcw)
1794{ 1798{
1795 CHECK_ERROR(); 1799 CHECK_ERROR();
1796 CHECK(check_sljit_emit_fast_return(compiler, src, srcw)); 1800 CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
1797 ADJUST_LOCAL_OFFSET(src, srcw); 1801 ADJUST_LOCAL_OFFSET(src, srcw);
1798 1802
1799 if (FAST_IS_REG(src)) 1803 if (FAST_IS_REG(src))
1800 FAIL_IF(push_inst(compiler, ORR | RD(TMP_LR) | RN(TMP_ZERO) | RM(src))); 1804 FAIL_IF(push_inst(compiler, ORR | RD(TMP_LR) | RN(TMP_ZERO) | RM(src)));
1801 else if (src & SLJIT_MEM) 1805 else if (src & SLJIT_MEM)
1802 FAIL_IF(emit_op_mem(compiler, WORD_SIZE, TMP_LR, src, srcw)); 1806 FAIL_IF(emit_op_mem(compiler, WORD_SIZE, TMP_LR, src, srcw));
1803 else if (src & SLJIT_IMM) 1807 else if (src & SLJIT_IMM)
1804 FAIL_IF(load_immediate(compiler, TMP_LR, srcw)); 1808 FAIL_IF(load_immediate(compiler, TMP_LR, srcw));
1805 1809
1806 return push_inst(compiler, RET | RN(TMP_LR)); 1810 return push_inst(compiler, RET | RN(TMP_LR));
1807} 1811}
1808 1812
1809/* --------------------------------------------------------------------- */ 1813/* --------------------------------------------------------------------- */
1810/* Conditional instructions */ 1814/* Conditional instructions */
1811/* --------------------------------------------------------------------- */ 1815/* --------------------------------------------------------------------- */
1812 1816
1813static sljit_uw get_cc(sljit_s32 type) 1817static sljit_uw get_cc(sljit_s32 type)
1814{ 1818{
1815 switch (type) { 1819 switch (type) {
1816 case SLJIT_EQUAL: 1820 case SLJIT_EQUAL:
1817 case SLJIT_MUL_NOT_OVERFLOW: 1821 case SLJIT_MUL_NOT_OVERFLOW:
1818 case SLJIT_EQUAL_F64: 1822 case SLJIT_EQUAL_F64:
1819 return 0x1; 1823 return 0x1;
1820 1824
1821 case SLJIT_NOT_EQUAL: 1825 case SLJIT_NOT_EQUAL:
1822 case SLJIT_MUL_OVERFLOW: 1826 case SLJIT_MUL_OVERFLOW:
1823 case SLJIT_NOT_EQUAL_F64: 1827 case SLJIT_NOT_EQUAL_F64:
1824 return 0x0; 1828 return 0x0;
1825 1829
1826 case SLJIT_LESS: 1830 case SLJIT_LESS:
1827 case SLJIT_LESS_F64: 1831 case SLJIT_LESS_F64:
1828 return 0x2; 1832 return 0x2;
1829 1833
1830 case SLJIT_GREATER_EQUAL: 1834 case SLJIT_GREATER_EQUAL:
1831 case SLJIT_GREATER_EQUAL_F64: 1835 case SLJIT_GREATER_EQUAL_F64:
1832 return 0x3; 1836 return 0x3;
1833 1837
1834 case SLJIT_GREATER: 1838 case SLJIT_GREATER:
1835 case SLJIT_GREATER_F64: 1839 case SLJIT_GREATER_F64:
1836 return 0x9; 1840 return 0x9;
1837 1841
1838 case SLJIT_LESS_EQUAL: 1842 case SLJIT_LESS_EQUAL:
1839 case SLJIT_LESS_EQUAL_F64: 1843 case SLJIT_LESS_EQUAL_F64:
1840 return 0x8; 1844 return 0x8;
1841 1845
1842 case SLJIT_SIG_LESS: 1846 case SLJIT_SIG_LESS:
1843 return 0xa; 1847 return 0xa;
1844 1848
1845 case SLJIT_SIG_GREATER_EQUAL: 1849 case SLJIT_SIG_GREATER_EQUAL:
1846 return 0xb; 1850 return 0xb;
1847 1851
1848 case SLJIT_SIG_GREATER: 1852 case SLJIT_SIG_GREATER:
1849 return 0xd; 1853 return 0xd;
1850 1854
1851 case SLJIT_SIG_LESS_EQUAL: 1855 case SLJIT_SIG_LESS_EQUAL:
1852 return 0xc; 1856 return 0xc;
1853 1857
1854 case SLJIT_OVERFLOW: 1858 case SLJIT_OVERFLOW:
1855 case SLJIT_UNORDERED_F64: 1859 case SLJIT_UNORDERED_F64:
1856 return 0x7; 1860 return 0x7;
1857 1861
1858 case SLJIT_NOT_OVERFLOW: 1862 case SLJIT_NOT_OVERFLOW:
1859 case SLJIT_ORDERED_F64: 1863 case SLJIT_ORDERED_F64:
1860 return 0x6; 1864 return 0x6;
1861 1865
1862 default: 1866 default:
1863 SLJIT_UNREACHABLE(); 1867 SLJIT_UNREACHABLE();
1864 return 0xe; 1868 return 0xe;
1865 } 1869 }
1866} 1870}
1867 1871
1868SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) 1872SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler)
1869{ 1873{
1870 struct sljit_label *label; 1874 struct sljit_label *label;
1871 1875
1872 CHECK_ERROR_PTR(); 1876 CHECK_ERROR_PTR();
1873 CHECK_PTR(check_sljit_emit_label(compiler)); 1877 CHECK_PTR(check_sljit_emit_label(compiler));
1874 1878
1875 if (compiler->last_label && compiler->last_label->size == compiler->size) 1879 if (compiler->last_label && compiler->last_label->size == compiler->size)
1876 return compiler->last_label; 1880 return compiler->last_label;
1877 1881
1878 label = (struct sljit_label*)ensure_abuf(compiler, sizeof(struct sljit_label)); 1882 label = (struct sljit_label*)ensure_abuf(compiler, sizeof(struct sljit_label));
1879 PTR_FAIL_IF(!label); 1883 PTR_FAIL_IF(!label);
1880 set_label(label, compiler); 1884 set_label(label, compiler);
1881 return label; 1885 return label;
1882} 1886}
1883 1887
1884SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, sljit_s32 type) 1888SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, sljit_s32 type)
1885{ 1889{
1886 struct sljit_jump *jump; 1890 struct sljit_jump *jump;
1887 1891
1888 CHECK_ERROR_PTR(); 1892 CHECK_ERROR_PTR();
1889 CHECK_PTR(check_sljit_emit_jump(compiler, type)); 1893 CHECK_PTR(check_sljit_emit_jump(compiler, type));
1890 1894
1891 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump)); 1895 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
1892 PTR_FAIL_IF(!jump); 1896 PTR_FAIL_IF(!jump);
1893 set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP); 1897 set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP);
1894 type &= 0xff; 1898 type &= 0xff;
1895 1899
1896 if (type < SLJIT_JUMP) { 1900 if (type < SLJIT_JUMP) {
1897 jump->flags |= IS_COND; 1901 jump->flags |= IS_COND;
1898 PTR_FAIL_IF(push_inst(compiler, B_CC | (6 << 5) | get_cc(type))); 1902 PTR_FAIL_IF(push_inst(compiler, B_CC | (6 << 5) | get_cc(type)));
1899 } 1903 }
1900 else if (type >= SLJIT_FAST_CALL) 1904 else if (type >= SLJIT_FAST_CALL)
1901 jump->flags |= IS_BL; 1905 jump->flags |= IS_BL;
1902 1906
1903 PTR_FAIL_IF(emit_imm64_const(compiler, TMP_REG1, 0)); 1907 PTR_FAIL_IF(emit_imm64_const(compiler, TMP_REG1, 0));
1904 jump->addr = compiler->size; 1908 jump->addr = compiler->size;
1905 PTR_FAIL_IF(push_inst(compiler, ((type >= SLJIT_FAST_CALL) ? BLR : BR) | RN(TMP_REG1))); 1909 PTR_FAIL_IF(push_inst(compiler, ((type >= SLJIT_FAST_CALL) ? BLR : BR) | RN(TMP_REG1)));
1906 1910
1907 return jump; 1911 return jump;
1908} 1912}
1909 1913
1910static SLJIT_INLINE struct sljit_jump* emit_cmp_to0(struct sljit_compiler *compiler, sljit_s32 type, 1914static SLJIT_INLINE struct sljit_jump* emit_cmp_to0(struct sljit_compiler *compiler, sljit_s32 type,
1911 sljit_s32 src, sljit_sw srcw) 1915 sljit_s32 src, sljit_sw srcw)
1912{ 1916{
1913 struct sljit_jump *jump; 1917 struct sljit_jump *jump;
1914 sljit_ins inv_bits = (type & SLJIT_I32_OP) ? (1 << 31) : 0; 1918 sljit_ins inv_bits = (type & SLJIT_I32_OP) ? (1 << 31) : 0;
1915 1919
1916 SLJIT_ASSERT((type & 0xff) == SLJIT_EQUAL || (type & 0xff) == SLJIT_NOT_EQUAL); 1920 SLJIT_ASSERT((type & 0xff) == SLJIT_EQUAL || (type & 0xff) == SLJIT_NOT_EQUAL);
1917 ADJUST_LOCAL_OFFSET(src, srcw); 1921 ADJUST_LOCAL_OFFSET(src, srcw);
1918 1922
1919 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump)); 1923 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
1920 PTR_FAIL_IF(!jump); 1924 PTR_FAIL_IF(!jump);
1921 set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP); 1925 set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP);
1922 jump->flags |= IS_CBZ | IS_COND; 1926 jump->flags |= IS_CBZ | IS_COND;
1923 1927
1924 if (src & SLJIT_MEM) { 1928 if (src & SLJIT_MEM) {
1925 PTR_FAIL_IF(emit_op_mem(compiler, inv_bits ? INT_SIZE : WORD_SIZE, TMP_REG1, src, srcw)); 1929 PTR_FAIL_IF(emit_op_mem(compiler, inv_bits ? INT_SIZE : WORD_SIZE, TMP_REG1, src, srcw));
1926 src = TMP_REG1; 1930 src = TMP_REG1;
1927 } 1931 }
1928 else if (src & SLJIT_IMM) { 1932 else if (src & SLJIT_IMM) {
1929 PTR_FAIL_IF(load_immediate(compiler, TMP_REG1, srcw)); 1933 PTR_FAIL_IF(load_immediate(compiler, TMP_REG1, srcw));
1930 src = TMP_REG1; 1934 src = TMP_REG1;
1931 } 1935 }
1932 SLJIT_ASSERT(FAST_IS_REG(src)); 1936 SLJIT_ASSERT(FAST_IS_REG(src));
1933 1937
1934 if ((type & 0xff) == SLJIT_EQUAL) 1938 if ((type & 0xff) == SLJIT_EQUAL)
1935 inv_bits |= 1 << 24; 1939 inv_bits |= 1 << 24;
1936 1940
1937 PTR_FAIL_IF(push_inst(compiler, (CBZ ^ inv_bits) | (6 << 5) | RT(src))); 1941 PTR_FAIL_IF(push_inst(compiler, (CBZ ^ inv_bits) | (6 << 5) | RT(src)));
1938 PTR_FAIL_IF(emit_imm64_const(compiler, TMP_REG1, 0)); 1942 PTR_FAIL_IF(emit_imm64_const(compiler, TMP_REG1, 0));
1939 jump->addr = compiler->size; 1943 jump->addr = compiler->size;
1940 PTR_FAIL_IF(push_inst(compiler, BR | RN(TMP_REG1))); 1944 PTR_FAIL_IF(push_inst(compiler, BR | RN(TMP_REG1)));
1941 return jump; 1945 return jump;
1942} 1946}
1943 1947
1944SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_ijump(struct sljit_compiler *compiler, sljit_s32 type, sljit_s32 src, sljit_sw srcw) 1948SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_ijump(struct sljit_compiler *compiler, sljit_s32 type, sljit_s32 src, sljit_sw srcw)
1945{ 1949{
1946 struct sljit_jump *jump; 1950 struct sljit_jump *jump;
1947 1951
1948 CHECK_ERROR(); 1952 CHECK_ERROR();
1949 CHECK(check_sljit_emit_ijump(compiler, type, src, srcw)); 1953 CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
1950 ADJUST_LOCAL_OFFSET(src, srcw); 1954 ADJUST_LOCAL_OFFSET(src, srcw);
1951 1955
1952 /* In ARM, we don't need to touch the arguments. */ 1956 /* In ARM, we don't need to touch the arguments. */
1953 if (!(src & SLJIT_IMM)) { 1957 if (!(src & SLJIT_IMM)) {
1954 if (src & SLJIT_MEM) { 1958 if (src & SLJIT_MEM) {
1955 FAIL_IF(emit_op_mem(compiler, WORD_SIZE, TMP_REG1, src, srcw)); 1959 FAIL_IF(emit_op_mem(compiler, WORD_SIZE, TMP_REG1, src, srcw));
1956 src = TMP_REG1; 1960 src = TMP_REG1;
1957 } 1961 }
1958 return push_inst(compiler, ((type >= SLJIT_FAST_CALL) ? BLR : BR) | RN(src)); 1962 return push_inst(compiler, ((type >= SLJIT_FAST_CALL) ? BLR : BR) | RN(src));
1959 } 1963 }
1960 1964
1961 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump)); 1965 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
1962 FAIL_IF(!jump); 1966 FAIL_IF(!jump);
1963 set_jump(jump, compiler, JUMP_ADDR | ((type >= SLJIT_FAST_CALL) ? IS_BL : 0)); 1967 set_jump(jump, compiler, JUMP_ADDR | ((type >= SLJIT_FAST_CALL) ? IS_BL : 0));
1964 jump->u.target = srcw; 1968 jump->u.target = srcw;
1965 1969
1966 FAIL_IF(emit_imm64_const(compiler, TMP_REG1, 0)); 1970 FAIL_IF(emit_imm64_const(compiler, TMP_REG1, 0));
1967 jump->addr = compiler->size; 1971 jump->addr = compiler->size;
1968 return push_inst(compiler, ((type >= SLJIT_FAST_CALL) ? BLR : BR) | RN(TMP_REG1)); 1972 return push_inst(compiler, ((type >= SLJIT_FAST_CALL) ? BLR : BR) | RN(TMP_REG1));
1969} 1973}
1970 1974
1971SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_s32 op, 1975SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_s32 op,
1972 sljit_s32 dst, sljit_sw dstw, 1976 sljit_s32 dst, sljit_sw dstw,
1973 sljit_s32 src, sljit_sw srcw, 1977 sljit_s32 src, sljit_sw srcw,
1974 sljit_s32 type) 1978 sljit_s32 type)
1975{ 1979{
1976 sljit_s32 dst_r, flags, mem_flags; 1980 sljit_s32 dst_r, flags, mem_flags;
1977 sljit_ins cc; 1981 sljit_ins cc;
1978 1982
1979 CHECK_ERROR(); 1983 CHECK_ERROR();
1980 CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type)); 1984 CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type));
1981 ADJUST_LOCAL_OFFSET(dst, dstw); 1985 ADJUST_LOCAL_OFFSET(dst, dstw);
1982 ADJUST_LOCAL_OFFSET(src, srcw); 1986 ADJUST_LOCAL_OFFSET(src, srcw);
1983 1987
1984 if (dst == SLJIT_UNUSED) 1988 if (dst == SLJIT_UNUSED)
1985 return SLJIT_SUCCESS; 1989 return SLJIT_SUCCESS;
1986 1990
1987 cc = get_cc(type & 0xff); 1991 cc = get_cc(type & 0xff);
1988 dst_r = FAST_IS_REG(dst) ? dst : TMP_REG1; 1992 dst_r = FAST_IS_REG(dst) ? dst : TMP_REG1;
1989 1993
1990 if (GET_OPCODE(op) < SLJIT_ADD) { 1994 if (GET_OPCODE(op) < SLJIT_ADD) {
1991 FAIL_IF(push_inst(compiler, CSINC | (cc << 12) | RD(dst_r) | RN(TMP_ZERO) | RM(TMP_ZERO))); 1995 FAIL_IF(push_inst(compiler, CSINC | (cc << 12) | RD(dst_r) | RN(TMP_ZERO) | RM(TMP_ZERO)));
1992 if (dst_r != TMP_REG1) 1996 if (dst_r != TMP_REG1)
1993 return SLJIT_SUCCESS; 1997 return SLJIT_SUCCESS;
1994 return emit_op_mem(compiler, (GET_OPCODE(op) == SLJIT_MOV ? WORD_SIZE : INT_SIZE) | STORE, TMP_REG1, dst, dstw); 1998 return emit_op_mem(compiler, (GET_OPCODE(op) == SLJIT_MOV ? WORD_SIZE : INT_SIZE) | STORE, TMP_REG1, dst, dstw);
1995 } 1999 }
1996 2000
1997 compiler->cache_arg = 0; 2001 compiler->cache_arg = 0;
1998 compiler->cache_argw = 0; 2002 compiler->cache_argw = 0;
1999 flags = HAS_FLAGS(op) ? SET_FLAGS : 0; 2003 flags = HAS_FLAGS(op) ? SET_FLAGS : 0;
2000 mem_flags = WORD_SIZE; 2004 mem_flags = WORD_SIZE;
2001 if (op & SLJIT_I32_OP) { 2005 if (op & SLJIT_I32_OP) {
2002 flags |= INT_OP; 2006 flags |= INT_OP;
2003 mem_flags = INT_SIZE; 2007 mem_flags = INT_SIZE;
2004 } 2008 }
2005 2009
2006 if (src & SLJIT_MEM) { 2010 if (src & SLJIT_MEM) {
2007 FAIL_IF(emit_op_mem2(compiler, mem_flags, TMP_REG1, src, srcw, dst, dstw)); 2011 FAIL_IF(emit_op_mem2(compiler, mem_flags, TMP_REG1, src, srcw, dst, dstw));
2008 src = TMP_REG1; 2012 src = TMP_REG1;
2009 srcw = 0; 2013 srcw = 0;
2010 } else if (src & SLJIT_IMM) 2014 } else if (src & SLJIT_IMM)
2011 flags |= ARG1_IMM; 2015 flags |= ARG1_IMM;
2012 2016
2013 FAIL_IF(push_inst(compiler, CSINC | (cc << 12) | RD(TMP_REG2) | RN(TMP_ZERO) | RM(TMP_ZERO))); 2017 FAIL_IF(push_inst(compiler, CSINC | (cc << 12) | RD(TMP_REG2) | RN(TMP_ZERO) | RM(TMP_ZERO)));
2014 emit_op_imm(compiler, flags | GET_OPCODE(op), dst_r, src, TMP_REG2); 2018 emit_op_imm(compiler, flags | GET_OPCODE(op), dst_r, src, TMP_REG2);
2015 2019
2016 if (dst_r != TMP_REG1) 2020 if (dst_r != TMP_REG1)
2017 return SLJIT_SUCCESS; 2021 return SLJIT_SUCCESS;
2018 return emit_op_mem2(compiler, mem_flags | STORE, TMP_REG1, dst, dstw, 0, 0); 2022 return emit_op_mem2(compiler, mem_flags | STORE, TMP_REG1, dst, dstw, 0, 0);
2019} 2023}
2020 2024
2021SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw, sljit_sw init_value) 2025SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw, sljit_sw init_value)
2022{ 2026{
2023 struct sljit_const *const_; 2027 struct sljit_const *const_;
2024 sljit_s32 dst_r; 2028 sljit_s32 dst_r;
2025 2029
2026 CHECK_ERROR_PTR(); 2030 CHECK_ERROR_PTR();
2027 CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value)); 2031 CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
2028 ADJUST_LOCAL_OFFSET(dst, dstw); 2032 ADJUST_LOCAL_OFFSET(dst, dstw);
2029 2033
2030 const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const)); 2034 const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));
2031 PTR_FAIL_IF(!const_); 2035 PTR_FAIL_IF(!const_);
2032 set_const(const_, compiler); 2036 set_const(const_, compiler);
2033 2037
2034 dst_r = SLOW_IS_REG(dst) ? dst : TMP_REG1; 2038 dst_r = SLOW_IS_REG(dst) ? dst : TMP_REG1;
2035 PTR_FAIL_IF(emit_imm64_const(compiler, dst_r, init_value)); 2039 PTR_FAIL_IF(emit_imm64_const(compiler, dst_r, init_value));
2036 2040
2037 if (dst & SLJIT_MEM) 2041 if (dst & SLJIT_MEM)
2038 PTR_FAIL_IF(emit_op_mem(compiler, WORD_SIZE | STORE, dst_r, dst, dstw)); 2042 PTR_FAIL_IF(emit_op_mem(compiler, WORD_SIZE | STORE, dst_r, dst, dstw));
2039 return const_; 2043 return const_;
2040} 2044}
2041 2045
2042SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset) 2046SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset)
2043{ 2047{
2044 sljit_ins* inst = (sljit_ins*)addr; 2048 sljit_ins* inst = (sljit_ins*)addr;
2045 modify_imm64_const(inst, new_target); 2049 modify_imm64_const(inst, new_target);
2046 inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset); 2050 inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
2047 SLJIT_CACHE_FLUSH(inst, inst + 4); 2051 SLJIT_CACHE_FLUSH(inst, inst + 4);
2048} 2052}
2049 2053
2050SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset) 2054SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset)
2051{ 2055{
2052 sljit_ins* inst = (sljit_ins*)addr; 2056 sljit_ins* inst = (sljit_ins*)addr;
2053 modify_imm64_const(inst, new_constant); 2057 modify_imm64_const(inst, new_constant);
2054 inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset); 2058 inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
2055 SLJIT_CACHE_FLUSH(inst, inst + 4); 2059 SLJIT_CACHE_FLUSH(inst, inst + 4);
2056} 2060}

cvs diff -r1.274.2.2 -r1.274.2.3 src/sys/modules/Makefile (switch to unified diff)

--- src/sys/modules/Makefile 2023/12/30 19:13:50 1.274.2.2
+++ src/sys/modules/Makefile 2024/04/18 15:21:55 1.274.2.3
@@ -1,505 +1,499 @@ @@ -1,505 +1,499 @@
1# $NetBSD: Makefile,v 1.274.2.2 2023/12/30 19:13:50 martin Exp $ 1# $NetBSD: Makefile,v 1.274.2.3 2024/04/18 15:21:55 martin Exp $
2 2
3.include <bsd.own.mk> 3.include <bsd.own.mk>
4 4
5# For all platforms 5# For all platforms
6 6
7# Modules for compatibility with earlier versions of NetBSD 7# Modules for compatibility with earlier versions of NetBSD
8 8
9SUBDIR+= compat_util 9SUBDIR+= compat_util
10SUBDIR+= compat_43 compat_sysctl_09_43 10SUBDIR+= compat_43 compat_sysctl_09_43
11SUBDIR+= compat_09 compat_10 compat_12 compat_13 compat_14 11SUBDIR+= compat_09 compat_10 compat_12 compat_13 compat_14
12SUBDIR+= compat_16 compat_20 compat_30 compat_40 compat_50 12SUBDIR+= compat_16 compat_20 compat_30 compat_40 compat_50
13SUBDIR+= compat_60 compat_70 compat_80 compat_90 13SUBDIR+= compat_60 compat_70 compat_80 compat_90
14 14
15SUBDIR+= compat_sysv_10 compat_sysv_14 compat_sysv_50 15SUBDIR+= compat_sysv_10 compat_sysv_14 compat_sysv_50
16 16
17SUBDIR+= compat_50_quota 17SUBDIR+= compat_50_quota
18 18
19SUBDIR+= compat_raid_50 19SUBDIR+= compat_raid_50
20SUBDIR+= compat_raid_80 20SUBDIR+= compat_raid_80
21 21
22SUBDIR+= compat_crypto_50 22SUBDIR+= compat_crypto_50
23 23
24SUBDIR+= accf_dataready 24SUBDIR+= accf_dataready
25SUBDIR+= accf_httpready 25SUBDIR+= accf_httpready
26SUBDIR+= adosfs 26SUBDIR+= adosfs
27SUBDIR+= adiantum 27SUBDIR+= adiantum
28SUBDIR+= aht20temp 28SUBDIR+= aht20temp
29SUBDIR+= aio 29SUBDIR+= aio
30SUBDIR+= audio 30SUBDIR+= audio
31SUBDIR+= autofs 31SUBDIR+= autofs
32SUBDIR+= blake2s 32SUBDIR+= blake2s
33SUBDIR+= blowfish 33SUBDIR+= blowfish
34SUBDIR+= bpf 34SUBDIR+= bpf
35SUBDIR+= bpf_filter 35SUBDIR+= bpf_filter
36SUBDIR+= bmx280thp 36SUBDIR+= bmx280thp
37SUBDIR+= bmx280thpi2c 37SUBDIR+= bmx280thpi2c
38SUBDIR+= bufq_disksort 38SUBDIR+= bufq_disksort
39SUBDIR+= bufq_fcfs 39SUBDIR+= bufq_fcfs
40SUBDIR+= bufq_priocscan 40SUBDIR+= bufq_priocscan
41SUBDIR+= bufq_readprio 41SUBDIR+= bufq_readprio
42SUBDIR+= camellia 42SUBDIR+= camellia
43SUBDIR+= cast128 43SUBDIR+= cast128
44SUBDIR+= ccd 44SUBDIR+= ccd
45SUBDIR+= cd9660 45SUBDIR+= cd9660
46SUBDIR+= cgd 46SUBDIR+= cgd
47SUBDIR+= chfs 47SUBDIR+= chfs
48SUBDIR+= clockctl 48SUBDIR+= clockctl
49SUBDIR+= compat_ossaudio 49SUBDIR+= compat_ossaudio
50SUBDIR+= crypto 50SUBDIR+= crypto
51SUBDIR+= coda 51SUBDIR+= coda
52SUBDIR+= coda5 52SUBDIR+= coda5
53SUBDIR+= coredump 53SUBDIR+= coredump
54SUBDIR+= dbcool 54SUBDIR+= dbcool
55SUBDIR+= des 55SUBDIR+= des
56SUBDIR+= dk_subr 56SUBDIR+= dk_subr
57SUBDIR+= drvctl 57SUBDIR+= drvctl
58SUBDIR+= efs 58SUBDIR+= efs
59SUBDIR+= ext2fs 59SUBDIR+= ext2fs
60SUBDIR+= exec_script 60SUBDIR+= exec_script
61SUBDIR+= fdesc 61SUBDIR+= fdesc
62SUBDIR+= ffs 62SUBDIR+= ffs
63SUBDIR+= filecore 63SUBDIR+= filecore
64SUBDIR+= flash 64SUBDIR+= flash
65SUBDIR+= fss 65SUBDIR+= fss
66SUBDIR+= gpio 66SUBDIR+= gpio
67SUBDIR+= gpioiic 67SUBDIR+= gpioiic
68SUBDIR+= gpioow 68SUBDIR+= gpioow
69SUBDIR+= gpiosim 69SUBDIR+= gpiosim
70SUBDIR+= gpioirq 70SUBDIR+= gpioirq
71SUBDIR+= gpiopps 71SUBDIR+= gpiopps
72SUBDIR+= hfs 72SUBDIR+= hfs
73SUBDIR+= hythygtemp 73SUBDIR+= hythygtemp
74SUBDIR+= am2315temp 74SUBDIR+= am2315temp
75SUBDIR+= i2cexec 75SUBDIR+= i2cexec
76SUBDIR+= i2c_bitbang 76SUBDIR+= i2c_bitbang
77SUBDIR+= i2c_subr 77SUBDIR+= i2c_subr
78SUBDIR+= if_agr 78SUBDIR+= if_agr
79SUBDIR+= if_aue 79SUBDIR+= if_aue
80SUBDIR+= if_axe 80SUBDIR+= if_axe
81SUBDIR+= if_axen 81SUBDIR+= if_axen
82SUBDIR+= if_cdce 82SUBDIR+= if_cdce
83SUBDIR+= if_cue 83SUBDIR+= if_cue
84SUBDIR+= if_faith 84SUBDIR+= if_faith
85SUBDIR+= if_gif 85SUBDIR+= if_gif
86SUBDIR+= if_gre 86SUBDIR+= if_gre
87SUBDIR+= if_kue 87SUBDIR+= if_kue
88SUBDIR+= if_l2tp 88SUBDIR+= if_l2tp
89SUBDIR+= if_lagg 89SUBDIR+= if_lagg
90SUBDIR+= if_loop 90SUBDIR+= if_loop
91SUBDIR+= if_mpls 91SUBDIR+= if_mpls
92SUBDIR+= if_mue 92SUBDIR+= if_mue
93SUBDIR+= if_npflog 93SUBDIR+= if_npflog
94SUBDIR+= if_ppp 94SUBDIR+= if_ppp
95SUBDIR+= if_pppoe 95SUBDIR+= if_pppoe
96SUBDIR+= if_run 96SUBDIR+= if_run
97SUBDIR+= if_sl 97SUBDIR+= if_sl
98SUBDIR+= if_smsc 98SUBDIR+= if_smsc
99SUBDIR+= if_srt srt 99SUBDIR+= if_srt srt
100SUBDIR+= if_stf 100SUBDIR+= if_stf
101SUBDIR+= if_tap tap 101SUBDIR+= if_tap tap
102SUBDIR+= if_tun tun 102SUBDIR+= if_tun tun
103SUBDIR+= if_udav 103SUBDIR+= if_udav
104SUBDIR+= if_upl 104SUBDIR+= if_upl
105SUBDIR+= if_ure 105SUBDIR+= if_ure
106SUBDIR+= if_url 106SUBDIR+= if_url
107SUBDIR+= if_urndis 107SUBDIR+= if_urndis
108SUBDIR+= if_vlan 108SUBDIR+= if_vlan
109SUBDIR+= if_wg 109SUBDIR+= if_wg
110SUBDIR+= iic 110SUBDIR+= iic
111SUBDIR+= ip_ecn 111SUBDIR+= ip_ecn
112SUBDIR+= ipl 112SUBDIR+= ipl
113SUBDIR+= kernfs 113SUBDIR+= kernfs
114SUBDIR+= layerfs 114SUBDIR+= layerfs
115SUBDIR+= lfs 115SUBDIR+= lfs
116SUBDIR+= lua 116SUBDIR+= lua
117SUBDIR+= luasystm 117SUBDIR+= luasystm
118SUBDIR+= luapmf 118SUBDIR+= luapmf
119SUBDIR+= mfs 119SUBDIR+= mfs
120SUBDIR+= midi 120SUBDIR+= midi
121SUBDIR+= midi_seq 121SUBDIR+= midi_seq
122SUBDIR+= miiverbose 122SUBDIR+= miiverbose
123SUBDIR+= miniroot 123SUBDIR+= miniroot
124SUBDIR+= mqueue 124SUBDIR+= mqueue
125SUBDIR+= msdos 125SUBDIR+= msdos
126SUBDIR+= nand 126SUBDIR+= nand
127SUBDIR+= nandemulator 127SUBDIR+= nandemulator
128SUBDIR+= nfs 128SUBDIR+= nfs
129SUBDIR+= nfsserver 129SUBDIR+= nfsserver
130SUBDIR+= nilfs 130SUBDIR+= nilfs
131SUBDIR+= npf 131SUBDIR+= npf
132SUBDIR+= npf_alg_icmp 132SUBDIR+= npf_alg_icmp
133SUBDIR+= npf_ext_log 133SUBDIR+= npf_ext_log
134SUBDIR+= npf_ext_normalize 134SUBDIR+= npf_ext_normalize
135SUBDIR+= npf_ext_rndblock 135SUBDIR+= npf_ext_rndblock
136SUBDIR+= ntfs 136SUBDIR+= ntfs
137SUBDIR+= null 137SUBDIR+= null
138SUBDIR+= onewire 138SUBDIR+= onewire
139SUBDIR+= opencrypto 139SUBDIR+= opencrypto
140SUBDIR+= overlay 140SUBDIR+= overlay
141SUBDIR+= pad 141SUBDIR+= pad
142SUBDIR+= pciverbose 142SUBDIR+= pciverbose
143SUBDIR+= pf 143SUBDIR+= pf
144SUBDIR+= ppp_bsdcomp 144SUBDIR+= ppp_bsdcomp
145SUBDIR+= ppp_deflate 145SUBDIR+= ppp_deflate
146SUBDIR+= procfs 146SUBDIR+= procfs
147SUBDIR+= ptrace 147SUBDIR+= ptrace
148SUBDIR+= ptrace_common 148SUBDIR+= ptrace_common
149SUBDIR+= ptyfs 149SUBDIR+= ptyfs
150SUBDIR+= puffs 150SUBDIR+= puffs
151SUBDIR+= putter 151SUBDIR+= putter
152SUBDIR+= raid 152SUBDIR+= raid
153SUBDIR+= scmd 153SUBDIR+= scmd
154SUBDIR+= scmdi2c 154SUBDIR+= scmdi2c
155SUBDIR+= scsi_subr 155SUBDIR+= scsi_subr
156SUBDIR+= scsiverbose 156SUBDIR+= scsiverbose
157SUBDIR+= sdtemp 157SUBDIR+= sdtemp
158SUBDIR+= secmodel_bsd44 158SUBDIR+= secmodel_bsd44
159SUBDIR+= secmodel_extensions 159SUBDIR+= secmodel_extensions
160SUBDIR+= secmodel_overlay 160SUBDIR+= secmodel_overlay
161SUBDIR+= securelevel 161SUBDIR+= securelevel
162SUBDIR+= sequencer 162SUBDIR+= sequencer
163SUBDIR+= sgp40mox 163SUBDIR+= sgp40mox
164SUBDIR+= sht3xtemp 164SUBDIR+= sht3xtemp
165SUBDIR+= sht4xtemp 165SUBDIR+= sht4xtemp
166SUBDIR+= si70xxtemp 166SUBDIR+= si70xxtemp
167SUBDIR+= skipjack 167SUBDIR+= skipjack
168SUBDIR+= slcompress 168SUBDIR+= slcompress
169SUBDIR+= spdmem 169SUBDIR+= spdmem
170SUBDIR+= spkr 170SUBDIR+= spkr
171SUBDIR+= sppp_subr 171SUBDIR+= sppp_subr
172SUBDIR+= sysmon 172SUBDIR+= sysmon
173SUBDIR+= sysmon_envsys 173SUBDIR+= sysmon_envsys
174SUBDIR+= sysmon_power 174SUBDIR+= sysmon_power
175SUBDIR+= sysmon_taskq 175SUBDIR+= sysmon_taskq
176SUBDIR+= sysmon_wdog 176SUBDIR+= sysmon_wdog
177SUBDIR+= sysvbfs 177SUBDIR+= sysvbfs
178SUBDIR+= sysv_ipc 178SUBDIR+= sysv_ipc
179SUBDIR+= suser 179SUBDIR+= suser
180SUBDIR+= swcrypto 180SUBDIR+= swcrypto
181SUBDIR+= swsensor 181SUBDIR+= swsensor
182SUBDIR+= swwdog 182SUBDIR+= swwdog
183SUBDIR+= tmpfs 183SUBDIR+= tmpfs
184SUBDIR+= ualea 184SUBDIR+= ualea
185SUBDIR+= uatp 185SUBDIR+= uatp
186SUBDIR+= udf 186SUBDIR+= udf
187SUBDIR+= ufs 187SUBDIR+= ufs
188SUBDIR+= umap 188SUBDIR+= umap
189SUBDIR+= union 189SUBDIR+= union
190SUBDIR+= usbnet 190SUBDIR+= usbnet
191SUBDIR+= usbverbose 191SUBDIR+= usbverbose
192SUBDIR+= vcoda 192SUBDIR+= vcoda
193SUBDIR+= v7fs 193SUBDIR+= v7fs
194SUBDIR+= vnd 194SUBDIR+= vnd
195SUBDIR+= wapbl 195SUBDIR+= wapbl
196SUBDIR+= wsbell 196SUBDIR+= wsbell
197SUBDIR+= zlib 197SUBDIR+= zlib
198SUBDIR+= tprof 198SUBDIR+= tprof
199.if (defined(NOTYET)) 199.if (defined(NOTYET))
200SUBDIR+= unionfs 200SUBDIR+= unionfs
201.endif 201.endif
202.if ${MKBINUTILS} != "no" 202.if ${MKBINUTILS} != "no"
203SUBDIR+= xldscripts 203SUBDIR+= xldscripts
204.endif 204.endif
205 205
206# Machine dependent section 206# Machine dependent section
207.if ${MACHINE_ARCH} == "i386" || \ 207.if ${MACHINE_ARCH} == "i386" || \
208 ${MACHINE_CPU} == "m68k" 208 ${MACHINE_CPU} == "m68k"
209SUBDIR+= exec_aout 209SUBDIR+= exec_aout
210.endif 210.endif
211 211
212.if ${MACHINE_ARCH} != "alpha" && \ 212.if ${MACHINE_ARCH} != "alpha" && \
213 ${MACHINE_ARCH} != "ia64" 213 ${MACHINE_ARCH} != "ia64"
214SUBDIR+= exec_elf32 214SUBDIR+= exec_elf32
215.endif 215.endif
216 216
217.if ${MACHINE_CPU} == "aarch64" || \ 217.if ${MACHINE_CPU} == "aarch64" || \
218 ${MACHINE_ARCH} == "alpha" || \ 218 ${MACHINE_ARCH} == "alpha" || \
219 ${MACHINE_ARCH} == "ia64" || \ 219 ${MACHINE_ARCH} == "ia64" || \
220 ${MACHINE_ARCH} == "sparc64" || \ 220 ${MACHINE_ARCH} == "sparc64" || \
221 ${MACHINE_ARCH} == "x86_64" 221 ${MACHINE_ARCH} == "x86_64"
222SUBDIR+= exec_elf64 222SUBDIR+= exec_elf64
223.endif 223.endif
224 224
225.if ${MACHINE_ARCH} == "i386" || \ 225.if ${MACHINE_ARCH} == "i386" || \
226 ${MACHINE_ARCH} == "x86_64" 226 ${MACHINE_ARCH} == "x86_64"
227SUBDIR+= amdsmn 227SUBDIR+= amdsmn
228SUBDIR+= amdtemp 228SUBDIR+= amdtemp
229SUBDIR+= amdzentemp 229SUBDIR+= amdzentemp
230SUBDIR+= coretemp 230SUBDIR+= coretemp
231SUBDIR+= est 231SUBDIR+= est
232SUBDIR+= hdafg 232SUBDIR+= hdafg
233SUBDIR+= hdaudio 233SUBDIR+= hdaudio
234SUBDIR+= hdaudio_pci 234SUBDIR+= hdaudio_pci
235SUBDIR+= hdaudioverbose 235SUBDIR+= hdaudioverbose
236SUBDIR+= hpet 236SUBDIR+= hpet
237SUBDIR+= ichsmb 237SUBDIR+= ichsmb
238SUBDIR+= odcm 238SUBDIR+= odcm
239SUBDIR+= powernow 239SUBDIR+= powernow
240SUBDIR+= tco 240SUBDIR+= tco
241SUBDIR+= tprof_x86 241SUBDIR+= tprof_x86
242SUBDIR+= vmt 242SUBDIR+= vmt
243.endif 243.endif
244 244
245.if ${HAVE_NVMM:Uno} == "yes" 245.if ${HAVE_NVMM:Uno} == "yes"
246SUBDIR+= nvmm 246SUBDIR+= nvmm
247.endif 247.endif
248 248
249# Builds on architectures with PCI bus 249# Builds on architectures with PCI bus
250.if \ 250.if \
251 ${MACHINE} == "evbarm" || \ 251 ${MACHINE} == "evbarm" || \
252 ${MACHINE_ARCH} == "i386" || \ 252 ${MACHINE_ARCH} == "i386" || \
253 ${MACHINE_ARCH} == "x86_64" 253 ${MACHINE_ARCH} == "x86_64"
254#SUBDIR+= hifn 254#SUBDIR+= hifn
255SUBDIR+= if_iavf 255SUBDIR+= if_iavf
256SUBDIR+= if_ixl 256SUBDIR+= if_ixl
257SUBDIR+= ubsec 257SUBDIR+= ubsec
258.endif 258.endif
259 259
260.if ${MKSLJIT} != "no" 260.if ${MKSLJIT} != "no"
261# No modules for 32-bit arm, mips and powerpc yet. 
262.if ${MACHINE_ARCH} == "aarch64" || \ 
263 ${MACHINE_ARCH} == "i386" || \ 
264 ${MACHINE_ARCH} == "sparc" || \ 
265 ${MACHINE_ARCH} == "x86_64" 
266SUBDIR+= bpfjit 261SUBDIR+= bpfjit
267SUBDIR+= sljit 262SUBDIR+= sljit
268.endif 263.endif
269.endif 
270 264
271# 265#
272# ACPI modules 266# ACPI modules
273# 267#
274.if ${MACHINE_ARCH} == "i386" || \ 268.if ${MACHINE_ARCH} == "i386" || \
275 ${MACHINE_ARCH} == "ia64" || \ 269 ${MACHINE_ARCH} == "ia64" || \
276 ${MACHINE_ARCH} == "x86_64" 270 ${MACHINE_ARCH} == "x86_64"
277SUBDIR+= acpiverbose 271SUBDIR+= acpiverbose
278.endif 272.endif
279 273
280.if ${MACHINE_ARCH} == "i386" || \ 274.if ${MACHINE_ARCH} == "i386" || \
281 ${MACHINE_ARCH} == "x86_64" 275 ${MACHINE_ARCH} == "x86_64"
282SUBDIR+= acpiacad 276SUBDIR+= acpiacad
283SUBDIR+= acpibat 277SUBDIR+= acpibat
284SUBDIR+= acpibut 278SUBDIR+= acpibut
285SUBDIR+= acpicpu 279SUBDIR+= acpicpu
286SUBDIR+= acpidalb 280SUBDIR+= acpidalb
287SUBDIR+= acpifan 281SUBDIR+= acpifan
288SUBDIR+= acpilid 282SUBDIR+= acpilid
289SUBDIR+= acpipmtr 283SUBDIR+= acpipmtr
290SUBDIR+= acpitz 284SUBDIR+= acpitz
291SUBDIR+= acpivga 285SUBDIR+= acpivga
292SUBDIR+= acpiwdrt 286SUBDIR+= acpiwdrt
293SUBDIR+= acpiwmi 287SUBDIR+= acpiwmi
294SUBDIR+= aibs 288SUBDIR+= aibs
295SUBDIR+= asus 289SUBDIR+= asus
296SUBDIR+= fujbp 290SUBDIR+= fujbp
297SUBDIR+= fujhk 291SUBDIR+= fujhk
298SUBDIR+= hpacel 292SUBDIR+= hpacel
299SUBDIR+= hpqlb 293SUBDIR+= hpqlb
300SUBDIR+= thinkpad 294SUBDIR+= thinkpad
301SUBDIR+= wmidell 295SUBDIR+= wmidell
302SUBDIR+= wmieeepc 296SUBDIR+= wmieeepc
303SUBDIR+= wmihp 297SUBDIR+= wmihp
304SUBDIR+= wmimsi 298SUBDIR+= wmimsi
305.endif 299.endif
306 300
307.include "${.CURDIR}/../compat/netbsd32/netbsd32.mk" 301.include "${.CURDIR}/../compat/netbsd32/netbsd32.mk"
308.if ${COMPAT_USE_NETBSD32} != "no" 302.if ${COMPAT_USE_NETBSD32} != "no"
309 303
310SUBDIR+= compat_netbsd32 304SUBDIR+= compat_netbsd32
311SUBDIR+= compat_netbsd32_09 compat_netbsd32_12 305SUBDIR+= compat_netbsd32_09 compat_netbsd32_12
312SUBDIR+= compat_netbsd32_13 compat_netbsd32_16 306SUBDIR+= compat_netbsd32_13 compat_netbsd32_16
313SUBDIR+= compat_netbsd32_20 compat_netbsd32_30 307SUBDIR+= compat_netbsd32_20 compat_netbsd32_30
314SUBDIR+= compat_netbsd32_40 compat_netbsd32_50 308SUBDIR+= compat_netbsd32_40 compat_netbsd32_50
315SUBDIR+= compat_netbsd32_60 compat_netbsd32_80 309SUBDIR+= compat_netbsd32_60 compat_netbsd32_80
316SUBDIR+= compat_netbsd32_90 310SUBDIR+= compat_netbsd32_90
317SUBDIR+= compat_netbsd32_43 311SUBDIR+= compat_netbsd32_43
318SUBDIR+= compat_netbsd32_coredump 312SUBDIR+= compat_netbsd32_coredump
319SUBDIR+= compat_netbsd32_mqueue 313SUBDIR+= compat_netbsd32_mqueue
320SUBDIR+= compat_netbsd32_nfssrv 314SUBDIR+= compat_netbsd32_nfssrv
321SUBDIR+= compat_netbsd32_ptrace 315SUBDIR+= compat_netbsd32_ptrace
322SUBDIR+= compat_netbsd32_quota 316SUBDIR+= compat_netbsd32_quota
323SUBDIR+= compat_netbsd32_quota_50 317SUBDIR+= compat_netbsd32_quota_50
324SUBDIR+= compat_netbsd32_raid 318SUBDIR+= compat_netbsd32_raid
325SUBDIR+= compat_netbsd32_sysvipc 319SUBDIR+= compat_netbsd32_sysvipc
326SUBDIR+= compat_netbsd32_sysvipc_10 320SUBDIR+= compat_netbsd32_sysvipc_10
327SUBDIR+= compat_netbsd32_sysvipc_14 321SUBDIR+= compat_netbsd32_sysvipc_14
328SUBDIR+= compat_netbsd32_sysvipc_50 322SUBDIR+= compat_netbsd32_sysvipc_50
329 323
330.if ${MACHINE_ARCH} == "x86_64" 324.if ${MACHINE_ARCH} == "x86_64"
331SUBDIR+= compat_linux32 325SUBDIR+= compat_linux32
332.endif 326.endif
333 327
334.endif 328.endif
335 329
336.if ${MACHINE_ARCH} == "i386" 330.if ${MACHINE_ARCH} == "i386"
337SUBDIR+= ati_pcigart 331SUBDIR+= ati_pcigart
338SUBDIR+= compat_freebsd 332SUBDIR+= compat_freebsd
339SUBDIR+= mach64drm 333SUBDIR+= mach64drm
340SUBDIR+= mgadrm 334SUBDIR+= mgadrm
341SUBDIR+= nsclpcsio 335SUBDIR+= nsclpcsio
342SUBDIR+= padlock 336SUBDIR+= padlock
343SUBDIR+= r128drm 337SUBDIR+= r128drm
344#SUBDIR+= radeondrm 338#SUBDIR+= radeondrm
345SUBDIR+= savagedrm 339SUBDIR+= savagedrm
346SUBDIR+= sisdrm 340SUBDIR+= sisdrm
347SUBDIR+= tdfxdrm 341SUBDIR+= tdfxdrm
348SUBDIR+= viac7temp 342SUBDIR+= viac7temp
349.endif 343.endif
350 344
351.if ${MACHINE_ARCH} == "i386" || \ 345.if ${MACHINE_ARCH} == "i386" || \
352 ${MACHINE_ARCH} == "x86_64" 346 ${MACHINE_ARCH} == "x86_64"
353SUBDIR+= amdgpu 347SUBDIR+= amdgpu
354SUBDIR+= compat_linux 348SUBDIR+= compat_linux
355SUBDIR+= drm 349SUBDIR+= drm
356SUBDIR+= drmkms 350SUBDIR+= drmkms
357SUBDIR+= drmkms_agp 351SUBDIR+= drmkms_agp
358SUBDIR+= drmkms_linux 352SUBDIR+= drmkms_linux
359SUBDIR+= drmkms_pci 353SUBDIR+= drmkms_pci
360SUBDIR+= drmkms_sched 354SUBDIR+= drmkms_sched
361SUBDIR+= drmkms_ttm 355SUBDIR+= drmkms_ttm
362SUBDIR+= i915drm 356SUBDIR+= i915drm
363SUBDIR+= i915drmkms 357SUBDIR+= i915drmkms
364SUBDIR+= viadrmums 358SUBDIR+= viadrmums
365# 359#
366# ISA modules 360# ISA modules
367# 361#
368SUBDIR+= aps 362SUBDIR+= aps
369SUBDIR+= finsio 363SUBDIR+= finsio
370SUBDIR+= itesio 364SUBDIR+= itesio
371SUBDIR+= lm 365SUBDIR+= lm
372SUBDIR+= lm_isa 366SUBDIR+= lm_isa
373SUBDIR+= lm_isa_common 367SUBDIR+= lm_isa_common
374SUBDIR+= lm_wbsio 368SUBDIR+= lm_wbsio
375SUBDIR+= wbsio 369SUBDIR+= wbsio
376.endif 370.endif
377 371
378.if ${MACHINE_CPU} == "aarch64" 372.if ${MACHINE_CPU} == "aarch64"
379SUBDIR+= compat_linux 373SUBDIR+= compat_linux
380SUBDIR+= compat_linux32 374SUBDIR+= compat_linux32
381.endif 375.endif
382 376
383.if ${MACHINE_CPU} == "m68k" 377.if ${MACHINE_CPU} == "m68k"
384SUBDIR+= compat_aoutm68k 378SUBDIR+= compat_aoutm68k
385#SUBDIR+= compat_linux 379#SUBDIR+= compat_linux
386#SUBDIR+= compat_sunos 380#SUBDIR+= compat_sunos
387.endif 381.endif
388 382
389.if ${MACHINE_ARCH} == "i386" || \ 383.if ${MACHINE_ARCH} == "i386" || \
390 ${MACHINE_ARCH} == "x86_64" || \ 384 ${MACHINE_ARCH} == "x86_64" || \
391 ${MACHINE_ARCH} == "sparc64" 385 ${MACHINE_ARCH} == "sparc64"
392SUBDIR+= pwdog 386SUBDIR+= pwdog
393.endif 387.endif
394 388
395.include <bsd.own.mk> 389.include <bsd.own.mk>
396 390
397# 391#
398# NetBSD/usermode support 392# NetBSD/usermode support
399# 393#
400.if ${MACHINE_ARCH} == "i386" || \ 394.if ${MACHINE_ARCH} == "i386" || \
401 ${MACHINE_ARCH} == "x86_64" 395 ${MACHINE_ARCH} == "x86_64"
402SUBDIR+= ../arch/usermode/modules/syscallemu 396SUBDIR+= ../arch/usermode/modules/syscallemu
403.endif 397.endif
404 398
405# we need our device mapper for LVM 399# we need our device mapper for LVM
406.if (${MKLVM} != "no") 400.if (${MKLVM} != "no")
407SUBDIR+= dm 401SUBDIR+= dm
408.endif 402.endif
409 403
410.if (${MKDTRACE} != "no") 404.if (${MKDTRACE} != "no")
411SUBDIR+= cyclic 405SUBDIR+= cyclic
412SUBDIR+= dtrace 406SUBDIR+= dtrace
413.endif 407.endif
414 408
415SUBDIR+= sodium 409SUBDIR+= sodium
416 410
417# we need solaris for the dtrace and zfs modules 411# we need solaris for the dtrace and zfs modules
418.if (${MKDTRACE} != "no" || ${MKZFS} != "no") 412.if (${MKDTRACE} != "no" || ${MKZFS} != "no")
419SUBDIR+= solaris 413SUBDIR+= solaris
420.endif 414.endif
421 415
422.if (${MKZFS} != "no") 416.if (${MKZFS} != "no")
423SUBDIR+= zfs 417SUBDIR+= zfs
424.endif 418.endif
425 419
426.if (${MKCOMPATMODULES} != "no") 420.if (${MKCOMPATMODULES} != "no")
427SUBDIR+= arch 421SUBDIR+= arch
428.endif 422.endif
429 423
430# 424#
431# DTV modules 425# DTV modules
432# 426#
433SUBDIR+= dtv 427SUBDIR+= dtv
434SUBDIR+= dtv_math 428SUBDIR+= dtv_math
435.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" 429.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
436# tuners/demods 430# tuners/demods
437SUBDIR+= au8522 431SUBDIR+= au8522
438SUBDIR+= cx24227 432SUBDIR+= cx24227
439SUBDIR+= lg3303 433SUBDIR+= lg3303
440SUBDIR+= mt2131 434SUBDIR+= mt2131
441SUBDIR+= nxt2k 435SUBDIR+= nxt2k
442SUBDIR+= tvpll 436SUBDIR+= tvpll
443SUBDIR+= xc3028 437SUBDIR+= xc3028
444SUBDIR+= xc5k 438SUBDIR+= xc5k
445SUBDIR+= zl10353 439SUBDIR+= zl10353
446# hardware drivers 440# hardware drivers
447SUBDIR+= auvitek 441SUBDIR+= auvitek
448SUBDIR+= coram 442SUBDIR+= coram
449SUBDIR+= cxdtv 443SUBDIR+= cxdtv
450SUBDIR+= emdtv 444SUBDIR+= emdtv
451 445
452# Intel Integrated Memory Controller and associated SMBus 446# Intel Integrated Memory Controller and associated SMBus
453# (Experimental) 447# (Experimental)
454SUBDIR+= imc 448SUBDIR+= imc
455SUBDIR+= imcsmb 449SUBDIR+= imcsmb
456 450
457.endif 451.endif
458 452
459.if (${MKISCSI} != "no") 453.if (${MKISCSI} != "no")
460SUBDIR+= iscsi 454SUBDIR+= iscsi
461.endif 455.endif
462 456
463# For now, all of these are disabled, pending resolution of how to deal 457# For now, all of these are disabled, pending resolution of how to deal
464# with attachment-specific modules and bus-specific modules (as opposed 458# with attachment-specific modules and bus-specific modules (as opposed
465# to machine- or architecture-specific modules) 459# to machine- or architecture-specific modules)
466 460
467.if 0 461.if 0
468SUBDIR+= aac 462SUBDIR+= aac
469SUBDIR+= amr 463SUBDIR+= amr
470SUBDIR+= ataraid 464SUBDIR+= ataraid
471SUBDIR+= cac 465SUBDIR+= cac
472SUBDIR+= cac_eisa 466SUBDIR+= cac_eisa
473SUBDIR+= cac_pci 467SUBDIR+= cac_pci
474SUBDIR+= emuxki 468SUBDIR+= emuxki
475SUBDIR+= if_aq 469SUBDIR+= if_aq
476SUBDIR+= if_vioif 470SUBDIR+= if_vioif
477SUBDIR+= if_vmx 471SUBDIR+= if_vmx
478SUBDIR+= ld 472SUBDIR+= ld
479SUBDIR+= ld_aac 473SUBDIR+= ld_aac
480SUBDIR+= ld_amr 474SUBDIR+= ld_amr
481SUBDIR+= ld_ataraid 475SUBDIR+= ld_ataraid
482SUBDIR+= ld_cac 476SUBDIR+= ld_cac
483SUBDIR+= ld_icp 477SUBDIR+= ld_icp
484SUBDIR+= ld_mlx 478SUBDIR+= ld_mlx
485SUBDIR+= ld_sdmmc 479SUBDIR+= ld_sdmmc
486SUBDIR+= ld_twa 480SUBDIR+= ld_twa
487SUBDIR+= ld_twe 481SUBDIR+= ld_twe
488SUBDIR+= ld_virtio 482SUBDIR+= ld_virtio
489SUBDIR+= mlx 483SUBDIR+= mlx
490SUBDIR+= mlx_eisa 484SUBDIR+= mlx_eisa
491SUBDIR+= mlx_pci 485SUBDIR+= mlx_pci
492SUBDIR+= ld_nvme 486SUBDIR+= ld_nvme
493SUBDIR+= nvme 487SUBDIR+= nvme
494SUBDIR+= twa 488SUBDIR+= twa
495SUBDIR+= twe 489SUBDIR+= twe
496SUBDIR+= vio9p 490SUBDIR+= vio9p
497SUBDIR+= viomb 491SUBDIR+= viomb
498SUBDIR+= virtio 492SUBDIR+= virtio
499SUBDIR+= virtio_pci 493SUBDIR+= virtio_pci
500SUBDIR+= vioscsi 494SUBDIR+= vioscsi
501.endif 495.endif
502 496
503SUBDIR+= examples # build these regularly to avoid bit-rot 497SUBDIR+= examples # build these regularly to avoid bit-rot
504 498
505.include <bsd.subdir.mk> 499.include <bsd.subdir.mk>