diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-04-24 12:54:12 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-24 12:54:12 -0700 |
| commit | ef0a02081d0506dc497ffc89f06e16db7d4b8184 (patch) | |
| tree | 1053eea2476171c799cc3fb7bb509e386a9ca359 /src/Sema.zig | |
| parent | 7439eb5e99ba98bbdb2a0d0d71535e57d13f3c6e (diff) | |
| parent | 3878586821bbcd18c1693e7547c85643be60b61b (diff) | |
| download | zig-ef0a02081d0506dc497ffc89f06e16db7d4b8184.tar.gz zig-ef0a02081d0506dc497ffc89f06e16db7d4b8184.zip | |
Merge pull request #15290 from mlugg/feat/builtin-in-comptime
Add `@inComptime` builtin
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 393a05f123..eed53a8264 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -1166,6 +1166,7 @@ fn analyzeBodyInner( .work_item_id => try sema.zirWorkItem( block, extended, extended.opcode), .work_group_size => try sema.zirWorkItem( block, extended, extended.opcode), .work_group_id => try sema.zirWorkItem( block, extended, extended.opcode), + .in_comptime => try sema.zirInComptime( block), // zig fmt: on .fence => { @@ -22466,6 +22467,18 @@ fn zirWorkItem( }); } +fn zirInComptime( + sema: *Sema, + block: *Block, +) CompileError!Air.Inst.Ref { + _ = sema; + if (block.is_comptime) { + return Air.Inst.Ref.bool_true; + } else { + return Air.Inst.Ref.bool_false; + } +} + fn requireRuntimeBlock(sema: *Sema, block: *Block, src: LazySrcLoc, runtime_src: ?LazySrcLoc) !void { if (block.is_comptime) { const msg = msg: { |
