stage2: move most simple values to InternPool

This commit is contained in:
Andrew Kelley
2023-05-03 19:12:53 -07:00
parent 836d8a1f64
commit ca3cf93b21
12 changed files with 524 additions and 746 deletions

View File

@@ -1191,7 +1191,7 @@ pub const DeclGen = struct {
}
},
.Bool => {
if (val.toBool()) {
if (val.toBool(mod)) {
return writer.writeAll("true");
} else {
return writer.writeAll("false");

View File

@@ -2793,7 +2793,7 @@ pub const DeclGen = struct {
if (std.debug.runtime_safety and false) check: {
if (t.zigTypeTag(mod) == .Opaque) break :check;
if (!t.hasRuntimeBits(mod)) break :check;
if (!llvm_ty.isSized().toBool()) break :check;
if (!llvm_ty.isSized().toBool(mod)) break :check;
const zig_size = t.abiSize(mod);
const llvm_size = dg.object.target_data.abiSizeOfType(llvm_ty);
@@ -3272,7 +3272,7 @@ pub const DeclGen = struct {
switch (tv.ty.zigTypeTag(mod)) {
.Bool => {
const llvm_type = try dg.lowerType(tv.ty);
return if (tv.val.toBool()) llvm_type.constAllOnes() else llvm_type.constNull();
return if (tv.val.toBool(mod)) llvm_type.constAllOnes() else llvm_type.constNull();
},
// TODO this duplicates code with Pointer but they should share the handling
// of the tv.val.tag() and then Int should do extra constPtrToInt on top

View File

@@ -621,7 +621,7 @@ pub const DeclGen = struct {
switch (ty.zigTypeTag(mod)) {
.Int => try self.addInt(ty, val),
.Float => try self.addFloat(ty, val),
.Bool => try self.addConstBool(val.toBool()),
.Bool => try self.addConstBool(val.toBool(mod)),
.Array => switch (val.tag()) {
.aggregate => {
const elem_vals = val.castTag(.aggregate).?.data;
@@ -989,8 +989,8 @@ pub const DeclGen = struct {
}
},
.Bool => switch (repr) {
.direct => return try self.spv.constBool(result_ty_ref, val.toBool()),
.indirect => return try self.spv.constInt(result_ty_ref, @boolToInt(val.toBool())),
.direct => return try self.spv.constBool(result_ty_ref, val.toBool(mod)),
.indirect => return try self.spv.constInt(result_ty_ref, @boolToInt(val.toBool(mod))),
},
.Float => return switch (ty.floatBits(target)) {
16 => try self.spv.resolveId(.{ .float = .{ .ty = result_ty_ref, .value = .{ .float16 = val.toFloat(f16) } } }),