add behavior test for float widening f16 to f128

it's disabled on aarch64, see #3282
This commit is contained in:
Andrew Kelley 2019-09-21 14:22:23 -04:00
parent f3a7c346dd
commit 2c681d7ba1
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
4 changed files with 16 additions and 6 deletions

View File

@ -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;
}

View File

@ -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");

View File

@ -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);

View File

@ -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);
}