Skip to content

Commit 0900bc0

Browse files
committed
force compilation with -d:CTT_32 for the moment
Need to finalize the logic of mapping 64 bit limbs to 32 bit limb constants
1 parent bc5b2f0 commit 0900bc0

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

constantine/math_compiler/experimental/nvrtc_field_ops.nim

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,19 @@ macro asm_comment*(msg: typed): untyped =
2222

2323
template bigintToUint32Limbs*(b: typed): untyped =
2424
let limbs = b.limbs
25-
var res = default(array[b.limbs.len, uint32])
26-
for i in 0 ..< limbs.len:
27-
res[i] = limbs[i].uint32
25+
when CTT_32:
26+
var res = default(array[b.limbs.len, uint32])
27+
for i in 0 ..< limbs.len:
28+
res[i] = limbs[i].uint32
29+
else:
30+
{.error: "Logic to convert 64 bit limbs to 32 bit limbs at compile time still unfinished.".}
31+
# need twice as many limbs to go from 64bit to 32bit
32+
## XXX: Use number of bits required to check if the
33+
## last limbs needs to be dropped
34+
var res = default(array[b.limbs.len * 2, uint32])
35+
for i in 0 ..< b.limbs.len:
36+
res[i*2] = limbs[i].uint32
37+
res[i*2 + 1] = (limbs[i] shr 32).uint32
2838
res
2939

3040
template defBigInt*(N: typed): untyped {.dirty.} =

0 commit comments

Comments
 (0)