mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
parent
fc4b7c968a
commit
68cfa736df
2 changed files with 18 additions and 9 deletions
|
|
@ -1103,11 +1103,7 @@ const FormatAirData = struct {
|
|||
inst: Air.Inst.Index,
|
||||
};
|
||||
fn formatAir(data: FormatAirData, w: *std.io.Writer) Writer.Error!void {
|
||||
// not acceptable implementation because it ignores `w`:
|
||||
//data.self.air.dumpInst(data.inst, data.self.pt, data.self.liveness);
|
||||
_ = data;
|
||||
_ = w;
|
||||
@panic("TODO: unimplemented");
|
||||
data.self.air.writeInst(w, data.inst, data.self.pt, data.self.liveness);
|
||||
}
|
||||
fn fmtAir(self: *CodeGen, inst: Air.Inst.Index) std.fmt.Formatter(FormatAirData, formatAir) {
|
||||
return .{ .data = .{ .self = self, .inst = inst } };
|
||||
|
|
@ -179300,10 +179296,13 @@ fn lowerSwitchBr(
|
|||
} else undefined;
|
||||
const table_start: u31 = @intCast(cg.mir_table.items.len);
|
||||
{
|
||||
const condition_index_reg = if (condition_index.isRegister())
|
||||
condition_index.getReg().?
|
||||
else
|
||||
try cg.copyToTmpRegister(.usize, condition_index);
|
||||
const condition_index_reg = condition_index_reg: {
|
||||
if (condition_index.isRegister()) {
|
||||
const condition_index_reg = condition_index.getReg().?;
|
||||
if (condition_index_reg.isClass(.general_purpose)) break :condition_index_reg condition_index_reg;
|
||||
}
|
||||
break :condition_index_reg try cg.copyToTmpRegister(.usize, condition_index);
|
||||
};
|
||||
const condition_index_lock = cg.register_manager.lockReg(condition_index_reg);
|
||||
defer if (condition_index_lock) |lock| cg.register_manager.unlockReg(lock);
|
||||
try cg.truncateRegister(condition_ty, condition_index_reg);
|
||||
|
|
|
|||
|
|
@ -1072,3 +1072,13 @@ test "switch on a signed value smaller than the smallest prong value" {
|
|||
else => {},
|
||||
}
|
||||
}
|
||||
|
||||
test "switch on 8-bit mod result" {
|
||||
var x: u8 = undefined;
|
||||
x = 16;
|
||||
switch (x % 4) {
|
||||
0 => {},
|
||||
1, 2, 3 => return error.TestFailed,
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue