Skip to content
Open
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
4 changes: 4 additions & 0 deletions lib/compiler/translate-c/Translator.zig
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,12 @@ pub const builtin_typedef_map = std.StaticStringMap([]const u8).initComptime(.{
.{ "int8_t", "i8" },
.{ "uint16_t", "u16" },
.{ "int16_t", "i16" },
.{ "uint24_t", "u24" },
.{ "int24_t", "i24" },
.{ "uint32_t", "u32" },
.{ "int32_t", "i32" },
.{ "uint48_t", "u48" },
.{ "int48_t", "i48" },
.{ "uint64_t", "u64" },
.{ "int64_t", "i64" },
.{ "intptr_t", "isize" },
Expand Down
53 changes: 50 additions & 3 deletions lib/std/Target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ pub const Os = struct {
opengl,
vulkan,

tios,

// LLVM tags deliberately omitted:
// - bridgeos
// - cheriotrtos
Expand Down Expand Up @@ -205,6 +207,8 @@ pub const Os = struct {
.opencl,
.opengl,
.vulkan,

.tios,
=> .semver,

.hurd => .hurd,
Expand Down Expand Up @@ -659,6 +663,12 @@ pub const Os = struct {
.max = .{ .major = 4, .minor = 6, .patch = 0 },
},
},
.tios => .{
.semver = .{
.min = .{ .major = 5, .minor = 0, .patch = 0 },
.max = .{ .major = 5, .minor = 8, .patch = 4 },
},
},
.vulkan => .{
.semver = .{
.min = .{ .major = 1, .minor = 2, .patch = 0 },
Expand Down Expand Up @@ -746,6 +756,7 @@ pub const wasm = @import("Target/wasm.zig");
pub const x86 = @import("Target/x86.zig");
pub const xcore = @import("Target/xcore.zig");
pub const xtensa = @import("Target/xtensa.zig");
pub const z80 = @import("Target/generic.zig");

pub const Abi = enum {
none,
Expand Down Expand Up @@ -932,6 +943,7 @@ pub const Abi = enum {
.opencl,
.opengl,
.vulkan,
.tios,
=> .none,
};
}
Expand Down Expand Up @@ -1064,6 +1076,7 @@ pub fn toElfMachine(target: *const Target) std.elf.EM {
.avr => .AVR,
.bpfeb, .bpfel => .BPF,
.csky => .CSKY,
.ez80 => .Z80,
.hexagon => .QDSP6,
.hppa, .hppa64 => .PARISC,
.kalimba => .CSR_KALIMBA,
Expand Down Expand Up @@ -1125,6 +1138,7 @@ pub fn toCoffMachine(target: *const Target) std.coff.IMAGE.FILE.MACHINE {
.bpfeb,
.bpfel,
.csky,
.ez80,
.hexagon,
.hppa,
.hppa64,
Expand Down Expand Up @@ -1338,6 +1352,7 @@ pub const Cpu = struct {
bpfeb,
bpfel,
csky,
ez80,
hexagon,
hppa,
hppa64,
Expand Down Expand Up @@ -1437,6 +1452,7 @@ pub const Cpu = struct {
x86,
xcore,
xtensa,
z80,
};

pub inline fn family(arch: Arch) Family {
Expand All @@ -1449,6 +1465,7 @@ pub const Cpu = struct {
.avr => .avr,
.bpfeb, .bpfel => .bpf,
.csky => .csky,
.ez80 => .z80,
.hexagon => .hexagon,
.hppa, .hppa64 => .hppa,
.kalimba => .kalimba,
Expand Down Expand Up @@ -1676,6 +1693,7 @@ pub const Cpu = struct {
.x86_64,
.xcore,
.xtensa,
.ez80,
=> .little,

.aarch64_be,
Expand Down Expand Up @@ -1942,6 +1960,10 @@ pub const Cpu = struct {
.spirv_fragment,
.spirv_vertex,
=> &.{ .spirv32, .spirv64 },

.ez80_cet,
.ez80_tiflags,
=> &.{.ez80},
};
}
};
Expand Down Expand Up @@ -2211,6 +2233,7 @@ pub fn requiresLibC(target: *const Target) bool {
.plan9,
.other,
.@"3ds",
.tios,
=> false,
};
}
Expand Down Expand Up @@ -2373,6 +2396,8 @@ pub const DynamicLinker = struct {
.ps4,
.ps5,
.vita,

.tios,
=> .none,
};
}
Expand Down Expand Up @@ -2782,6 +2807,8 @@ pub const DynamicLinker = struct {
.opencl,
.opengl,
.vulkan,

.tios,
=> none,

// TODO go over each item in this list and either move it to the above list, or
Expand Down Expand Up @@ -2816,6 +2843,9 @@ pub fn ptrBitWidth_arch_abi(cpu_arch: Cpu.Arch, abi: Abi) u16 {
.x86_16,
=> 16,

.ez80,
=> 24,

.arc,
.arceb,
.arm,
Expand Down Expand Up @@ -2883,6 +2913,8 @@ pub fn ptrBitWidth(target: *const Target) u16 {
pub fn stackAlignment(target: *const Target) u16 {
// Overrides for when the stack alignment is not equal to the pointer width.
switch (target.cpu.arch) {
.ez80,
=> return 1,
.m68k,
=> return 2,
.amdgcn,
Expand Down Expand Up @@ -2962,6 +2994,7 @@ pub fn cCharSignedness(target: *const Target) std.builtin.Signedness {
.arc,
.arceb,
.csky,
.ez80,
.hexagon,
.msp430,
.powerpc,
Expand Down Expand Up @@ -3333,6 +3366,13 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
.long, .ulong => return 64,
.longlong, .ulonglong, .double, .longdouble => return 64,
},
.tios => switch (c_type) {
.char => return 8,
.short, .ushort => return 16,
.int, .uint => return 24,
.long, .ulong, .float, .double => return 32,
.longlong, .ulonglong, .longdouble => return 64,
},

.ps3,
.contiki,
Expand All @@ -3345,7 +3385,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
// Overrides for unusual alignments
switch (target.cpu.arch) {
.avr => return 1,
.avr, .ez80 => return 1,
.x86 => switch (target.os.tag) {
.windows, .uefi => switch (c_type) {
.longlong, .ulonglong, .double => return 8,
Expand Down Expand Up @@ -3382,6 +3422,8 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
return @min(
std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
@as(u16, switch (target.cpu.arch) {
.ez80 => 1,

.msp430,
.x86_16,
=> 2,
Expand Down Expand Up @@ -3459,7 +3501,7 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
.longdouble => return 4,
else => {},
},
.avr => return 1,
.avr, .ez80 => return 1,
.x86 => switch (target.os.tag) {
.windows, .uefi => switch (c_type) {
.longdouble => switch (target.abi) {
Expand Down Expand Up @@ -3491,6 +3533,8 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
return @min(
std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
@as(u16, switch (target.cpu.arch) {
.ez80 => 1,

.x86_16, .msp430 => 2,

.arc,
Expand Down Expand Up @@ -3561,7 +3605,9 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {

pub fn cMaxIntAlignment(target: *const Target) u16 {
return switch (target.cpu.arch) {
.avr => 1,
.avr,
.ez80,
=> 1,

.msp430, .x86_16 => 2,

Expand Down Expand Up @@ -3698,6 +3744,7 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention
.amdgcn => .{ .amdgcn_device = .{} },
.nvptx, .nvptx64 => .nvptx_device,
.spirv32, .spirv64 => .spirv_device,
.ez80 => .ez80_cet,
};
}

Expand Down
4 changes: 4 additions & 0 deletions lib/std/builtin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,10 @@ pub const CallingConvention = union(enum(u8)) {
spirv_fragment,
spirv_vertex,

// Calling conventions for the `ez80` architecture.
ez80_cet,
ez80_tiflags,

/// Options shared across most calling conventions.
pub const CommonOptions = struct {
/// The boundary the stack is aligned to when the function is called.
Expand Down
4 changes: 4 additions & 0 deletions lib/std/zig/target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,10 @@ pub fn intAlignment(target: *const std.Target, bits: u16) u16 {
33...64 => 8,
else => 16,
},
.ez80 => switch (bits) {
0 => 0,
else => 1,
},
else => return @min(
std.math.ceilPowerOfTwoPromote(u16, @as(u16, @intCast((@as(u17, bits) + 7) / 8))),
target.cMaxIntAlignment(),
Expand Down
Loading