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...@@ -7633,7 +7633,7 @@ static void resolve_llvm_types_slice(CodeGen *g, ZigType *type, ResolveStatus wa
7633 type->data.structure.resolve_status = ResolveStatusLLVMFull;7633 type->data.structure.resolve_status = ResolveStatusLLVMFull;
7634}7634}
76357635
7636static LLVMTypeRef get_llvm_array_type(unsigned byte_size) {7636static LLVMTypeRef get_llvm_type_of_n_bytes(unsigned byte_size) {
7637 return byte_size == 1 ?7637 return byte_size == 1 ?
7638 LLVMInt8Type() : LLVMArrayType(LLVMInt8Type(), byte_size);7638 LLVMInt8Type() : LLVMArrayType(LLVMInt8Type(), byte_size);
7639}7639}
...@@ -7735,7 +7735,7 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS...@@ -7735,7 +7735,7 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS
7735 size_t full_abi_size = get_abi_size_bytes(full_bit_count, g->pointer_size_bytes);7735 size_t full_abi_size = get_abi_size_bytes(full_bit_count, g->pointer_size_bytes);
7736 if (full_abi_size * 8 == full_bit_count) {7736 if (full_abi_size * 8 == full_bit_count) {
7737 // next field recovers ABI alignment7737 // 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);
7739 gen_field_index += 1;7739 gen_field_index += 1;
7740 first_packed_bits_offset_misalign = SIZE_MAX;7740 first_packed_bits_offset_misalign = SIZE_MAX;
7741 }7741 }
...@@ -7808,7 +7808,7 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS...@@ -7808,7 +7808,7 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS
7808 if (first_packed_bits_offset_misalign != SIZE_MAX) {7808 if (first_packed_bits_offset_misalign != SIZE_MAX) {
7809 size_t full_bit_count = packed_bits_offset - first_packed_bits_offset_misalign;7809 size_t full_bit_count = packed_bits_offset - first_packed_bits_offset_misalign;
7810 size_t full_abi_size = get_abi_size_bytes(full_bit_count, g->pointer_size_bytes);7810 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);
7812 gen_field_index += 1;7812 gen_field_index += 1;
7813 }7813 }
78147814
test/stage1/behavior.zig+1-3
...@@ -72,9 +72,7 @@ comptime {...@@ -72,9 +72,7 @@ comptime {
72 _ = @import("behavior/misc.zig");72 _ = @import("behavior/misc.zig");
73 _ = @import("behavior/muladd.zig");73 _ = @import("behavior/muladd.zig");
74 _ = @import("behavior/namespace_depends_on_compile_var.zig");74 _ = @import("behavior/namespace_depends_on_compile_var.zig");
75 // See #326875 _ = @import("behavior/new_stack_call.zig");
76 if (@import("builtin").arch != .aarch64)
77 _ = @import("behavior/new_stack_call.zig");
78 _ = @import("behavior/null.zig");76 _ = @import("behavior/null.zig");
79 _ = @import("behavior/optional.zig");77 _ = @import("behavior/optional.zig");
80 _ = @import("behavior/pointers.zig");78 _ = @import("behavior/pointers.zig");
test/stage1/behavior/new_stack_call.zig+3
...@@ -4,6 +4,9 @@ const expect = std.testing.expect;...@@ -4,6 +4,9 @@ const expect = std.testing.expect;
4var new_stack_bytes: [1024]u8 align(16) = undefined;4var new_stack_bytes: [1024]u8 align(16) = undefined;
55
6test "calling a function with a new stack" {6test "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
7 const arg = 1234;10 const arg = 1234;
811
9 const a = @newStackCall(new_stack_bytes[0..512], targetFunction, arg);12 const a = @newStackCall(new_stack_bytes[0..512], targetFunction, arg);
test/stage1/behavior/widening.zig+9
...@@ -27,3 +27,12 @@ test "float widening" {...@@ -27,3 +27,12 @@ test "float widening" {
27 expect(b == c);27 expect(b == c);
28 expect(c == d);28 expect(c == d);
29}29}
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}