mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
parent
bfd5ca623c
commit
fc635abe0b
3 changed files with 11 additions and 22 deletions
|
@ -805,19 +805,12 @@ impl<'a> WasmBackend<'a> {
|
||||||
// Zig's "fast calling convention" packs structs into CPU registers (stack machine slots) if possible.
|
// Zig's "fast calling convention" packs structs into CPU registers (stack machine slots) if possible.
|
||||||
// If they're small enough they can go into an I32 or I64. If they're big, they're pointers (I32).
|
// If they're small enough they can go into an I32 or I64. If they're big, they're pointers (I32).
|
||||||
for arg in arguments {
|
for arg in arguments {
|
||||||
match self.storage.get(arg) {
|
param_types.push(match self.storage.get(arg) {
|
||||||
StoredValue::StackMemory { size, .. } if *size > 4 && *size <= 8 => {
|
StoredValue::StackMemory { size, .. } if *size > 4 && *size <= 8 => {
|
||||||
param_types.push(ValueType::I64);
|
ValueType::I64
|
||||||
}
|
}
|
||||||
StoredValue::StackMemory { size, .. } if *size == 16 => {
|
stored => stored.value_type(),
|
||||||
// the exception to the rule: A Decimal is passed as two i64s
|
});
|
||||||
param_types.push(ValueType::I64);
|
|
||||||
param_types.push(ValueType::I64);
|
|
||||||
}
|
|
||||||
stored => {
|
|
||||||
param_types.push(stored.value_type());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let signature_index = self.module.types.insert(Signature {
|
let signature_index = self.module.types.insert(Signature {
|
||||||
|
|
|
@ -63,16 +63,12 @@ pub fn decode_low_level<'a>(
|
||||||
return NotImplemented;
|
return NotImplemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
NumAdd => {
|
NumAdd => match ret_layout.value_type() {
|
||||||
return BuiltinCall(bitcode::DEC_ADD_WITH_OVERFLOW);
|
I32 => code_builder.i32_add(),
|
||||||
|
I64 => code_builder.i64_add(),
|
||||||
match ret_layout.value_type() {
|
F32 => code_builder.f32_add(),
|
||||||
I32 => code_builder.i32_add(),
|
F64 => code_builder.f64_add(),
|
||||||
I64 => code_builder.i64_add(),
|
},
|
||||||
F32 => code_builder.f32_add(),
|
|
||||||
F64 => code_builder.f64_add(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NumAddWrap => match ret_layout.value_type() {
|
NumAddWrap => match ret_layout.value_type() {
|
||||||
I32 => {
|
I32 => {
|
||||||
code_builder.i32_add();
|
code_builder.i32_add();
|
||||||
|
|
|
@ -609,7 +609,7 @@ fn gen_float_eq() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm"))]
|
||||||
fn gen_add_dec() {
|
fn gen_add_dec() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue