diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-10-20 13:29:58 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-10-20 20:11:12 +0300 |
| commit | 646d927c792dbdd6db4a5bbee3cf5847283fe861 (patch) | |
| tree | f285b620485ff0b8e01035ce08b42fd66551a41b /src/codegen/llvm.zig | |
| parent | 07b6173cb8877ce22fe6cb754cfc17367989b11e (diff) | |
| download | zig-646d927c792dbdd6db4a5bbee3cf5847283fe861.tar.gz zig-646d927c792dbdd6db4a5bbee3cf5847283fe861.zip | |
stage2: fix handling of aarch64 C ABI float array like structs
Closes #11702
Closes #13125
Diffstat (limited to 'src/codegen/llvm.zig')
| -rw-r--r-- | src/codegen/llvm.zig | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index b16fc76c01..9894f3efd6 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -3125,10 +3125,10 @@ pub const DeclGen = struct { .as_u16 => { try llvm_params.append(dg.context.intType(16)); }, - .float_array => { + .float_array => |count| { const param_ty = fn_info.param_types[it.zig_index - 1]; - const float_ty = try dg.lowerType(param_ty.structFieldType(0)); - const field_count = @intCast(c_uint, param_ty.structFieldCount()); + const float_ty = try dg.lowerType(aarch64_c_abi.getFloatArrayType(param_ty).?); + const field_count = @intCast(c_uint, count); const arr_ty = float_ty.arrayType(field_count); try llvm_params.append(arr_ty); }, @@ -4801,7 +4801,7 @@ pub const FuncGen = struct { const casted = self.builder.buildBitCast(llvm_arg, self.dg.context.intType(16), ""); try llvm_args.append(casted); }, - .float_array => { + .float_array => |count| { const arg = args[it.zig_index - 1]; const arg_ty = self.air.typeOf(arg); var llvm_arg = try self.resolveInst(arg); @@ -4812,9 +4812,8 @@ pub const FuncGen = struct { llvm_arg = store_inst; } - const float_ty = try self.dg.lowerType(arg_ty.structFieldType(0)); - const field_count = @intCast(u32, arg_ty.structFieldCount()); - const array_llvm_ty = float_ty.arrayType(field_count); + const float_ty = try self.dg.lowerType(aarch64_c_abi.getFloatArrayType(arg_ty).?); + const array_llvm_ty = float_ty.arrayType(count); const casted = self.builder.buildBitCast(llvm_arg, array_llvm_ty.pointerType(0), ""); const alignment = arg_ty.abiAlignment(target); @@ -10214,7 +10213,7 @@ const ParamTypeIterator = struct { llvm_types_buffer: [8]u16, byval_attr: bool, - const Lowering = enum { + const Lowering = union(enum) { no_bits, byval, byref, @@ -10223,7 +10222,7 @@ const ParamTypeIterator = struct { multiple_llvm_float, slice, as_u16, - float_array, + float_array: u8, }; pub fn next(it: *ParamTypeIterator) ?Lowering { @@ -10400,7 +10399,7 @@ const ParamTypeIterator = struct { return .byref; } if (classes[0] == .float_array) { - return .float_array; + return Lowering{ .float_array = @enumToInt(classes[1]) }; } if (classes[1] == .none) { it.llvm_types_len = 1; |
