Commit 2c681d7ba1

Andrew Kelley <andrew@ziglang.org>
2019-09-21 20:22:23
add behavior test for float widening f16 to f128
it's disabled on aarch64, see #3282
1 parent f3a7c34
Changed files (4)
src/analyze.cpp
@@ -7633,7 +7633,7 @@ static void resolve_llvm_types_slice(CodeGen *g, ZigType *type, ResolveStatus wa
     type->data.structure.resolve_status = ResolveStatusLLVMFull;
 }
 
-static LLVMTypeRef get_llvm_array_type(unsigned byte_size) {
+static LLVMTypeRef get_llvm_type_of_n_bytes(unsigned byte_size) {
     return byte_size == 1 ?
         LLVMInt8Type() : LLVMArrayType(LLVMInt8Type(), byte_size);
 }
@@ -7735,7 +7735,7 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS
                 size_t full_abi_size = get_abi_size_bytes(full_bit_count, g->pointer_size_bytes);
                 if (full_abi_size * 8 == full_bit_count) {
                     // next field recovers ABI alignment
-                    element_types[gen_field_index] = get_llvm_array_type(full_abi_size);
+                    element_types[gen_field_index] = get_llvm_type_of_n_bytes(full_abi_size);
                     gen_field_index += 1;
                     first_packed_bits_offset_misalign = SIZE_MAX;
                 }
@@ -7808,7 +7808,7 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS
     if (first_packed_bits_offset_misalign != SIZE_MAX) {
         size_t full_bit_count = packed_bits_offset - first_packed_bits_offset_misalign;
         size_t full_abi_size = get_abi_size_bytes(full_bit_count, g->pointer_size_bytes);
-        element_types[gen_field_index] = get_llvm_array_type(full_abi_size);
+        element_types[gen_field_index] = get_llvm_type_of_n_bytes(full_abi_size);
         gen_field_index += 1;
     }
 
test/stage1/behavior/new_stack_call.zig
@@ -4,6 +4,9 @@ const expect = std.testing.expect;
 var new_stack_bytes: [1024]u8 align(16) = undefined;
 
 test "calling a function with a new stack" {
+    // TODO: https://github.com/ziglang/zig/issues/3268
+    if (@import("builtin").arch == .aarch64) return error.SkipZigTest;
+
     const arg = 1234;
 
     const a = @newStackCall(new_stack_bytes[0..512], targetFunction, arg);
test/stage1/behavior/widening.zig
@@ -27,3 +27,12 @@ test "float widening" {
     expect(b == c);
     expect(c == d);
 }
+
+test "float widening f16 to f128" {
+    // TODO https://github.com/ziglang/zig/issues/3282
+    if (@import("builtin").arch == .aarch64) return error.SkipZigTest;
+
+    var x: f16 = 12.34;
+    var y: f128 = x;
+    expect(x == y);
+}
test/stage1/behavior.zig
@@ -72,9 +72,7 @@ comptime {
     _ = @import("behavior/misc.zig");
     _ = @import("behavior/muladd.zig");
     _ = @import("behavior/namespace_depends_on_compile_var.zig");
-    // See #3268
-    if (@import("builtin").arch != .aarch64)
-        _ = @import("behavior/new_stack_call.zig");
+    _ = @import("behavior/new_stack_call.zig");
     _ = @import("behavior/null.zig");
     _ = @import("behavior/optional.zig");
     _ = @import("behavior/pointers.zig");