From eadbee2041bba1cd03b24d8f30161025af8e3590 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 15 Jul 2021 15:52:06 -0700 Subject: stage2: first pass at printing AIR/Liveness to text * some instructions are not implemented yet * fix off-by-1 in Air.getMainBody * Compilation: use `@import("builtin")` rather than `std.builtin` for the values that are different for different build configurations. * Sema: avoid calling `addType` in between air_instructions.ensureUnusedCapacity and corresponding appendAssumeCapacity because it can possibly add an instruction. * Value: functions print their names --- src/Compilation.zig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/Compilation.zig') diff --git a/src/Compilation.zig b/src/Compilation.zig index f241ae6b10..50d1f5760e 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -1,6 +1,7 @@ const Compilation = @This(); const std = @import("std"); +const builtin = @import("builtin"); const mem = std.mem; const Allocator = std.mem.Allocator; const assert = std.debug.assert; @@ -907,7 +908,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { // comptime conditions ((build_options.have_llvm and comptime std.Target.current.isDarwin()) and // runtime conditions - (use_lld and std.builtin.os.tag == .macos and options.target.isDarwin())); + (use_lld and builtin.os.tag == .macos and options.target.isDarwin())); const sysroot = blk: { if (options.sysroot) |sysroot| { @@ -2026,8 +2027,10 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor var liveness = try Liveness.analyze(gpa, air, decl.namespace.file_scope.zir); defer liveness.deinit(gpa); - if (std.builtin.mode == .Debug and self.verbose_air) { - @panic("TODO implement dumping AIR and liveness"); + if (builtin.mode == .Debug and self.verbose_air) { + std.debug.print("# Begin Function AIR: {s}:\n", .{decl.name}); + @import("print_air.zig").dump(gpa, air, liveness); + std.debug.print("# End Function AIR: {s}:\n", .{decl.name}); } assert(decl.ty.hasCodeGenBits()); -- cgit v1.2.3