| author | |
| committer | |
| log | cd5f69794d63ece18cd8f8aa0e2ce8bc16a31ab7 |
| tree | 8874dcf7f2ddade357cff053eaad230dcde834a5 |
| parent | 69a5f0d7973f2a3fefb69bc30c7dc1f0b430bba2 |
2 files changed, 16 insertions(+), 4 deletions(-)
src-self-hosted/test.zig+5-1| ... | ... | @@ -29,6 +29,7 @@ pub const TestContext = struct { |
| 29 | 29 | name: []const u8, |
| 30 | 30 | src: [:0]const u8, |
| 31 | 31 | expected_zir: []const u8, |
| 32 | cross_target: std.zig.CrossTarget, | |
| 32 | 33 | }; |
| 33 | 34 | |
| 34 | 35 | pub fn addZIRCompareOutput( |
| ... | ... | @@ -47,6 +48,7 @@ pub const TestContext = struct { |
| 47 | 48 | pub fn addZIRTransform( |
| 48 | 49 | ctx: *TestContext, |
| 49 | 50 | name: []const u8, |
| 51 | cross_target: std.zig.CrossTarget, | |
| 50 | 52 | src: [:0]const u8, |
| 51 | 53 | expected_zir: []const u8, |
| 52 | 54 | ) void { |
| ... | ... | @@ -54,6 +56,7 @@ pub const TestContext = struct { |
| 54 | 56 | .name = name, |
| 55 | 57 | .src = src, |
| 56 | 58 | .expected_zir = expected_zir, |
| 59 | .cross_target = cross_target, | |
| 57 | 60 | }) catch unreachable; |
| 58 | 61 | } |
| 59 | 62 | |
| ... | ... | @@ -85,7 +88,8 @@ pub const TestContext = struct { |
| 85 | 88 | } |
| 86 | 89 | for (self.zir_transform_cases.items) |case| { |
| 87 | 90 | std.testing.base_allocator_instance.reset(); |
| 88 | try self.runOneZIRTransformCase(std.testing.allocator, root_node, case, native_info.target); | |
| 91 | const info = try std.zig.system.NativeTargetInfo.detect(std.testing.allocator, case.cross_target); | |
| 92 | try self.runOneZIRTransformCase(std.testing.allocator, root_node, case, info.target); | |
| 89 | 93 | try std.testing.allocator_instance.validate(); |
| 90 | 94 | } |
| 91 | 95 | } |
test/stage2/zir.zig+11-3| ... | ... | @@ -1,7 +1,15 @@ |
| 1 | const std = @import("std"); | |
| 1 | 2 | const TestContext = @import("../../src-self-hosted/test.zig").TestContext; |
| 3 | // self-hosted does not yet support PE executable files / COFF object files | |
| 4 | // or mach-o files. So we do the ZIR transform test cases cross compiling for | |
| 5 | // x86_64-linux. | |
| 6 | const linux_x64 = std.zig.CrossTarget{ | |
| 7 | .cpu_arch = .x86_64, | |
| 8 | .os_tag = .linux, | |
| 9 | }; | |
| 2 | 10 | |
| 3 | 11 | pub fn addCases(ctx: *TestContext) void { |
| 4 | ctx.addZIRTransform("elemptr, add, cmp, condbr, return, breakpoint", | |
| 12 | ctx.addZIRTransform("elemptr, add, cmp, condbr, return, breakpoint", linux_x64, | |
| 5 | 13 | \\@void = primitive(void) |
| 6 | 14 | \\@usize = primitive(usize) |
| 7 | 15 | \\@fnty = fntype([], @void, cc=C) |
| ... | ... | @@ -49,8 +57,8 @@ pub fn addCases(ctx: *TestContext) void { |
| 49 | 57 | \\ |
| 50 | 58 | ); |
| 51 | 59 | |
| 52 | if (@import("std").Target.current.os.tag != .linux or | |
| 53 | @import("std").Target.current.cpu.arch != .x86_64) | |
| 60 | if (std.Target.current.os.tag != .linux or | |
| 61 | std.Target.current.cpu.arch != .x86_64) | |
| 54 | 62 | { |
| 55 | 63 | // TODO implement self-hosted PE (.exe file) linking |
| 56 | 64 | // TODO implement more ZIR so we don't depend on x86_64-linux |