aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-07-15 15:52:06 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-07-20 12:19:16 -0700
commiteadbee2041bba1cd03b24d8f30161025af8e3590 (patch)
treeaebad285c7cd852fcc1c9d62f3beeb4395c6d04e /src/Compilation.zig
parent12c10139e3e0166e91d2dbb1801c2054ca12d413 (diff)
downloadzig-eadbee2041bba1cd03b24d8f30161025af8e3590.tar.gz
zig-eadbee2041bba1cd03b24d8f30161025af8e3590.zip
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
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig9
1 files changed, 6 insertions, 3 deletions
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());