aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compile.zig13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/compile.zig b/src/compile.zig
index 3ee3eb0..80279fb 100644
--- a/src/compile.zig
+++ b/src/compile.zig
@@ -98,8 +98,13 @@ pub const BasicBlock = struct {
fn finalize(self: *BasicBlock, allocator: Allocator) !void {
std.debug.assert(self.instrs.items.len > 0);
+ for (self.instrs.items[0 .. self.instrs.items.len - 1]) |instr| {
+ std.debug.assert(switch (instr.type) {
+ inline else => |ty| !@hasDecl(@TypeOf(ty), "ends_block"),
+ });
+ }
std.debug.assert(switch (self.instrs.getLast().type) {
- inline else => |ty| @hasDecl(@TypeOf(ty), "may_end_block"),
+ inline else => |ty| @hasDecl(@TypeOf(ty), "ends_block"),
});
self.vreg_last_use = .empty;
@@ -195,7 +200,7 @@ pub const Instr = struct {
true: BlockRef,
false: BlockRef,
- pub const may_end_block = {};
+ pub const ends_block = {};
pub fn sources(_: Branch) Sources {
return Sources.init(0) catch unreachable;
@@ -205,7 +210,7 @@ pub const Instr = struct {
pub const Jump = struct {
to: BlockRef,
- pub const may_end_block = {};
+ pub const ends_block = {};
pub fn sources(_: Jump) Sources {
return Sources.init(0) catch unreachable;
@@ -233,7 +238,7 @@ pub const Instr = struct {
pub const Return = struct {
val: VReg,
- pub const may_end_block = {};
+ pub const ends_block = {};
pub fn sources(self: Return) Sources {
return Sources.fromSlice(&.{self.val}) catch unreachable;