This source file includes following definitions.
- mul_32_32
- add_Xsig_Xsig
- add_two_Xsig
- negate_Xsig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 #ifndef _POLY_H
16 #define _POLY_H
17
18
19
20
21
22
23 typedef struct {
24 unsigned long lsw;
25 unsigned long midw;
26 unsigned long msw;
27 } Xsig;
28
29 asmlinkage void mul64(unsigned long long const *a, unsigned long long const *b,
30 unsigned long long *result);
31 asmlinkage void polynomial_Xsig(Xsig *, const unsigned long long *x,
32 const unsigned long long terms[], const int n);
33
34 asmlinkage void mul32_Xsig(Xsig *, const unsigned long mult);
35 asmlinkage void mul64_Xsig(Xsig *, const unsigned long long *mult);
36 asmlinkage void mul_Xsig_Xsig(Xsig *dest, const Xsig *mult);
37
38 asmlinkage void shr_Xsig(Xsig *, const int n);
39 asmlinkage int round_Xsig(Xsig *);
40 asmlinkage int norm_Xsig(Xsig *);
41 asmlinkage void div_Xsig(Xsig *x1, const Xsig *x2, const Xsig *dest);
42
43
44 #define LL_MSW(x) (((unsigned long *)&x)[1])
45
46
47 #define MK_XSIG(a,b,c) { c, b, a }
48
49
50 #define XSIG_LL(x) (*(unsigned long long *)&x.midw)
51
52
53
54
55
56
57
58
59 extern inline void mul_32_32(const unsigned long arg1,
60 const unsigned long arg2,
61 unsigned long *out)
62 {
63 asm volatile ("movl %1,%%eax; mull %2; movl %%edx,%0" \
64 :"=g" (*out) \
65 :"g" (arg1), "g" (arg2) \
66 :"ax","dx");
67 }
68
69
70
71 extern inline void add_Xsig_Xsig(Xsig *dest, const Xsig *x2)
72 {
73 asm volatile ("movl %1,%%edi; movl %2,%%esi;
74 movl (%%esi),%%eax; addl %%eax,(%%edi);
75 movl 4(%%esi),%%eax; adcl %%eax,4(%%edi);
76 movl 8(%%esi),%%eax; adcl %%eax,8(%%edi);"
77 :"=g" (*dest):"g" (dest), "g" (x2)
78 :"ax","si","di");
79 }
80
81
82
83
84
85
86 extern inline int add_two_Xsig(Xsig *dest, const Xsig *x2, long int *exp)
87 {
88 asm volatile ("movl %2,%%ecx; movl %3,%%esi;
89 movl (%%esi),%%eax; addl %%eax,(%%ecx);
90 movl 4(%%esi),%%eax; adcl %%eax,4(%%ecx);
91 movl 8(%%esi),%%eax; adcl %%eax,8(%%ecx);
92 jnc 0f;
93 rcrl 8(%%ecx); rcrl 4(%%ecx); rcrl (%%ecx)
94 movl %4,%%ecx; incl (%%ecx)
95 movl $1,%%eax; jmp 1f;
96 0: xorl %%eax,%%eax;
97 1:"
98 :"=g" (*exp), "=g" (*dest)
99 :"g" (dest), "g" (x2), "g" (exp)
100 :"cx","si","ax");
101 }
102
103
104
105
106 extern inline void negate_Xsig(Xsig *x)
107 {
108 asm volatile("movl %1,%%esi; "
109 "xorl %%ecx,%%ecx; "
110 "movl %%ecx,%%eax; subl (%%esi),%%eax; movl %%eax,(%%esi); "
111 "movl %%ecx,%%eax; sbbl 4(%%esi),%%eax; movl %%eax,4(%%esi); "
112 "movl %%ecx,%%eax; sbbl 8(%%esi),%%eax; movl %%eax,8(%%esi); "
113 :"=g" (*x):"g" (x):"si","ax","cx");
114 }
115
116 #endif _POLY_H