CVS commit: src/sys/arch/playstation2/conf

2014-07-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jul  4 07:03:35 UTC 2014

Modified Files:
src/sys/arch/playstation2/conf: build.playstation2.sh

Log Message:
Add missing OBJCOPY


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/playstation2/conf/build.playstation2.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/playstation2/conf/build.playstation2.sh
diff -u src/sys/arch/playstation2/conf/build.playstation2.sh:1.7 src/sys/arch/playstation2/conf/build.playstation2.sh:1.8
--- src/sys/arch/playstation2/conf/build.playstation2.sh:1.7	Wed Jul  2 12:44:15 2014
+++ src/sys/arch/playstation2/conf/build.playstation2.sh	Fri Jul  4 07:03:35 2014
@@ -16,6 +16,7 @@ AR=${root}/bin/${target}-ar;		export AR
 NM=${root}/bin/${target}-nm;		export NM
 SIZE=${root}/bin/${target}-size;	export SIZE
 STRIP=${root}/bin/${target}-strip;	export STRIP
+OBJCOPY=${root}/bin/${target}-objcopy;	export OBJCOPY
 
 MAKE=make; export MAKE
 



CVS commit: src/sys/arch/playstation2/playstation2

2014-07-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jul  4 07:27:57 UTC 2014

Modified Files:
src/sys/arch/playstation2/playstation2: autoconf.c

Log Message:
Add missing sys/device.h include


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/playstation2/playstation2/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/playstation2/playstation2/autoconf.c
diff -u src/sys/arch/playstation2/playstation2/autoconf.c:1.8 src/sys/arch/playstation2/playstation2/autoconf.c:1.9
--- src/sys/arch/playstation2/playstation2/autoconf.c:1.8	Mon Mar 31 11:25:49 2014
+++ src/sys/arch/playstation2/playstation2/autoconf.c	Fri Jul  4 07:27:57 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.8 2014/03/31 11:25:49 martin Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.9 2014/07/04 07:27:57 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -27,10 +27,11 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: autoconf.c,v 1.8 2014/03/31 11:25:49 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: autoconf.c,v 1.9 2014/07/04 07:27:57 martin Exp $);
 
 #include sys/param.h
 #include sys/systm.h
+#include sys/device.h
 #include sys/conf.h
 
 #include playstation2/ee/sifvar.h			/* sif_init */



CVS commit: src/sys/arch/playstation2/playstation2

2014-07-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jul  4 07:27:29 UTC 2014

Modified Files:
src/sys/arch/playstation2/playstation2: interrupt.h

Log Message:
md_imask_update is not an inline function, fix declaration.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/playstation2/playstation2/interrupt.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/playstation2/playstation2/interrupt.h
diff -u src/sys/arch/playstation2/playstation2/interrupt.h:1.5 src/sys/arch/playstation2/playstation2/interrupt.h:1.6
--- src/sys/arch/playstation2/playstation2/interrupt.h:1.5	Mon Mar 31 11:25:49 2014
+++ src/sys/arch/playstation2/playstation2/interrupt.h	Fri Jul  4 07:27:28 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: interrupt.h,v 1.5 2014/03/31 11:25:49 martin Exp $	*/
+/*	$NetBSD: interrupt.h,v 1.6 2014/07/04 07:27:28 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -60,4 +60,4 @@ void _sif_call_end(void);
 
 /* SPL */
 void md_ipl_register(enum ipl_type, struct _ipl_holder *);
-inline void md_imask_update(void);
+void md_imask_update(void);



CVS commit: src/sys/arch/playstation2/playstation2

2014-07-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jul  4 07:51:14 UTC 2014

Modified Files:
src/sys/arch/playstation2/playstation2: bus_space.c

