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>
This commit is contained in:
2026-03-07 07:22:00 +00:00
parent 5d6f9537f0
commit b90553615a

View File

@@ -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.