@@ -734,14 +734,6 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
734
734
}
735
735
emit_print_int ();
736
736
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 ();
745
737
746
738
{
747
739
// Pre-declare all functions first, then generate code
@@ -1649,24 +1641,42 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
1649
1641
switch (x.m_op ) {
1650
1642
case ASR::binopType::Add: {
1651
1643
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
+ }
1652
1647
wasm::emit_call (m_code_section, m_al, m_self_func_name_idx_map[" add_c32" ]);
1653
1648
} 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
+ }
1654
1652
wasm::emit_call (m_code_section, m_al, m_self_func_name_idx_map[" add_c64" ]);
1655
1653
}
1656
1654
break ;
1657
1655
};
1658
1656
case ASR::binopType::Sub: {
1659
1657
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
+ }
1660
1661
wasm::emit_call (m_code_section, m_al, m_self_func_name_idx_map[" sub_c32" ]);
1661
1662
} 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
+ }
1662
1666
wasm::emit_call (m_code_section, m_al, m_self_func_name_idx_map[" sub_c64" ]);
1663
1667
}
1664
1668
break ;
1665
1669
};
1666
1670
case ASR::binopType::Mul: {
1667
1671
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
+ }
1668
1675
wasm::emit_call (m_code_section, m_al, m_self_func_name_idx_map[" mul_c32" ]);
1669
1676
} 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
+ }
1670
1680
wasm::emit_call (m_code_section, m_al, m_self_func_name_idx_map[" mul_c64" ]);
1671
1681
}
1672
1682
break ;
@@ -2593,10 +2603,16 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
2593
2603
int arg_kind = -1 , dest_kind = -1 ;
2594
2604
extract_kinds (x, arg_kind, dest_kind);
2595
2605
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
+ }
2596
2609
wasm::emit_call (m_code_section, m_al, m_self_func_name_idx_map[" abs_c32" ]);
2597
2610
wasm::emit_f32_const (m_code_section, m_al, 0.0 );
2598
2611
wasm::emit_f32_gt (m_code_section, m_al);
2599
2612
} 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
+ }
2600
2616
wasm::emit_call (m_code_section, m_al, m_self_func_name_idx_map[" abs_c64" ]);
2601
2617
wasm::emit_f64_const (m_code_section, m_al, 0.0 );
2602
2618
wasm::emit_f64_gt (m_code_section, m_al);
0 commit comments