Gen test for hash Dec

This commit is contained in:
Ayaz Hafiz 2023-05-26 11:38:19 -05:00
parent 3585d5bb5b
commit 5c43c0c91b
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 30 additions and 2 deletions

View file

@ -1189,8 +1189,7 @@ pub(crate) fn run_low_level<'a, 'ctx>(
}
I128OfDec => {
arguments!(dec);
call_bitcode_fn(env, &[dec], bitcode::DEC_TO_I128)
dec_to_i128(env, dec)
}
Eq => {
arguments_with_layouts!((lhs_arg, lhs_layout), (rhs_arg, rhs_layout));
@ -1812,6 +1811,25 @@ fn dec_to_str<'ctx>(env: &Env<'_, 'ctx, '_>, dec: BasicValueEnum<'ctx>) -> Basic
}
}
fn dec_to_i128<'ctx>(env: &Env<'_, 'ctx, '_>, dec: BasicValueEnum<'ctx>) -> BasicValueEnum<'ctx> {
use roc_target::OperatingSystem::*;
let dec = dec.into_int_value();
match env.target_info.operating_system {
Windows => {
//
call_bitcode_fn(env, &[dec_alloca(env, dec).into()], bitcode::DEC_TO_I128)
}
Unix => {
let (low, high) = dec_split_into_words(env, dec);
call_bitcode_fn(env, &[low.into(), high.into()], bitcode::DEC_TO_I128)
}
Wasi => unimplemented!(),
}
}
fn dec_binop_with_overflow<'ctx>(
env: &Env<'_, 'ctx, '_>,
fn_name: &str,