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
#line 2 "../src/kernel/hppa/asm0.h"
2
/* Copyright (C) 2004 The PARI group.
3
4
This file is part of the PARI/GP package.
5
6
PARI/GP is free software; you can redistribute it and/or modify it under the
7
terms of the GNU General Public License as published by the Free Software
8
Foundation; either version 2 of the License, or (at your option) any later
9
version. 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
15
16
/* This file was made using idea from Bruno Haible ix86 asm inline kernel
17
* and code from Nigel Smart hppa asm kernel. mulll was inspired from
18
* longlong.h from the GNU MP package.*/
19
20
/*
21
ASM addll mulll
22
NOASM bfffo divll
23
*/
24
#ifdef ASMINLINE
25
26
#define LOCAL_HIREMAINDER register ulong hiremainder
27
#define LOCAL_OVERFLOW register ulong overflow
28
29
#define addll(a,b) \
30
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
31
__asm__ ("add %2,%3,%0\n\taddc %%r0,%%r0,%1" \
32
: "=r" (__value), "=r" (overflow) \
33
: "r" (__arg1), "r" (__arg2) \
34
: "cc"); \
35
__value; \
36
})
37
38
#define addllx(a,b) \
39
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
40
__asm__ ("sub %4,%5,%%r0\n\taddc %2,%3,%0\n\taddc %%r0,%%r0,%1" \
41
: "=r" (__value), "=r" (overflow) \
42
: "r" (__arg1), "r" (__arg2), "r" (overflow), "r" ((ulong) 1)\
43
: "cc"); \
44
__value; \
45
})
46
47
#define subll(a,b) \
48
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
49
__asm__ ("sub %2,%3,%0\n\taddc %%r0,%%r0,%1\n\tsubi 1,%1,%1" \
50
: "=r" (__value), "=r" (overflow) \
51
: "r" (__arg1), "r" (__arg2) \
52
: "cc"); \
53
__value; \
54
})
55
56
#define subllx(a,b) \
57
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
58
__asm__ ("sub %%r0,%4,%%r0\n\tsubb %2,%3,%0\n\taddc %%r0,%%r0,%1\n\tsubi 1,%1,%1" \
59
: "=r" (__value), "=r" (overflow) \
60
: "r" (__arg1), "r" (__arg2), "r" (overflow)\
61
: "cc"); \
62
__value; \
63
})
64
65
#define mulll(a,b) \
66
__extension__ ({ ulong __arg1 = (a), __arg2 = (b); \
67
union {double z; ulong x[2];} __vtab; \
68
__asm__ ("xmpyu %1,%2,%0" \
69
: "=f" (__vtab.z) \
70
: "f" (__arg1), "f" (__arg2) \
71
: "cc"); \
72
hiremainder=__vtab.x[0]; \
73
__vtab.x[1]; \
74
})
75
76
#define addmul(a,b) \
77
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
78
union {double z; ulong x[2];} __vtab; \
79
__asm__ ("xmpyu %1,%2,%0" \
80
: "=f" (__vtab.z) \
81
: "f" (__arg1), "f" (__arg2) \
82
: "cc"); \
83
__asm__ ("add %2,%3,%0\n\taddc %%r0, %4, %1" \
84
: "=&r" (__value), "=r" (hiremainder) \
85
: "r" (__vtab.x[1]),"r" (hiremainder), "r" (__vtab.x[0]) \
86
: "cc"); \
87
__value; \
88
})
89
90
#endif
91
92