Skip to content

Commit 6878528

Browse files
committed
WASM: Support shift operations
BitRShift is currently signed/arithmetic right shift. This is similar to LLVM Backend.
1 parent 0331203 commit 6878528

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/libasr/codegen/asr_to_wasm.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,14 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
890890
wasm::emit_i32_xor(m_code_section, m_al);
891891
break;
892892
};
893+
case ASR::binopType::BitLShift: {
894+
wasm::emit_i32_shl(m_code_section, m_al);
895+
break;
896+
};
897+
case ASR::binopType::BitRShift: {
898+
wasm::emit_i32_shr_s(m_code_section, m_al);
899+
break;
900+
};
893901
default: {
894902
throw CodeGenError(
895903
"ICE IntegerBinop kind 4: unknown operation");
@@ -947,6 +955,14 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
947955
wasm::emit_i64_xor(m_code_section, m_al);
948956
break;
949957
};
958+
case ASR::binopType::BitLShift: {
959+
wasm::emit_i64_shl(m_code_section, m_al);
960+
break;
961+
};
962+
case ASR::binopType::BitRShift: {
963+
wasm::emit_i64_shr_s(m_code_section, m_al);
964+
break;
965+
};
950966
default: {
951967
throw CodeGenError(
952968
"ICE IntegerBinop kind 8: unknown operation");

0 commit comments

Comments
 (0)