Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* rpcc
@ 1999-01-12  3:55 Christoph Dworzak
  1999-01-12  3:20 ` rpcc Peter Petrakis
  1999-01-12  4:59 ` rpcc Richard Henderson
  0 siblings, 2 replies; 25+ messages in thread
From: Christoph Dworzak @ 1999-01-12  3:55 UTC (permalink / raw)
  To: axp-list

Hi

With some help from this list, I'm getting better
with axp-asm :)

Now my next question is, how do I measure the speed
of my code?

My test looks like this:

--------------------------------------------------------
unsigned long c1, c2, ccm=~0UL, ccs=0, n;

    
for (n=0; n<(1UL<<19); n++){
    asm volatile("rpcc %0" : "=r"(c1) : : "memory");
    core();
    asm volatile("rpcc %0" : "=r"(c2) : : "memory");
    c1 = (c1 + (c1<<32)) >> 32;
    c2 = (c2 + (c2<<32)) >> 32;
    c2 = (c2>c1) ? c2-c1 : c2+(1UL<<32)-c1;
    ccs += c2;
    if (c2<ccm) ccm = c2;
}
printf("\nMin=%ld Avg=%ld\n\n", ccm, ccs/n;
--------------------------------------------------------

When I run this several times, I get strange results
(see end of my mail)


Why does it take up to 50% longer sometimes? (it really
does, checking with my wrist-watch.)

Of course I know, there are some task-switches or interupts,
but I would expect, that at least one loop out of one million
runs uninteruptet on full speed...

Has it something to do with alignment of the code in memory
and if so, how could I place the code so it runs at full speed?

Bye
 dworz

--------------------------------------------------------
[dworz@really speed]# time ./speedtest

Min=6063 Avg=6552

13.85user 0.00system 0:15.11elapsed 91%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (69major+14minor)pagefaults 0swaps
[dworz@really speed]# time ./speedtest

Min=6065 Avg=6546

13.84user 0.00system 0:15.54elapsed 89%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (69major+14minor)pagefaults 0swaps
[dworz@really speed]# time ./speedtest

Min=7961 Avg=8975

18.93user 0.00system 0:20.66elapsed 91%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (69major+14minor)pagefaults 0swaps
[dworz@really speed]# time ./speedtest

Min=6063 Avg=6532

13.80user 0.00system 0:15.52elapsed 88%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (69major+14minor)pagefaults 0swaps
[dworz@really speed]# time ./speedtest

Min=7975 Avg=8970

18.92user 0.00system 0:20.66elapsed 91%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (69major+14minor)pagefaults 0swaps
[dworz@really speed]# time ./speedtest

Min=6062 Avg=6477

13.69user 0.00system 0:14.96elapsed 91%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (69major+14minor)pagefaults 0swaps
[dworz@really speed]# time ./speedtest

Min=6063 Avg=6520

13.78user 0.00system 0:15.06elapsed 91%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (69major+14minor)pagefaults 0swaps
--------------------------------------------------------


^ permalink raw reply	[flat|nested] 25+ messages in thread
* Alpha 21264.
@ 1999-01-13 14:10 Andy Almond
  1999-01-13 16:36 ` Jeff Sturm
  0 siblings, 1 reply; 25+ messages in thread
From: Andy Almond @ 1999-01-13 14:10 UTC (permalink / raw)
  To: 'axp-list@redhat.com'

Three questions relating to the 21264 CPU and 264DP motherboard.

(a) I haven't used a dual processor before, so how much performance can you expect over a single CPU machine when working on a single job using an SMP linux kernel. Can you configure the system to use both CPUs for an ordinary job, or does that require a special compilation option/re-coding?

(b) Are DEC fortran/C ev6 compilers going to be available under linux? or is DEC UNIX or NT the only way to achieve this? I assume that the performance of gcc will be relatively poor compared with DECs C compiler, as is the case for the 21164 processor.

(c) Will code already compiled for ev56 CPUs run efficiently on an ev6 CPU?

Any comments appreciated.

Dr. Andrew Almond.
University of Manchester. UK.


^ permalink raw reply	[flat|nested] 25+ messages in thread
* PATCH: (on Alpha) emulating missing instructions
@ 1999-10-15  9:30 Luke Deller
  1999-10-16  9:13 ` patch_v2: " Luke Deller
  0 siblings, 1 reply; 25+ messages in thread
From: Luke Deller @ 1999-10-15  9:30 UTC (permalink / raw)
  To: linux-kernel; +Cc: axp-list, Daniel Paul Potts

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1715 bytes --]

