From 9b17c0ff7fa7a3981697f4239afb5c66c609cd42 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 11 Dec 2016 16:30:01 -0500 Subject: IR: implement intType builtin and int type field access and fix compile time bool not --- src/codegen.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index 0642fbd7ec..06f9b295b9 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -1230,11 +1230,6 @@ static LLVMValueRef ir_render_un_op(CodeGen *g, IrExecutable *executable, IrInst zig_unreachable(); } } - case IrUnOpBoolNot: - { - LLVMValueRef zero = LLVMConstNull(LLVMTypeOf(expr)); - return LLVMBuildICmp(g->builder, LLVMIntEQ, expr, zero, ""); - } case IrUnOpBinNot: return LLVMBuildNot(g->builder, expr, ""); case IrUnOpAddressOf: @@ -1339,6 +1334,12 @@ static LLVMValueRef ir_render_un_op(CodeGen *g, IrExecutable *executable, IrInst zig_unreachable(); } +static LLVMValueRef ir_render_bool_not(CodeGen *g, IrExecutable *executable, IrInstructionBoolNot *instruction) { + LLVMValueRef value = ir_llvm_value(g, instruction->value); + LLVMValueRef zero = LLVMConstNull(LLVMTypeOf(value)); + return LLVMBuildICmp(g->builder, LLVMIntEQ, value, zero, ""); +} + static LLVMValueRef ir_render_decl_var(CodeGen *g, IrExecutable *executable, IrInstructionDeclVar *decl_var_instruction) { @@ -1927,6 +1928,7 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable, case IrInstructionIdCDefine: case IrInstructionIdCUndef: case IrInstructionIdEmbedFile: + case IrInstructionIdIntType: zig_unreachable(); case IrInstructionIdReturn: return ir_render_return(g, executable, (IrInstructionReturn *)instruction); @@ -1984,6 +1986,8 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable, return ir_render_div_exact(g, executable, (IrInstructionDivExact *)instruction); case IrInstructionIdTruncate: return ir_render_truncate(g, executable, (IrInstructionTruncate *)instruction); + case IrInstructionIdBoolNot: + return ir_render_bool_not(g, executable, (IrInstructionBoolNot *)instruction); case IrInstructionIdSwitchVar: case IrInstructionIdContainerInitList: case IrInstructionIdStructInit: -- cgit v1.2.3