mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Merge remote-tracking branch 'origin/main' into remove-nat
This commit is contained in:
commit
aabd95404f
104 changed files with 1031 additions and 651 deletions
|
@ -1640,6 +1640,7 @@ impl<'a> LowLevelCall<'a> {
|
|||
match arg_type {
|
||||
F32 => self.load_args_and_call_zig(backend, &bitcode::NUM_ROUND_F32[width]),
|
||||
F64 => self.load_args_and_call_zig(backend, &bitcode::NUM_ROUND_F64[width]),
|
||||
Decimal => self.load_args_and_call_zig(backend, &bitcode::DEC_ROUND[width]),
|
||||
_ => internal_error!("Invalid argument type for round: {:?}", arg_type),
|
||||
}
|
||||
}
|
||||
|
@ -1647,6 +1648,14 @@ impl<'a> LowLevelCall<'a> {
|
|||
self.load_args(backend);
|
||||
let arg_type = CodeGenNumType::for_symbol(backend, self.arguments[0]);
|
||||
let ret_type = CodeGenNumType::from(self.ret_layout);
|
||||
|
||||
let width = match ret_type {
|
||||
CodeGenNumType::I32 => IntWidth::I32,
|
||||
CodeGenNumType::I64 => IntWidth::I64,
|
||||
CodeGenNumType::I128 => todo!("{:?} for I128", self.lowlevel),
|
||||
_ => internal_error!("Invalid return type for round: {:?}", ret_type),
|
||||
};
|
||||
|
||||
match (arg_type, self.lowlevel) {
|
||||
(F32, NumCeiling) => {
|
||||
backend.code_builder.f32_ceil();
|
||||
|
@ -1654,14 +1663,21 @@ impl<'a> LowLevelCall<'a> {
|
|||
(F64, NumCeiling) => {
|
||||
backend.code_builder.f64_ceil();
|
||||
}
|
||||
(Decimal, NumCeiling) => {
|
||||
return self.load_args_and_call_zig(backend, &bitcode::DEC_CEILING[width]);
|
||||
}
|
||||
(F32, NumFloor) => {
|
||||
backend.code_builder.f32_floor();
|
||||
}
|
||||
(F64, NumFloor) => {
|
||||
backend.code_builder.f64_floor();
|
||||
}
|
||||
(Decimal, NumFloor) => {
|
||||
return self.load_args_and_call_zig(backend, &bitcode::DEC_FLOOR[width]);
|
||||
}
|
||||
_ => internal_error!("Invalid argument type for ceiling: {:?}", arg_type),
|
||||
}
|
||||
|
||||
match (ret_type, arg_type) {
|
||||
// TODO: unsigned truncation
|
||||
(I32, F32) => backend.code_builder.i32_trunc_s_f32(),
|
||||
|
|
|
@ -75,19 +75,36 @@ impl Wasm32Sized for isize {
|
|||
const ALIGN_OF_WASM: usize = 4;
|
||||
}
|
||||
|
||||
const fn next_multiple_of(lhs: usize, rhs: usize) -> usize {
|
||||
if lhs == 0 {
|
||||
return lhs;
|
||||
}
|
||||
|
||||
match lhs % rhs {
|
||||
0 => lhs,
|
||||
r => lhs + (rhs - r),
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Wasm32Sized, U: Wasm32Sized> Wasm32Sized for (T, U) {
|
||||
const SIZE_OF_WASM: usize = T::SIZE_OF_WASM + U::SIZE_OF_WASM;
|
||||
const SIZE_OF_WASM: usize =
|
||||
next_multiple_of(T::SIZE_OF_WASM + U::SIZE_OF_WASM, Self::ALIGN_OF_WASM);
|
||||
const ALIGN_OF_WASM: usize = max(&[T::ALIGN_OF_WASM, U::ALIGN_OF_WASM]);
|
||||
}
|
||||
|
||||
impl<T: Wasm32Sized, U: Wasm32Sized, V: Wasm32Sized> Wasm32Sized for (T, U, V) {
|
||||
const SIZE_OF_WASM: usize = T::SIZE_OF_WASM + U::SIZE_OF_WASM + V::SIZE_OF_WASM;
|
||||
const SIZE_OF_WASM: usize = next_multiple_of(
|
||||
T::SIZE_OF_WASM + U::SIZE_OF_WASM + V::SIZE_OF_WASM,
|
||||
Self::ALIGN_OF_WASM,
|
||||
);
|
||||
const ALIGN_OF_WASM: usize = max(&[T::ALIGN_OF_WASM, U::ALIGN_OF_WASM, V::ALIGN_OF_WASM]);
|
||||
}
|
||||
|
||||
impl<T: Wasm32Sized, U: Wasm32Sized, V: Wasm32Sized, W: Wasm32Sized> Wasm32Sized for (T, U, V, W) {
|
||||
const SIZE_OF_WASM: usize =
|
||||
T::SIZE_OF_WASM + U::SIZE_OF_WASM + V::SIZE_OF_WASM + W::SIZE_OF_WASM;
|
||||
const SIZE_OF_WASM: usize = next_multiple_of(
|
||||
T::SIZE_OF_WASM + U::SIZE_OF_WASM + V::SIZE_OF_WASM + W::SIZE_OF_WASM,
|
||||
Self::ALIGN_OF_WASM,
|
||||
);
|
||||
const ALIGN_OF_WASM: usize = max(&[
|
||||
T::ALIGN_OF_WASM,
|
||||
U::ALIGN_OF_WASM,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue