From 660c45fe34fc0ec8ca5ce899feae368da773bff9 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 27 May 2020 20:34:52 -0700 Subject: [PATCH] [cranelift-interpreter] Add integer multiplication --- cranelift/interpreter/src/interpreter.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cranelift/interpreter/src/interpreter.rs b/cranelift/interpreter/src/interpreter.rs index e2a1d5a8d4..3b30c1b150 100644 --- a/cranelift/interpreter/src/interpreter.rs +++ b/cranelift/interpreter/src/interpreter.rs @@ -12,7 +12,7 @@ use cranelift_codegen::ir::{ }; use cranelift_reader::{DataValue, DataValueCastFailure}; use log::trace; -use std::ops::{Add, Sub}; +use std::ops::{Add, Mul, Sub}; use thiserror::Error; /// The valid control flow states. @@ -152,6 +152,7 @@ impl Interpreter { let result = match opcode { Iadd => binary_op!(Add::add[arg1, arg2]; [I8, I16, I32, I64]; inst), Isub => binary_op!(Sub::sub[arg1, arg2]; [I8, I16, I32, I64]; inst), + Imul => binary_op!(Mul::mul[arg1, arg2]; [I8, I16, I32, I64]; inst), _ => unimplemented!("interpreter does not support opcode yet: {}", opcode), }?; frame.set(first_result(frame.function, inst), result); @@ -164,6 +165,7 @@ impl Interpreter { let result = match opcode { IaddImm => binary_op!(Add::add[arg, imm]; [I8, I16, I32, I64]; inst), IrsubImm => binary_op!(Sub::sub[imm, arg]; [I8, I16, I32, I64]; inst), + ImulImm => binary_op!(Mul::mul[arg, imm]; [I8, I16, I32, I64]; inst), _ => unimplemented!("interpreter does not support opcode yet: {}", opcode), }?; frame.set(first_result(frame.function, inst), result);