authorgravatar for 58830309+g-w1@users.noreply.github.comg-w1 <58830309+g-w1@users.noreply.github.com> 2021-04-09 02:11:33-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-04-09 02:11:33-04:00
logc6791d87d4f49598aab54064df683fc86e97dbd9
tree1622d848a9bdb17eacf8bf69678c12c1bd3861f2
parent23db96931e5226f09a451663ba1c8bf2398af91b
signature Signed by PGP key 4AEE18F83AFDEB23

stage2: delete allowing input (and output) zir from the pipeline (#8471)

Remove -femit-zir as we aren't going to need it. Also remove zir test code This removes a TODO that asserts the file is not zir.

3 files changed, 18 insertions(+), 62 deletions(-)

src/Compilation.zig+1-11
......@@ -939,11 +939,6 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
939939 // However we currently do not have serialization of such metadata, so for now
940940 // we set up an empty Module that does the entire compilation fresh.
941941
942 // TODO remove CLI support for .zir files and then we can remove this error
943 // handling and assertion.
944 if (mem.endsWith(u8, root_pkg.root_src_path, ".zir")) return error.ZirFilesUnsupported;
945 assert(mem.endsWith(u8, root_pkg.root_src_path, ".zig"));
946
947942 const root_scope = try gpa.create(Module.Scope.File);
948943 errdefer gpa.destroy(root_scope);
949944
......@@ -2487,7 +2482,7 @@ pub fn addCCArgs(
24872482 try argv.append("-fPIC");
24882483 }
24892484 },
2490 .shared_library, .assembly, .ll, .bc, .unknown, .static_library, .object, .zig, .zir => {},
2485 .shared_library, .assembly, .ll, .bc, .unknown, .static_library, .object, .zig => {},
24912486 }
24922487 if (out_dep_path) |p| {
24932488 try argv.appendSlice(&[_][]const u8{ "-MD", "-MV", "-MF", p });
......@@ -2561,7 +2556,6 @@ pub const FileExt = enum {
25612556 object,
25622557 static_library,
25632558 zig,
2564 zir,
25652559 unknown,
25662560
25672561 pub fn clangSupportsDepFile(ext: FileExt) bool {
......@@ -2575,7 +2569,6 @@ pub const FileExt = enum {
25752569 .object,
25762570 .static_library,
25772571 .zig,
2578 .zir,
25792572 .unknown,
25802573 => false,
25812574 };
......@@ -2647,8 +2640,6 @@ pub fn classifyFileExt(filename: []const u8) FileExt {
26472640 return .h;
26482641 } else if (mem.endsWith(u8, filename, ".zig")) {
26492642 return .zig;
2650 } else if (mem.endsWith(u8, filename, ".zir")) {
2651 return .zir;
26522643 } else if (hasSharedLibraryExt(filename)) {
26532644 return .shared_library;
26542645 } else if (hasStaticLibraryExt(filename)) {
......@@ -2669,7 +2660,6 @@ test "classifyFileExt" {
26692660 std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2.3"));
26702661 std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.so.1.2.3~"));
26712662 std.testing.expectEqual(FileExt.zig, classifyFileExt("foo.zig"));
2672 std.testing.expectEqual(FileExt.zir, classifyFileExt("foo.zir"));
26732663}
26742664
26752665fn haveFramePointer(comp: *const Compilation) bool {
src/main.zig+2-16
......@@ -505,7 +505,6 @@ fn buildOutputType(
505505 var emit_bin: EmitBin = .yes_default_path;
506506 var emit_asm: Emit = .no;
507507 var emit_llvm_ir: Emit = .no;
508 var emit_zir: Emit = .no;
509508 var emit_docs: Emit = .no;
510509 var emit_analysis: Emit = .no;
511510 var target_arch_os_abi: []const u8 = "native";
......@@ -923,12 +922,6 @@ fn buildOutputType(
923922 emit_bin = .{ .yes = arg["-femit-bin=".len..] };
924923 } else if (mem.eql(u8, arg, "-fno-emit-bin")) {
925924 emit_bin = .no;
926 } else if (mem.eql(u8, arg, "-femit-zir")) {
927 emit_zir = .yes_default_path;
928 } else if (mem.startsWith(u8, arg, "-femit-zir=")) {
929 emit_zir = .{ .yes = arg["-femit-zir=".len..] };
930 } else if (mem.eql(u8, arg, "-fno-emit-zir")) {
931 emit_zir = .no;
932925 } else if (mem.eql(u8, arg, "-femit-h")) {
933926 emit_h = .yes_default_path;
934927 } else if (mem.startsWith(u8, arg, "-femit-h=")) {
......@@ -1025,7 +1018,7 @@ fn buildOutputType(
10251018 .extra_flags = try arena.dupe([]const u8, extra_cflags.items),
10261019 });
10271020 },
1028 .zig, .zir => {
1021 .zig => {
10291022 if (root_src_file) |other| {
10301023 fatal("found another zig file '{s}' after root source file '{s}'", .{ arg, other });
10311024 } else {
......@@ -1086,7 +1079,7 @@ fn buildOutputType(
10861079 .unknown, .shared_library, .object, .static_library => {
10871080 try link_objects.append(it.only_arg);
10881081 },
1089 .zig, .zir => {
1082 .zig => {
10901083 if (root_src_file) |other| {
10911084 fatal("found another zig file '{s}' after root source file '{s}'", .{ it.only_arg, other });
10921085 } else {
......@@ -1724,13 +1717,6 @@ fn buildOutputType(
17241717 var emit_docs_resolved = try emit_docs.resolve("docs");
17251718 defer emit_docs_resolved.deinit();
17261719
1727 switch (emit_zir) {
1728 .no => {},
1729 .yes_default_path, .yes => {
1730 fatal("The -femit-zir implementation has been intentionally deleted so that it can be rewritten as a proper backend.", .{});
1731 },
1732 }
1733
17341720 const root_pkg: ?*Package = if (root_src_file) |src_path| blk: {
17351721 if (main_pkg_path) |p| {
17361722 const rel_src_path = try fs.path.relative(gpa, p, src_path);
src/test.zig+15-35
......@@ -122,11 +122,6 @@ pub const TestContext = struct {
122122 path: []const u8,
123123 };
124124
125 pub const Extension = enum {
126 Zig,
127 ZIR,
128 };
129
130125 /// A `Case` consists of a list of `Update`. The same `Compilation` is used for each
131126 /// update, so each update's source is treated as a single file being
132127 /// updated by the test harness and incrementally compiled.
......@@ -141,7 +136,6 @@ pub const TestContext = struct {
141136 /// to Executable.
142137 output_mode: std.builtin.OutputMode,
143138 updates: std.ArrayList(Update),
144 extension: Extension,
145139 object_format: ?std.builtin.ObjectFormat = null,
146140 emit_h: bool = false,
147141 llvm_backend: bool = false,
......@@ -238,14 +232,12 @@ pub const TestContext = struct {
238232 ctx: *TestContext,
239233 name: []const u8,
240234 target: CrossTarget,
241 extension: Extension,
242235 ) *Case {
243236 ctx.cases.append(Case{
244237 .name = name,
245238 .target = target,
246239 .updates = std.ArrayList(Update).init(ctx.cases.allocator),
247240 .output_mode = .Exe,
248 .extension = extension,
249241 .files = std.ArrayList(File).init(ctx.cases.allocator),
250242 }) catch @panic("out of memory");
251243 return &ctx.cases.items[ctx.cases.items.len - 1];
......@@ -253,7 +245,7 @@ pub const TestContext = struct {
253245
254246 /// Adds a test case for Zig input, producing an executable
255247 pub fn exe(ctx: *TestContext, name: []const u8, target: CrossTarget) *Case {
256 return ctx.addExe(name, target, .Zig);
248 return ctx.addExe(name, target);
257249 }
258250
259251 /// Adds a test case for ZIR input, producing an executable
......@@ -269,7 +261,6 @@ pub const TestContext = struct {
269261 .target = target,
270262 .updates = std.ArrayList(Update).init(ctx.cases.allocator),
271263 .output_mode = .Exe,
272 .extension = .Zig,
273264 .object_format = .c,
274265 .files = std.ArrayList(File).init(ctx.cases.allocator),
275266 }) catch @panic("out of memory");
......@@ -284,7 +275,6 @@ pub const TestContext = struct {
284275 .target = target,
285276 .updates = std.ArrayList(Update).init(ctx.cases.allocator),
286277 .output_mode = .Exe,
287 .extension = .Zig,
288278 .files = std.ArrayList(File).init(ctx.cases.allocator),
289279 .llvm_backend = true,
290280 }) catch @panic("out of memory");
......@@ -295,14 +285,12 @@ pub const TestContext = struct {
295285 ctx: *TestContext,
296286 name: []const u8,
297287 target: CrossTarget,
298 extension: Extension,
299288 ) *Case {
300289 ctx.cases.append(Case{
301290 .name = name,
302291 .target = target,
303292 .updates = std.ArrayList(Update).init(ctx.cases.allocator),
304293 .output_mode = .Obj,
305 .extension = extension,
306294 .files = std.ArrayList(File).init(ctx.cases.allocator),
307295 }) catch @panic("out of memory");
308296 return &ctx.cases.items[ctx.cases.items.len - 1];
......@@ -310,7 +298,7 @@ pub const TestContext = struct {
310298
311299 /// Adds a test case for Zig input, producing an object file.
312300 pub fn obj(ctx: *TestContext, name: []const u8, target: CrossTarget) *Case {
313 return ctx.addObj(name, target, .Zig);
301 return ctx.addObj(name, target);
314302 }
315303
316304 /// Adds a test case for ZIR input, producing an object file.
......@@ -319,13 +307,12 @@ pub const TestContext = struct {
319307 }
320308
321309 /// Adds a test case for Zig or ZIR input, producing C code.
322 pub fn addC(ctx: *TestContext, name: []const u8, target: CrossTarget, ext: Extension) *Case {
310 pub fn addC(ctx: *TestContext, name: []const u8, target: CrossTarget) *Case {
323311 ctx.cases.append(Case{
324312 .name = name,
325313 .target = target,
326314 .updates = std.ArrayList(Update).init(ctx.cases.allocator),
327315 .output_mode = .Obj,
328 .extension = ext,
329316 .object_format = .c,
330317 .files = std.ArrayList(File).init(ctx.cases.allocator),
331318 }) catch @panic("out of memory");
......@@ -333,21 +320,20 @@ pub const TestContext = struct {
333320 }
334321
335322 pub fn c(ctx: *TestContext, name: []const u8, target: CrossTarget, src: [:0]const u8, comptime out: [:0]const u8) void {
336 ctx.addC(name, target, .Zig).addCompareObjectFile(src, zig_h ++ out);
323 ctx.addC(name, target).addCompareObjectFile(src, zig_h ++ out);
337324 }
338325
339326 pub fn h(ctx: *TestContext, name: []const u8, target: CrossTarget, src: [:0]const u8, comptime out: [:0]const u8) void {
340 ctx.addC(name, target, .Zig).addHeader(src, zig_h ++ out);
327 ctx.addC(name, target).addHeader(src, zig_h ++ out);
341328 }
342329
343330 pub fn addCompareOutput(
344331 ctx: *TestContext,
345332 name: []const u8,
346 extension: Extension,
347333 src: [:0]const u8,
348334 expected_stdout: []const u8,
349335 ) void {
350 ctx.addExe(name, .{}, extension).addCompareOutput(src, expected_stdout);
336 ctx.addExe(name, .{}).addCompareOutput(src, expected_stdout);
351337 }
352338
353339 /// Adds a test case that compiles the Zig source given in `src`, executes
......@@ -358,7 +344,7 @@ pub const TestContext = struct {
358344 src: [:0]const u8,
359345 expected_stdout: []const u8,
360346 ) void {
361 return ctx.addCompareOutput(name, .Zig, src, expected_stdout);
347 return ctx.addCompareOutput(name, src, expected_stdout);
362348 }
363349
364350 /// Adds a test case that compiles the ZIR source given in `src`, executes
......@@ -376,11 +362,10 @@ pub const TestContext = struct {
376362 ctx: *TestContext,
377363 name: []const u8,
378364 target: CrossTarget,
379 extension: Extension,
380365 src: [:0]const u8,
381366 result: [:0]const u8,
382367 ) void {
383 ctx.addObj(name, target, extension).addTransform(src, result);
368 ctx.addObj(name, target).addTransform(src, result);
384369 }
385370
386371 /// Adds a test case that compiles the Zig given in `src` to ZIR and tests
......@@ -392,7 +377,7 @@ pub const TestContext = struct {
392377 src: [:0]const u8,
393378 result: [:0]const u8,
394379 ) void {
395 ctx.addTransform(name, target, .Zig, src, result);
380 ctx.addTransform(name, target, src, result);
396381 }
397382
398383 /// Adds a test case that cleans up the ZIR source given in `src`, and
......@@ -411,11 +396,10 @@ pub const TestContext = struct {
411396 ctx: *TestContext,
412397 name: []const u8,
413398 target: CrossTarget,
414 extension: Extension,
415399 src: [:0]const u8,
416400 expected_errors: []const []const u8,
417401 ) void {
418 ctx.addObj(name, target, extension).addError(src, expected_errors);
402 ctx.addObj(name, target).addError(src, expected_errors);
419403 }
420404
421405 /// Adds a test case that ensures that the Zig given in `src` fails to
......@@ -428,7 +412,7 @@ pub const TestContext = struct {
428412 src: [:0]const u8,
429413 expected_errors: []const []const u8,
430414 ) void {
431 ctx.addError(name, target, .Zig, src, expected_errors);
415 ctx.addError(name, target, src, expected_errors);
432416 }
433417
434418 /// Adds a test case that ensures that the ZIR given in `src` fails to
......@@ -448,10 +432,9 @@ pub const TestContext = struct {
448432 ctx: *TestContext,
449433 name: []const u8,
450434 target: CrossTarget,
451 extension: Extension,
452435 src: [:0]const u8,
453436 ) void {
454 ctx.addObj(name, target, extension).compiles(src);
437 ctx.addObj(name, target).compiles(src);
455438 }
456439
457440 /// Adds a test case that asserts that the Zig given in `src` compiles
......@@ -462,7 +445,7 @@ pub const TestContext = struct {
462445 target: CrossTarget,
463446 src: [:0]const u8,
464447 ) void {
465 ctx.addCompiles(name, target, .Zig, src);
448 ctx.addCompiles(name, target, src);
466449 }
467450
468451 /// Adds a test case that asserts that the ZIR given in `src` compiles
......@@ -489,7 +472,7 @@ pub const TestContext = struct {
489472 expected_errors: []const []const u8,
490473 fixed_src: [:0]const u8,
491474 ) void {
492 var case = ctx.addObj(name, target, .Zig);
475 var case = ctx.addObj(name, target);
493476 case.addError(src, expected_errors);
494477 case.compiles(fixed_src);
495478 }
......@@ -614,10 +597,7 @@ pub const TestContext = struct {
614597 .path = try std.fs.path.join(arena, &[_][]const u8{ tmp_dir_path, "zig-cache" }),
615598 };
616599
617 const tmp_src_path = switch (case.extension) {
618 .Zig => "test_case.zig",
619 .ZIR => "test_case.zir",
620 };
600 const tmp_src_path = "test_case.zig";
621601
622602 var root_pkg: Package = .{
623603 .root_src_directory = .{ .path = tmp_dir_path, .handle = tmp.dir },