make specific twice_ptr_width helper

This commit is contained in:
Folkert 2022-03-12 19:57:26 +01:00
parent 9d9e7d10d4
commit 4e22ae57cd
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
2 changed files with 9 additions and 4 deletions

View file

@ -204,12 +204,17 @@ impl<'a, 'ctx, 'env> Env<'a, 'ctx, 'env> {
} }
} }
/// The integer type representing a RocList or RocStr when following the C ABI /// The integer type representing twice the width of a pointer
/// ///
/// on 64-bit systems, this is i128 /// on 64-bit systems, this is i128
/// on 32-bit systems, this is i64 /// on 32-bit systems, this is i64
pub fn str_list_c_abi(&self) -> IntType<'ctx> { pub fn twice_ptr_int(&self) -> IntType<'ctx> {
crate::llvm::convert::str_list_int(self.context, self.target_info) let ctx = self.context;
match self.target_info.ptr_width() {
roc_target::PtrWidth::Bytes4 => ctx.i64_type(),
roc_target::PtrWidth::Bytes8 => ctx.i128_type(),
}
} }
pub fn small_str_bytes(&self) -> u32 { pub fn small_str_bytes(&self) -> u32 {

View file

@ -359,7 +359,7 @@ pub fn str_from_utf8_range<'a, 'ctx, 'env>(
complex_bitcast( complex_bitcast(
env.builder, env.builder,
count_and_start.into(), count_and_start.into(),
env.str_list_c_abi().into(), env.twice_ptr_int().into(),
"to_i128", "to_i128",
), ),
result_ptr.into(), result_ptr.into(),