aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorr00ster91 <r00ster91@proton.me>2023-03-03 17:30:18 +0100
committerr00ster91 <r00ster91@proton.me>2023-03-03 21:16:21 +0100
commitd6bd00e85500fa1a7909695ae5943be438f7521d (patch)
tree55999396212ade2f2494b585ceeb7af3e64ab13d /src/Sema.zig
parent75ff34db9e93056482233f8476a06f78b4a2f3c2 (diff)
downloadzig-d6bd00e85500fa1a7909695ae5943be438f7521d.tar.gz
zig-d6bd00e85500fa1a7909695ae5943be438f7521d.zip
Zir: move set_cold from Inst.Tag to Inst.Extended
If I could mark a builtin function as cold, I would mark @setCold as cold. We have run out of `Zir.Inst.Tag`s so I had to move a tag from Zir.Inst.Tag to Zir.Inst.Extended. This is because a new noreturn builtin will be added and noreturn builtins cannot be part of Inst.Tag: ``` /// `noreturn` instructions may not go here; they must be part of the main `Tag` enum. pub const Extended = enum(u16) { ``` Here's another reason I went for @setCold: ``` $ git grep setRuntimeSafety | wc -l 322 $ git grep setCold | wc -l 79 $ git grep setEvalBranchQuota | wc -l 82 ``` This also simply removes @setCold from Autodoc and the docs frontend because as far as I could understand it, builtins represented using Zir extended instructions are not yet supported because I couldn't find @setStackAlign or @setFloatMode there, either.
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index f9a6f39867..4702d10688 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -1167,6 +1167,11 @@ fn analyzeBodyInner(
i += 1;
continue;
},
+ .set_cold => {
+ try sema.zirSetCold(block, extended);
+ i += 1;
+ continue;
+ },
.breakpoint => {
if (!block.is_comptime) {
_ = try block.addNoOp(.breakpoint);
@@ -1304,11 +1309,6 @@ fn analyzeBodyInner(
i += 1;
continue;
},
- .set_cold => {
- try sema.zirSetCold(block, inst);
- i += 1;
- continue;
- },
.set_runtime_safety => {
try sema.zirSetRuntimeSafety(block, inst);
i += 1;
@@ -5721,10 +5721,10 @@ fn zirSetAlignStack(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst
gop.value_ptr.* = .{ .alignment = alignment, .src = src };
}
-fn zirSetCold(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
- const inst_data = sema.code.instructions.items(.data)[inst].un_node;
- const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
- const is_cold = try sema.resolveConstBool(block, operand_src, inst_data.operand, "operand to @setCold must be comptime-known");
+fn zirSetCold(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {
+ const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
+ const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };
+ const is_cold = try sema.resolveConstBool(block, operand_src, extra.operand, "operand to @setCold must be comptime-known");
const func = sema.func orelse return; // does nothing outside a function
func.is_cold = is_cold;
}