Skip to content

Commit

Permalink
WASM_X64: Support add, sub, mul and div operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaikh-Ubaid committed Dec 13, 2022
1 parent dc527a9 commit 409a773
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/libasr/codegen/wasm_to_x64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,31 @@ class X64Visitor : public WASMDecoder<X64Visitor>,
m_a.asm_push_r64(X64Reg::rax);
}

void visit_I32Add() {
m_a.asm_pop_r64(X64Reg::rbx);
m_a.asm_pop_r64(X64Reg::rax);
m_a.asm_add_r64_r64(X64Reg::rax, X64Reg::rbx);
m_a.asm_push_r64(X64Reg::rax);
}
void visit_I32Sub() {
m_a.asm_pop_r64(X64Reg::rbx);
m_a.asm_pop_r64(X64Reg::rax);
m_a.asm_sub_r64_r64(X64Reg::rax, X64Reg::rbx);
m_a.asm_push_r64(X64Reg::rax);
}
void visit_I32Mul() {
m_a.asm_pop_r64(X64Reg::rbx);
m_a.asm_pop_r64(X64Reg::rax);
m_a.asm_mul_r64(X64Reg::rbx);
m_a.asm_push_r64(X64Reg::rax);
}
void visit_I32DivS() {
m_a.asm_pop_r64(X64Reg::rbx);
m_a.asm_pop_r64(X64Reg::rax);
m_a.asm_div_r64(X64Reg::rbx);
m_a.asm_push_r64(X64Reg::rax);
}

void gen_x64_bytes() {
{ // Initialize/Modify values of entities for code simplicity later

Expand Down

0 comments on commit 409a773

Please sign in to comment.