diff options
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 01f3fe60c9..24608bc553 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -478,6 +478,25 @@ static LLVMValueRef gen_cast_expr(CodeGen *g, AstNode *node) { return cast_expr->tmp_ptr; } + case CastOpIntToFloat: + assert(actual_type->id == TypeTableEntryIdInt); + if (actual_type->data.integral.is_signed) { + add_debug_source_node(g, node); + return LLVMBuildSIToFP(g->builder, expr_val, wanted_type->type_ref, ""); + } else { + add_debug_source_node(g, node); + return LLVMBuildUIToFP(g->builder, expr_val, wanted_type->type_ref, ""); + } + case CastOpFloatToInt: + assert(wanted_type->id == TypeTableEntryIdInt); + if (wanted_type->data.integral.is_signed) { + add_debug_source_node(g, node); + return LLVMBuildFPToSI(g->builder, expr_val, wanted_type->type_ref, ""); + } else { + add_debug_source_node(g, node); + return LLVMBuildFPToUI(g->builder, expr_val, wanted_type->type_ref, ""); + } + } zig_unreachable(); } |