Daniel & I tried to run Loki's new beta version of Civilization Call to
Power for alpha linux on a multia (ev4 alpha).  We got an illegal
instruction exception.  We discovered that it was compiled for ev6, and so
contained instructions not supported by our CPU.

So we have patched the linux kernel to emulate the instructions we needed.
These instructions are:
- byte/word load/store instructions (ldbu,stb,ldwu,stw)
- some multimedia instructions (minsw, maxsw, minuw, maxuw, minsb, maxsb,
  minub, maxub)

We have tried to make the emulation fairly fast - we have added it as some
assembly language code to the "illegal instruction exception" kernel entry
point in arch/alpha/kernel/entry.S:entIF.  (Of course it's still faster
to avoid emulation and use a binary compiled for your generation of alpha
cpu).

We put an option for enabling it in the "Kernel Hacking" section of the
configuration.

The patch is applied to kernel version 2.2.11
(Loki say not to use 2.2.12 for Civilization CTP) 

We only wrote enough emulation code to get CivilizationCTP to run ..  in the
future it would be cool to see emulation of a more complete set of
instructions in the kernel.

Hope this is useful to somebody,

Luke Deller & Daniel Potts.

--------------------------------------------------------------------------
           Luke Deller                               luked@cse.unsw.edu.au
 _--_|\    Computer Engineering student           
/      \   School of Computer Science and Engineering     ? ? ? ?        
\_.--._*   The University of New South Wales               ~~^^~  
      v    Sydney, NSW     2052    AUSTRALIA                o o
-------------------------------------------------------ooO--(_)--Ooo------

[-- Attachment #2: linux-alpha-emu-for2_2_11.patch --]
[-- Type: TEXT/PLAIN, Size: 16525 bytes --]

diff -u --recursive --new-file v2.2.11/linux/arch/alpha/config.in linux/arch/alpha/config.in
--- v2.2.11/linux/arch/alpha/config.in	Sun May 23 06:41:37 1999
+++ linux/arch/alpha/config.in	Fri Oct 15 18:18:16 1999
@@ -280,6 +280,7 @@
 #bool 'Debug kmalloc/kfree' CONFIG_DEBUG_MALLOC
 if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
   tristate 'Kernel FP software completion' CONFIG_MATHEMU
+  bool 'Emulation of some extended instruction sets' CONFIG_ALPHA_EXTINSNS
 else
   define_bool CONFIG_MATHEMU y
 fi
diff -u --recursive --new-file v2.2.11/linux/arch/alpha/defconfig linux/arch/alpha/defconfig
--- v2.2.11/linux/arch/alpha/defconfig	Sun Jun 13 04:52:51 1999
+++ linux/arch/alpha/defconfig	Fri Oct 15 18:17:50 1999
@@ -330,4 +330,5 @@
 # Kernel hacking
 #
 CONFIG_MATHEMU=y
+# CONFIG_ALPHA_EXTINSNS is not set
 # CONFIG_MAGIC_SYSRQ is not set
diff -u --recursive --new-file v2.2.11/linux/arch/alpha/kernel/entry.S linux/arch/alpha/kernel/entry.S
--- v2.2.11/linux/arch/alpha/kernel/entry.S	Tue Aug 10 05:04:57 1999
+++ linux/arch/alpha/kernel/entry.S	Fri Oct 15 18:18:30 1999
@@ -173,10 +173,819 @@
 	jsr	$31,do_entArith
 .end entArith
 
+#ifdef CONFIG_ALPHA_EXTINSNS
+/* emulation of some extended alpha instructions */
+
+.align 3
+.ent	get_user_sp
+get_user_sp:
+	subq		$30,6*8,$30
+	stq		$0,0($30)
+	stq		$1,8($30)
+	stq		$16,16($30)
+	mov		$25,$3
+	stq		$22,24($30)
+	stq		$23,32($30)
+	stq		$24,40($30)
+	call_pal	PAL_rdusp
+	ldq		$24,40($30)
+	mov		$3,$25
+	ldq		$23,32($30)
+	ldq		$22,24($30)
+	mov		$0,$3
+	ldq		$16,16($30)
+	ldq		$1,8($30)
+	ldq		$0,0($30)
+	addq		$30,6*8,$30
+	ret		$31,($5)
+.end	get_user_sp
+
+.align 3
+.ent	put_user_sp
+put_user_sp:
+	subq		$30,5*8,$30
+	stq		$16,0($30)
+	stq		$22,8($30)
+	stq		$23,16($30)
+	mov		$3,$16
+	stq		$24,24($30)
+	mov		$1,$3
+	stq		$25,32($30)
+	call_pal	PAL_wrusp
+	ldq		$25,32($30)
+	ldq		$24,24($30)
+	mov		$3,$1
+	ldq		$23,16($30)
+	ldq		$22,8($30)
+	ldq		$16,0($30)
+	addq		$30,5*8,$30
+	ret		$31,($5)
+.end	put_user_sp
+
+/* a code table .. make sure each entry is exactly 2 instructions */
+.align 3
+.ent	get_ureg_table
+get_ureg0:
+	ldq	$3,8*0($30)
+	ret	$31,($5)
+get_ureg1:
+	ldq	$3,8*1($30)
+	ret	$31,($5)
+get_ureg2:
+	ldq	$3,8*2($30)
+	ret	$31,($5)
+get_ureg3:
+	ldq	$3,8*3($30)
+	ret	$31,($5)
+get_ureg4:
+	ldq	$3,8*4($30)
+	ret	$31,($5)
+get_ureg5:
+	ldq	$3,8*5($30)
+	ret	$31,($5)
+get_ureg6:
+	mov	$6,$3
+	ret	$31,($5)
+get_ureg7:
+	mov	$7,$3
+	ret	$31,($5)
+get_ureg8:
+	mov	$8,$3
+	ret	$31,($5)
+get_ureg9:
+	mov	$9,$3
+	ret	$31,($5)
+get_ureg10:
+	mov	$10,$3
+	ret	$31,($5)
+get_ureg11:
+	mov	$11,$3
+	ret	$31,($5)
+get_ureg12:
+	mov	$12,$3
+	ret	$31,($5)
+get_ureg13:
+	mov	$13,$3
+	ret	$31,($5)
+get_ureg14:
+	mov	$14,$3
+	ret	$31,($5)
+get_ureg15:
+	mov	$15,$3
+	ret	$31,($5)
+get_ureg16:
+	ldq	$3,8*10($30)
+	ret	$31,($5)
+get_ureg17:
+	ldq	$3,8*11($30)
+	ret	$31,($5)
+get_ureg18:
+	ldq	$3,8*12($30)
+	ret	$31,($5)
+get_ureg19:
+	mov	$19,$3
+	ret	$31,($5)
+get_ureg20:
+	mov	$20,$3
+	ret	$31,($5)
+get_ureg21:
+	mov	$21,$3
+	ret	$31,($5)
+get_ureg22:
+	mov	$22,$3
+	ret	$31,($5)
+get_ureg23:
+	mov	$23,$3
+	ret	$31,($5)
+get_ureg24:
+	mov	$24,$3
+	ret	$31,($5)
+get_ureg25:
+	mov	$25,$3
+	ret	$31,($5)
+get_ureg26:
+	mov	$26,$3
+	ret	$31,($5)
+get_ureg27:
+	mov	$27,$3
+	ret	$31,($5)
+get_ureg28:
+	mov	$28,$3
+	ret	$31,($5)
+get_ureg29:
+	ldq	$3,9*8($30)
+	ret	$31,($5)
+get_ureg30:
+	br	$31,get_user_sp 
+	ret	$31,($5)
+get_ureg31:
+	mov	$31,$3
+	ret	$31,($5)
+.end	get_ureg_table
+
+/* another code table .. make sure each entry is exactly 2 instructions */
+.align 3
+.ent	put_ureg_table
+put_ureg0:
+	stq	$3,8*0($30)
+	ret	$31,($5)
+put_ureg1:
+	stq	$3,8*1($30)
+	ret	$31,($5)
+put_ureg2:
+	stq	$3,8*2($30)
+	ret	$31,($5)
+put_ureg3:
+	stq	$3,8*3($30)
+	ret	$31,($5)
+put_ureg4:
+	stq	$3,8*4($30)
+	ret	$31,($5)
+put_ureg5:
+	stq	$3,8*5($30)
+	ret	$31,($5)
+put_ureg6:
+	mov	$3,$6
+	ret	$31,($5)
+put_ureg7:
+	mov	$3,$7
+	ret	$31,($5)
+put_ureg8:
+	mov	$3,$8
+	ret	$31,($5)
+put_ureg9:
+	mov	$3,$9
+	ret	$31,($5)
+put_ureg10:
+	mov	$3,$10
+	ret	$31,($5)
+put_ureg11:
+	mov	$3,$11
+	ret	$31,($5)
+put_ureg12:
+	mov	$3,$12
+	ret	$31,($5)
+put_ureg13:
+	mov	$3,$13
+	ret	$31,($5)
+put_ureg14:
+	mov	$3,$14
+	ret	$31,($5)
+put_ureg15:
+	mov	$3,$15
+	ret	$31,($5)
+put_ureg16:
+	stq	$3,8*10($30)
+	ret	$31,($5)
+put_ureg17:
+	stq	$3,8*11($30)
+	ret	$31,($5)
+put_ureg18:
+	stq	$3,8*12($30)
+	ret	$31,($5)
+put_ureg19:
+	mov	$3,$19
+	ret	$31,($5)
+put_ureg20:
+	mov	$3,$20
+	ret	$31,($5)
+put_ureg21:
+	mov	$3,$21
+	ret	$31,($5)
+put_ureg22:
+	mov	$3,$22
+	ret	$31,($5)
+put_ureg23:
+	mov	$3,$23
+	ret	$31,($5)
+put_ureg24:
+	mov	$3,$24
+	ret	$31,($5)
+put_ureg25:
+	mov	$3,$25
+	ret	$31,($5)
+put_ureg26:
+	mov	$3,$26
+	ret	$31,($5)
+put_ureg27:
+	mov	$3,$27
+	ret	$31,($5)
+put_ureg28:
+	mov	$3,$28
+	ret	$31,($5)
+put_ureg29:
+	stq	$3,9*8($30)
+	ret	$31,($5)
+put_ureg30:
+	br	$31,put_user_sp 
+	ret	$31,($5)
+put_ureg31:
+	ret	$31,($5)
+.end	put_ureg_table
+
+/* this macro trashes $5 & index, and returns user reg val in $3 */
+#define get_user_reg(index)           \
+	br	$3,1f                 ;\
+1:	                              ;\
+	s8addq	index,$3,index        ;\
+	lda	$5,get_ureg0-1b($31)  ;\
+	addq	index,$5,index        ;\
+	jsr	$5,(index),get_ureg16
+
+/* this macro trashes $3, $5 & index, and takes new user reg val in $3 */
+#define put_user_reg(index)           \
+	br	$5,1f                 ;\
+1:	                              ;\
+	s8addq	index,$5,index        ;\
+	lda	$5,put_ureg0-1b($31)  ;\
+	addq	index,$5,index        ;\
+	jsr	$5,(index),put_ureg16
+
+.align 3
+.globl	emul_ldwu
+.ent	emul_ldwu
+emul_ldwu:
+	stq	$3,24($30)
+	stq	$4,32($30)
+	stq	$5,40($30)
+
+	srl	$0,21,$1
+	srl	$0,16,$2
+	and	$1,0x1f,$1
+	sll	$0,48,$0
+	and	$2,0x1f,$2
+	sra	$0,48,$0   /* $0 = disp */
+	get_user_reg($2)   /* $3 = Rb  */
+	addq	$0,$3,$0
+	ldq_u	$3,0($0)
+	ldq_u	$5,1($0)
+	extwl	$3,$0,$3
+	extwh	$5,$0,$5
+	or	$3,$5,$3
+	put_user_reg($1)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_ldwu
+
+.align 3
+.globl	emul_stw
+.ent	emul_stw
+emul_stw:
+	stq	$3,24($30)
+	stq	$4,32($30)
+	stq	$5,40($30)
+
+	srl	$0,21,$1
+	srl	$0,16,$2
+	and	$1,0x1f,$1
+	sll	$0,48,$0
+	and	$2,0x1f,$2
+	sra	$0,48,$0   /* $0 = disp */
+	get_user_reg($1)
+	mov	$3,$1
+	get_user_reg($2)   /* $3 = Rb  */
+	/* needs writing here */
+	addq	$0,$3,$0
+	ldq_u	$3,1($0)
+	ldq_u	$2,0($0)
+	inswh	$1,$0,$5
+	inswl	$1,$0,$4
+	mskwh	$3,$0,$3
+	mskwl	$2,$0,$2
+	or	$3,$5,$3
+	or	$2,$4,$2
+	stq_u	$3,1($0)
+	stq_u	$2,0($0)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_stw
+
+.align 3
+.globl	emul_ldbu
+.ent	emul_ldbu
+emul_ldbu:
+	stq	$3,24($30)
+	stq	$4,32($30)
+	stq	$5,40($30)
+
+	srl	$0,21,$1
+	srl	$0,16,$2
+	and	$1,0x1f,$1
+	sll	$0,48,$4
+	and	$2,0x1f,$2
+	sra	$4,48,$4   /* $0 = disp */
+	get_user_reg($2)   /* $3 = Rb  */
+	addq	$4,$3,$4
+	ldq_u	$3,0($4)
+	extbl	$3,$4,$3
+	put_user_reg($1)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_ldbu
+
+.align 3
+.globl	emul_stb
+.ent	emul_stb
+emul_stb:
+	stq	$3,24($30)
+	stq	$4,32($30)
+	stq	$5,40($30)
+
+	srl	$0,21,$1
+	srl	$0,16,$2
+	and	$1,0x1f,$1
+	sll	$0,48,$0
+	and	$2,0x1f,$2
+	sra	$0,48,$0   /* $0 = disp */
+	get_user_reg($1)
+	mov	$3,$1
+	get_user_reg($2)   /* $3 = Rb  */
+	addq	$0,$3,$0
+	ldq_u	$2,0($0)
+	insbl	$1,$0,$3
+	mskbl	$2,$0,$2
+
+	ldq	$5,40($30)
+	or	$2,$3,$2
+
+	ldq	$3,24($30)
+	stq_u	$2,0($0)
+
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_stb
+
+.align 3
+.globl	emul_minsw_4
+.ent	emul_minsw_4
+emul_minsw_4:
+	stq	$6,48($30)
+
+	extwl	$3,0x6,$4 /* get word 3 of ra (most significant) -> $4 */
+	extwl	$2,0x6,$1 /* get word 3 of rb                    -> $2 */
+	cmple	$2,$3,$6
+	cmovne	$6,$1,$4
+
+	extwl	$3,0x4,$5 /* get word 2 of ra                    -> $5 */
+	extwl	$2,0x4,$1 /* get word 2 of rb                    -> $1 */
+	cmple	$2,$3,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$4
+
+	extwl	$3,0x2,$5 /* get word 1 of ra                    -> $5 */
+	extwl	$2,0x2,$1 /* get word 1 of rb                    -> $1 */
+	cmple	$2,$3,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$4
+
+	extwl	$3,0x0,$5 /* get word 1 of ra                    -> $5 */
+	extwl	$2,0x0,$1 /* get word 1 of rb                    -> $1 */
+	cmple	$2,$3,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$3
+	
+	ldq	$6,48($30)
+
+	put_user_reg($0)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_minsw_4
+
+.align 3
+.globl	emul_minuw_4
+.ent	emul_minuw_4
+emul_minuw_4:
+	stq	$6,48($30)
+
+	extwl	$3,0x6,$4 /* get word 3 of ra (most significant) -> $4 */
+	extwl	$2,0x6,$1 /* get word 3 of rb                    -> $2 */
+	cmpule	$2,$3,$6
+	cmovne	$6,$1,$4
+
+	extwl	$3,0x4,$5 /* get word 2 of ra                    -> $5 */
+	extwl	$2,0x4,$1 /* get word 2 of rb                    -> $1 */
+	cmpule	$2,$3,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$4
+
+	extwl	$3,0x2,$5 /* get word 1 of ra                    -> $5 */
+	extwl	$2,0x2,$1 /* get word 1 of rb                    -> $1 */
+	cmpule	$2,$3,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$4
+
+	extwl	$3,0x0,$5 /* get word 1 of ra                    -> $5 */
+	extwl	$2,0x0,$1 /* get word 1 of rb                    -> $1 */
+	cmpule	$2,$3,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$3
+	
+	ldq	$6,48($30)
+
+	put_user_reg($0)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_minuw_4
+
+.align 3
+.globl	emul_maxsw_4
+.ent	emul_maxsw_4
+emul_maxsw_4:
+	stq	$6,48($30)
+
+	extwl	$3,0x6,$4 /* get word 3 of ra (most significant) -> $4 */
+	extwl	$2,0x6,$1 /* get word 3 of rb                    -> $2 */
+	cmple	$4,$1,$6
+	cmovne	$6,$1,$4
+
+	extwl	$3,0x4,$5 /* get word 2 of ra                    -> $5 */
+	extwl	$2,0x4,$1 /* get word 2 of rb                    -> $1 */
+	cmple	$5,$1,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$4
+
+	extwl	$3,0x2,$5 /* get word 1 of ra                    -> $5 */
+	extwl	$2,0x2,$1 /* get word 1 of rb                    -> $1 */
+	cmple	$5,$1,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$4
+
+	extwl	$3,0x0,$5 /* get word 1 of ra                    -> $5 */
+	extwl	$2,0x0,$1 /* get word 1 of rb                    -> $1 */
+	cmple	$5,$1,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$3
+	
+	ldq	$6,48($30)
+
+	put_user_reg($0)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_maxsw_4
+
+.align 3
+.globl	emul_maxuw_4
+.ent	emul_maxuw_4
+emul_maxuw_4:
+	stq	$6,48($30)
+
+	extwl	$3,0x6,$4 /* get word 3 of ra (most significant) -> $4 */
+	extwl	$2,0x6,$1 /* get word 3 of rb                    -> $2 */
+	cmpule	$4,$1,$6
+	cmovne	$6,$1,$4
+
+	extwl	$3,0x4,$5 /* get word 2 of ra                    -> $5 */
+	extwl	$2,0x4,$1 /* get word 2 of rb                    -> $1 */
+	cmpule	$5,$1,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$4
+
+	extwl	$3,0x2,$5 /* get word 1 of ra                    -> $5 */
+	extwl	$2,0x2,$1 /* get word 1 of rb                    -> $1 */
+	cmpule	$5,$1,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$4
+
+	extwl	$3,0x0,$5 /* get word 1 of ra                    -> $5 */
+	extwl	$2,0x0,$1 /* get word 1 of rb                    -> $1 */
+	cmpule	$5,$1,$6
+	sll	$4,16,$4
+	cmovne	$6,$1,$5
+	or	$4,$5,$3
+	
+	ldq	$6,48($30)
+
+	put_user_reg($0)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_maxuw_4
+
+.align 3
+.globl	emul_maxub_8
+.ent	emul_maxub_8
+emul_maxub_8:
+	cmpbge	$2,$3,$1
+	zap	$3,$1,$3
+	zapnot	$2,$1,$2
+	or	$3,$2,$3
+	put_user_reg($0)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_maxub_8
+
+.align 3
+.globl	emul_maxub_8
+.ent	emul_maxub_8
+emul_maxsb_8:
+	lda	$1,0x7f7f($31)
+	ldah	$1,0x7f7f($1)
+	sll	$1,32,$5
+	or	$1,$5,$1
+	not	$1,$1
+	xor	$3,$1,$5
+	xor	$2,$1,$1
+
+	cmpbge	$1,$5,$1
+	zap	$3,$1,$3
+	zapnot	$2,$1,$2
+	or	$3,$2,$3
+	put_user_reg($0)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_maxub_8
+
+.align 3
+.globl	emul_minub_8
+.ent	emul_minub_8
+emul_minub_8:
+	cmpbge	$3,$2,$1
+	zap	$3,$1,$3
+	zapnot	$2,$1,$2
+	or	$3,$2,$3
+	put_user_reg($0)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_minub_8
+
+.align 3
+.globl	emul_minsb_8
+.ent	emul_minsb_8
+emul_minsb_8:
+	lda	$1,0x7f7f($31)
+	ldah	$1,0x7f7f($1)
+	sll	$1,32,$5
+	or	$1,$5,$1
+	not	$1,$1
+	xor	$3,$1,$5
+	xor	$2,$1,$1
+
+	cmpbge	$5,$1,$1
+	zap	$3,$1,$3
+	zapnot	$2,$1,$2
+	or	$3,$2,$3
+	put_user_reg($0)
+
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_minsb_8
+
+.align 3
+.globl	emul_sexw
+.ent	emul_sexw
+emul_sexw:
+	sll	$3,48,$3
+	and	$0,0x1f,$1
+	sra	$3,48,$3
+	put_user_reg($1)
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_sexw
+
+.align 3
+.globl	emul_sexb
+.ent	emul_sexb
+emul_sexb:
+	sll	$3,56,$3
+	and	$0,0x1f,$1
+	sra	$3,56,$3
+	put_user_reg($1)
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	call_pal PAL_rti
+.end	emul_sexb
+
+.align 3
+.globl	emul_mmx
+.ent	emul_mmx
+emul_mmx:
+	stq	$3,24($30)
+	stq	$4,32($30)
+	stq	$5,40($30)
+
+	srl	$0,5,$4
+	srl	$0,12,$2
+	and	$4,0x3f,$4
+	blbs	$2,21f
+	srl	$0,16,$1
+	and	$1,0x1f,$1
+	get_user_reg($1)
+21:
+	srl	$0,13,$1
+	and	$1,0xff,$1
+	cmovlbs	$2,$1,$3
+	/* now:	$0 = insn
+		$3 = regb val
+		$4 = operation function code */
+	cmpeq	$4,0x1,$2
+	beq	$4,emul_sexb
+	bne	$2,emul_sexw
+	srl	$0,21,$1
+	mov	$3,$2
+	and	$1,0x1f,$1
+	get_user_reg($1)
+	cmpeq	$4,0x3a,$1
+	cmpeq	$4,0x38,$5
+	and	$0,0x1f,$0
+	/* now:	$0 = rc index
+		$2 = rb val
+		$3 = ra val
+		$4 = operation function code */
+	bne	$1,emul_minub_8
+	bne	$5,emul_minsb_8
+	cmpeq	$4,0x3e,$1
+	cmpeq	$4,0x3c,$5
+	bne	$1,emul_maxsb_8
+	bne	$5,emul_maxub_8
+	cmpeq	$4,0x39,$1
+	cmpeq	$4,0x3f,$5
+	bne	$1,emul_minsw_4
+	bne	$5,emul_maxsw_4
+	cmpeq	$4,0x3b,$1
+	cmpeq	$4,0x3d,$5
+	bne	$1,emul_minuw_4
+	bne	$5,emul_maxuw_4
+	ldq	$5,40($30)
+	ldq	$4,32($30)
+	ldq	$3,24($30)
+	ldq	$2,16($30)
+	ldq	$1,8($30)
+	ldq	$0,0($30)
+	addq	$30,7*8,$30
+	br	old_entIF
+.end	emul_mmx
+
+#endif /* CONFIG_ALPHA_EXTINSNS */
+
 .align 3
 .globl	entIF
 .ent	entIF
 entIF:
+#ifdef CONFIG_ALPHA_EXTINSNS
+	subq	$30,7*8,$30 /* 3 regs saved here, 3 or 4 more saved in fns */
+	stq	$0,0($30)
+	ldq	$0,8+7*8($30)
+	stq	$1,8($30)
+	ldl	$0,-4($0)
+	stq	$2,16($30)
+	srl	$0,26,$1
+	and	$1,0x3f,$1
+	cmpeq	$1,0x1c,$2
+	bne	$2,emul_mmx
+	cmpeq	$1,0x0a,$2
+	bne	$2,emul_ldbu
+	cmpeq	$1,0x0e,$2
+	bne	$2,emul_stb
+	cmpeq	$1,0x0c,$2
+	cmpeq	$1,0x0d,$1
+	bne	$2,emul_ldwu
+	bne	$1,emul_stw
+	ldq	$0,0($30)
+	ldq	$1,8($30)
+	ldq	$2,16($30)
+	addq	$30,7*8,$30
+old_entIF:
+#endif /* CONFIG_ALPHA_EXTINSNS */
 	SAVE_ALL
 	lda	$8,0x3fff
 	lda	$26,ret_from_sys_call

^ permalink raw reply	[flat|nested] 25+ messages in thread
* Re: patch_v2: (on Alpha) emulating missing instructions
@ 1999-10-18 13:05 Robert Harley
  0 siblings, 0 replies; 25+ messages in thread
From: Robert Harley @ 1999-10-18 13:05 UTC (permalink / raw)
  To: axp-list

Luke Deller wrote:
>+ extwl $3,0x6,$4 /* get word 3 of ra (most significant) -> $4 */ 
>+ extwl $2,0x6,$1 /* get word 3 of rb -> $2 */ 
>+ cmple $2,$3,$6 
>+ cmovne $6,$1,$4 

Surely you should compare registers 1 and 4, rather than 2 and 3.


>+ extwl $3,0x4,$5 /* get word 2 of ra -> $5 */ 
>+ extwl $2,0x4,$1 /* get word 2 of rb -> $1 */ 
>+ cmple $2,$3,$6 
>+ sll $4,16,$4 
>+ cmovne $6,$1,$5 
>+ or $4,$5,$4 

Likewise with 1 and 5.  Same elsewhere.


>+.globl emul_maxub_8 
>+.ent emul_maxub_8 
>+emul_maxsb_8: 

ub or sb?


>+ lda $1,0x7f7f($31) 
>+ ldah $1,0x7f7f($1) 
>+ sll $1,32,$5 
>+ or $1,$5,$1 
>+ not $1,$1 

I think you could get the 0x8080808080808080 pattern shorter by something like:

not $31, $1
zap $1, 0x55, $1
srl $1, 1, $5
xor $1, $5, $1


Bye,
  Rob.


^ permalink raw reply	[flat|nested] 25+ messages in thread
* Re: patch_v2: (on Alpha) emulating missing instructions
@ 1999-10-18 14:46 Robert Harley
  1999-10-18 15:31 ` Phil Carmody
  1999-10-21 16:23 ` patch_v3: emulating missing instructions on Alpha Luke Deller
  0 siblings, 2 replies; 25+ messages in thread
From: Robert Harley @ 1999-10-18 14:46 UTC (permalink / raw)
  To: axp-list

BTW, here is a fast and short way of doing minuw():

------------------------------------------------------------------------------
#define CMPBGE(a, b, c) \
  asm("cmpbge %1, %2, %0" : "=r" (c) : "r" (a), "r" (b))
#define ZAP(a, b, c) \
  asm("zap %1, %2, %0" : "=r" (c) : "r" (a), "r" (b))
#define ZAPNOT(a, b, c) \
  asm("zapnot %1, %2, %0" : "=r" (c) : "r" (a), "r" (b))

static u64 minuw(u64 x, u64 y) {
  u64 eq, ge1, ge2;

  CMPBGE(x, y, ge1);
  CMPBGE(0, x ^ y, eq);

  ge2 = (ge1 & ~eq | eq & ge1<<1) & 0xAA;
  ge2 |= ge2>>1;

  ZAP(x, ge2, x);
  ZAPNOT(y, ge2, y);

  return x | y;
} /* end function minuw */
------------------------------------------------------------------------------


The output from gcc 2.95 looks like:

------------------------------------------------------------------------------
minuw:
        cmpbge $16, $17, $1
        xor $16,$17,$3
        mov $31,$2
        cmpbge $2, $3, $2
        addq $1,$1,$4
        bic $1,$2,$1
        and $2,$4,$2
        bis $1,$2,$1
        and $1,170,$1
        srl $1,1,$2
        bis $1,$2,$1
        zapnot $17, $1, $17
        zap $16, $1, $16
        bis $16,$17,$0
        ret $31,($26),1
        .end minuw
------------------------------------------------------------------------------


This bit:

        mov $31,$2
        cmpbge $2, $3, $2

would be better as:

        cmpbge $31, $3, $2


Bye,
  Rob.


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~1999-10-28 23:34 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-01-12  3:55 rpcc Christoph Dworzak
1999-01-12  3:20 ` rpcc Peter Petrakis
1999-01-12  4:59 ` rpcc Richard Henderson
     [not found]   ` <rth@twiddle.net>
1999-01-12 16:59     ` rpcc Christoph Dworzak
1999-01-12 19:27       ` rpcc Richard Henderson
1999-01-12 21:06         ` rpcc Wes Bauske
1999-01-13  2:16           ` rpcc Richard Henderson
1999-01-14 16:17     ` Alpha 21264 Christoph Dworzak
1999-01-14 15:46       ` Greg Lindahl
1999-01-14 17:27       ` Richard Henderson
1999-10-24 15:04     ` patch_v2: (on Alpha) emulating missing instructions Christoph Dworzak
1999-10-25  9:47       ` Phil Carmody
  -- strict thread matches above, loose matches on Subject: below --
1999-01-13 14:10 Alpha 21264 Andy Almond
1999-01-13 16:36 ` Jeff Sturm
1999-01-14  6:50   ` Richard Henderson
1999-10-15  9:30 PATCH: (on Alpha) emulating missing instructions Luke Deller
1999-10-16  9:13 ` patch_v2: " Luke Deller
1999-10-18 13:05 Robert Harley
1999-10-18 14:46 Robert Harley
1999-10-18 15:31 ` Phil Carmody
1999-10-23 20:39   ` Richard Henderson
1999-10-21 16:23 ` patch_v3: emulating missing instructions on Alpha Luke Deller
1999-10-23 20:55   ` Richard Henderson
1999-10-24  0:28     ` Daniel Potts
1999-10-25  1:22     ` Luke Deller
1999-10-28 23:34       ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox