authorgravatar for quint@daenen.emailQuint Daenen <quint@daenen.email> 2026-05-04 20:34:55+02:00
committergravatar for alichraghi@noreply.codeberg.orgAli Cheraghi <alichraghi@noreply.codeberg.org> 2026-06-18 13:38:58+02:00
logecb627eb396b550812e709e7f4277df8c88ad062
treede06ae96e5a783b2c57a478a0dc5a5509d0c1e0e
parentcf950691cb967826c4df5bede1bb5c654fede129

fix(spirv): convert composite_integer unreachables to cg.todo

Eleven arithmetic/comparison/reduce paths panicked on big-int operands. Replace each with cg.todo so unsupported widths surface as compile errors instead of crashes.

1 files changed, 11 insertions(+), 11 deletions(-)

src/codegen/spirv/CodeGen.zig+11-11
...@@ -3342,7 +3342,7 @@ fn airDivFloor(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -3342,7 +3342,7 @@ fn airDivFloor(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
33423342
3343 const info = cg.arithmeticTypeInfo(lhs.ty);3343 const info = cg.arithmeticTypeInfo(lhs.ty);
3344 switch (info.class) {3344 switch (info.class) {
3345 .composite_integer => unreachable, // TODO3345 .composite_integer => return cg.todo("div_floor for composite integers", .{}),
3346 .integer, .strange_integer => {3346 .integer, .strange_integer => {
3347 switch (info.signedness) {3347 switch (info.signedness) {
3348 .unsigned => {3348 .unsigned => {
...@@ -3381,7 +3381,7 @@ fn airDivTrunc(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -3381,7 +3381,7 @@ fn airDivTrunc(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
3381 const rhs = try cg.temporary(bin_op.rhs);3381 const rhs = try cg.temporary(bin_op.rhs);
3382 const info = cg.arithmeticTypeInfo(lhs.ty);3382 const info = cg.arithmeticTypeInfo(lhs.ty);
3383 switch (info.class) {3383 switch (info.class) {
3384 .composite_integer => unreachable, // TODO3384 .composite_integer => return cg.todo("div_trunc for composite integers", .{}),
3385 .integer, .strange_integer => switch (info.signedness) {3385 .integer, .strange_integer => switch (info.signedness) {
3386 .unsigned => {3386 .unsigned => {
3387 const result = try cg.buildBinary(.OpUDiv, lhs, rhs);3387 const result = try cg.buildBinary(.OpUDiv, lhs, rhs);
...@@ -3420,7 +3420,7 @@ fn airArithOp(...@@ -3420,7 +3420,7 @@ fn airArithOp(
3420 const rhs = try cg.temporary(bin_op.rhs);3420 const rhs = try cg.temporary(bin_op.rhs);
3421 const info = cg.arithmeticTypeInfo(lhs.ty);3421 const info = cg.arithmeticTypeInfo(lhs.ty);
3422 const result = switch (info.class) {3422 const result = switch (info.class) {
3423 .composite_integer => unreachable, // TODO3423 .composite_integer => return cg.todo("arith op for composite integers", .{}),
3424 .integer, .strange_integer => res: {3424 .integer, .strange_integer => res: {
3425 const raw = switch (info.signedness) {3425 const raw = switch (info.signedness) {
3426 .signed => try cg.buildBinary(sop, lhs, rhs),3426 .signed => try cg.buildBinary(sop, lhs, rhs),
...@@ -3461,7 +3461,7 @@ fn abs(cg: *CodeGen, result_ty: Type, value: Temporary) !Temporary {...@@ -3461,7 +3461,7 @@ fn abs(cg: *CodeGen, result_ty: Type, value: Temporary) !Temporary {
3461 }3461 }
3462 return try cg.normalize(abs_value, cg.arithmeticTypeInfo(result_ty));3462 return try cg.normalize(abs_value, cg.arithmeticTypeInfo(result_ty));
3463 },3463 },
3464 .composite_integer => unreachable, // TODO3464 .composite_integer => return cg.todo("@abs for composite integers", .{}),
3465 .bool => unreachable,3465 .bool => unreachable,
3466 }3466 }
3467}3467}
...@@ -3489,7 +3489,7 @@ fn airAddSubOverflow(...@@ -3489,7 +3489,7 @@ fn airAddSubOverflow(
34893489
3490 const info = cg.arithmeticTypeInfo(lhs.ty);3490 const info = cg.arithmeticTypeInfo(lhs.ty);
3491 switch (info.class) {3491 switch (info.class) {
3492 .composite_integer => unreachable, // TODO3492 .composite_integer => return cg.todo("add/sub-with-overflow for composite integers", .{}),
3493 .strange_integer, .integer => {},3493 .strange_integer, .integer => {},
3494 .float, .bool => unreachable,3494 .float, .bool => unreachable,
3495 }3495 }
...@@ -3539,7 +3539,7 @@ fn airMulOverflow(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -3539,7 +3539,7 @@ fn airMulOverflow(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
35393539
3540 const info = cg.arithmeticTypeInfo(lhs.ty);3540 const info = cg.arithmeticTypeInfo(lhs.ty);
3541 switch (info.class) {3541 switch (info.class) {
3542 .composite_integer => unreachable, // TODO3542 .composite_integer => return cg.todo("mul-with-overflow for composite integers", .{}),
3543 .strange_integer, .integer => {},3543 .strange_integer, .integer => {},
3544 .float, .bool => unreachable,3544 .float, .bool => unreachable,
3545 }3545 }
...@@ -3710,7 +3710,7 @@ fn airShlOverflow(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -3710,7 +3710,7 @@ fn airShlOverflow(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
37103710
3711 const info = cg.arithmeticTypeInfo(base.ty);3711 const info = cg.arithmeticTypeInfo(base.ty);
3712 switch (info.class) {3712 switch (info.class) {
3713 .composite_integer => unreachable, // TODO3713 .composite_integer => return cg.todo("shl-with-overflow for composite integers", .{}),
3714 .integer, .strange_integer => {},3714 .integer, .strange_integer => {},
3715 .float, .bool => unreachable,3715 .float, .bool => unreachable,
3716 }3716 }
...@@ -3761,7 +3761,7 @@ fn airClzCtz(cg: *CodeGen, inst: Air.Inst.Index, op: UnaryOp) !?Id {...@@ -3761,7 +3761,7 @@ fn airClzCtz(cg: *CodeGen, inst: Air.Inst.Index, op: UnaryOp) !?Id {
37613761
3762 const info = cg.arithmeticTypeInfo(operand.ty);3762 const info = cg.arithmeticTypeInfo(operand.ty);
3763 switch (info.class) {3763 switch (info.class) {
3764 .composite_integer => unreachable, // TODO3764 .composite_integer => return cg.todo("@clz/@ctz for composite integers", .{}),
3765 .integer, .strange_integer => {},3765 .integer, .strange_integer => {},
3766 .float, .bool => unreachable,3766 .float, .bool => unreachable,
3767 }3767 }
...@@ -3846,7 +3846,7 @@ fn airReduce(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -3846,7 +3846,7 @@ fn airReduce(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
3846 .Mul => .OpFMul,3846 .Mul => .OpFMul,
3847 else => unreachable,3847 else => unreachable,
3848 },3848 },
3849 .composite_integer => unreachable, // TODO3849 .composite_integer => return cg.todo("@reduce for composite integers", .{}),
3850 };3850 };
38513851
3852 const needs_normalize = info.class == .strange_integer and3852 const needs_normalize = info.class == .strange_integer and
...@@ -4181,7 +4181,7 @@ fn cmp(...@@ -4181,7 +4181,7 @@ fn cmp(
41814181
4182 const info = cg.arithmeticTypeInfo(scalar_ty);4182 const info = cg.arithmeticTypeInfo(scalar_ty);
4183 const pred: Opcode = switch (info.class) {4183 const pred: Opcode = switch (info.class) {
4184 .composite_integer => unreachable, // TODO4184 .composite_integer => return cg.todo("comparison for composite integers", .{}),
4185 .float => switch (op) {4185 .float => switch (op) {
4186 .eq => .OpFOrdEqual,4186 .eq => .OpFOrdEqual,
4187 .neq => .OpFUnordNotEqual,4187 .neq => .OpFUnordNotEqual,
...@@ -4449,7 +4449,7 @@ fn airNot(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -4449,7 +4449,7 @@ fn airNot(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
4449 const result = switch (info.class) {4449 const result = switch (info.class) {
4450 .bool => try cg.buildUnary(.l_not, operand),4450 .bool => try cg.buildUnary(.l_not, operand),
4451 .float => unreachable,4451 .float => unreachable,
4452 .composite_integer => unreachable, // TODO4452 .composite_integer => return cg.todo("bitwise not for composite integers", .{}),
4453 .strange_integer, .integer => blk: {4453 .strange_integer, .integer => blk: {
4454 const complement = try cg.buildUnary(.bit_not, operand);4454 const complement = try cg.buildUnary(.bit_not, operand);
4455 break :blk try cg.normalize(complement, info);4455 break :blk try cg.normalize(complement, info);