Skip to content

Commit fe94531

Browse files
rtfeldmanclaude
andcommitted
Remove NumKind.numeral from backend code
The numeral variant was a placeholder for unresolved numeric types that should never make it to code generation. By the time code reaches the backend, all numeric types should be resolved to concrete types (u8, i64, dec, etc.). Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 7a4d2b3 commit fe94531

File tree

2 files changed

+4
-46
lines changed

2 files changed

+4
-46
lines changed

src/backend/dev/CodeGen.zig

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ pub const NumKind = enum {
4444
f32,
4545
f64,
4646
dec,
47-
numeral,
4847

4948
pub fn isFloat(self: NumKind) bool {
5049
return self == .f32 or self == .f64;
@@ -54,7 +53,7 @@ pub const NumKind = enum {
5453
return switch (self) {
5554
.i8, .i16, .i32, .i64, .i128 => true,
5655
.u8, .u16, .u32, .u64, .u128 => false,
57-
.f32, .f64, .dec, .numeral => true, // floats are signed
56+
.f32, .f64, .dec => true, // floats are signed
5857
};
5958
}
6059

@@ -63,41 +62,12 @@ pub const NumKind = enum {
6362
.u8, .i8 => 1,
6463
.u16, .i16 => 2,
6564
.u32, .i32, .f32 => 4,
66-
.u64, .i64, .f64, .numeral => 8,
65+
.u64, .i64, .f64 => 8,
6766
.u128, .i128, .dec => 16,
6867
};
6968
}
7069
};
7170

72-
/// Binary operation types
73-
pub const BinOp = enum {
74-
add,
75-
sub,
76-
mul,
77-
div,
78-
rem,
79-
div_trunc,
80-
lt,
81-
gt,
82-
le,
83-
ge,
84-
eq,
85-
ne,
86-
@"and",
87-
@"or",
88-
89-
pub fn isComparison(self: BinOp) bool {
90-
return switch (self) {
91-
.lt, .gt, .le, .ge, .eq, .ne => true,
92-
else => false,
93-
};
94-
}
95-
96-
pub fn isLogical(self: BinOp) bool {
97-
return self == .@"and" or self == .@"or";
98-
}
99-
};
100-
10171
/// Code generator that produces native machine code from high-level operations.
10272
/// This is parameterized by the target architecture's types.
10373
pub fn CodeGen(
@@ -251,13 +221,3 @@ test "NumKind properties" {
251221
try std.testing.expectEqual(@as(u8, 8), NumKind.i64.byteSize());
252222
try std.testing.expectEqual(@as(u8, 16), NumKind.i128.byteSize());
253223
}
254-
255-
test "BinOp properties" {
256-
try std.testing.expect(BinOp.lt.isComparison());
257-
try std.testing.expect(BinOp.eq.isComparison());
258-
try std.testing.expect(!BinOp.add.isComparison());
259-
260-
try std.testing.expect(BinOp.@"and".isLogical());
261-
try std.testing.expect(BinOp.@"or".isLogical());
262-
try std.testing.expect(!BinOp.add.isLogical());
263-
}

src/backend/llvm/emit.zig

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,15 @@ pub const NumKind = enum {
3232
f32,
3333
f64,
3434
dec,
35-
numeral,
3635

3736
/// Compile-time validation that this enum matches the expected structure.
3837
pub fn validate() void {
3938
comptime {
4039
const fields = @typeInfo(NumKind).@"enum".fields;
41-
if (fields.len != 14) @compileError("NumKind must have exactly 14 variants");
40+
if (fields.len != 13) @compileError("NumKind must have exactly 13 variants");
4241
if (!std.mem.eql(u8, fields[0].name, "u8")) @compileError("NumKind[0] must be u8");
4342
if (!std.mem.eql(u8, fields[1].name, "i8")) @compileError("NumKind[1] must be i8");
44-
if (!std.mem.eql(u8, fields[13].name, "numeral")) @compileError("NumKind[13] must be numeral");
43+
if (!std.mem.eql(u8, fields[12].name, "dec")) @compileError("NumKind[12] must be dec");
4544
}
4645
}
4746
};
@@ -141,7 +140,6 @@ pub const LlvmEmitter = struct {
141140
.f32 => .float,
142141
.f64 => .double,
143142
.dec => .i128, // Dec is stored as i128
144-
.numeral => .i64, // Default unspecialized numeric type
145143
};
146144
}
147145

0 commit comments

Comments
 (0)