Closed Toni-Graphics closed 1 month ago
LLVM can take arbitrary sized integers, so really even a u128
wouldn't be sufficient. The use of u64
comes from the C++ API (which decides the C API), since 128 bit integers aren't widely supported and don't exactly have great ABI compatibility.
If you want to construct constant integers with more than 64 bits, you can use const_int_from_string
which will parse it for a simple solution, or you can use const_int_arbitrary_precision
to pass in a slice of u64
s, which is generally a better solution.
If you insist on using u128
, then this should do what you need:
fn const_int_u128(ty: IntType, val: u128) -> IntValue {
let bytes = [(val & 0xffffffffffffffff) as u64, (val >> 64) as u64];
ty.const_int_arbitrary_precision(&bytes)
}
Generally though, 64 bit integers are more than enough.
Thanks
Describe the Bug Hi, The
const_int
function has an argument ofu64
and notu128
so it won't support 128 bit intengers.(If this is skill issue sorry, I never worked with llvm)
To Reproduce
Expected Behavior I expect that the function would take a 128 bit wide input and not 64bit.
LLVM Version:
Desktop:
Bye