Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zig update: fix target functions #753

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/aro/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ fn generateDateAndTime(w: anytype, timestamp: u47) !void {
});

const day_names = [_][]const u8{ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
// days since Thu Oct 1 1970
const day_name = day_names[@intCast((epoch_day.day + 3) % 7)];
try w.print("#define __TIMESTAMP__ \"{s} {s} {d: >2} {d:0>2}:{d:0>2}:{d:0>2} {d}\"\n", .{
day_name,
Expand Down
6 changes: 3 additions & 3 deletions src/aro/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5753,15 +5753,15 @@ pub const Result = struct {
};
const a_spec = a.ty.canonicalize(.standard).specifier;
const b_spec = b.ty.canonicalize(.standard).specifier;
if (p.comp.target.c_type_bit_size(.longdouble) == 128) {
if (p.comp.target.cTypeBitSize(.longdouble) == 128) {
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[0])) return;
}
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[1])) return;
if (p.comp.target.c_type_bit_size(.longdouble) == 80) {
if (p.comp.target.cTypeBitSize(.longdouble) == 80) {
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[0])) return;
}
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[2])) return;
if (p.comp.target.c_type_bit_size(.longdouble) == 64) {
if (p.comp.target.cTypeBitSize(.longdouble) == 64) {
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[0])) return;
}
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[3])) return;
Expand Down
46 changes: 23 additions & 23 deletions src/aro/Type.zig
Original file line number Diff line number Diff line change
Expand Up @@ -977,19 +977,19 @@ pub fn sizeof(ty: Type, comp: *const Compilation) ?u64 {
.incomplete_array => return if (comp.langopts.emulate == .msvc) @as(?u64, 0) else null,
.func, .var_args_func, .old_style_func, .void, .bool => 1,
.char, .schar, .uchar => 1,
.short => comp.target.c_type_byte_size(.short),
.ushort => comp.target.c_type_byte_size(.ushort),
.int => comp.target.c_type_byte_size(.int),
.uint => comp.target.c_type_byte_size(.uint),
.long => comp.target.c_type_byte_size(.long),
.ulong => comp.target.c_type_byte_size(.ulong),
.long_long => comp.target.c_type_byte_size(.longlong),
.ulong_long => comp.target.c_type_byte_size(.ulonglong),
.long_double => comp.target.c_type_byte_size(.longdouble),
.short => comp.target.cTypeByteSize(.short),
.ushort => comp.target.cTypeByteSize(.ushort),
.int => comp.target.cTypeByteSize(.int),
.uint => comp.target.cTypeByteSize(.uint),
.long => comp.target.cTypeByteSize(.long),
.ulong => comp.target.cTypeByteSize(.ulong),
.long_long => comp.target.cTypeByteSize(.longlong),
.ulong_long => comp.target.cTypeByteSize(.ulonglong),
.long_double => comp.target.cTypeByteSize(.longdouble),
.int128, .uint128 => 16,
.fp16, .float16 => 2,
.float => comp.target.c_type_byte_size(.float),
.double => comp.target.c_type_byte_size(.double),
.float => comp.target.cTypeByteSize(.float),
.double => comp.target.cTypeByteSize(.double),
.float128 => 16,
.bit_int => {
return std.mem.alignForward(u64, (@as(u32, ty.data.int.bits) + 7) / 8, ty.alignof(comp));
Expand Down Expand Up @@ -1034,7 +1034,7 @@ pub fn bitSizeof(ty: Type, comp: *const Compilation) ?u64 {
.typeof_expr => ty.data.expr.ty.bitSizeof(comp),
.attributed => ty.data.attributed.base.bitSizeof(comp),
.bit_int => return ty.data.int.bits,
.long_double => comp.target.c_type_bit_size(.longdouble),
.long_double => comp.target.cTypeBitSize(.longdouble),
else => 8 * (ty.sizeof(comp) orelse return null),
};
}
Expand Down Expand Up @@ -1088,15 +1088,15 @@ pub fn alignof(ty: Type, comp: *const Compilation) u29 {
=> return ty.makeReal().alignof(comp),
// zig fmt: on

.short => comp.target.c_type_alignment(.short),
.ushort => comp.target.c_type_alignment(.ushort),
.int => comp.target.c_type_alignment(.int),
.uint => comp.target.c_type_alignment(.uint),
.short => comp.target.cTypeAlignment(.short),
.ushort => comp.target.cTypeAlignment(.ushort),
.int => comp.target.cTypeAlignment(.int),
.uint => comp.target.cTypeAlignment(.uint),

.long => comp.target.c_type_alignment(.long),
.ulong => comp.target.c_type_alignment(.ulong),
.long_long => comp.target.c_type_alignment(.longlong),
.ulong_long => comp.target.c_type_alignment(.ulonglong),
.long => comp.target.cTypeAlignment(.long),
.ulong => comp.target.cTypeAlignment(.ulong),
.long_long => comp.target.cTypeAlignment(.longlong),
.ulong_long => comp.target.cTypeAlignment(.ulonglong),

.bit_int => {
// https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2709.pdf
Expand All @@ -1108,9 +1108,9 @@ pub fn alignof(ty: Type, comp: *const Compilation) u29 {
return basic_type.alignof(comp);
},

.float => comp.target.c_type_alignment(.float),
.double => comp.target.c_type_alignment(.double),
.long_double => comp.target.c_type_alignment(.longdouble),
.float => comp.target.cTypeAlignment(.float),
.double => comp.target.cTypeAlignment(.double),
.long_double => comp.target.cTypeAlignment(.longdouble),

.int128, .uint128 => if (comp.target.cpu.arch == .s390x and comp.target.os.tag == .linux and comp.target.isGnu()) 8 else 16,
.fp16, .float16 => 2,
Expand Down
8 changes: 3 additions & 5 deletions src/aro/target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ pub const FPSemantics = enum {
/// Only intended for generating float.h macros for the preprocessor
pub fn forType(ty: std.Target.CType, target: std.Target) FPSemantics {
std.debug.assert(ty == .float or ty == .double or ty == .longdouble);
return switch (target.c_type_bit_size(ty)) {
return switch (target.cTypeBitSize(ty)) {
32 => .IEEESingle,
64 => .IEEEDouble,
80 => .x87ExtendedDouble,
Expand Down Expand Up @@ -355,7 +355,7 @@ pub const FPSemantics = enum {
};

pub fn isLP64(target: std.Target) bool {
return target.c_type_bit_size(.int) == 32 and target.ptrBitWidth() == 64;
return target.cTypeBitSize(.int) == 32 and target.ptrBitWidth() == 64;
}

pub fn isKnownWindowsMSVCEnvironment(target: std.Target) bool {
Expand Down Expand Up @@ -634,7 +634,6 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 {
.windows => "windows",
.zos => "zos",
.haiku => "haiku",
.minix => "minix",
.rtems => "rtems",
.aix => "aix",
.cuda => "cuda",
Expand All @@ -657,11 +656,10 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 {
.watchos => "watchos",
.driverkit => "driverkit",
.shadermodel => "shadermodel",
.liteos => "liteos",
.visionos => "xros",
.serenity => "serenity",
.opencl,
.glsl450,
.opengl,
.vulkan,
.plan9,
.other,
Expand Down
Loading