aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64/lib/idiv64.S
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/ia64/lib/idiv64.S
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/ia64/lib/idiv64.S')
-rw-r--r--arch/ia64/lib/idiv64.S80
1 files changed, 80 insertions, 0 deletions
diff --git a/arch/ia64/lib/idiv64.S b/arch/ia64/lib/idiv64.S
new file mode 100644
index 000000000000..f69bd2b0987a
--- /dev/null
+++ b/arch/ia64/lib/idiv64.S
@@ -0,0 +1,80 @@
1/*
2 * Copyright (C) 1999-2000 Hewlett-Packard Co
3 * Copyright (C) 1999-2000 David Mosberger-Tang <davidm@hpl.hp.com>
4 *
5 * 64-bit integer division.
6 *
7 * This code is based on the application note entitled "Divide, Square Root
8 * and Remainder Algorithms for the IA-64 Architecture". This document
9 * is available as Intel document number 248725-002 or via the web at
10 * http://developer.intel.com/software/opensource/numerics/
11 *
12 * For more details on the theory behind these algorithms, see "IA-64
13 * and Elementary Functions" by Peter Markstein; HP Professional Books
14 * (http://www.hp.com/go/retailbooks/)
15 */
16
17#include <asm/asmmacro.h>
18
19#ifdef MODULO
20# define OP mod
21#else
22# define OP div
23#endif
24
25#ifdef UNSIGNED
26# define SGN u
27# define INT_TO_FP(a,b) fcvt.xuf.s1 a=b
28# define FP_TO_INT(a,b) fcvt.fxu.trunc.s1 a=b
29#else
30# define SGN
31# define INT_TO_FP(a,b) fcvt.xf a=b
32# define FP_TO_INT(a,b) fcvt.fx.trunc.s1 a=b
33#endif
34
35#define PASTE1(a,b) a##b
36#define PASTE(a,b) PASTE1(a,b)
37#define NAME PASTE(PASTE(__,SGN),PASTE(OP,di3))
38
39GLOBAL_ENTRY(NAME)
40 .regstk 2,0,0,0
41 // Transfer inputs to FP registers.
42 setf.sig f8 = in0
43 setf.sig f9 = in1
44 ;;
45 // Convert the inputs to FP, to avoid FP software-assist faults.
46 INT_TO_FP(f8, f8)
47 INT_TO_FP(f9, f9)
48 ;;
49 frcpa.s1 f11, p6 = f8, f9 // y0 = frcpa(b)
50 ;;
51(p6) fmpy.s1 f7 = f8, f11 // q0 = a*y0
52(p6) fnma.s1 f6 = f9, f11, f1 // e0 = -b*y0 + 1
53 ;;
54(p6) fma.s1 f10 = f7, f6, f7 // q1 = q0*e0 + q0
55(p6) fmpy.s1 f7 = f6, f6 // e1 = e0*e0
56 ;;
57#ifdef MODULO
58 sub in1 = r0, in1 // in1 = -b
59#endif
60(p6) fma.s1 f10 = f10, f7, f10 // q2 = q1*e1 + q1
61(p6) fma.s1 f6 = f11, f6, f11 // y1 = y0*e0 + y0
62 ;;
63(p6) fma.s1 f6 = f6, f7, f6 // y2 = y1*e1 + y1
64(p6) fnma.s1 f7 = f9, f10, f8 // r = -b*q2 + a
65 ;;
66#ifdef MODULO
67 setf.sig f8 = in0 // f8 = a
68 setf.sig f9 = in1 // f9 = -b
69#endif
70(p6) fma.s1 f11 = f7, f6, f10 // q3 = r*y2 + q2
71 ;;
72 FP_TO_INT(f11, f11) // q = trunc(q3)
73 ;;
74#ifdef MODULO
75 xma.l f11 = f11, f9, f8 // r = q*(-b) + a
76 ;;
77#endif
78 getf.sig r8 = f11 // transfer result to result register
79 br.ret.sptk.many rp
80END(NAME)