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