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
2021-07-15 15:52:06 -07:00
parent 12c10139e3
commit eadbee2041
7 changed files with 307 additions and 574 deletions

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),
});