| ... | ... | @@ -122,9 +122,19 @@ allow_memoize: bool = true, |
| 122 | 122 | /// This state is on `Sema` so that `cold` hints can be propagated up through blocks with less special handling. |
| 123 | 123 | branch_hint: ?std.builtin.BranchHint = null, |
| 124 | 124 | |
| 125 | const RuntimeIndex = enum(u32) { |
| 126 | zero = 0, |
| 127 | comptime_field_ptr = std.math.maxInt(u32), |
| 128 | _, |
| 129 | |
| 130 | pub fn increment(ri: *RuntimeIndex) void { |
| 131 | ri.* = @enumFromInt(@intFromEnum(ri.*) + 1); |
| 132 | } |
| 133 | }; |
| 134 | |
| 125 | 135 | const MaybeComptimeAlloc = struct { |
| 126 | 136 | /// The runtime index of the `alloc` instruction. |
| 127 | | runtime_index: Value.RuntimeIndex, |
| 137 | runtime_index: RuntimeIndex, |
| 128 | 138 | /// Backed by sema.arena. Tracks all comptime-known stores to this `alloc`. Due to |
| 129 | 139 | /// RLS, a single comptime-known allocation may have arbitrarily many stores. |
| 130 | 140 | /// This list also contains `set_union_tag`, `optional_payload_ptr_set`, and |
| ... | ... | @@ -144,7 +154,7 @@ const ComptimeAlloc = struct { |
| 144 | 154 | /// This is the `runtime_index` at the point of this allocation. If an store |
| 145 | 155 | /// to this alloc ever occurs with a runtime index greater than this one, it |
| 146 | 156 | /// is behind a runtime condition, so a compile error will be emitted. |
| 147 | | runtime_index: Value.RuntimeIndex, |
| 157 | runtime_index: RuntimeIndex, |
| 148 | 158 | }; |
| 149 | 159 | |
| 150 | 160 | fn newComptimeAlloc(sema: *Sema, block: *Block, ty: Type, alignment: Alignment) !ComptimeAllocIndex { |
| ... | ... | @@ -364,7 +374,7 @@ pub const Block = struct { |
| 364 | 374 | runtime_loop: ?LazySrcLoc = null, |
| 365 | 375 | /// Non zero if a non-inline loop or a runtime conditional have been encountered. |
| 366 | 376 | /// Stores to comptime variables are only allowed when var.runtime_index <= runtime_index. |
| 367 | | runtime_index: Value.RuntimeIndex = .zero, |
| 377 | runtime_index: RuntimeIndex = .zero, |
| 368 | 378 | inline_block: Zir.Inst.OptionalIndex = .none, |
| 369 | 379 | |
| 370 | 380 | comptime_reason: ?*const ComptimeReason = null, |