| author | |
| committer | |
| log | fb9ba5e4b315e76c3ff1d01ebd56c651e13c314d |
| tree | f4c76488973ac4b909764c89211808252496b347 |
| parent | 5cc281e7232b9f1bc5f4d732e4a37fb5df02f780 |
| parent | df3aba6cc08622b908c47b6ae3aab2c1795e652e |
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/32028
Reviewed-by: Andrew Kelley <andrew@ziglang.org>7 files changed, 107 insertions(+), 111 deletions(-)
build.zig+10-10| ... | @@ -416,7 +416,7 @@ pub fn build(b: *std.Build) !void { | ... | @@ -416,7 +416,7 @@ pub fn build(b: *std.Build) !void { |
| 416 | chosen_opt_modes_buf[chosen_mode_index] = builtin.OptimizeMode.ReleaseSmall; | 416 | chosen_opt_modes_buf[chosen_mode_index] = builtin.OptimizeMode.ReleaseSmall; |
| 417 | chosen_mode_index += 1; | 417 | chosen_mode_index += 1; |
| 418 | } | 418 | } |
| 419 | const optimization_modes = chosen_opt_modes_buf[0..chosen_mode_index]; | 419 | const optimize_modes = chosen_opt_modes_buf[0..chosen_mode_index]; |
| 420 | 420 | ||
| 421 | const test_only: ?tests.ModuleTestOptions.TestOnly = if (no_matrix) | 421 | const test_only: ?tests.ModuleTestOptions.TestOnly = if (no_matrix) |
| 422 | .default | 422 | .default |
| ... | @@ -476,7 +476,7 @@ pub fn build(b: *std.Build) !void { | ... | @@ -476,7 +476,7 @@ pub fn build(b: *std.Build) !void { |
| 476 | .root_src = "test/behavior.zig", | 476 | .root_src = "test/behavior.zig", |
| 477 | .name = "behavior", | 477 | .name = "behavior", |
| 478 | .desc = "Run the behavior tests", | 478 | .desc = "Run the behavior tests", |
| 479 | .optimize_modes = optimization_modes, | 479 | .optimize_modes = optimize_modes, |
| 480 | .include_paths = &.{}, | 480 | .include_paths = &.{}, |
| 481 | .sanitize_thread = sanitize_thread, | 481 | .sanitize_thread = sanitize_thread, |
| 482 | .skip_single_threaded = skip_single_threaded, | 482 | .skip_single_threaded = skip_single_threaded, |
| ... | @@ -502,7 +502,7 @@ pub fn build(b: *std.Build) !void { | ... | @@ -502,7 +502,7 @@ pub fn build(b: *std.Build) !void { |
| 502 | .root_src = "lib/compiler_rt.zig", | 502 | .root_src = "lib/compiler_rt.zig", |
| 503 | .name = "compiler-rt", | 503 | .name = "compiler-rt", |
| 504 | .desc = "Run the compiler_rt tests", | 504 | .desc = "Run the compiler_rt tests", |
| 505 | .optimize_modes = optimization_modes, | 505 | .optimize_modes = optimize_modes, |
| 506 | .include_paths = &.{}, | 506 | .include_paths = &.{}, |
| 507 | .sanitize_thread = sanitize_thread, | 507 | .sanitize_thread = sanitize_thread, |
| 508 | .skip_single_threaded = true, | 508 | .skip_single_threaded = true, |
| ... | @@ -529,7 +529,7 @@ pub fn build(b: *std.Build) !void { | ... | @@ -529,7 +529,7 @@ pub fn build(b: *std.Build) !void { |
| 529 | .root_src = "lib/std/std.zig", | 529 | .root_src = "lib/std/std.zig", |
| 530 | .name = "std", | 530 | .name = "std", |
| 531 | .desc = "Run the standard library tests", | 531 | .desc = "Run the standard library tests", |
| 532 | .optimize_modes = optimization_modes, | 532 | .optimize_modes = optimize_modes, |
| 533 | .include_paths = &.{}, | 533 | .include_paths = &.{}, |
| 534 | .sanitize_thread = sanitize_thread, | 534 | .sanitize_thread = sanitize_thread, |
| 535 | .skip_single_threaded = skip_single_threaded, | 535 | .skip_single_threaded = skip_single_threaded, |
| ... | @@ -555,7 +555,7 @@ pub fn build(b: *std.Build) !void { | ... | @@ -555,7 +555,7 @@ pub fn build(b: *std.Build) !void { |
| 555 | .root_src = "test/c.zig", | 555 | .root_src = "test/c.zig", |
| 556 | .name = "libc", | 556 | .name = "libc", |
| 557 | .desc = "Run the libc API tests", | 557 | .desc = "Run the libc API tests", |
| 558 | .optimize_modes = optimization_modes, | 558 | .optimize_modes = optimize_modes, |
| 559 | .include_paths = &.{}, | 559 | .include_paths = &.{}, |
| 560 | .sanitize_thread = sanitize_thread, | 560 | .sanitize_thread = sanitize_thread, |
| 561 | .skip_single_threaded = true, | 561 | .skip_single_threaded = true, |
| ... | @@ -599,13 +599,14 @@ pub fn build(b: *std.Build) !void { | ... | @@ -599,13 +599,14 @@ pub fn build(b: *std.Build) !void { |
| 599 | 599 | ||
| 600 | test_step.dependOn(tests.addStandaloneTests( | 600 | test_step.dependOn(tests.addStandaloneTests( |
| 601 | b, | 601 | b, |
| 602 | optimization_modes, | 602 | optimize_modes, |
| 603 | enable_macos_sdk, | 603 | enable_macos_sdk, |
| 604 | enable_ios_sdk, | 604 | enable_ios_sdk, |
| 605 | enable_symlinks_windows, | 605 | enable_symlinks_windows, |
| 606 | )); | 606 | )); |
| 607 | test_step.dependOn(tests.addCAbiTests(b, .{ | 607 | test_step.dependOn(tests.addCAbiTests(b, .{ |
| 608 | .test_target_filters = test_target_filters, | 608 | .test_target_filters = test_target_filters, |
| 609 | .optimize_modes = optimize_modes, | ||
| 609 | .skip_non_native = skip_non_native, | 610 | .skip_non_native = skip_non_native, |
| 610 | .skip_wasm = skip_wasm, | 611 | .skip_wasm = skip_wasm, |
| 611 | .skip_freebsd = skip_freebsd, | 612 | .skip_freebsd = skip_freebsd, |
| ... | @@ -615,19 +616,18 @@ pub fn build(b: *std.Build) !void { | ... | @@ -615,19 +616,18 @@ pub fn build(b: *std.Build) !void { |
| 615 | .skip_darwin = skip_darwin, | 616 | .skip_darwin = skip_darwin, |
| 616 | .skip_linux = skip_linux, | 617 | .skip_linux = skip_linux, |
| 617 | .skip_llvm = skip_llvm, | 618 | .skip_llvm = skip_llvm, |
| 618 | .skip_release = skip_release, | ||
| 619 | .max_rss = 3_300_000_000, | 619 | .max_rss = 3_300_000_000, |
| 620 | })); | 620 | })); |
| 621 | test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, enable_ios_sdk, enable_symlinks_windows)); | 621 | test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, enable_ios_sdk, enable_symlinks_windows)); |
| 622 | test_step.dependOn(tests.addStackTraceTests(b, test_filters, skip_non_native)); | 622 | test_step.dependOn(tests.addStackTraceTests(b, test_filters, skip_non_native)); |
| 623 | test_step.dependOn(tests.addErrorTraceTests(b, test_filters, optimization_modes, skip_non_native)); | 623 | test_step.dependOn(tests.addErrorTraceTests(b, test_filters, optimize_modes, skip_non_native)); |
| 624 | test_step.dependOn(tests.addCliTests(b)); | 624 | test_step.dependOn(tests.addCliTests(b)); |
| 625 | if (tests.addDebuggerTests(b, .{ | 625 | if (tests.addDebuggerTests(b, .{ |
| 626 | .test_filters = test_filters, | 626 | .test_filters = test_filters, |
| 627 | .test_target_filters = test_target_filters, | 627 | .test_target_filters = test_target_filters, |
| 628 | .gdb = b.option([]const u8, "gdb", "path to gdb binary"), | 628 | .gdb = b.option([]const u8, "gdb", "path to gdb binary"), |
| 629 | .lldb = b.option([]const u8, "lldb", "path to lldb binary"), | 629 | .lldb = b.option([]const u8, "lldb", "path to lldb binary"), |
| 630 | .optimize_modes = optimization_modes, | 630 | .optimize_modes = optimize_modes, |
| 631 | .skip_single_threaded = skip_single_threaded, | 631 | .skip_single_threaded = skip_single_threaded, |
| 632 | .skip_libc = skip_libc, | 632 | .skip_libc = skip_libc, |
| 633 | })) |test_debugger_step| test_step.dependOn(test_debugger_step); | 633 | })) |test_debugger_step| test_step.dependOn(test_debugger_step); |
| ... | @@ -663,7 +663,7 @@ pub fn build(b: *std.Build) !void { | ... | @@ -663,7 +663,7 @@ pub fn build(b: *std.Build) !void { |
| 663 | if (!skip_test_incremental) test_step.dependOn(test_incremental_step); | 663 | if (!skip_test_incremental) test_step.dependOn(test_incremental_step); |
| 664 | 664 | ||
| 665 | if (tests.addLibcTestNszTests(b, .{ | 665 | if (tests.addLibcTestNszTests(b, .{ |
| 666 | .optimize_modes = optimization_modes, | 666 | .optimize_modes = optimize_modes, |
| 667 | .test_filters = test_filters, | 667 | .test_filters = test_filters, |
| 668 | .test_target_filters = test_target_filters, | 668 | .test_target_filters = test_target_filters, |
| 669 | .skip_wasm = skip_wasm, | 669 | .skip_wasm = skip_wasm, |
src/InternPool.zig+6| ... | @@ -5888,6 +5888,12 @@ pub const Alignment = enum(u6) { | ... | @@ -5888,6 +5888,12 @@ pub const Alignment = enum(u6) { |
| 5888 | return @enumFromInt(@min(@intFromEnum(lhs), @intFromEnum(rhs))); | 5888 | return @enumFromInt(@min(@intFromEnum(lhs), @intFromEnum(rhs))); |
| 5889 | } | 5889 | } |
| 5890 | 5890 | ||
| 5891 | /// Given a base address known to be aligned to `a`, | ||
| 5892 | /// computes the known alignment of base address plus `off`. | ||
| 5893 | pub fn offset(a: Alignment, off: u64) Alignment { | ||
| 5894 | return .fromLog2Units(@min(a.toLog2Units(), @ctz(off))); | ||
| 5895 | } | ||
| 5896 | |||
| 5891 | /// Align an address forwards to this alignment. | 5897 | /// Align an address forwards to this alignment. |
| 5892 | pub fn forward(a: Alignment, addr: u64) u64 { | 5898 | pub fn forward(a: Alignment, addr: u64) u64 { |
| 5893 | assert(a != .none); | 5899 | assert(a != .none); |
src/codegen/llvm.zig+15-10| ... | @@ -1358,24 +1358,22 @@ pub const Object = struct { | ... | @@ -1358,24 +1358,22 @@ pub const Object = struct { |
| 1358 | }, | 1358 | }, |
| 1359 | .multiple_llvm_types => { | 1359 | .multiple_llvm_types => { |
| 1360 | assert(!it.byval_attr); | 1360 | assert(!it.byval_attr); |
| 1361 | const field_types = it.types_buffer[0..it.types_len]; | ||
| 1362 | const param_ty: Type = .fromInterned(fn_info.param_types.get(ip)[it.zig_index - 1]); | 1361 | const param_ty: Type = .fromInterned(fn_info.param_types.get(ip)[it.zig_index - 1]); |
| 1363 | const param_llvm_ty = try o.lowerType(param_ty); | 1362 | const param_llvm_ty = try o.lowerType(param_ty); |
| 1364 | const param_alignment = param_ty.abiAlignment(zcu).toLlvm(); | 1363 | const param_alignment = param_ty.abiAlignment(zcu); |
| 1365 | const arg_ptr = try buildAllocaInner(&wip, param_llvm_ty, param_alignment, target); | 1364 | const llvm_ty = try o.builder.arrayType(it.offsets_buffer[it.types_len], .i8); |
| 1366 | const llvm_ty = try o.builder.structType(.normal, field_types); | 1365 | const arg_ptr = try buildAllocaInner(&wip, llvm_ty, param_alignment.toLlvm(), target); |
| 1367 | const llvm_args_start = it.llvm_index - field_types.len; | 1366 | const llvm_args_start = it.llvm_index - it.types_len; |
| 1368 | for (0..field_types.len, llvm_args_start..) |field_i, llvm_arg_index| { | 1367 | for (llvm_args_start.., it.offsets_buffer[0..it.types_len]) |llvm_arg_index, offset| { |
| 1369 | const param = wip.arg(@intCast(llvm_arg_index)); | 1368 | const param = wip.arg(@intCast(llvm_arg_index)); |
| 1370 | const field_ptr = try wip.gepStruct(llvm_ty, arg_ptr, field_i, ""); | 1369 | const part_ptr = try o.ptraddConst(&wip, arg_ptr, offset); |
| 1371 | const alignment = Type.ptrAbiAlignment(target).toLlvm(); | 1370 | _ = try wip.store(.normal, param, part_ptr, param_alignment.offset(offset).toLlvm()); |
| 1372 | _ = try wip.store(.normal, param, field_ptr, alignment); | ||
| 1373 | } | 1371 | } |
| 1374 | 1372 | ||
| 1375 | if (isByRef(param_ty, zcu)) { | 1373 | if (isByRef(param_ty, zcu)) { |
| 1376 | args.appendAssumeCapacity(arg_ptr); | 1374 | args.appendAssumeCapacity(arg_ptr); |
| 1377 | } else { | 1375 | } else { |
| 1378 | args.appendAssumeCapacity(try wip.load(.normal, param_llvm_ty, arg_ptr, param_alignment, "")); | 1376 | args.appendAssumeCapacity(try wip.load(.normal, param_llvm_ty, arg_ptr, param_alignment.toLlvm(), "")); |
| 1379 | } | 1377 | } |
| 1380 | }, | 1378 | }, |
| 1381 | .float_array => { | 1379 | .float_array => { |
| ... | @@ -4362,6 +4360,13 @@ pub const Object = struct { | ... | @@ -4362,6 +4360,13 @@ pub const Object = struct { |
| 4362 | toLlvmAddressSpace(.generic, o.zcu.getTarget()), | 4360 | toLlvmAddressSpace(.generic, o.zcu.getTarget()), |
| 4363 | ); | 4361 | ); |
| 4364 | } | 4362 | } |
| 4363 | |||
| 4364 | pub fn ptraddConst(o: *Object, wip: *Builder.WipFunction, ptr: Builder.Value, offset: u64) Allocator.Error!Builder.Value { | ||
| 4365 | if (offset == 0) return ptr; | ||
| 4366 | const llvm_usize_ty = try o.lowerType(.usize); | ||
| 4367 | const offset_val = try o.builder.intValue(llvm_usize_ty, offset); | ||
| 4368 | return wip.gep(.inbounds, .i8, ptr, &.{offset_val}, ""); | ||
| 4369 | } | ||
| 4365 | }; | 4370 | }; |
| 4366 | 4371 | ||
| 4367 | const CallingConventionInfo = struct { | 4372 | const CallingConventionInfo = struct { |
src/codegen/llvm/FuncGen.zig+52-49| ... | @@ -709,22 +709,25 @@ fn airCall(self: *FuncGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif | ... | @@ -709,22 +709,25 @@ fn airCall(self: *FuncGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif |
| 709 | .multiple_llvm_types => { | 709 | .multiple_llvm_types => { |
| 710 | const arg = args[it.zig_index - 1]; | 710 | const arg = args[it.zig_index - 1]; |
| 711 | const param_ty = self.typeOf(arg); | 711 | const param_ty = self.typeOf(arg); |
| 712 | const llvm_types = it.types_buffer[0..it.types_len]; | ||
| 713 | const llvm_arg = try self.resolveInst(arg); | 712 | const llvm_arg = try self.resolveInst(arg); |
| 714 | const is_by_ref = isByRef(param_ty, zcu); | 713 | const is_by_ref = isByRef(param_ty, zcu); |
| 715 | const arg_ptr = if (is_by_ref) llvm_arg else ptr: { | 714 | const param_alignment = param_ty.abiAlignment(zcu); |
| 716 | const alignment = param_ty.abiAlignment(zcu).toLlvm(); | 715 | const llvm_ty = try o.builder.arrayType(it.offsets_buffer[it.types_len], .i8); |
| 717 | const ptr = try self.buildAlloca(llvm_arg.typeOfWip(&self.wip), alignment); | 716 | const arg_ptr = try self.buildAlloca(llvm_ty, param_alignment.toLlvm()); |
| 718 | _ = try self.wip.store(.normal, llvm_arg, ptr, alignment); | 717 | if (is_by_ref) _ = try self.wip.callMemCpy( |
| 719 | break :ptr ptr; | 718 | arg_ptr, |
| 720 | }; | 719 | param_alignment.toLlvm(), |
| 720 | llvm_arg, | ||
| 721 | param_alignment.toLlvm(), | ||
| 722 | try o.builder.intValue(try o.lowerType(.usize), param_ty.abiSize(zcu)), | ||
| 723 | .normal, | ||
| 724 | self.disable_intrinsics, | ||
| 725 | ) else _ = try self.wip.store(.normal, llvm_arg, arg_ptr, param_alignment.toLlvm()); | ||
| 721 | 726 | ||
| 722 | const llvm_ty = try o.builder.structType(.normal, llvm_types); | ||
| 723 | try llvm_args.ensureUnusedCapacity(it.types_len); | 727 | try llvm_args.ensureUnusedCapacity(it.types_len); |
| 724 | for (llvm_types, 0..) |field_ty, i| { | 728 | for (it.types_buffer[0..it.types_len], it.offsets_buffer[0..it.types_len]) |field_ty, offset| { |
| 725 | const alignment: Builder.Alignment = .fromByteUnits(@divExact(target.ptrBitWidth(), 8)); | 729 | const field_ptr = try self.ptraddConst(arg_ptr, offset); |
| 726 | const field_ptr = try self.wip.gepStruct(llvm_ty, arg_ptr, i, ""); | 730 | const loaded = try self.wip.load(.normal, field_ty, field_ptr, param_alignment.offset(offset).toLlvm(), ""); |
| 727 | const loaded = try self.wip.load(.normal, field_ty, field_ptr, alignment, ""); | ||
| 728 | llvm_args.appendAssumeCapacity(loaded); | 731 | llvm_args.appendAssumeCapacity(loaded); |
| 729 | } | 732 | } |
| 730 | }, | 733 | }, |
| ... | @@ -2269,10 +2272,7 @@ fn airStructFieldVal(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Build | ... | @@ -2269,10 +2272,7 @@ fn airStructFieldVal(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Build |
| 2269 | 2272 | ||
| 2270 | const struct_ptr_align = struct_ty.abiAlignment(zcu); | 2273 | const struct_ptr_align = struct_ty.abiAlignment(zcu); |
| 2271 | const field_ptr = try self.ptraddConst(struct_llvm_val, offset); | 2274 | const field_ptr = try self.ptraddConst(struct_llvm_val, offset); |
| 2272 | const field_ptr_align: InternPool.Alignment = switch (offset) { | 2275 | const field_ptr_align = struct_ptr_align.offset(offset); |
| 2273 | 0 => struct_ptr_align, | ||
| 2274 | else => struct_ptr_align.minStrict(.fromLog2Units(@ctz(offset))), | ||
| 2275 | }; | ||
| 2276 | 2276 | ||
| 2277 | if (isByRef(field_ty, zcu)) { | 2277 | if (isByRef(field_ty, zcu)) { |
| 2278 | return self.loadByRef(field_ptr, field_ty, field_ptr_align.toLlvm(), .normal); | 2278 | return self.loadByRef(field_ptr, field_ty, field_ptr_align.toLlvm(), .normal); |
| ... | @@ -3120,11 +3120,7 @@ fn airSaveErrReturnTraceIndex(self: *FuncGen, inst: Air.Inst.Index) Allocator.Er | ... | @@ -3120,11 +3120,7 @@ fn airSaveErrReturnTraceIndex(self: *FuncGen, inst: Air.Inst.Index) Allocator.Er |
| 3120 | 3120 | ||
| 3121 | const field_ty = struct_ty.fieldType(field_index, zcu); | 3121 | const field_ty = struct_ty.fieldType(field_index, zcu); |
| 3122 | const field_offset = struct_ty.structFieldOffset(field_index, zcu); | 3122 | const field_offset = struct_ty.structFieldOffset(field_index, zcu); |
| 3123 | const field_align = switch (field_offset) { | 3123 | const field_align = struct_ty.abiAlignment(zcu).offset(field_offset); |
| 3124 | 0 => struct_ty.abiAlignment(zcu), | ||
| 3125 | else => struct_ty.abiAlignment(zcu).minStrict(.fromLog2Units(@ctz(field_offset))), | ||
| 3126 | }; | ||
| 3127 | |||
| 3128 | const field_ptr = try self.ptraddConst(self.err_ret_trace, field_offset); | 3124 | const field_ptr = try self.ptraddConst(self.err_ret_trace, field_offset); |
| 3129 | return self.load(field_ptr, field_ty, field_align.toLlvm(), .normal); | 3125 | return self.load(field_ptr, field_ty, field_align.toLlvm(), .normal); |
| 3130 | } | 3126 | } |
| ... | @@ -5279,10 +5275,7 @@ fn airSetUnionTag(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder. | ... | @@ -5279,10 +5275,7 @@ fn airSetUnionTag(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder. |
| 5279 | return .none; | 5275 | return .none; |
| 5280 | } | 5276 | } |
| 5281 | const tag_field_ptr = try self.ptraddConst(union_ptr, layout.tagOffset()); | 5277 | const tag_field_ptr = try self.ptraddConst(union_ptr, layout.tagOffset()); |
| 5282 | const tag_ptr_align: InternPool.Alignment = switch (layout.tagOffset()) { | 5278 | const tag_ptr_align = union_ptr_align.offset(layout.tagOffset()); |
| 5283 | 0 => union_ptr_align, | ||
| 5284 | else => |off| .minStrict(union_ptr_align, .fromLog2Units(@ctz(off))), | ||
| 5285 | }; | ||
| 5286 | _ = try self.wip.store(access_kind, new_tag, tag_field_ptr, tag_ptr_align.toLlvm()); | 5279 | _ = try self.wip.store(access_kind, new_tag, tag_field_ptr, tag_ptr_align.toLlvm()); |
| 5287 | return .none; | 5280 | return .none; |
| 5288 | } | 5281 | } |
| ... | @@ -5922,10 +5915,7 @@ fn airAggregateInit(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builde | ... | @@ -5922,10 +5915,7 @@ fn airAggregateInit(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builde |
| 5922 | if (!field_ty.hasRuntimeBits(zcu)) continue; | 5915 | if (!field_ty.hasRuntimeBits(zcu)) continue; |
| 5923 | const offset = result_ty.structFieldOffset(field_index, zcu); | 5916 | const offset = result_ty.structFieldOffset(field_index, zcu); |
| 5924 | const field_ptr = try self.ptraddConst(alloca_inst, offset); | 5917 | const field_ptr = try self.ptraddConst(alloca_inst, offset); |
| 5925 | const field_ptr_align: InternPool.Alignment = switch (offset) { | 5918 | const field_ptr_align = struct_align.offset(offset); |
| 5926 | 0 => struct_align, | ||
| 5927 | else => struct_align.minStrict(.fromLog2Units(@ctz(offset))), | ||
| 5928 | }; | ||
| 5929 | 5919 | ||
| 5930 | const llvm_field_val = try self.resolveInst(elem); | 5920 | const llvm_field_val = try self.resolveInst(elem); |
| 5931 | 5921 | ||
| ... | @@ -6581,6 +6571,7 @@ const ParamTypeIterator = struct { | ... | @@ -6581,6 +6571,7 @@ const ParamTypeIterator = struct { |
| 6581 | llvm_index: u32, | 6571 | llvm_index: u32, |
| 6582 | types_len: u32, | 6572 | types_len: u32, |
| 6583 | types_buffer: [8]Builder.Type, | 6573 | types_buffer: [8]Builder.Type, |
| 6574 | offsets_buffer: [9]u64, | ||
| 6584 | byval_attr: bool, | 6575 | byval_attr: bool, |
| 6585 | 6576 | ||
| 6586 | const Lowering = union(enum) { | 6577 | const Lowering = union(enum) { |
| ... | @@ -6672,7 +6663,12 @@ const ParamTypeIterator = struct { | ... | @@ -6672,7 +6663,12 @@ const ParamTypeIterator = struct { |
| 6672 | .memory => return .byref_mut, | 6663 | .memory => return .byref_mut, |
| 6673 | .float_array => |len| return Lowering{ .float_array = len }, | 6664 | .float_array => |len| return Lowering{ .float_array = len }, |
| 6674 | .byval => return .byval, | 6665 | .byval => return .byval, |
| 6675 | .integer => return .abi_sized_int, | 6666 | .integer => { |
| 6667 | it.types_len = 1; | ||
| 6668 | it.types_buffer[0..1].* = .{.i64}; | ||
| 6669 | it.offsets_buffer[0..2].* = .{ 0, 8 }; | ||
| 6670 | return .multiple_llvm_types; | ||
| 6671 | }, | ||
| 6676 | .double_integer => return Lowering{ .i64_array = 2 }, | 6672 | .double_integer => return Lowering{ .i64_array = 2 }, |
| 6677 | } | 6673 | } |
| 6678 | }, | 6674 | }, |
| ... | @@ -6711,12 +6707,17 @@ const ParamTypeIterator = struct { | ... | @@ -6711,12 +6707,17 @@ const ParamTypeIterator = struct { |
| 6711 | .double_integer => return Lowering{ .i64_array = 2 }, | 6707 | .double_integer => return Lowering{ .i64_array = 2 }, |
| 6712 | .fields => { | 6708 | .fields => { |
| 6713 | it.types_len = 0; | 6709 | it.types_len = 0; |
| 6710 | var offset: u64 = 0; | ||
| 6714 | for (0..ty.structFieldCount(zcu)) |field_index| { | 6711 | for (0..ty.structFieldCount(zcu)) |field_index| { |
| 6715 | const field_ty = ty.fieldType(field_index, zcu); | 6712 | const field_ty = ty.fieldType(field_index, zcu); |
| 6716 | if (!field_ty.hasRuntimeBits(zcu)) continue; | 6713 | if (!field_ty.hasRuntimeBits(zcu)) continue; |
| 6714 | offset = field_ty.abiAlignment(zcu).forward(offset); | ||
| 6717 | it.types_buffer[it.types_len] = try it.object.lowerType(field_ty); | 6715 | it.types_buffer[it.types_len] = try it.object.lowerType(field_ty); |
| 6716 | it.offsets_buffer[it.types_len] = offset; | ||
| 6718 | it.types_len += 1; | 6717 | it.types_len += 1; |
| 6718 | offset += field_ty.abiSize(zcu); | ||
| 6719 | } | 6719 | } |
| 6720 | it.offsets_buffer[it.types_len] = offset; | ||
| 6720 | it.llvm_index += it.types_len - 1; | 6721 | it.llvm_index += it.types_len - 1; |
| 6721 | return .multiple_llvm_types; | 6722 | return .multiple_llvm_types; |
| 6722 | }, | 6723 | }, |
| ... | @@ -6729,9 +6730,8 @@ const ParamTypeIterator = struct { | ... | @@ -6729,9 +6730,8 @@ const ParamTypeIterator = struct { |
| 6729 | it.llvm_index += 1; | 6730 | it.llvm_index += 1; |
| 6730 | return .byval; | 6731 | return .byval; |
| 6731 | } else { | 6732 | } else { |
| 6732 | var types_buffer: [8]Builder.Type = undefined; | 6733 | it.types_buffer[0..1].* = .{try it.object.lowerType(scalar_ty)}; |
| 6733 | types_buffer[0] = try it.object.lowerType(scalar_ty); | 6734 | it.offsets_buffer[0..2].* = .{ 0, scalar_ty.abiSize(zcu) }; |
| 6734 | it.types_buffer = types_buffer; | ||
| 6735 | it.types_len = 1; | 6735 | it.types_len = 1; |
| 6736 | it.llvm_index += 1; | 6736 | it.llvm_index += 1; |
| 6737 | it.zig_index += 1; | 6737 | it.zig_index += 1; |
| ... | @@ -6804,31 +6804,36 @@ const ParamTypeIterator = struct { | ... | @@ -6804,31 +6804,36 @@ const ParamTypeIterator = struct { |
| 6804 | return .byval; | 6804 | return .byval; |
| 6805 | } | 6805 | } |
| 6806 | var types_index: u32 = 0; | 6806 | var types_index: u32 = 0; |
| 6807 | var types_buffer: [8]Builder.Type = undefined; | 6807 | var offset: u64 = 0; |
| 6808 | for (classes) |class| { | 6808 | for (classes) |class| { |
| 6809 | switch (class) { | 6809 | switch (class) { |
| 6810 | .integer => { | 6810 | .integer => { |
| 6811 | types_buffer[types_index] = .i64; | 6811 | it.types_buffer[types_index] = .i64; |
| 6812 | it.offsets_buffer[types_index] = offset; | ||
| 6812 | types_index += 1; | 6813 | types_index += 1; |
| 6813 | }, | 6814 | }, |
| 6814 | .sse => { | 6815 | .sse => { |
| 6815 | types_buffer[types_index] = .double; | 6816 | it.types_buffer[types_index] = .double; |
| 6817 | it.offsets_buffer[types_index] = offset; | ||
| 6816 | types_index += 1; | 6818 | types_index += 1; |
| 6817 | }, | 6819 | }, |
| 6818 | .sseup => { | 6820 | .sseup => { |
| 6819 | if (types_buffer[types_index - 1] == .double) { | 6821 | if (it.types_buffer[types_index - 1] == .double) { |
| 6820 | types_buffer[types_index - 1] = .fp128; | 6822 | it.types_buffer[types_index - 1] = .fp128; |
| 6821 | } else { | 6823 | } else { |
| 6822 | types_buffer[types_index] = .double; | 6824 | it.types_buffer[types_index] = .double; |
| 6825 | it.offsets_buffer[types_index] = offset; | ||
| 6823 | types_index += 1; | 6826 | types_index += 1; |
| 6824 | } | 6827 | } |
| 6825 | }, | 6828 | }, |
| 6826 | .float => { | 6829 | .float => { |
| 6827 | types_buffer[types_index] = .float; | 6830 | it.types_buffer[types_index] = .float; |
| 6831 | it.offsets_buffer[types_index] = offset; | ||
| 6828 | types_index += 1; | 6832 | types_index += 1; |
| 6829 | }, | 6833 | }, |
| 6830 | .float_combine => { | 6834 | .float_combine => { |
| 6831 | types_buffer[types_index] = try it.object.builder.vectorType(.normal, 2, .float); | 6835 | it.types_buffer[types_index] = try it.object.builder.vectorType(.normal, 2, .float); |
| 6836 | it.offsets_buffer[types_index] = offset; | ||
| 6832 | types_index += 1; | 6837 | types_index += 1; |
| 6833 | }, | 6838 | }, |
| 6834 | .x87 => { | 6839 | .x87 => { |
| ... | @@ -6845,6 +6850,7 @@ const ParamTypeIterator = struct { | ... | @@ -6845,6 +6850,7 @@ const ParamTypeIterator = struct { |
| 6845 | @panic("TODO"); | 6850 | @panic("TODO"); |
| 6846 | }, | 6851 | }, |
| 6847 | } | 6852 | } |
| 6853 | offset += 8; | ||
| 6848 | } | 6854 | } |
| 6849 | const first_non_integer = std.mem.indexOfNone(x86_64_abi.Class, &classes, &.{.integer}); | 6855 | const first_non_integer = std.mem.indexOfNone(x86_64_abi.Class, &classes, &.{.integer}); |
| 6850 | if (first_non_integer == null or classes[first_non_integer.?] == .none) { | 6856 | if (first_non_integer == null or classes[first_non_integer.?] == .none) { |
| ... | @@ -6865,15 +6871,15 @@ const ParamTypeIterator = struct { | ... | @@ -6865,15 +6871,15 @@ const ParamTypeIterator = struct { |
| 6865 | const size = ty.abiSize(zcu); | 6871 | const size = ty.abiSize(zcu); |
| 6866 | assert((std.math.divCeil(u64, size, 8) catch unreachable) == types_index); | 6872 | assert((std.math.divCeil(u64, size, 8) catch unreachable) == types_index); |
| 6867 | if (size % 8 > 0) { | 6873 | if (size % 8 > 0) { |
| 6868 | types_buffer[types_index - 1] = | 6874 | it.types_buffer[types_index - 1] = |
| 6869 | try it.object.builder.intType(@intCast(size % 8 * 8)); | 6875 | try it.object.builder.intType(@intCast(size % 8 * 8)); |
| 6870 | } | 6876 | } |
| 6871 | }, | 6877 | }, |
| 6872 | else => {}, | 6878 | else => {}, |
| 6873 | } | 6879 | } |
| 6874 | } | 6880 | } |
| 6881 | it.offsets_buffer[types_index] = offset; | ||
| 6875 | it.types_len = types_index; | 6882 | it.types_len = types_index; |
| 6876 | it.types_buffer = types_buffer; | ||
| 6877 | it.llvm_index += types_index; | 6883 | it.llvm_index += types_index; |
| 6878 | it.zig_index += 1; | 6884 | it.zig_index += 1; |
| 6879 | return .multiple_llvm_types; | 6885 | return .multiple_llvm_types; |
| ... | @@ -6887,6 +6893,7 @@ pub fn iterateParamTypes(object: *Object, fn_info: InternPool.Key.FuncType) Para | ... | @@ -6887,6 +6893,7 @@ pub fn iterateParamTypes(object: *Object, fn_info: InternPool.Key.FuncType) Para |
| 6887 | .llvm_index = 0, | 6893 | .llvm_index = 0, |
| 6888 | .types_len = 0, | 6894 | .types_len = 0, |
| 6889 | .types_buffer = undefined, | 6895 | .types_buffer = undefined, |
| 6896 | .offsets_buffer = undefined, | ||
| 6890 | .byval_attr = false, | 6897 | .byval_attr = false, |
| 6891 | }; | 6898 | }; |
| 6892 | } | 6899 | } |
| ... | @@ -6965,7 +6972,7 @@ pub fn lowerFnRetTy(o: *Object, fn_info: InternPool.Key.FuncType) Allocator.Erro | ... | @@ -6965,7 +6972,7 @@ pub fn lowerFnRetTy(o: *Object, fn_info: InternPool.Key.FuncType) Allocator.Erro |
| 6965 | .memory => return .void, | 6972 | .memory => return .void, |
| 6966 | .float_array => return o.lowerType(return_type), | 6973 | .float_array => return o.lowerType(return_type), |
| 6967 | .byval => return o.lowerType(return_type), | 6974 | .byval => return o.lowerType(return_type), |
| 6968 | .integer => return o.builder.intType(@intCast(return_type.bitSize(zcu))), | 6975 | .integer => return .i64, |
| 6969 | .double_integer => return o.builder.arrayType(2, .i64), | 6976 | .double_integer => return o.builder.arrayType(2, .i64), |
| 6970 | }, | 6977 | }, |
| 6971 | .arm_aapcs, .arm_aapcs_vfp => switch (arm_c_abi.classifyType(return_type, zcu, .ret)) { | 6978 | .arm_aapcs, .arm_aapcs_vfp => switch (arm_c_abi.classifyType(return_type, zcu, .ret)) { |
| ... | @@ -7285,11 +7292,7 @@ fn getAtomicAbiType(fg: *const FuncGen, ty: Type, is_rmw_xchg: bool) Allocator.E | ... | @@ -7285,11 +7292,7 @@ fn getAtomicAbiType(fg: *const FuncGen, ty: Type, is_rmw_xchg: bool) Allocator.E |
| 7285 | } | 7292 | } |
| 7286 | 7293 | ||
| 7287 | fn ptraddConst(fg: *FuncGen, ptr: Builder.Value, offset: u64) Allocator.Error!Builder.Value { | 7294 | fn ptraddConst(fg: *FuncGen, ptr: Builder.Value, offset: u64) Allocator.Error!Builder.Value { |
| 7288 | if (offset == 0) return ptr; | 7295 | return fg.object.ptraddConst(&fg.wip, ptr, offset); |
| 7289 | const o = fg.object; | ||
| 7290 | const llvm_usize_ty = try o.lowerType(.usize); | ||
| 7291 | const offset_val = try o.builder.intValue(llvm_usize_ty, offset); | ||
| 7292 | return fg.wip.gep(.inbounds, .i8, ptr, &.{offset_val}, ""); | ||
| 7293 | } | 7296 | } |
| 7294 | fn ptraddScaled(fg: *FuncGen, ptr: Builder.Value, index: Builder.Value, scale: u64) Allocator.Error!Builder.Value { | 7297 | fn ptraddScaled(fg: *FuncGen, ptr: Builder.Value, index: Builder.Value, scale: u64) Allocator.Error!Builder.Value { |
| 7295 | if (scale == 0) return ptr; | 7298 | if (scale == 0) return ptr; |
test/c_abi/cfuncs.c+4-12| ... | @@ -2802,7 +2802,6 @@ void run_c_tests(void) { | ... | @@ -2802,7 +2802,6 @@ void run_c_tests(void) { |
| 2802 | } | 2802 | } |
| 2803 | #endif | 2803 | #endif |
| 2804 | 2804 | ||
| 2805 | #if !defined(__AARCH_BIG_ENDIAN) | ||
| 2806 | #if !defined(__mips64) | 2805 | #if !defined(__mips64) |
| 2807 | #if !defined(ZIG_PPC32) | 2806 | #if !defined(ZIG_PPC32) |
| 2808 | #if !defined(__s390x__) | 2807 | #if !defined(__s390x__) |
| ... | @@ -2814,9 +2813,7 @@ void run_c_tests(void) { | ... | @@ -2814,9 +2813,7 @@ void run_c_tests(void) { |
| 2814 | #endif | 2813 | #endif |
| 2815 | #endif | 2814 | #endif |
| 2816 | #endif | 2815 | #endif |
| 2817 | #endif | ||
| 2818 | 2816 | ||
| 2819 | #if !defined(__AARCH_BIG_ENDIAN) | ||
| 2820 | #if !defined(__mips64) | 2817 | #if !defined(__mips64) |
| 2821 | #if !defined(ZIG_PPC32) | 2818 | #if !defined(ZIG_PPC32) |
| 2822 | #if !defined(__s390x__) | 2819 | #if !defined(__s390x__) |
| ... | @@ -2828,9 +2825,7 @@ void run_c_tests(void) { | ... | @@ -2828,9 +2825,7 @@ void run_c_tests(void) { |
| 2828 | #endif | 2825 | #endif |
| 2829 | #endif | 2826 | #endif |
| 2830 | #endif | 2827 | #endif |
| 2831 | #endif | ||
| 2832 | 2828 | ||
| 2833 | #if !defined(__AARCH_BIG_ENDIAN) | ||
| 2834 | #if !defined(__mips64) | 2829 | #if !defined(__mips64) |
| 2835 | #if !defined(ZIG_PPC32) | 2830 | #if !defined(ZIG_PPC32) |
| 2836 | #if !defined(__s390x__) | 2831 | #if !defined(__s390x__) |
| ... | @@ -2842,7 +2837,6 @@ void run_c_tests(void) { | ... | @@ -2842,7 +2837,6 @@ void run_c_tests(void) { |
| 2842 | #endif | 2837 | #endif |
| 2843 | #endif | 2838 | #endif |
| 2844 | #endif | 2839 | #endif |
| 2845 | #endif | ||
| 2846 | 2840 | ||
| 2847 | #if !defined(ZIG_PPC32) | 2841 | #if !defined(ZIG_PPC32) |
| 2848 | #if !defined(ZIG_RISCV32) | 2842 | #if !defined(ZIG_RISCV32) |
| ... | @@ -2872,7 +2866,6 @@ void run_c_tests(void) { | ... | @@ -2872,7 +2866,6 @@ void run_c_tests(void) { |
| 2872 | zig_struct_u64_u64_8(0, 1, 2, 3, 4, 5, 6, 7, (struct Struct_u64_u64){ .a = 19, .b = 20 }, 9); | 2866 | zig_struct_u64_u64_8(0, 1, 2, 3, 4, 5, 6, 7, (struct Struct_u64_u64){ .a = 19, .b = 20 }, 9); |
| 2873 | } | 2867 | } |
| 2874 | 2868 | ||
| 2875 | #if !defined(ZIG_RISCV64) | ||
| 2876 | #if !defined(__mips64__) | 2869 | #if !defined(__mips64__) |
| 2877 | { | 2870 | { |
| 2878 | struct Struct_f32 s = zig_ret_struct_f32(); | 2871 | struct Struct_f32 s = zig_ret_struct_f32(); |
| ... | @@ -2908,7 +2901,6 @@ void run_c_tests(void) { | ... | @@ -2908,7 +2901,6 @@ void run_c_tests(void) { |
| 2908 | } | 2901 | } |
| 2909 | #endif | 2902 | #endif |
| 2910 | #endif | 2903 | #endif |
| 2911 | #endif | ||
| 2912 | 2904 | ||
| 2913 | #if !defined(__powerpc__) && !defined(__loongarch__) && !defined(__mips64__) | 2905 | #if !defined(__powerpc__) && !defined(__loongarch__) && !defined(__mips64__) |
| 2914 | { | 2906 | { |
| ... | @@ -2933,8 +2925,8 @@ void run_c_tests(void) { | ... | @@ -2933,8 +2925,8 @@ void run_c_tests(void) { |
| 2933 | #endif | 2925 | #endif |
| 2934 | #endif | 2926 | #endif |
| 2935 | 2927 | ||
| 2936 | #if !defined __i386__ && !defined __arm__ && !defined(__AARCH_BIG_ENDIAN) && \ | 2928 | #if !defined __i386__ && !defined __arm__ && \ |
| 2937 | !defined __powerpc__ && !defined ZIG_RISCV64 && !defined(__loongarch__) && \ | 2929 | !defined __powerpc__ && !defined(__loongarch__) && \ |
| 2938 | !defined(__mips64__) && !defined(__hexagon__) && !defined(__s390x__) | 2930 | !defined(__mips64__) && !defined(__hexagon__) && !defined(__s390x__) |
| 2939 | { | 2931 | { |
| 2940 | struct SmallStructInts s = {1, 2, 3, 4}; | 2932 | struct SmallStructInts s = {1, 2, 3, 4}; |
| ... | @@ -2942,8 +2934,8 @@ void run_c_tests(void) { | ... | @@ -2942,8 +2934,8 @@ void run_c_tests(void) { |
| 2942 | } | 2934 | } |
| 2943 | #endif | 2935 | #endif |
| 2944 | 2936 | ||
| 2945 | #if !defined __arm__ && !defined(__AARCH_BIG_ENDIAN) && \ | 2937 | #if !defined __arm__ && \ |
| 2946 | !defined __powerpc__ && !defined ZIG_RISCV64 && !defined(__loongarch__) && \ | 2938 | !defined __powerpc__ && !defined(__loongarch__) && \ |
| 2947 | !defined(__mips64__) && !defined(__hexagon__) && !defined(__s390x__) | 2939 | !defined(__mips64__) && !defined(__hexagon__) && !defined(__s390x__) |
| 2948 | { | 2940 | { |
| 2949 | struct MedStructInts s = {1, 2, 3}; | 2941 | struct MedStructInts s = {1, 2, 3}; |
test/c_abi/main.zig-6| ... | @@ -287,7 +287,6 @@ extern fn c_ret_struct_u8() Struct_u8; | ... | @@ -287,7 +287,6 @@ extern fn c_ret_struct_u8() Struct_u8; |
| 287 | extern fn c_struct_u8(Struct_u8, usize) void; | 287 | extern fn c_struct_u8(Struct_u8, usize) void; |
| 288 | 288 | ||
| 289 | test "C ABI struct u8" { | 289 | test "C ABI struct u8" { |
| 290 | if (builtin.cpu.arch == .aarch64_be) return error.SkipZigTest; | ||
| 291 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; | 290 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; |
| 292 | if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; | 291 | if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; |
| 293 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; | 292 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| ... | @@ -315,7 +314,6 @@ extern fn c_ret_struct_u16() Struct_u16; | ... | @@ -315,7 +314,6 @@ extern fn c_ret_struct_u16() Struct_u16; |
| 315 | extern fn c_struct_u16(Struct_u16, usize) void; | 314 | extern fn c_struct_u16(Struct_u16, usize) void; |
| 316 | 315 | ||
| 317 | test "C ABI struct u16" { | 316 | test "C ABI struct u16" { |
| 318 | if (builtin.cpu.arch == .aarch64_be) return error.SkipZigTest; | ||
| 319 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; | 317 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; |
| 320 | if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; | 318 | if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; |
| 321 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; | 319 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| ... | @@ -343,7 +341,6 @@ extern fn c_ret_struct_u32() Struct_u32; | ... | @@ -343,7 +341,6 @@ extern fn c_ret_struct_u32() Struct_u32; |
| 343 | extern fn c_struct_u32(Struct_u32, usize) void; | 341 | extern fn c_struct_u32(Struct_u32, usize) void; |
| 344 | 342 | ||
| 345 | test "C ABI struct u32" { | 343 | test "C ABI struct u32" { |
| 346 | if (builtin.cpu.arch == .aarch64_be) return error.SkipZigTest; | ||
| 347 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; | 344 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; |
| 348 | if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; | 345 | if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; |
| 349 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; | 346 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| ... | @@ -770,7 +767,6 @@ test "C ABI small struct of ints" { | ... | @@ -770,7 +767,6 @@ test "C ABI small struct of ints" { |
| 770 | if (builtin.cpu.arch == .x86) return error.SkipZigTest; | 767 | if (builtin.cpu.arch == .x86) return error.SkipZigTest; |
| 771 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; | 768 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; |
| 772 | if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest; | 769 | if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest; |
| 773 | if (builtin.cpu.arch == .aarch64_be) return error.SkipZigTest; | ||
| 774 | if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest; | 770 | if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest; |
| 775 | if (builtin.cpu.arch == .hexagon) return error.SkipZigTest; | 771 | if (builtin.cpu.arch == .hexagon) return error.SkipZigTest; |
| 776 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; | 772 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| ... | @@ -5613,7 +5609,6 @@ extern fn c_ret_ptr_size_float_struct() Vector2; | ... | @@ -5613,7 +5609,6 @@ extern fn c_ret_ptr_size_float_struct() Vector2; |
| 5613 | 5609 | ||
| 5614 | test "C ABI pointer sized float struct" { | 5610 | test "C ABI pointer sized float struct" { |
| 5615 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; | 5611 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; |
| 5616 | if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest; | ||
| 5617 | if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; | 5612 | if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; |
| 5618 | if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest; | 5613 | if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest; |
| 5619 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; | 5614 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| ... | @@ -5978,7 +5973,6 @@ extern fn stdcall_coord2(Coord2, Coord2, Coord2) callconv(stdcall_callconv) Coor | ... | @@ -5978,7 +5973,6 @@ extern fn stdcall_coord2(Coord2, Coord2, Coord2) callconv(stdcall_callconv) Coor |
| 5978 | test "Stdcall ABI structs" { | 5973 | test "Stdcall ABI structs" { |
| 5979 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; | 5974 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; |
| 5980 | if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest; | 5975 | if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest; |
| 5981 | if (builtin.cpu.arch == .aarch64_be) return error.SkipZigTest; | ||
| 5982 | if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest; | 5976 | if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest; |
| 5983 | if (builtin.cpu.arch == .hexagon) return error.SkipZigTest; | 5977 | if (builtin.cpu.arch == .hexagon) return error.SkipZigTest; |
| 5984 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; | 5978 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
test/tests.zig+20-24| ... | @@ -2749,6 +2749,7 @@ pub fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: Opt | ... | @@ -2749,6 +2749,7 @@ pub fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: Opt |
| 2749 | 2749 | ||
| 2750 | const CAbiTestOptions = struct { | 2750 | const CAbiTestOptions = struct { |
| 2751 | test_target_filters: []const []const u8, | 2751 | test_target_filters: []const []const u8, |
| 2752 | optimize_modes: []const OptimizeMode, | ||
| 2752 | skip_non_native: bool, | 2753 | skip_non_native: bool, |
| 2753 | skip_wasm: bool, | 2754 | skip_wasm: bool, |
| 2754 | skip_freebsd: bool, | 2755 | skip_freebsd: bool, |
| ... | @@ -2758,43 +2759,38 @@ const CAbiTestOptions = struct { | ... | @@ -2758,43 +2759,38 @@ const CAbiTestOptions = struct { |
| 2758 | skip_darwin: bool, | 2759 | skip_darwin: bool, |
| 2759 | skip_linux: bool, | 2760 | skip_linux: bool, |
| 2760 | skip_llvm: bool, | 2761 | skip_llvm: bool, |
| 2761 | skip_release: bool, | ||
| 2762 | max_rss: usize = 0, | 2762 | max_rss: usize = 0, |
| 2763 | }; | 2763 | }; |
| 2764 | 2764 | ||
| 2765 | pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step { | 2765 | pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step { |
| 2766 | const step = b.step("test-c-abi", "Run the C ABI tests"); | 2766 | const step = b.step("test-c-abi", "Run the C ABI tests"); |
| 2767 | 2767 | ||
| 2768 | const optimize_modes: [3]OptimizeMode = .{ .Debug, .ReleaseSafe, .ReleaseFast }; | 2768 | for (c_abi_targets) |c_abi_target| { |
| 2769 | if (options.skip_non_native and !c_abi_target.target.isNative()) continue; | ||
| 2769 | 2770 | ||
| 2770 | for (optimize_modes) |optimize_mode| { | 2771 | if (options.skip_wasm and c_abi_target.target.cpu_arch != null and c_abi_target.target.cpu_arch.?.isWasm()) continue; |
| 2771 | if (optimize_mode != .Debug and options.skip_release) continue; | ||
| 2772 | 2772 | ||
| 2773 | for (c_abi_targets) |c_abi_target| { | 2773 | if (options.skip_freebsd and c_abi_target.target.os_tag == .freebsd) continue; |
| 2774 | if (options.skip_non_native and !c_abi_target.target.isNative()) continue; | 2774 | if (options.skip_netbsd and c_abi_target.target.os_tag == .netbsd) continue; |
| 2775 | if (options.skip_openbsd and c_abi_target.target.os_tag == .openbsd) continue; | ||
| 2776 | if (options.skip_windows and c_abi_target.target.os_tag == .windows) continue; | ||
| 2777 | if (options.skip_darwin and c_abi_target.target.os_tag != null and c_abi_target.target.os_tag.?.isDarwin()) continue; | ||
| 2778 | if (options.skip_linux and c_abi_target.target.os_tag == .linux) continue; | ||
| 2775 | 2779 | ||
| 2776 | if (options.skip_wasm and c_abi_target.target.cpu_arch != null and c_abi_target.target.cpu_arch.?.isWasm()) continue; | 2780 | const resolved_target = b.resolveTargetQuery(c_abi_target.target); |
| 2781 | const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM"); | ||
| 2782 | const target = &resolved_target.result; | ||
| 2777 | 2783 | ||
| 2778 | if (options.skip_freebsd and c_abi_target.target.os_tag == .freebsd) continue; | 2784 | if (options.test_target_filters.len > 0) { |
| 2779 | if (options.skip_netbsd and c_abi_target.target.os_tag == .netbsd) continue; | 2785 | for (options.test_target_filters) |filter| { |
| 2780 | if (options.skip_openbsd and c_abi_target.target.os_tag == .openbsd) continue; | 2786 | if (std.mem.indexOf(u8, triple_txt, filter) != null) break; |
| 2781 | if (options.skip_windows and c_abi_target.target.os_tag == .windows) continue; | 2787 | } else continue; |
| 2782 | if (options.skip_darwin and c_abi_target.target.os_tag != null and c_abi_target.target.os_tag.?.isDarwin()) continue; | 2788 | } |
| 2783 | if (options.skip_linux and c_abi_target.target.os_tag == .linux) continue; | ||
| 2784 | 2789 | ||
| 2785 | const would_use_llvm = wouldUseLlvm(c_abi_target.use_llvm, c_abi_target.target, .Debug); | 2790 | for (options.optimize_modes) |optimize_mode| { |
| 2791 | const would_use_llvm = wouldUseLlvm(c_abi_target.use_llvm, c_abi_target.target, optimize_mode); | ||
| 2786 | if (options.skip_llvm and would_use_llvm) continue; | 2792 | if (options.skip_llvm and would_use_llvm) continue; |
| 2787 | 2793 | ||
| 2788 | const resolved_target = b.resolveTargetQuery(c_abi_target.target); | ||
| 2789 | const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM"); | ||
| 2790 | const target = &resolved_target.result; | ||
| 2791 | |||
| 2792 | if (options.test_target_filters.len > 0) { | ||
| 2793 | for (options.test_target_filters) |filter| { | ||
| 2794 | if (std.mem.indexOf(u8, triple_txt, filter) != null) break; | ||
| 2795 | } else continue; | ||
| 2796 | } | ||
| 2797 | |||
| 2798 | const test_mod = b.createModule(.{ | 2794 | const test_mod = b.createModule(.{ |
| 2799 | .root_source_file = b.path("test/c_abi/main.zig"), | 2795 | .root_source_file = b.path("test/c_abi/main.zig"), |
| 2800 | .target = resolved_target, | 2796 | .target = resolved_target, |