-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
u128 is largest unsigned type? #1485
Comments
The short answer to this and #1534 is that we need to send a patch to LLVM to make it emit library calls for this even though the scope of those library calls is outside of the standardized compiler-rt. |
Would a zig fork of LLVM with upstream merging be a solution? |
It would be a solution, but ideally we could use upstream without any patches. I think the feature is not so critical that we can't wait for one llvm release cycle (after getting the patch into llvm) |
Inefficient workaround const std = @import("std");
const Int = std.math.big.Int;
const warn = std.debug.warn;
pub fn main() void {
var alloc = std.heap.direct_allocator;
const a: u1024 = 1234;
const b: u1024 = 5678;
const c = a + b;
const i = Int.initSet(alloc, c);
warn("{}\n", i);
} |
an upstream bug report looking like there is no planned LLVM solution: https://bugs.llvm.org/show_bug.cgi?id=45649 |
We can and should lower to our own lib calls instead of LLVM arithmetic for cases where we know LLVM cannot lower them. |
LLVM15 is able to correctly lower addition, substraction, multiplication, all bitwise operations and comparisions for all integer types. |
->
340282366920938463463374607431768211455 3689348814741910323222
if you change
uType
to anything higher thanu128
compiling fails withLLVM ERROR: Unsupported library call operation!
(lower works fine though)Maximum width for unsigned types isn't mentioned in the docs (anyway there is no explicit list of unsigned types).
Is 128 as max intentional? I might like a u256...
The text was updated successfully, but these errors were encountered: