-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
For example, aarch64
. This avoids intrinsics but uses uint128
:
nim-stint/stint/private/primitives/addcarry_subborrow.nim
Lines 87 to 89 in 7bb0ccc
const | |
useIntrinsics = X86 and not stintNoIntrinsics | |
useInt128 = GCC_Compatible and sizeof(int) == 8 and not stintNoIntrinsics |
import "."/"nim-stint"/stint
const x: UInt256 = 0.u256
discard $x
commit 7bb0ccc7842577243edc3b8d61f75bf498551a7a (HEAD -> master, origin/master, origin/HEAD)
Author: andri lim <jangko128@gmail.com>
Date: Tue Feb 27 19:55:11 2024 +0700
Upgrade github actions to v4 (#149)
Nim 1.6 builds this fine:
Nim Compiler Version 1.6.19 [Linux: amd64]
Compiled at 2024-03-13
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: afced7d9ab62be2d1394e884fe20ce1dd5f24918
active boot switches: -d:release
Nim 2.0 and devel both create compilation messages when doing the decimal base conversion relating to
nim-stint/stint/private/primitives/addcarry_subborrow.nim
Lines 182 to 183 in 7bb0ccc
{.emit:["*",bOut, " = (NU64)(", dblPrec," >> ", 64'u64, ") & 1;"].} | |
{.emit:["*",diff, " = (NU64)", dblPrec,";"].} |
.cache/nim/r_d/@mnim-stint@sstint@sprivate@suint_div.nim.c:368:25: error: invalid type argument of unary ‘*’ (have ‘int’)
368 | nimln_(184); *(*bOut_p0) = (NU64)(dblPrec >> 64ULL) & 1;
| ^~~~~~~~~~~
.cache/nim/r_d/@mnim-stint@sstint@sprivate@suint_div.nim.c:369:25: error: invalid type argument of unary ‘*’ (have ‘NU64’ {aka ‘long unsigned int’})
369 | nimln_(185); *(*diff_p1) = (NU64)dblPrec;
| ^~~~~~~~~~~
.cache/nim/r_d/@mnim-stint@sstint@sprivate@suint_div.nim.c: In function ‘addC__nim45stintZstintZprivateZprimitivesZaddcarry95subborrow_u62’:
.cache/nim/r_d/@mnim-stint@sstint@sprivate@suint_div.nim.c:376:25: error: invalid type argument of unary ‘*’ (have ‘int’)
376 | nimln_(161); *(*cOut_p0) = (NU64)(dblPrec >> 64ULL);
| ^~~~~~~~~~~
with commits
Nim Compiler Version 2.0.3 [Linux: amd64]
Compiled at 2024-03-13
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: e374759f29da733f3c404718c333f5f3cb5f332d
active boot switches: -d:release
and
Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2024-03-13
Copyright (c) 2006-2024 by Andreas Rumpf
git hash: 78c834dd76f273d8813247647531005a1f7db1a6
active boot switches: -d:release
Nim 2.0 generates this, in particular
static N_INLINE(
void, subB__nim45stintZstintZprivateZprimitivesZaddcarry95subborrow_u88)(
NU8 *bOut_p0, NU64 *diff_p1, NU64 a_p2, NU64 b_p3, NU8 bIn_p4) {
unsigned __int128 dblPrec;
dblPrec = (unsigned __int128)a_p2 - (unsigned __int128)b_p3 -
(unsigned __int128)bIn_p4;
*(*bOut_p0) = (NU64)(dblPrec >> 64ULL) & 1; /* doesn't compile */
*(*diff_p1) = (NU64)dblPrec; /* doesn't compile */
popFrame();
}
static N_INLINE(
void, addC__nim45stintZstintZprivateZprimitivesZaddcarry95subborrow_u62)(
NU8 *cOut_p0, NU64 *sum_p1, NU64 a_p2, NU64 b_p3, NU8 cIn_p4) {
unsigned __int128 dblPrec;
dblPrec = (unsigned __int128)a_p2 + (unsigned __int128)b_p3 +
(unsigned __int128)cIn_p4;
*(*cOut_p0) = (NU64)(dblPrec >> 64ULL); /* doesn't compile */
*(*sum_p1) = (NU64)dblPrec;
popFrame();
}
where Nim 1.6 generates:
static N_INLINE(
void, subB__nim45stintZstintZprivateZprimitivesZaddcarry95subborrow_u78)(
NU8 *bOut, NU64 *diff, NU64 a, NU64 b, NU8 bIn) {
unsigned __int128 dblPrec;
dblPrec =
(unsigned __int128)a - (unsigned __int128)b - (unsigned __int128)bIn;
*bOut = (NU64)(dblPrec >> 64ULL) & 1;
*diff = (NU64)dblPrec;
popFrame();
}
static N_INLINE(
void, addC__nim45stintZstintZprivateZprimitivesZaddcarry95subborrow_u62)(
NU8 *cOut, NU64 *sum, NU64 a, NU64 b, NU8 cIn) {
unsigned __int128 dblPrec;
dblPrec =
(unsigned __int128)a + (unsigned __int128)b + (unsigned __int128)cIn;
*cOut = (NU64)(dblPrec >> 64ULL);
*sum = (NU64)dblPrec;
popFrame();
}
Metadata
Metadata
Assignees
Labels
No labels