From c5efa615a2aecea53dd4440bd08733cc146ffcb8 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 30 Mar 2020 12:34:38 +0800 Subject: [PATCH] implement division --- src/main.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.rs b/src/main.rs index 55f2d33a2..f29922884 100644 --- a/src/main.rs +++ b/src/main.rs @@ -222,6 +222,11 @@ impl<'ctx> CodeGen<'ctx> { => Ok(self.builder.build_float_sub(a, b, "tmpsub").into()), (Mult, values::BasicValueEnum::FloatValue(a), values::BasicValueEnum::FloatValue(b)) => Ok(self.builder.build_float_mul(a, b, "tmpmul").into()), + + (Div, values::BasicValueEnum::FloatValue(a), values::BasicValueEnum::FloatValue(b)) + => Ok(self.builder.build_float_div(a, b, "tmpdiv").into()), + (FloorDiv, values::BasicValueEnum::IntValue(a), values::BasicValueEnum::IntValue(b)) + => Ok(self.builder.build_int_signed_div(a, b, "tmpdiv").into()), _ => return Err(self.compile_error(CompileErrorKind::Unsupported("unimplemented operation"))), } },