authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-21 14:22:23-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-21 14:22:23-04:00
log2c681d7ba15e9eba2e94cb74e7e7d03c90c01863
tree11592db6952817d2ec000d721cbb93a379edf23d
parentf3a7c346ddfdac516cf82f5c0771fd07398a20ef
signaturelock-open Commit is signed but in an unrecognized format.

add behavior test for float widening f16 to f128

it's disabled on aarch64, see #3282

4 files changed, 16 insertions(+), 6 deletions(-)

src/analyze.cpp+3-3
......@@ -7633,7 +7633,7 @@ static void resolve_llvm_types_slice(CodeGen *g, ZigType *type, ResolveStatus wa
76337633 type->data.structure.resolve_status = ResolveStatusLLVMFull;
76347634}
76357635
7636static LLVMTypeRef get_llvm_array_type(unsigned byte_size) {
7636static LLVMTypeRef get_llvm_type_of_n_bytes(unsigned byte_size) {
76377637 return byte_size == 1 ?
76387638 LLVMInt8Type() : LLVMArrayType(LLVMInt8Type(), byte_size);
76397639}
......@@ -7735,7 +7735,7 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS
77357735 size_t full_abi_size = get_abi_size_bytes(full_bit_count, g->pointer_size_bytes);
77367736 if (full_abi_size * 8 == full_bit_count) {
77377737 // next field recovers ABI alignment
7738 element_types[gen_field_index] = get_llvm_array_type(full_abi_size);
7738 element_types[gen_field_index] = get_llvm_type_of_n_bytes(full_abi_size);
77397739 gen_field_index += 1;
77407740 first_packed_bits_offset_misalign = SIZE_MAX;
77417741 }
......@@ -7808,7 +7808,7 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS
78087808 if (first_packed_bits_offset_misalign != SIZE_MAX) {
78097809 size_t full_bit_count = packed_bits_offset - first_packed_bits_offset_misalign;
78107810 size_t full_abi_size = get_abi_size_bytes(full_bit_count, g->pointer_size_bytes);
7811 element_types[gen_field_index] = get_llvm_array_type(full_abi_size);
7811 element_types[gen_field_index] = get_llvm_type_of_n_bytes(full_abi_size);
78127812 gen_field_index += 1;
78137813 }
78147814
test/stage1/behavior.zig+1-3
......@@ -72,9 +72,7 @@ comptime {
7272 _ = @import("behavior/misc.zig");
7373 _ = @import("behavior/muladd.zig");
7474 _ = @import("behavior/namespace_depends_on_compile_var.zig");
75 // See #3268
76 if (@import("builtin").arch != .aarch64)
77 _ = @import("behavior/new_stack_call.zig");
75 _ = @import("behavior/new_stack_call.zig");
7876 _ = @import("behavior/null.zig");
7977 _ = @import("behavior/optional.zig");
8078 _ = @import("behavior/pointers.zig");
test/stage1/behavior/new_stack_call.zig+3
......@@ -4,6 +4,9 @@ const expect = std.testing.expect;
44var new_stack_bytes: [1024]u8 align(16) = undefined;
55
66test "calling a function with a new stack" {
7 // TODO: https://github.com/ziglang/zig/issues/3268
8 if (@import("builtin").arch == .aarch64) return error.SkipZigTest;
9
710 const arg = 1234;
811
912 const a = @newStackCall(new_stack_bytes[0..512], targetFunction, arg);
test/stage1/behavior/widening.zig+9
......@@ -27,3 +27,12 @@ test "float widening" {
2727 expect(b == c);
2828 expect(c == d);
2929}
30
31test "float widening f16 to f128" {
32 // TODO https://github.com/ziglang/zig/issues/3282
33 if (@import("builtin").arch == .aarch64) return error.SkipZigTest;
34
35 var x: f16 = 12.34;
36 var y: f128 = x;
37 expect(x == y);
38}