IR: implement divExact builtin

This commit is contained in:
Andrew Kelley
2016-12-11 14:27:37 -05:00
parent 8fcb1a141b
commit 433c17aeb1
5 changed files with 145 additions and 48 deletions

View File

@@ -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: