authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-21 11:48:04-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-21 16:37:50-07:00
loga2d81c547ccdb1130c4f55bb736d82f97902a3dd
tree47b6b938633c1e217aa594518345ab01a786411a
parent426e737292ffb3ec1d4c5780bd3c0511d4cdbc2b

llvm: fix building for 32-bit targets


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

src/codegen/llvm/Builder.zig+11-7
......@@ -496,14 +496,14 @@ pub const Type = enum(u32) {
496496 };
497497 }
498498
499 pub fn aggregateLen(self: Type, builder: *const Builder) u64 {
499 pub fn aggregateLen(self: Type, builder: *const Builder) usize {
500500 const item = builder.type_items.items[@intFromEnum(self)];
501501 return switch (item.tag) {
502502 .vector,
503503 .scalable_vector,
504504 .small_array,
505505 => builder.typeExtraData(Type.Vector, item.data).len,
506 .array => builder.typeExtraData(Type.Array, item.data).length(),
506 .array => @intCast(builder.typeExtraData(Type.Array, item.data).length()),
507507 .structure,
508508 .packed_structure,
509509 => builder.typeExtraData(Type.Structure, item.data).fields_len,
......@@ -5158,7 +5158,7 @@ pub fn stringIfExists(self: *const Builder, bytes: []const u8) ?String {
51585158
51595159pub fn fmt(self: *Builder, comptime fmt_str: []const u8, fmt_args: anytype) Allocator.Error!String {
51605160 try self.string_map.ensureUnusedCapacity(self.gpa, 1);
5161 try self.string_bytes.ensureUnusedCapacity(self.gpa, std.fmt.count(fmt_str ++ .{0}, fmt_args));
5161 try self.string_bytes.ensureUnusedCapacity(self.gpa, @intCast(std.fmt.count(fmt_str ++ .{0}, fmt_args)));
51625162 try self.string_indices.ensureUnusedCapacity(self.gpa, 1);
51635163 return self.fmtAssumeCapacity(fmt_str, fmt_args);
51645164}
......@@ -5230,8 +5230,10 @@ pub fn structType(
52305230
52315231pub fn opaqueType(self: *Builder, name: String) Allocator.Error!Type {
52325232 try self.string_map.ensureUnusedCapacity(self.gpa, 1);
5233 if (name.toSlice(self)) |id| try self.string_bytes.ensureUnusedCapacity(self.gpa, id.len +
5234 comptime std.fmt.count("{d}" ++ .{0}, .{std.math.maxInt(u32)}));
5233 if (name.toSlice(self)) |id| {
5234 const count: usize = comptime std.fmt.count("{d}" ++ .{0}, .{std.math.maxInt(u32)});
5235 try self.string_bytes.ensureUnusedCapacity(self.gpa, id.len + count);
5236 }
52355237 try self.string_indices.ensureUnusedCapacity(self.gpa, 1);
52365238 try self.types.ensureUnusedCapacity(self.gpa, 1);
52375239 try self.next_unique_type_id.ensureUnusedCapacity(self.gpa, 1);
......@@ -6236,8 +6238,10 @@ fn isValidIdentifier(id: []const u8) bool {
62366238fn ensureUnusedGlobalCapacity(self: *Builder, name: String) Allocator.Error!void {
62376239 if (self.useLibLlvm()) try self.llvm.globals.ensureUnusedCapacity(self.gpa, 1);
62386240 try self.string_map.ensureUnusedCapacity(self.gpa, 1);
6239 if (name.toSlice(self)) |id| try self.string_bytes.ensureUnusedCapacity(self.gpa, id.len +
6240 comptime std.fmt.count("{d}" ++ .{0}, .{std.math.maxInt(u32)}));
6241 if (name.toSlice(self)) |id| {
6242 const count: usize = comptime std.fmt.count("{d}" ++ .{0}, .{std.math.maxInt(u32)});
6243 try self.string_bytes.ensureUnusedCapacity(self.gpa, id.len + count);
6244 }
62416245 try self.string_indices.ensureUnusedCapacity(self.gpa, 1);
62426246 try self.globals.ensureUnusedCapacity(self.gpa, 1);
62436247 try self.next_unique_global_id.ensureUnusedCapacity(self.gpa, 1);