From 433c17aeb192740053b1b9aea6220dca760303e2 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 11 Dec 2016 14:27:37 -0500 Subject: IR: implement divExact builtin --- src/codegen.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index dca316e84e..e4eb8dd323 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -1871,6 +1871,14 @@ static LLVMValueRef ir_render_fence(CodeGen *g, IrExecutable *executable, IrInst return nullptr; } +static LLVMValueRef ir_render_div_exact(CodeGen *g, IrExecutable *executable, IrInstructionDivExact *instruction) { + LLVMValueRef op1_val = ir_llvm_value(g, instruction->op1); + LLVMValueRef op2_val = ir_llvm_value(g, instruction->op2); + + bool want_debug_safety = ir_want_debug_safety(g, &instruction->base); + return gen_div(g, want_debug_safety, op1_val, op2_val, instruction->base.type_entry, true); +} + static void set_debug_location(CodeGen *g, IrInstruction *instruction) { AstNode *source_node = instruction->source_node; Scope *scope = instruction->scope; @@ -1964,6 +1972,8 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable, return ir_render_cmpxchg(g, executable, (IrInstructionCmpxchg *)instruction); case IrInstructionIdFence: return ir_render_fence(g, executable, (IrInstructionFence *)instruction); + case IrInstructionIdDivExact: + return ir_render_div_exact(g, executable, (IrInstructionDivExact *)instruction); case IrInstructionIdSwitchVar: case IrInstructionIdContainerInitList: case IrInstructionIdStructInit: -- cgit v1.2.3