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