From 8fce8ddefc975a6cff2d6bdef57665582f620376 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 27 May 2020 20:41:22 -0700 Subject: [PATCH] [cranelift-interpreter] Add basic floating point arithmetic --- cranelift/interpreter/src/interpreter.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cranelift/interpreter/src/interpreter.rs b/cranelift/interpreter/src/interpreter.rs index 3b30c1b150..3d4988096e 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, Mul, Sub}; +use std::ops::{Add, Div, Mul, Sub}; use thiserror::Error; /// The valid control flow states. @@ -153,6 +153,10 @@ impl Interpreter { 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), + Fadd => binary_op!(Add::add[arg1, arg2]; [F32, F64]; inst), + Fsub => binary_op!(Sub::sub[arg1, arg2]; [F32, F64]; inst), + Fmul => binary_op!(Mul::mul[arg1, arg2]; [F32, F64]; inst), + Fdiv => binary_op!(Div::div[arg1, arg2]; [F32, F64]; inst), _ => unimplemented!("interpreter does not support opcode yet: {}", opcode), }?; frame.set(first_result(frame.function, inst), result);