Skip to content

Commit 226c278

Browse files
committed
tmp
1 parent 4dd3bff commit 226c278

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

src/libasr/codegen/asr_to_wasm.cpp

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -734,14 +734,6 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
734734
}
735735
emit_print_int();
736736
emit_print_float();
737-
emit_complex_add_32();
738-
emit_complex_add_64();
739-
emit_complex_sub_32();
740-
emit_complex_sub_64();
741-
emit_complex_mul_32();
742-
emit_complex_mul_64();
743-
emit_complex_abs_32();
744-
emit_complex_abs_64();
745737

746738
{
747739
// Pre-declare all functions first, then generate code
@@ -1649,24 +1641,42 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
16491641
switch (x.m_op) {
16501642
case ASR::binopType::Add: {
16511643
if (a_kind == 4) {
1644+
if (m_self_func_name_idx_map.find("add_c32") == m_self_func_name_idx_map.end()) {
1645+
emit_complex_add_32();
1646+
}
16521647
wasm::emit_call(m_code_section, m_al, m_self_func_name_idx_map["add_c32"]);
16531648
} else {
1649+
if (m_self_func_name_idx_map.find("add_c64") == m_self_func_name_idx_map.end()) {
1650+
emit_complex_add_64();
1651+
}
16541652
wasm::emit_call(m_code_section, m_al, m_self_func_name_idx_map["add_c64"]);
16551653
}
16561654
break;
16571655
};
16581656
case ASR::binopType::Sub: {
16591657
if (a_kind == 4) {
1658+
if (m_self_func_name_idx_map.find("sub_c32") == m_self_func_name_idx_map.end()) {
1659+
emit_complex_sub_32();
1660+
}
16601661
wasm::emit_call(m_code_section, m_al, m_self_func_name_idx_map["sub_c32"]);
16611662
} else {
1663+
if (m_self_func_name_idx_map.find("sub_c64") == m_self_func_name_idx_map.end()) {
1664+
emit_complex_sub_64();
1665+
}
16621666
wasm::emit_call(m_code_section, m_al, m_self_func_name_idx_map["sub_c64"]);
16631667
}
16641668
break;
16651669
};
16661670
case ASR::binopType::Mul: {
16671671
if (a_kind == 4) {
1672+
if (m_self_func_name_idx_map.find("mul_c32") == m_self_func_name_idx_map.end()) {
1673+
emit_complex_mul_32();
1674+
}
16681675
wasm::emit_call(m_code_section, m_al, m_self_func_name_idx_map["mul_c32"]);
16691676
} else {
1677+
if (m_self_func_name_idx_map.find("mul_c64") == m_self_func_name_idx_map.end()) {
1678+
emit_complex_mul_64();
1679+
}
16701680
wasm::emit_call(m_code_section, m_al, m_self_func_name_idx_map["mul_c64"]);
16711681
}
16721682
break;
@@ -2593,10 +2603,16 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
25932603
int arg_kind = -1, dest_kind = -1;
25942604
extract_kinds(x, arg_kind, dest_kind);
25952605
if (arg_kind == 4) {
2606+
if (m_self_func_name_idx_map.find("abs_c32") == m_self_func_name_idx_map.end()) {
2607+
emit_complex_abs_32();
2608+
}
25962609
wasm::emit_call(m_code_section, m_al, m_self_func_name_idx_map["abs_c32"]);
25972610
wasm::emit_f32_const(m_code_section, m_al, 0.0);
25982611
wasm::emit_f32_gt(m_code_section, m_al);
25992612
} else if (arg_kind == 8) {
2613+
if (m_self_func_name_idx_map.find("abs_c64") == m_self_func_name_idx_map.end()) {
2614+
emit_complex_abs_64();
2615+
}
26002616
wasm::emit_call(m_code_section, m_al, m_self_func_name_idx_map["abs_c64"]);
26012617
wasm::emit_f64_const(m_code_section, m_al, 0.0);
26022618
wasm::emit_f64_gt(m_code_section, m_al);

0 commit comments

Comments
 (0)