shithub: riscv

Download patch

ref: 69b0980a42da16d97349ea962e57a5f55684e1a8
parent: a99cf56c7d670f6af88cab39de91f1d6ac36416f
author: cinap_lenrek <[email protected]>
date: Sun Jun 26 11:16:23 EDT 2016

libc: native _addv() and _subv() routines for arm

--- a/sys/src/libc/arm/vlop.s
+++ b/sys/src/libc/arm/vlop.s
@@ -3,11 +3,30 @@
 	MOVW	8(FP),R11	/* h0 */
 	MOVW	12(FP),R4	/* l1 */
 	MOVW	16(FP),R5	/* h1 */
-	MULLU	R8,R4,(R6, R7)	/* l0*l1 */
+	MULLU	R8,R4,(R7,R6)	/* l0*l1 */
 	MUL	R8,R5,R5	/* l0*h1 */
+	ADD	R5,R7
 	MUL	R11,R4,R4	/* h0*l1 */
-	ADD	R4,R6
-	ADD	R5,R6
-	MOVW	R6,4(R0)
-	MOVW	R7,0(R0)
+	ADD	R4,R7
+	MOVM.IA	[R6,R7],(R0)
+	RET
+
+TEXT	_addv(SB), 1, $0
+	MOVW	4(FP),R8	/* l0 */
+	MOVW	8(FP),R11	/* h0 */
+	MOVW	12(FP),R4	/* l1 */
+	MOVW	16(FP),R5	/* h1 */
+	ADD.S	R8,R4
+	ADC	R11,R5
+	MOVM.IA	[R4,R5],(R0)
+	RET
+
+TEXT	_subv(SB), 1, $0
+	MOVW	4(FP),R8	/* l0 */
+	MOVW	8(FP),R11	/* h0 */
+	MOVW	12(FP),R4	/* l1 */
+	MOVW	16(FP),R5	/* h1 */
+	SUB.S	R4,R8,R4
+	SBC	R5,R11,R5
+	MOVM.IA	[R4,R5],(R0)
 	RET
--- a/sys/src/libc/arm/vlrt.c
+++ b/sys/src/libc/arm/vlrt.c
@@ -15,37 +15,6 @@
 
 void	abort(void);
 
-/* needed by profiler; can't be profiled */
-#pragma profile off
-
-void
-_addv(Vlong *r, Vlong a, Vlong b)
-{
-	ulong lo, hi;
-
-	lo = a.lo + b.lo;
-	hi = a.hi + b.hi;
-	if(lo < a.lo)
-		hi++;
-	r->lo = lo;
-	r->hi = hi;
-}
-
-void
-_subv(Vlong *r, Vlong a, Vlong b)
-{
-	ulong lo, hi;
-
-	lo = a.lo - b.lo;
-	hi = a.hi - b.hi;
-	if(lo > a.lo)
-		hi--;
-	r->lo = lo;
-	r->hi = hi;
-}
-
-#pragma profile on
-
 void
 _d2v(Vlong *y, double d)
 {