diff options
Diffstat (limited to 'src/llvm_backend.cpp')
| -rw-r--r-- | src/llvm_backend.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index d04344c1f..c9eaadfda 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -6373,11 +6373,6 @@ LLVMValueRef lb_big_int_to_llvm(lbModule *m, Type *original_type, BigInt const * size_t size = 1; size_t nails = 0; mp_endian endian = MP_NATIVE_ENDIAN; - if (is_type_endian_little(original_type)) { - endian = MP_LITTLE_ENDIAN; - } else if (is_type_endian_big(original_type)) { - endian = MP_BIG_ENDIAN; - } max_count = mp_pack_count(a, nails, size); rop = cast(u8 *)gb_alloc_align(permanent_allocator(), max_count, gb_align_of(u64)); @@ -6387,6 +6382,18 @@ LLVMValueRef lb_big_int_to_llvm(lbModule *m, Type *original_type, BigInt const * a); GB_ASSERT(err == MP_OKAY); + i64 sz = type_size_of(original_type); + if (is_type_different_to_arch_endianness(original_type)) { + GB_ASSERT(sz == cast(i64)written); + for (i64 i = 0; i < sz/2; i++) { + u8 tmp = rop[i]; + rop[i] = rop[sz-1-i]; + rop[sz-1-i] = tmp; + } + } + + + LLVMValueRef value = LLVMConstIntOfArbitraryPrecision(lb_type(m, original_type), cast(unsigned)((written+7)/8), cast(u64 *)rop); if (big_int_is_neg(a)) { value = LLVMConstNeg(value); |