Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

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

28494 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
14
15
/* This file is common to SuperSparc and MicroSparc */
16
/*
17
ASM addll mulll
18
NOASM bfffo
19
*/
20
#ifdef ASMINLINE
21
22
#define LOCAL_HIREMAINDER ulong hiremainder
23
#define LOCAL_OVERFLOW ulong overflow
24
25
#define addll(a,b) \
26
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
27
__asm__ ( "addcc %2,%3,%0; \
28
addx %%g0,%%g0,%1" \
29
: "=r" (__value), "=r" (overflow) \
30
: "r" (__arg1), "r" (__arg2) \
31
: "cc"); \
32
__value; })
33
34
#define addllx(a,b) \
35
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
36
__asm__ ( "subcc %%g0,%1,%%g0; \
37
addxcc %2,%3,%0; \
38
addx %%g0,%%g0,%1" \
39
: "=r" (__value), "=r" (overflow) \
40
: "r" (__arg1), "r" (__arg2), "1" (overflow) \
41
: "cc"); \
42
__value; })
43
44
#define subll(a,b) \
45
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
46
__asm__ ( "subcc %2,%3,%0; \
47
addx %%g0,%%g0,%1" \
48
: "=r" (__value), "=r" (overflow) \
49
: "r" (__arg1), "r" (__arg2) \
50
: "cc"); \
51
__value; })
52
53
#define subllx(a,b) \
54
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
55
__asm__ ( "subcc %%g0,%1,%%g0; \
56
subxcc %2,%3,%0; \
57
addx %%g0,%%g0,%1" \
58
: "=r" (__value), "=r" (overflow) \
59
: "r" (__arg1), "r" (__arg2), "1" (overflow) \
60
: "cc"); \
61
__value; })
62
63
#define mulll(a,b) \
64
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
65
__asm__ ( "umul %2,%3,%0; \
66
rd %%y,%1" \
67
: "=r" (__value), "=r" (hiremainder) \
68
: "r" (__arg1), "r" (__arg2)); \
69
__value;})
70
71
#define addmul(a,b) \
72
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b), __tmp; \
73
__asm__ ( "umul %3,%4,%0; \
74
rd %%y,%2; \
75
addcc %0,%1,%0; \
76
addx %%g0,%2,%1" \
77
: "=&r" (__value), "=&r" (hiremainder), "=&r" (__tmp) \
78
: "r" (__arg1), "r" (__arg2), "1" (hiremainder) \
79
: "cc"); \
80
__value;})
81
#endif
82
83