diff options
author | Mathias Magnusson <mathias@magnusson.space> | 2025-06-06 19:49:42 +0200 |
---|---|---|
committer | Mathias Magnusson <mathias@magnusson.space> | 2025-06-06 19:49:42 +0200 |
commit | 8c9a56311ac2774bf83eda4ea0aa9bde0aec125f (patch) | |
tree | 63b9c72ad3bda6c707cbd7f081f7510cf72519c5 | |
parent | 55f45123f21e63e883d0afe16d97dcb5dafdd296 (diff) | |
download | huginn-8c9a56311ac2774bf83eda4ea0aa9bde0aec125f.tar.gz |
assert that each block ends with an instruction which may do so
-rw-r--r-- | src/compile.zig | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/compile.zig b/src/compile.zig index 0918d30..8cf61ca 100644 --- a/src/compile.zig +++ b/src/compile.zig @@ -66,6 +66,8 @@ pub const Instr = struct { true: BlockRef, false: BlockRef, + pub const may_end_block = {}; + pub fn sources(self: Branch) Sources { return Sources.fromSlice(&.{self.cond}) catch unreachable; } @@ -74,12 +76,16 @@ pub const Instr = struct { pub const Jump = struct { to: BlockRef, + pub const may_end_block = {}; + pub fn sources(_: Jump) Sources { return Sources.init(0) catch unreachable; } }; pub const Exit = struct { + pub const may_end_block = {}; + pub fn sources(_: Exit) Sources { return Sources.init(0) catch unreachable; } @@ -164,6 +170,9 @@ pub const BasicBlock = struct { if (instr.dest()) |dest| try self.vreg_last_use.put(allocator, dest, i); } + std.debug.assert(switch (self.instrs.items[self.instrs.items.len - 1].type) { + inline else => |ty| @hasDecl(@TypeOf(ty), "may_end_block"), + }); } }; |