commit b90553615a73c856f8aabe96c73fe7764f54462f (tree)
parent 5d6f9537f08513ea1d578cee01a91a6e36258991
Author: Motiejus <motiejus@jakstys.lt>
Date: Sat, 7 Mar 2026 07:22:00 +0000
sema: extract analyzeBitNot from zirBitNot
Matches upstream Sema.zig which has zirBitNot → analyzeBitNot
two-function decomposition. Pure extraction, no behavioral change.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Diffstat:
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/stage0/sema.c b/stage0/sema.c
@@ -914,11 +914,10 @@ static AirInstRef zirNegateWrap(Sema* sema, SemaBlock* block, uint32_t inst) {
return semaAddInst(block, AIR_INST_SUB_WRAP, data);
}
-// zirBitNot: handle bit_not ZIR instruction (bitwise ~).
-// Ported from src/Sema.zig zirBitNot.
-static AirInstRef zirBitNot(Sema* sema, SemaBlock* block, uint32_t inst) {
- ZirInstRef operand_ref = sema->code.inst_datas[inst].un_node.operand;
- AirInstRef operand = resolveInst(sema, operand_ref);
+// analyzeBitNot: inner worker for bitwise NOT.
+// Ported from src/Sema.zig analyzeBitNot.
+static AirInstRef analyzeBitNot(
+ Sema* sema, SemaBlock* block, AirInstRef operand) {
// Comptime folding: if the operand is a comptime integer,
// compute ~value at comptime.
uint64_t val_lo, val_hi;
@@ -957,6 +956,14 @@ static AirInstRef zirBitNot(Sema* sema, SemaBlock* block, uint32_t inst) {
return semaAddInst(block, AIR_INST_NOT, data);
}
+// zirBitNot: handle bit_not ZIR instruction (bitwise ~).
+// Ported from src/Sema.zig zirBitNot.
+static AirInstRef zirBitNot(Sema* sema, SemaBlock* block, uint32_t inst) {
+ ZirInstRef operand_ref = sema->code.inst_datas[inst].un_node.operand;
+ AirInstRef operand = resolveInst(sema, operand_ref);
+ return analyzeBitNot(sema, block, operand);
+}
+
// zirBoolNot: handle bool_not ZIR instruction.
// Ported from src/Sema.zig zirBoolNot.
// Emits AIR_INST_NOT with type = bool.