Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Testing latest pari + WASM + node.js... and it works?! Wow.

28495 views
License: GPL3
ubuntu2004
1
/* Copyright (C) 2000 The PARI group.
2
3
This file is part of the PARI/GP package.
4
5
PARI/GP is free software; you can redistribute it and/or modify it under the
6
terms of the GNU General Public License as published by the Free Software
7
Foundation; either version 2 of the License, or (at your option) any later
8
version. It is distributed in the hope that it will be useful, but WITHOUT
9
ANY WARRANTY WHATSOEVER.
10
11
Check the License for details. You should have received a copy of it, along
12
with the package; see the file 'COPYING'. If not, write to the Free Software
13
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
14
/*
15
ASM addll mulll
16
NOASM bfffo divll
17
*/
18
#ifdef ASMINLINE
19
#define LOCAL_HIREMAINDER register ulong hiremainder
20
#define LOCAL_OVERFLOW register ulong overflow
21
22
#define addll(a, b) \
23
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
24
__asm__ ("adds %0,%2,%3\n\tadc %1,%4,%4\n\t" \
25
: "=&r" (__value), "=&r" (overflow) \
26
: "r" (__arg1), "r" (__arg2), "r" ((ulong)0): "cc"); \
27
__value; \
28
})
29
30
#define addllx(a, b) \
31
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
32
__asm__ ("subs %1,%4,#1\n\tadcs %0,%2,%3\n\tadc %1,%5,%5\n\t" \
33
: "=&r" (__value), "=&r" (overflow) \
34
: "r" (__arg1), "r" (__arg2), "r" (overflow), "r" ((ulong)0) \
35
: "cc"); \
36
__value; \
37
})
38
39
#define subll(a, b) \
40
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
41
__asm__ ("subs %0,%2,%3\n\tadc %1,%4,%4\n\trsb %1,%1,#1\n\t" \
42
: "=&r" (__value), "=&r" (overflow) \
43
: "r" (__arg1), "r" (__arg2), "r" ((ulong)0) \
44
: "cc"); \
45
__value; \
46
})
47
48
#define subllx(a, b) \
49
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
50
__asm__ ("rsbs %1,%4,%5\n\tsbcs %0,%2,%3\n\tadc %1,%5,%5\n\trsb %1,%1,#1\n\t" \
51
: "=&r" (__value), "=&r" (overflow) \
52
: "r" (__arg1), "r" (__arg2), "r" (overflow), "r" ((ulong)0) \
53
: "cc"); \
54
__value; \
55
})
56
57
#define mulll(a, b) \
58
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
59
__asm__ ("umull %0,%1,%2,%3\n\t" \
60
: "=&r" (__value), "=&r" (hiremainder) \
61
: "r" (__arg1), "r" (__arg2)); \
62
__value; \
63
})
64
65
#define addmul(a, b) \
66
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
67
__asm__ ("umlal %0,%1,%2,%3\n\t" \
68
: "=&r" (__value), "=&r" (hiremainder) \
69
: "r" (__arg1), "r" (__arg2), "1" ((ulong) 0), "0" (hiremainder)); \
70
__value; \
71
})
72
73
#if 0 /* Not supported by all CPU */
74
#define bfffo(a) \
75
__extension__ ({ \
76
ulong __arg1 = (a), __value; \
77
__asm__ ("clz %0,%1\n\t" \
78
: "=&r" (__value) \
79
: "r" (__arg1)); \
80
__value; \
81
})
82
#endif
83
84
#endif
85
86