| author | |
| committer | |
| log | 8bf425957b253d0ab2e4902d57340b19b7436698 |
| tree | 3a62b6c16a64313195c5b01154bf8ee631aec97f |
| parent | e48157c3cb817ff1551f74fc1da9f420e38ccbd5 |
| signature | Commit is signed but in an unrecognized format. |
6 files changed, 55 insertions(+), 32 deletions(-)
src/analyze.cpp+28-3| ... | ... | @@ -9396,6 +9396,9 @@ static void dump_value_indent(ZigValue *val, int indent) { |
| 9396 | 9396 | case ZigTypeIdUnreachable: |
| 9397 | 9397 | fprintf(stderr, "<unreachable>\n"); |
| 9398 | 9398 | return; |
| 9399 | case ZigTypeIdUndefined: | |
| 9400 | fprintf(stderr, "<undefined>\n"); | |
| 9401 | return; | |
| 9399 | 9402 | case ZigTypeIdVoid: |
| 9400 | 9403 | fprintf(stderr, "<{}>\n"); |
| 9401 | 9404 | return; |
| ... | ... | @@ -9405,11 +9408,16 @@ static void dump_value_indent(ZigValue *val, int indent) { |
| 9405 | 9408 | case ZigTypeIdBool: |
| 9406 | 9409 | fprintf(stderr, "<%s>\n", val->data.x_bool ? "true" : "false"); |
| 9407 | 9410 | return; |
| 9408 | case ZigTypeIdComptimeFloat: | |
| 9409 | 9411 | case ZigTypeIdComptimeInt: |
| 9410 | case ZigTypeIdInt: | |
| 9412 | case ZigTypeIdInt: { | |
| 9413 | Buf *tmp_buf = buf_alloc(); | |
| 9414 | bigint_append_buf(tmp_buf, &val->data.x_bigint, 10); | |
| 9415 | fprintf(stderr, "<%s>\n", buf_ptr(tmp_buf)); | |
| 9416 | buf_destroy(tmp_buf); | |
| 9417 | return; | |
| 9418 | } | |
| 9419 | case ZigTypeIdComptimeFloat: | |
| 9411 | 9420 | case ZigTypeIdFloat: |
| 9412 | case ZigTypeIdUndefined: | |
| 9413 | 9421 | fprintf(stderr, "<TODO dump number>\n"); |
| 9414 | 9422 | return; |
| 9415 | 9423 | |
| ... | ... | @@ -9458,6 +9466,23 @@ static void dump_value_indent(ZigValue *val, int indent) { |
| 9458 | 9466 | fprintf(stderr, "<ref\n"); |
| 9459 | 9467 | dump_value_indent(val->data.x_ptr.data.ref.pointee, indent + 1); |
| 9460 | 9468 | break; |
| 9469 | case ConstPtrSpecialBaseStruct: { | |
| 9470 | ZigValue *struct_val = val->data.x_ptr.data.base_struct.struct_val; | |
| 9471 | size_t field_index = val->data.x_ptr.data.base_struct.field_index; | |
| 9472 | fprintf(stderr, "<struct %p field %zu\n", struct_val, field_index); | |
| 9473 | if (struct_val != nullptr) { | |
| 9474 | ZigValue *field_val = struct_val->data.x_struct.fields[field_index]; | |
| 9475 | if (field_val != nullptr) { | |
| 9476 | dump_value_indent(field_val, indent + 1); | |
| 9477 | } else { | |
| 9478 | for (int i = 0; i < indent; i += 1) { | |
| 9479 | fprintf(stderr, " "); | |
| 9480 | } | |
| 9481 | fprintf(stderr, "(invalid null field)\n"); | |
| 9482 | } | |
| 9483 | } | |
| 9484 | break; | |
| 9485 | } | |
| 9461 | 9486 | default: |
| 9462 | 9487 | fprintf(stderr, "TODO dump more pointer things\n"); |
| 9463 | 9488 | } |
src/codegen.cpp+1| ... | ... | @@ -20,6 +20,7 @@ |
| 20 | 20 | #include "zig_llvm.h" |
| 21 | 21 | #include "userland.h" |
| 22 | 22 | #include "dump_analysis.hpp" |
| 23 | #include "softfloat.hpp" | |
| 23 | 24 | |
| 24 | 25 | #include <stdio.h> |
| 25 | 26 | #include <errno.h> |
src/ir.cpp+6-9| ... | ... | @@ -12313,8 +12313,8 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction |
| 12313 | 12313 | if (type_is_invalid(casted_payload->value->type)) |
| 12314 | 12314 | return ira->codegen->invalid_instruction; |
| 12315 | 12315 | |
| 12316 | ZigValue *val = ir_resolve_const(ira, casted_payload, UndefBad); | |
| 12317 | if (!val) | |
| 12316 | ZigValue *val = ir_resolve_const(ira, casted_payload, UndefOk); | |
| 12317 | if (val == nullptr) | |
| 12318 | 12318 | return ira->codegen->invalid_instruction; |
| 12319 | 12319 | |
| 12320 | 12320 | ZigValue *err_set_val = create_const_vals(1); |
| ... | ... | @@ -17519,6 +17519,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 17519 | 17519 | { |
| 17520 | 17520 | result_loc_pass1 = no_result_loc(); |
| 17521 | 17521 | } |
| 17522 | bool was_written = result_loc_pass1->written; | |
| 17522 | 17523 | IrInstruction *result_loc = ir_resolve_result_raw(ira, suspend_source_instr, result_loc_pass1, value_type, |
| 17523 | 17524 | value, force_runtime, allow_discard); |
| 17524 | 17525 | if (result_loc == nullptr || (instr_is_unreachable(result_loc) || type_is_invalid(result_loc->value->type))) |
| ... | ... | @@ -17596,6 +17597,9 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 17596 | 17597 | result_loc_pass1->resolved_loc = result_loc; |
| 17597 | 17598 | } |
| 17598 | 17599 | |
| 17600 | if (was_written) { | |
| 17601 | return result_loc; | |
| 17602 | } | |
| 17599 | 17603 | |
| 17600 | 17604 | ir_assert(result_loc->value->type->id == ZigTypeIdPointer, suspend_source_instr); |
| 17601 | 17605 | ZigType *actual_elem_type = result_loc->value->type->data.pointer.child_type; |
| ... | ... | @@ -18242,13 +18246,6 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18242 | 18246 | return ira->codegen->invalid_instruction; |
| 18243 | 18247 | } |
| 18244 | 18248 | |
| 18245 | if (fn_proto_node->data.fn_proto.is_var_args) { | |
| 18246 | ir_add_error(ira, source_instr, | |
| 18247 | buf_sprintf("compiler bug: unable to call var args function at compile time. https://github.com/ziglang/zig/issues/313")); | |
| 18248 | return ira->codegen->invalid_instruction; | |
| 18249 | } | |
| 18250 | ||
| 18251 | ||
| 18252 | 18249 | for (size_t call_i = 0; call_i < args_len; call_i += 1) { |
| 18253 | 18250 | IrInstruction *old_arg = args_ptr[call_i]; |
| 18254 | 18251 |
src/softfloat.hpp+17| ... | ... | @@ -12,4 +12,21 @@ extern "C" { |
| 12 | 12 | #include "softfloat.h" |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | static inline float16_t zig_double_to_f16(double x) { | |
| 16 | float64_t y; | |
| 17 | static_assert(sizeof(x) == sizeof(y), ""); | |
| 18 | memcpy(&y, &x, sizeof(x)); | |
| 19 | return f64_to_f16(y); | |
| 20 | } | |
| 21 | ||
| 22 | ||
| 23 | // Return value is safe to coerce to float even when |x| is NaN or Infinity. | |
| 24 | static inline double zig_f16_to_double(float16_t x) { | |
| 25 | float64_t y = f16_to_f64(x); | |
| 26 | double z; | |
| 27 | static_assert(sizeof(y) == sizeof(z), ""); | |
| 28 | memcpy(&z, &y, sizeof(y)); | |
| 29 | return z; | |
| 30 | } | |
| 31 | ||
| 15 | 32 | #endif |
src/util.hpp+2-19| ... | ... | @@ -38,6 +38,8 @@ |
| 38 | 38 | |
| 39 | 39 | #if defined(__MINGW32__) || defined(__MINGW64__) |
| 40 | 40 | #define BREAKPOINT __debugbreak() |
| 41 | #elif defined(__i386__) || defined(__x86_64__) | |
| 42 | #define BREAKPOINT __asm__ volatile("int $0x03"); | |
| 41 | 43 | #elif defined(__clang__) |
| 42 | 44 | #define BREAKPOINT __builtin_debugtrap() |
| 43 | 45 | #elif defined(__GNUC__) |
| ... | ... | @@ -49,8 +51,6 @@ |
| 49 | 51 | |
| 50 | 52 | #endif |
| 51 | 53 | |
| 52 | #include "softfloat.hpp" | |
| 53 | ||
| 54 | 54 | ATTRIBUTE_COLD |
| 55 | 55 | ATTRIBUTE_NORETURN |
| 56 | 56 | ATTRIBUTE_PRINTF(1, 2) |
| ... | ... | @@ -244,23 +244,6 @@ static inline uint8_t log2_u64(uint64_t x) { |
| 244 | 244 | return (63 - clzll(x)); |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | static inline float16_t zig_double_to_f16(double x) { | |
| 248 | float64_t y; | |
| 249 | static_assert(sizeof(x) == sizeof(y), ""); | |
| 250 | memcpy(&y, &x, sizeof(x)); | |
| 251 | return f64_to_f16(y); | |
| 252 | } | |
| 253 | ||
| 254 | ||
| 255 | // Return value is safe to coerce to float even when |x| is NaN or Infinity. | |
| 256 | static inline double zig_f16_to_double(float16_t x) { | |
| 257 | float64_t y = f16_to_f64(x); | |
| 258 | double z; | |
| 259 | static_assert(sizeof(y) == sizeof(z), ""); | |
| 260 | memcpy(&z, &y, sizeof(y)); | |
| 261 | return z; | |
| 262 | } | |
| 263 | ||
| 264 | 247 | void zig_pretty_print_bytes(FILE *f, double n); |
| 265 | 248 | |
| 266 | 249 | template<typename T> |
test/stage1/behavior.zig+1-1| ... | ... | @@ -59,7 +59,7 @@ comptime { |
| 59 | 59 | _ = @import("behavior/defer.zig"); |
| 60 | 60 | _ = @import("behavior/enum.zig"); |
| 61 | 61 | _ = @import("behavior/enum_with_members.zig"); |
| 62 | //_ = @import("behavior/error.zig"); | |
| 62 | _ = @import("behavior/error.zig"); | |
| 63 | 63 | _ = @import("behavior/eval.zig"); |
| 64 | 64 | _ = @import("behavior/field_parent_ptr.zig"); |
| 65 | 65 | _ = @import("behavior/floatop.zig"); |