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
This commit is contained in:
Andrew Kelley committed 2021-07-20 12:19:16 -07:00
1 parent 12c10139e3
commit eadbee2041
7 files changed
+307 -574

No files matched your search

+2 -1
View File
@@ -3551,7 +3551,8 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn) SemaError!Air {
try sema.analyzeFnBody(&inner_block, func.zir_body_inst);
// Copy the block into place and mark that as the main block.
try sema.air_extra.ensureUnusedCapacity(gpa, inner_block.instructions.items.len + 1);
try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len +
inner_block.instructions.items.len);
const main_block_index = sema.addExtraAssumeCapacity(Air.Block{
.body_len = @intCast(u32, inner_block.instructions.items.len),
});