diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-06-07 22:56:57 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-06-14 00:24:25 -0400 |
| commit | 7f0620a20fc431717d017d0c19f1e1f29723d93f (patch) | |
| tree | c8121edd20aa67bf5a22be1f817f679dcfbbdb52 /src/codegen.cpp | |
| parent | 6a93dda3e1c0ff5f400da25a5d14c907fc9a6fdf (diff) | |
| download | zig-7f0620a20fc431717d017d0c19f1e1f29723d93f.tar.gz zig-7f0620a20fc431717d017d0c19f1e1f29723d93f.zip | |
partial implementation of printing floating point numbers with errol3
also add bitCast builtin function. closes #387
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 0e5b8a5ea1..3a1fad3958 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -1693,6 +1693,14 @@ static LLVMValueRef ir_render_ptr_cast(CodeGen *g, IrExecutable *executable, return LLVMBuildBitCast(g->builder, ptr, wanted_type->type_ref, ""); } +static LLVMValueRef ir_render_bit_cast(CodeGen *g, IrExecutable *executable, + IrInstructionBitCast *instruction) +{ + TypeTableEntry *wanted_type = instruction->base.value.type; + LLVMValueRef value = ir_llvm_value(g, instruction->value); + return LLVMBuildBitCast(g->builder, value, wanted_type->type_ref, ""); +} + static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, IrExecutable *executable, IrInstructionWidenOrShorten *instruction) { @@ -3180,6 +3188,8 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable, return ir_render_struct_init(g, executable, (IrInstructionStructInit *)instruction); case IrInstructionIdPtrCast: return ir_render_ptr_cast(g, executable, (IrInstructionPtrCast *)instruction); + case IrInstructionIdBitCast: + return ir_render_bit_cast(g, executable, (IrInstructionBitCast *)instruction); case IrInstructionIdWidenOrShorten: return ir_render_widen_or_shorten(g, executable, (IrInstructionWidenOrShorten *)instruction); case IrInstructionIdPtrToInt: @@ -4514,6 +4524,7 @@ static void define_builtin_fns(CodeGen *g) { create_builtin_fn(g, BuiltinFnIdSetGlobalLinkage, "setGlobalLinkage", 2); create_builtin_fn(g, BuiltinFnIdPanic, "panic", 1); create_builtin_fn(g, BuiltinFnIdPtrCast, "ptrCast", 2); + create_builtin_fn(g, BuiltinFnIdBitCast, "bitCast", 2); create_builtin_fn(g, BuiltinFnIdIntToPtr, "intToPtr", 2); create_builtin_fn(g, BuiltinFnIdEnumTagName, "enumTagName", 1); create_builtin_fn(g, BuiltinFnIdFieldParentPtr, "fieldParentPtr", 3); |
