Skip to content

Commit ecbec92

Browse files
committed
Add support for ez80-tios
1 parent dbf9c7b commit ecbec92

File tree

18 files changed

+253
-6
lines changed

18 files changed

+253
-6
lines changed

lib/compiler/translate-c/Translator.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,12 @@ pub const builtin_typedef_map = std.StaticStringMap([]const u8).initComptime(.{
378378
.{ "int8_t", "i8" },
379379
.{ "uint16_t", "u16" },
380380
.{ "int16_t", "i16" },
381+
.{ "uint24_t", "u24" },
382+
.{ "int24_t", "i24" },
381383
.{ "uint32_t", "u32" },
382384
.{ "int32_t", "i32" },
385+
.{ "uint48_t", "u48" },
386+
.{ "int48_t", "i48" },
383387
.{ "uint64_t", "u64" },
384388
.{ "int64_t", "i64" },
385389
.{ "intptr_t", "isize" },

lib/std/Target.zig

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ pub const Os = struct {
7070
opengl,
7171
vulkan,
7272

73+
tios,
74+
7375
// LLVM tags deliberately omitted:
7476
// - bridgeos
7577
// - darwin
@@ -213,6 +215,8 @@ pub const Os = struct {
213215
.opencl,
214216
.opengl,
215217
.vulkan,
218+
219+
.tios,
216220
=> .semver,
217221

218222
.hurd => .hurd,
@@ -675,6 +679,12 @@ pub const Os = struct {
675679
.max = .{ .major = 4, .minor = 6, .patch = 0 },
676680
},
677681
},
682+
.tios => .{
683+
.semver = .{
684+
.min = .{ .major = 5, .minor = 0, .patch = 0 },
685+
.max = .{ .major = 5, .minor = 8, .patch = 3 },
686+
},
687+
},
678688
.vulkan => .{
679689
.semver = .{
680690
.min = .{ .major = 1, .minor = 2, .patch = 0 },
@@ -738,6 +748,7 @@ pub const arm = @import("Target/arm.zig");
738748
pub const avr = @import("Target/avr.zig");
739749
pub const bpf = @import("Target/bpf.zig");
740750
pub const csky = @import("Target/csky.zig");
751+
pub const ez80 = @import("Target/ez80.zig");
741752
pub const hexagon = @import("Target/hexagon.zig");
742753
pub const kalimba = @import("Target/generic.zig");
743754
pub const lanai = @import("Target/lanai.zig");
@@ -920,6 +931,7 @@ pub const Abi = enum {
920931
.opencl,
921932
.opengl,
922933
.vulkan,
934+
.tios,
923935
=> .none,
924936
};
925937
}
@@ -1072,6 +1084,7 @@ pub fn toElfMachine(target: *const Target) std.elf.EM {
10721084
.xcore => .XCORE,
10731085
.xtensa => .XTENSA,
10741086

1087+
.ez80,
10751088
.nvptx,
10761089
.nvptx64,
10771090
.spirv32,
@@ -1094,6 +1107,7 @@ pub fn toCoffMachine(target: *const Target) std.coff.IMAGE.FILE.MACHINE {
10941107
.x86 => .I386,
10951108
.x86_64 => .AMD64,
10961109

1110+
.ez80,
10971111
.amdgcn,
10981112
.arc,
10991113
.armeb,
@@ -1312,6 +1326,7 @@ pub const Cpu = struct {
13121326
bpfel,
13131327
bpfeb,
13141328
csky,
1329+
ez80,
13151330
hexagon,
13161331
kalimba,
13171332
lanai,
@@ -1379,6 +1394,7 @@ pub const Cpu = struct {
13791394
avr,
13801395
bpf,
13811396
csky,
1397+
ez80,
13821398
hexagon,
13831399
kalimba,
13841400
lanai,
@@ -1410,6 +1426,7 @@ pub const Cpu = struct {
14101426
.avr => .avr,
14111427
.bpfel, .bpfeb => .bpf,
14121428
.csky => .csky,
1429+
.ez80 => .ez80,
14131430
.hexagon => .hexagon,
14141431
.kalimba => .kalimba,
14151432
.lanai => .lanai,
@@ -1601,6 +1618,7 @@ pub const Cpu = struct {
16011618
.loongarch64,
16021619
.arc,
16031620
.propeller,
1621+
.ez80,
16041622
=> .little,
16051623

16061624
.armeb,
@@ -1827,6 +1845,10 @@ pub const Cpu = struct {
18271845
.spirv_fragment,
18281846
.spirv_vertex,
18291847
=> &.{ .spirv32, .spirv64 },
1848+
1849+
.ez80_sysv,
1850+
.ez80_tiflags,
1851+
=> &.{.ez80},
18301852
};
18311853
}
18321854
};
@@ -2100,6 +2122,7 @@ pub fn requiresLibC(target: *const Target) bool {
21002122
.plan9,
21012123
.other,
21022124
.@"3ds",
2125+
.tios,
21032126
=> false,
21042127
};
21052128
}
@@ -2246,6 +2269,8 @@ pub const DynamicLinker = struct {
22462269
.ps4,
22472270
.ps5,
22482271
.vita,
2272+
2273+
.tios,
22492274
=> .none,
22502275
};
22512276
}
@@ -2630,6 +2655,8 @@ pub const DynamicLinker = struct {
26302655
.opencl,
26312656
.opengl,
26322657
.vulkan,
2658+
2659+
.tios,
26332660
=> none,
26342661

26352662
// TODO go over each item in this list and either move it to the above list, or
@@ -2663,6 +2690,9 @@ pub fn ptrBitWidth_arch_abi(cpu_arch: Cpu.Arch, abi: Abi) u16 {
26632690
.msp430,
26642691
=> 16,
26652692

2693+
.ez80,
2694+
=> 24,
2695+
26662696
.arc,
26672697
.arm,
26682698
.armeb,
@@ -2721,6 +2751,8 @@ pub fn ptrBitWidth(target: *const Target) u16 {
27212751
pub fn stackAlignment(target: *const Target) u16 {
27222752
// Overrides for when the stack alignment is not equal to the pointer width.
27232753
switch (target.cpu.arch) {
2754+
.ez80,
2755+
=> return 1,
27242756
.m68k,
27252757
=> return 2,
27262758
.amdgcn,
@@ -2780,6 +2812,7 @@ pub fn cCharSignedness(target: *const Target) std.builtin.Signedness {
27802812
.aarch64_be,
27812813
.arc,
27822814
.csky,
2815+
.ez80,
27832816
.hexagon,
27842817
.msp430,
27852818
.powerpc,
@@ -3160,6 +3193,13 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
31603193
.long, .ulong => return 64,
31613194
.longlong, .ulonglong, .double, .longdouble => return 64,
31623195
},
3196+
.tios => switch (c_type) {
3197+
.char => return 8,
3198+
.short, .ushort => return 16,
3199+
.int, .uint => return 24,
3200+
.long, .ulong, .float, .double => return 32,
3201+
.longlong, .ulonglong, .longdouble => return 64,
3202+
},
31633203

31643204
.ps3,
31653205
.contiki,
@@ -3172,7 +3212,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
31723212
pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
31733213
// Overrides for unusual alignments
31743214
switch (target.cpu.arch) {
3175-
.avr => return 1,
3215+
.avr, .ez80 => return 1,
31763216
.x86 => switch (target.os.tag) {
31773217
.windows, .uefi => switch (c_type) {
31783218
.longlong, .ulonglong, .double => return 8,
@@ -3209,6 +3249,8 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
32093249
return @min(
32103250
std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
32113251
@as(u16, switch (target.cpu.arch) {
3252+
.ez80 => 1,
3253+
32123254
.msp430,
32133255
=> 2,
32143256

@@ -3276,7 +3318,7 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
32763318
.longdouble => return 4,
32773319
else => {},
32783320
},
3279-
.avr => return 1,
3321+
.avr, .ez80 => return 1,
32803322
.x86 => switch (target.os.tag) {
32813323
.windows, .uefi => switch (c_type) {
32823324
.longdouble => switch (target.abi) {
@@ -3308,6 +3350,8 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
33083350
return @min(
33093351
std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
33103352
@as(u16, switch (target.cpu.arch) {
3353+
.ez80 => 1,
3354+
33113355
.msp430 => 2,
33123356

33133357
.csky,
@@ -3369,7 +3413,9 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
33693413

33703414
pub fn cMaxIntAlignment(target: *const Target) u16 {
33713415
return switch (target.cpu.arch) {
3372-
.avr => 1,
3416+
.avr,
3417+
.ez80,
3418+
=> 1,
33733419

33743420
.msp430 => 2,
33753421

@@ -3493,6 +3539,7 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention
34933539
.amdgcn => .{ .amdgcn_device = .{} },
34943540
.nvptx, .nvptx64 => .nvptx_device,
34953541
.spirv32, .spirv64 => .spirv_device,
3542+
.ez80 => .ez80_sysv,
34963543
};
34973544
}
34983545

lib/std/Target/Query.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ pub const ParseOptions = struct {
209209
};
210210

211211
pub fn parse(args: ParseOptions) !Query {
212+
@setEvalBranchQuota(21000);
212213
var dummy_diags: ParseOptions.Diagnostics = undefined;
213214
const diags = args.diagnostics orelse &dummy_diags;
214215

lib/std/Target/ez80.zig

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const std = @import("../std.zig");
2+
const CpuFeature = std.Target.Cpu.Feature;
3+
const CpuModel = std.Target.Cpu.Model;
4+
5+
pub const Feature = enum {};
6+
7+
pub const featureSet = CpuFeature.FeatureSetFns(Feature).featureSet;
8+
pub const featureSetHas = CpuFeature.FeatureSetFns(Feature).featureSetHas;
9+
pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
10+
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
11+
12+
pub const all_features = blk: {
13+
const len = @typeInfo(Feature).@"enum".fields.len;
14+
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
15+
var result: [len]CpuFeature = undefined;
16+
const ti = @typeInfo(Feature);
17+
for (&result, 0..) |*elem, i| {
18+
elem.index = i;
19+
elem.name = ti.@"enum".fields[i].name;
20+
}
21+
break :blk result;
22+
};
23+
24+
pub const cpu = struct {
25+
pub const generic: CpuModel = .{
26+
.name = "generic",
27+
.llvm_name = null,
28+
.features = featureSet(&.{}),
29+
};
30+
};

lib/std/builtin.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ pub const CallingConvention = union(enum(u8)) {
350350
spirv_fragment,
351351
spirv_vertex,
352352

353+
// Calling conventions for the `ez80` architecture.
354+
ez80_sysv,
355+
ez80_tiflags,
356+
353357
/// Options shared across most calling conventions.
354358
pub const CommonOptions = struct {
355359
/// The boundary the stack is aligned to when the function is called.

lib/std/zig/AstGen.zig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10300,7 +10300,9 @@ const primitive_instrs = std.StaticStringMap(Zir.Inst.Ref).initComptime(.{
1030010300
.{ "f80", .f80_type },
1030110301
.{ "false", .bool_false },
1030210302
.{ "i16", .i16_type },
10303+
.{ "i24", .i24_type },
1030310304
.{ "i32", .i32_type },
10305+
.{ "i48", .i48_type },
1030410306
.{ "i64", .i64_type },
1030510307
.{ "i128", .i128_type },
1030610308
.{ "i8", .i8_type },
@@ -10310,8 +10312,10 @@ const primitive_instrs = std.StaticStringMap(Zir.Inst.Ref).initComptime(.{
1031010312
.{ "true", .bool_true },
1031110313
.{ "type", .type_type },
1031210314
.{ "u16", .u16_type },
10315+
.{ "u24", .u24_type },
1031310316
.{ "u29", .u29_type },
1031410317
.{ "u32", .u32_type },
10318+
.{ "u48", .u48_type },
1031510319
.{ "u64", .u64_type },
1031610320
.{ "u128", .u128_type },
1031710321
.{ "u1", .u1_type },
@@ -10789,15 +10793,19 @@ fn nodeImpliesMoreThanOnePossibleValue(tree: *const Ast, start_node: Ast.Node.In
1078910793
.f80_type,
1079010794
.f128_type,
1079110795
.i16_type,
10796+
.i24_type,
1079210797
.i32_type,
10798+
.i48_type,
1079310799
.i64_type,
1079410800
.i128_type,
1079510801
.i8_type,
1079610802
.isize_type,
1079710803
.type_type,
1079810804
.u16_type,
10805+
.u24_type,
1079910806
.u29_type,
1080010807
.u32_type,
10808+
.u48_type,
1080110809
.u64_type,
1080210810
.u128_type,
1080310811
.u1_type,
@@ -11026,14 +11034,18 @@ fn nodeImpliesComptimeOnly(tree: *const Ast, start_node: Ast.Node.Index) bool {
1102611034
.f80_type,
1102711035
.f128_type,
1102811036
.i16_type,
11037+
.i24_type,
1102911038
.i32_type,
11039+
.i48_type,
1103011040
.i64_type,
1103111041
.i128_type,
1103211042
.i8_type,
1103311043
.isize_type,
1103411044
.u16_type,
11045+
.u24_type,
1103511046
.u29_type,
1103611047
.u32_type,
11048+
.u48_type,
1103711049
.u64_type,
1103811050
.u128_type,
1103911051
.u1_type,
@@ -11152,8 +11164,12 @@ fn rvalueInner(
1115211164
as_ty | @intFromEnum(Zir.Inst.Ref.u16_type),
1115311165
as_ty | @intFromEnum(Zir.Inst.Ref.u29_type),
1115411166
as_ty | @intFromEnum(Zir.Inst.Ref.i16_type),
11167+
as_ty | @intFromEnum(Zir.Inst.Ref.u24_type),
11168+
as_ty | @intFromEnum(Zir.Inst.Ref.i24_type),
1115511169
as_ty | @intFromEnum(Zir.Inst.Ref.u32_type),
1115611170
as_ty | @intFromEnum(Zir.Inst.Ref.i32_type),
11171+
as_ty | @intFromEnum(Zir.Inst.Ref.u48_type),
11172+
as_ty | @intFromEnum(Zir.Inst.Ref.i48_type),
1115711173
as_ty | @intFromEnum(Zir.Inst.Ref.u64_type),
1115811174
as_ty | @intFromEnum(Zir.Inst.Ref.i64_type),
1115911175
as_ty | @intFromEnum(Zir.Inst.Ref.u128_type),

lib/std/zig/Zir.zig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2145,7 +2145,7 @@ pub const Inst = struct {
21452145
ref_start_index = static_len,
21462146
_,
21472147

2148-
pub const static_len = 124;
2148+
pub const static_len = 128;
21492149

21502150
pub fn toRef(i: Index) Inst.Ref {
21512151
return @enumFromInt(@intFromEnum(Index.ref_start_index) + @intFromEnum(i));
@@ -2185,9 +2185,17 @@ pub const Inst = struct {
21852185
i8_type,
21862186
u16_type,
21872187
i16_type,
2188+
/// It is IB to use this type on non-ez80 targets.
2189+
u24_type,
2190+
/// It is IB to use this type on non-ez80 targets.
2191+
i24_type,
21882192
u29_type,
21892193
u32_type,
21902194
i32_type,
2195+
/// It is IB to use this type on non-ez80 targets.
2196+
u48_type,
2197+
/// It is IB to use this type on non-ez80 targets.
2198+
i48_type,
21912199
u64_type,
21922200
i64_type,
21932201
u80_type,

0 commit comments

Comments
 (0)