-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add Int128 and UInt128 #5024
Add Int128 and UInt128 #5024
Conversation
Are there 128bit architectures to even support this yet? |
@jwaldrip 64bit architectures don't mean the maximum number they can process is 64bits it means that the pointer or address size is 64bits. x86 has been able to partially handle 128bit numbers since sse2 (it can put them into one register but they have limited instructions to use them), we even have avx512 now, but for most things you do with an |
Thank you for the clarification. I did not know that 64but architectures supported it. |
Support for 128bit integers is good idea. GeoIP databases use |
I'm still not sure 128 bit integers is widely supported: https://github.com/zig-lang/zig/tree/master/std/special/compiler_rt We can always merge this and remove it later if we find something is blocking this. |
@asterite I was under the impression that LLVM embedded it's own compiler_rt somehow. They seem to have re-implemented it in zig. I'm not entirely sure of the logistics of how it's linked in though. |
Yes, it's a bit confusing. In any case, when the time comes, we can implement compiler-rt in Crystal if that's really needed. |
@asterite I'm sure the LLVM project will do a much better and more optimised job than us. I don't see why we would. |
OK, so here's a proof Int128 doesn't work out of the box. This is on Centos 32 with the new compiler:
It seems we will need to define a bunch of methods to effectively support this. In any case this is all experimental, we might as well remove this feature entirely if it's too complex to implement. |
We don't need to define them, I think we just need to link llvm compiler-rt. |
Ah, I see. Maybe a discussion for omnibus-crystal (I don't know how to do that) |
We should just do what clang does, which is just to include the library in the linker command. If worst comes to worst we can just redistribute compiler-rt ourselves. |
To include the library in the linker command we must ship the library with the compiler. It's a new dimension I didn't expect to happen. |
We "ship" llvm-ext.so and libcrystal.a |
The 0.24.0 pre-release was finally built with LLVM 3.9.1 - @asterite's comment above was done with the old 3.8 - so we should re-check if the error still happens. |
@asterite on crystal master with LLVM 5 I see
perhaps this is an automatic thing then? |
Missing:
But we can do those after the next release. With the next release we will be able to use Int128 and UInt128 to more easily fix things around those types. So this is now ready to review and merge.