stage2: switch emit zir

This commit is contained in:
Vexu
2020-10-13 18:08:15 +03:00
parent 11998d2972
commit 2020ca640e
6 changed files with 127 additions and 48 deletions

View File

@@ -2098,6 +2098,29 @@ pub fn addCall(
return &inst.base;
}
pub fn addSwitchBr(
self: *Module,
block: *Scope.Block,
src: usize,
target_ptr: *Inst,
cases: []Inst.SwitchBr.Case,
else_body: ?Module.Body,
) !*Inst {
const inst = try block.arena.create(Inst.SwitchBr);
inst.* = .{
.base = .{
.tag = .switchbr,
.ty = Type.initTag(.noreturn),
.src = src,
},
.target_ptr = target_ptr,
.cases = cases,
.@"else" = else_body,
};
try block.instructions.append(self.gpa, &inst.base);
return &inst.base;
}
pub fn constInst(self: *Module, scope: *Scope, src: usize, typed_value: TypedValue) !*Inst {
const const_inst = try scope.arena().create(Inst.Constant);
const_inst.* = .{