From 2020ca640e8db50f1cb5a1ceaa42c28a25483bad Mon Sep 17 00:00:00 2001 From: Vexu Date: Tue, 13 Oct 2020 18:08:15 +0300 Subject: stage2: switch emit zir --- src/Module.zig | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index 0876b7f8d2..e821e5863a 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -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.* = .{ -- cgit v1.2.3