Annotation of OpenXM_contrib/pari-2.2/src/kernel/sparcv9/asmsparcv9.h, Revision 1.1.1.1
1.1 noro 1: /* $Id: asmsparcv9.h,v 1.3 2000/11/03 21:00:27 karim Exp $
2:
3: Copyright (C) 2000 The PARI group.
4:
5: This file is part of the PARI/GP package.
6:
7: PARI/GP is free software; you can redistribute it and/or modify it under the
8: terms of the GNU General Public License as published by the Free Software
9: Foundation. It is distributed in the hope that it will be useful, but WITHOUT
10: ANY WARRANTY WHATSOEVER.
11:
12: Check the License for details. You should have received a copy of it, along
13: with the package; see the file 'COPYING'. If not, write to the Free Software
14: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
15:
16: #ifndef __ASMSPARCV9_H__
17: #define __ASMSPARCV9_H__
18:
19: register ulong hiremainder asm("%g5");
20: register ulong overflow asm("%g6");
21:
22: #define addll(a,b) \
23: ({ ulong __value, __arg1 = (a), __arg2 = (b); \
24: asm ( "addcc %2,%3,%0; \
25: addc %%g0,%%g0,%1" \
26: : "=r" (__value), "=r" (overflow) \
27: : "r" (__arg1), "r" (__arg2) \
28: : "%g6","cc"); \
29: __value; })
30:
31: #define subll(a,b) \
32: ({ ulong __value, __arg1 = (a), __arg2 = (b); \
33: asm ( "subcc %2,%3,%0; \
34: addc %%g0,%%g0,%1" \
35: : "=r" (__value), "=r" (overflow) \
36: : "r" (__arg1), "r" (__arg2) \
37: : "%g6","cc"); \
38: __value; })
39:
40: #define addllx(a,b) \
41: ({ ulong __value, __arg1 = (a), __arg2 = (b); \
42: asm ( "subcc %%g0,%%g6,%%g0; \
43: addccc %2,%3,%0; \
44: addc %%g0,%%g0,%1" \
45: : "=r" (__value), "=r" (overflow) \
46: : "r" (__arg1), "r" (__arg2) \
47: : "%g6","cc"); \
48: __value; })
49:
50: #define subllx(a,b) \
51: ({ ulong __value, __arg1 = (a), __arg2 = (b); \
52: asm ( "subcc %%g0,%%g6,%%g0; \
53: subccc %2,%3,%0; \
54: addc %%g0,%%g0,%1" \
55: : "=r" (__value), "=r" (overflow) \
56: : "r" (__arg1), "r" (__arg2) \
57: : "%g6","cc"); \
58: __value; })
59:
60: #define shiftl(a,b) \
61: ({ ulong __value, __arg1 = (a), __arg2 = (b); \
62: asm ( "neg %3,%%o4; \
63: srl %2,%%o4,%1; \
64: sll %2,%3,%0" \
65: : "=r" (__value), "=r" (hiremainder) \
66: : "r" (__arg1), "r" (__arg2) \
67: : "%o4","%g5"); \
68: __value; })
69:
70: #define shiftl2(a,b,c) \
71: ({ ulong __value, __arg1 = (a), __arg2 = (b), __arg3 = (c); \
72: asm ( "srl %2,%4,%1; \
73: sll %2,%3,%0" \
74: : "=r" (__value), "=r" (hiremainder) \
75: : "r" (__arg1), "r" (__arg2), "r" (__arg3) \
76: : "%g5"); \
77: __value; })
78:
79: #define shiftlr(a,b) \
80: ({ ulong __value, __arg1 = (a), __arg2 = (b); \
81: asm ( "neg %3,%%o4; \
82: sll %2,%%o4,%1; \
83: srl %2,%3,%0" \
84: : "=r" (__value), "=r" (hiremainder) \
85: : "r" (__arg1), "r" (__arg2) \
86: : "%o4","%g5"); \
87: __value; })
88:
89: #define shiftlr1(a) \
90: ({ ulong __value, __arg1 = (a); \
91: asm ( "sll %2,31,%1; \
92: srl %2,1,%0" \
93: : "=r" (__value), "=r" (hiremainder) \
94: : "r" (__arg1) \
95: : "%g5"); \
96: __value; })
97:
98: #define shiftlr2(a,b,c) \
99: ({ ulong __value, __arg1 = (a), __arg2 = (b), __arg3 = (c); \
100: asm ( "sll %2,%4,%1; \
101: srl %2,%3,%0" \
102: : "=r" (__value), "=r" (hiremainder) \
103: : "r" (__arg1), "r" (__arg2), "r" (__arg3) \
104: : "%g5"); \
105: __value; })
106:
107: #define mulll(a,b) \
108: ({ ulong __value, __arg1 = (a), __arg2 = (b); \
109: asm ( "umul %2,%3,%0; \
110: srlx %0,32,%1" \
111: : "=r" (__value), "=r" (hiremainder) \
112: : "r" (__arg1), "r" (__arg2) \
113: : "%g5"); \
114: __value;})
115:
116: #define addmul(a,b) \
117: ({ ulong __value, __arg1 = (a), __arg2 = (b); \
118: asm ( "umul %2,%3,%0; \
119: add %0,%%g5,%0; \
120: srlx %0,32,%1" \
121: : "=r" (__value), "=r" (hiremainder) \
122: : "r" (__arg1), "r" (__arg2) \
123: : "%g5"); \
124: __value;})
125:
126: #define divll(a,b) \
127: ({ ulong __value, __arg1 = (a), __arg2 = (b); \
128: asm( "wr %%g5,%%g0,%%y;\
129: mov %2,%%o4;\
130: udivcc %2,%3,%0;\
131: bvc 1f;\
132: umul %0,%3,%%o5;\
133: mov 47,%%o0;\
134: call err,1;\
135: nop ;\
136: 1: sub %%o4,%%o5,%1"\
137: : "=r" (__value), "=r" (hiremainder) \
138: : "r" (__arg1), "r" (__arg2) \
139: : "%o4","%o5","%g5","cc"); \
140: __value;})
141:
142: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>