Log Message:
Fix extent_create() call


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/playstation2/playstation2/bus_space.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/playstation2/playstation2/bus_space.c
diff -u src/sys/arch/playstation2/playstation2/bus_space.c:1.9 src/sys/arch/playstation2/playstation2/bus_space.c:1.10
--- src/sys/arch/playstation2/playstation2/bus_space.c:1.9	Mon Mar 31 11:25:49 2014
+++ src/sys/arch/playstation2/playstation2/bus_space.c	Fri Jul  4 07:51:14 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_space.c,v 1.9 2014/03/31 11:25:49 martin Exp $	*/
+/*	$NetBSD: bus_space.c,v 1.10 2014/07/04 07:51:14 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: bus_space.c,v 1.9 2014/03/31 11:25:49 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: bus_space.c,v 1.10 2014/07/04 07:51:14 martin Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -166,7 +166,7 @@ bus_space_create(bus_space_tag_t t, cons
 		pbs-pbs_base_addr = addr; /* no extent */
 	} else {
 		pbs-pbs_extent = extent_create(name, addr, addr + size - 1,
-		M_DEVBUF, 0, 0, EX_NOWAIT);
+		0, 0, EX_NOWAIT);
 		if (pbs-pbs_extent == 0) {
 			panic(%s:: unable to create bus_space for 
 			0x%08lx-%#lx, __func__, addr, size);



CVS commit: src/sys/arch/playstation2/include

2014-07-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jul  4 07:59:17 UTC 2014

Modified Files:
src/sys/arch/playstation2/include: bus.h

Log Message:
Use .set arch=r5900 to enable r5900 specific instructions


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/playstation2/include/bus.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/playstation2/include/bus.h
diff -u src/sys/arch/playstation2/include/bus.h:1.14 src/sys/arch/playstation2/include/bus.h:1.15
--- src/sys/arch/playstation2/include/bus.h:1.14	Mon Mar 31 11:25:49 2014
+++ src/sys/arch/playstation2/include/bus.h	Fri Jul  4 07:59:17 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus.h,v 1.14 2014/03/31 11:25:49 martin Exp $	*/
+/*	$NetBSD: bus.h,v 1.15 2014/07/04 07:59:17 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -301,7 +301,7 @@ __write_8(bus_addr_t a, u_int64_t v)
 	__asm volatile(
 		.set noreorder;
 		.set push;
-		.set r5900;
+		.set arch = r5900;
 		pextlw	$8, %0, %1;
 		sd	$8, 0(%2);
 		sync.l;



CVS commit: src/sys/arch/playstation2/playstation2

2014-07-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jul  4 08:09:47 UTC 2014

Modified Files:
src/sys/arch/playstation2/playstation2: clock.c

Log Message:
Add missing includes, fix C99 struct initialization


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/playstation2/playstation2/clock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/playstation2/playstation2/clock.c
diff -u src/sys/arch/playstation2/playstation2/clock.c:1.9 src/sys/arch/playstation2/playstation2/clock.c:1.10
--- src/sys/arch/playstation2/playstation2/clock.c:1.9	Mon Mar 31 11:25:49 2014
+++ src/sys/arch/playstation2/playstation2/clock.c	Fri Jul  4 08:09:47 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: clock.c,v 1.9 2014/03/31 11:25:49 martin Exp $	*/
+/*	$NetBSD: clock.c,v 1.10 2014/07/04 08:09:47 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -27,15 +27,17 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: clock.c,v 1.9 2014/03/31 11:25:49 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: clock.c,v 1.10 2014/07/04 08:09:47 martin Exp $);
 
 #include debug_playstation2.h
 
 #include sys/param.h
 #include sys/systm.h
 #include sys/kernel.h		/* time */
+#include sys/proc.h
 
 #include mips/locore.h
+#include mips/mips3_clock.h
 
 #include dev/clock_subr.h
 #include machine/bootinfo.h
@@ -48,7 +50,7 @@ void
 cpu_initclocks(void)
 {
 	struct todr_chip_handle	todr = {
-		.todr_gettime_ymdhms = get_bootinfo_tod;
+		.todr_gettime_ymdhms = get_bootinfo_tod,
 	};
 
 	/*



CVS commit: src/sys/arch/playstation2/playstation2

2014-07-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jul  4 08:33:08 UTC 2014

Modified Files:
src/sys/arch/playstation2/playstation2: cpu.c

Log Message:
Adapt to new attach world order


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/playstation2/playstation2/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/playstation2/playstation2/cpu.c
diff -u src/sys/arch/playstation2/playstation2/cpu.c:1.8 src/sys/arch/playstation2/playstation2/cpu.c:1.9
--- src/sys/arch/playstation2/playstation2/cpu.c:1.8	Mon Mar 31 11:25:49 2014
+++ src/sys/arch/playstation2/playstation2/cpu.c	Fri Jul  4 08:33:08 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.8 2014/03/31 11:25:49 martin Exp $	*/
+/*	$NetBSD: cpu.c,v 1.9 2014/07/04 08:33:08 martin Exp $	*/
 
 /*
  * Copyright (c) 2000 Soren S. Jorvang.  All rights reserved.
@@ -26,24 +26,24 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.8 2014/03/31 11:25:49 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.9 2014/07/04 08:33:08 martin Exp $);
 
 #include sys/param.h
 #include sys/systm.h
+#include sys/device.h
 
 #include machine/autoconf.h
 
-static int cpumatch(struct device *, struct cfdata *, void *);
-static void cpuattach(struct device *, struct device *, void *);
+static int cpumatch(device_t, cfdata_t, void *);
+static void cpuattach(device_t, device_t, void *);
 
-CFATTACH_DECL(cpu, sizeof (struct device),
-cpumatch, cpuattach, NULL, NULL);
+CFATTACH_DECL_NEW(cpu, 0, cpumatch, cpuattach, NULL, NULL);
 
 extern struct cfdriver cpu_cd;
 static int __attached; /* PlayStation 2 has only one CPU */
 
 static int
-cpumatch(struct device *parent, struct cfdata *cf, void *aux)
+cpumatch(device_t parent, cfdata_t cf, void *aux)
 {
 	struct mainbus_attach_args *ma = aux;
 
@@ -55,11 +55,11 @@ cpumatch(struct device *parent, struct c
 }
 
 static void
-cpuattach(struct device *parent, struct device *dev, void *aux)
+cpuattach(struct device *parent, struct device *self, void *aux)
 {
 
 	printf(: );
 	__attached = 1;
 
-	cpu_identify();
+	cpu_identify(self);
 }



CVS commit: src/sys/arch/playstation2/playstation2

2014-07-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jul  4 08:51:15 UTC 2014

Modified Files:
src/sys/arch/playstation2/playstation2: disksubr.c

Log Message:
Adapt to struct buf changes


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/playstation2/playstation2/disksubr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/playstation2/playstation2/disksubr.c
diff -u src/sys/arch/playstation2/playstation2/disksubr.c:1.18 src/sys/arch/playstation2/playstation2/disksubr.c:1.19
--- src/sys/arch/playstation2/playstation2/disksubr.c:1.18	Mon Mar 31 11:25:49 2014
+++ src/sys/arch/playstation2/playstation2/disksubr.c	Fri Jul  4 08:51:15 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: disksubr.c,v 1.18 2014/03/31 11:25:49 martin Exp $	*/
+/*	$NetBSD: disksubr.c,v 1.19 2014/07/04 08:51:15 martin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: disksubr.c,v 1.18 2014/03/31 11:25:49 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: disksubr.c,v 1.19 2014/07/04 08:51:15 martin Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -57,12 +57,12 @@ mbr_findslice(struct mbr_partition *dp, 
 	int i;
 
 	/* Note: Magic number is little-endian. */
-	mbrmagicp = (u_int16_t *)(bp-b_data + MBR_MAGIC_OFFSET);
+	mbrmagicp = (u_int16_t *)((char*)bp-b_data + MBR_MAGIC_OFFSET);
 	if (*mbrmagicp != MBR_MAGIC)
 		return (NO_MBR_SIGNATURE);
 
 	/* XXX how do we check veracity/bounds of this? */
-	memcpy(dp, bp-b_data + MBR_PART_OFFSET, MBR_PART_COUNT * sizeof(*dp));
+	memcpy(dp, (char*)bp-b_data + MBR_PART_OFFSET, MBR_PART_COUNT * sizeof(*dp));
 
 	/* look for NetBSD partition */
 	for (i = 0; i  MBR_PART_COUNT; i++) {
@@ -198,7 +198,7 @@ nombrpart:
 		goto done;
 	}
 	for (dlp = (struct disklabel *)bp-b_data;
-	dlp = (struct disklabel *)(bp-b_data + lp-d_secsize - sizeof(*dlp));
+	dlp = (struct disklabel *)((char*)bp-b_data + lp-d_secsize - sizeof(*dlp));
 	dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
 		if (dlp-d_magic != DISKMAGIC || dlp-d_magic2 != DISKMAGIC) {
 			if (msg == NULL)
@@ -371,7 +371,7 @@ nombrpart:
 	if ((error = biowait(bp)) != 0)
 		goto done;
 	for (dlp = (struct disklabel *)bp-b_data;
-	dlp = (struct disklabel *)(bp-b_data + lp-d_secsize - sizeof(*dlp));
+	dlp = (struct disklabel *)((char*)bp-b_data + lp-d_secsize - sizeof(*dlp));
 	dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
 		if (dlp-d_magic == DISKMAGIC  dlp-d_magic2 == DISKMAGIC 
 		dkcksum(dlp) == 0) {



CVS commit: src/sys/lib/libkern

2014-07-04 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jul  4 16:44:26 UTC 2014

Modified Files:
src/sys/lib/libkern: Makefile.libkern

Log Message:
${.PARSEDIR} not .${PARSEDIR} for Makefile.compiler-rt include


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/lib/libkern/Makefile.libkern

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/lib/libkern/Makefile.libkern
diff -u src/sys/lib/libkern/Makefile.libkern:1.32 src/sys/lib/libkern/Makefile.libkern:1.33
--- src/sys/lib/libkern/Makefile.libkern:1.32	Wed Mar 12 00:22:53 2014
+++ src/sys/lib/libkern/Makefile.libkern	Fri Jul  4 16:44:26 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.libkern,v 1.32 2014/03/12 00:22:53 pooka Exp $
+#	$NetBSD: Makefile.libkern,v 1.33 2014/07/04 16:44:26 jmcneill Exp $
 
 # 
 # Variable definitions for libkern.  
@@ -44,7 +44,7 @@ CPPFLAGS+=	-I${KERNDIR}/../../../common/
 .endif
 
 .if !defined(RUMPKERNEL)
-.include .${PARSEDIR}/Makefile.compiler-rt
+.include ${.PARSEDIR}/Makefile.compiler-rt
 .endif
 
 # Other stuff



CVS commit: src/sys/net

2014-07-04 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Fri Jul  4 21:32:08 UTC 2014

Modified Files:
src/sys/net: bpfjit.c

Log Message:
Add optimization hints. They replace nscratches and ncopfuncs and improve
readability.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/net/bpfjit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/bpfjit.c
diff -u src/sys/net/bpfjit.c:1.19 src/sys/net/bpfjit.c:1.20
--- src/sys/net/bpfjit.c:1.19	Tue Jul  1 16:18:55 2014
+++ src/sys/net/bpfjit.c	Fri Jul  4 21:32:08 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpfjit.c,v 1.19 2014/07/01 16:18:55 alnsn Exp $	*/
+/*	$NetBSD: bpfjit.c,v 1.20 2014/07/04 21:32:08 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2011-2014 Alexander Nasonov.
@@ -31,9 +31,9 @@
 
 #include sys/cdefs.h
 #ifdef _KERNEL
-__KERNEL_RCSID(0, $NetBSD: bpfjit.c,v 1.19 2014/07/01 16:18:55 alnsn Exp $);
+__KERNEL_RCSID(0, $NetBSD: bpfjit.c,v 1.20 2014/07/04 21:32:08 alnsn Exp $);
 #else
-__RCSID($NetBSD: bpfjit.c,v 1.19 2014/07/01 16:18:55 alnsn Exp $);
+__RCSID($NetBSD: bpfjit.c,v 1.20 2014/07/04 21:32:08 alnsn Exp $);
 #endif
 
 #include sys/types.h
@@ -120,6 +120,16 @@ __RCSID($NetBSD: bpfjit.c,v 1.19 2014/0
 #define GET_MEMWORDS(bc) (GET_EXTWORDS(bc) ? GET_EXTWORDS(bc) : BPF_MEMWORDS)
 
 /*
+ * Optimization hints.
+ */
+typedef unsigned int bpfjit_hint_t;
+#define BJ_HINT_LDW  0x01 /* 32-bit packet read  */
+#define BJ_HINT_IND  0x02 /* packet read at a variable offset */
+#define BJ_HINT_COP  0x04 /* BPF_COP or BPF_COPX instruction  */
+#define BJ_HINT_XREG 0x08 /* BJ_XREG is needed   */
+#define BJ_HINT_LDX  0x10 /* BPF_LDX instruction */
+
+/*
  * Datatype for Array Bounds Check Elimination (ABC) pass.
  */
 typedef uint64_t bpfjit_abc_length_t;
@@ -232,6 +242,32 @@ bpfjit_modcmd(modcmd_t cmd, void *arg)
 }
 #endif
 
+/*
+ * Return a number of scratch regiters to pass
+ * to sljit_emit_enter() function.
+ */
+static sljit_si
+nscratches(bpfjit_hint_t hints)
+{
+	sljit_si rv = 2;
+
+	if (hints  BJ_HINT_LDW)
+		rv = 3; /* uses BJ_TMP2REG */
+
+	if (hints  BJ_HINT_COP)
+		rv = 3; /* calls copfunc with three arguments */
+
+	if (hints  BJ_HINT_XREG)
+		rv = 4; /* uses BJ_XREG */
+
+#ifdef _KERNEL
+	if (hints  BJ_HINT_LDX)
+		rv = 5; /* uses BJ_TMP3REG */
+#endif
+
+	return rv;
+}
+
 static uint32_t
 read_width(const struct bpf_insn *pc)
 {
@@ -1163,7 +1199,7 @@ optimize_init(struct bpfjit_insn_data *i
 static bool
 optimize_pass1(const bpf_ctx_t *bc, const struct bpf_insn *insns,
 struct bpfjit_insn_data *insn_dat, size_t insn_count,
-bpf_memword_init_t *initmask, int *nscratches, int *ncopfuncs)
+bpf_memword_init_t *initmask, bpfjit_hint_t *hints)
 {
 	struct bpfjit_jump *jtf;
 	size_t i;
@@ -1174,8 +1210,7 @@ optimize_pass1(const bpf_ctx_t *bc, cons
 
 	const size_t memwords = GET_MEMWORDS(bc);
 
-	*ncopfuncs = 0;
-	*nscratches = 2;
+	*hints = 0;
 	*initmask = BJ_INIT_NOBITS;
 
 	unreachable = false;
@@ -1203,22 +1238,16 @@ optimize_pass1(const bpf_ctx_t *bc, cons
 			continue;
 
 		case BPF_LD:
-			if (BPF_MODE(insns[i].code) == BPF_IND ||
-			BPF_MODE(insns[i].code) == BPF_ABS) {
-if (BPF_MODE(insns[i].code) == BPF_IND 
-*nscratches  4) {
-	/* uses BJ_XREG */
-	*nscratches = 4;
-}
-if (*nscratches  3 
-read_width(insns[i]) == 4) {
-	/* uses BJ_TMP2REG */
-	*nscratches = 3;
-}
+			if ((BPF_MODE(insns[i].code) == BPF_IND ||
+			BPF_MODE(insns[i].code) == BPF_ABS) 
+			read_width(insns[i]) == 4) {
+*hints |= BJ_HINT_LDW;
 			}
 
-			if (BPF_MODE(insns[i].code) == BPF_IND)
+			if (BPF_MODE(insns[i].code) == BPF_IND) {
+*hints |= BJ_HINT_XREG | BJ_HINT_IND;
 *initmask |= invalid  BJ_INIT_XBIT;
+			}
 
 			if (BPF_MODE(insns[i].code) == BPF_MEM 
 			(uint32_t)insns[i].k  memwords) {
@@ -1229,13 +1258,7 @@ optimize_pass1(const bpf_ctx_t *bc, cons
 			continue;
 
 		case BPF_LDX:
-#if defined(_KERNEL)
-			/* uses BJ_TMP3REG */
-			*nscratches = 5;
-#endif
-			/* uses BJ_XREG */
-			if (*nscratches  4)
-*nscratches = 4;
+			*hints |= BJ_HINT_XREG | BJ_HINT_LDX;
 
 			if (BPF_MODE(insns[i].code) == BPF_MEM 
 			(uint32_t)insns[i].k  memwords) {
@@ -1254,10 +1277,7 @@ optimize_pass1(const bpf_ctx_t *bc, cons
 			continue;
 
 		case BPF_STX:
-			/* uses BJ_XREG */
-			if (*nscratches  4)
-*nscratches = 4;
-
+			*hints |= BJ_HINT_XREG;
 			*initmask |= invalid  BJ_INIT_XBIT;
 
 			if ((uint32_t)insns[i].k  memwords)
@@ -1270,11 +1290,8 @@ optimize_pass1(const bpf_ctx_t *bc, cons
 
 			if (insns[i].code != (BPF_ALU|BPF_NEG) 
 			BPF_SRC(insns[i].code) == BPF_X) {
+*hints |= BJ_HINT_XREG;
 *initmask |= invalid  BJ_INIT_XBIT;
-/* uses BJ_XREG */
-if (*nscratches  4)
-	*nscratches = 4;
-
 			}
 
 			invalid = ~BJ_INIT_ABIT;
@@ -1283,35 +1300,23 @@ optimize_pass1(const bpf_ctx_t *bc, cons
 		case BPF_MISC:
 			switch