Skip to content

Commit ab40602

Browse files
committed
Add support for ez80-tios
1 parent feb05a7 commit ab40602

File tree

18 files changed

+229
-8
lines changed

18 files changed

+229
-8
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: 53 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
// - cheriotrtos
@@ -214,6 +216,8 @@ pub const Os = struct {
214216
.opencl,
215217
.opengl,
216218
.vulkan,
219+
220+
.tios,
217221
=> .semver,
218222

219223
.hurd => .hurd,
@@ -676,6 +680,12 @@ pub const Os = struct {
676680
.max = .{ .major = 4, .minor = 6, .patch = 0 },
677681
},
678682
},
683+
.tios => .{
684+
.semver = .{
685+
.min = .{ .major = 5, .minor = 0, .patch = 0 },
686+
.max = .{ .major = 5, .minor = 8, .patch = 4 },
687+
},
688+
},
679689
.vulkan => .{
680690
.semver = .{
681691
.min = .{ .major = 1, .minor = 2, .patch = 0 },
@@ -740,6 +750,7 @@ pub const arm = @import("Target/arm.zig");
740750
pub const avr = @import("Target/avr.zig");
741751
pub const bpf = @import("Target/bpf.zig");
742752
pub const csky = @import("Target/csky.zig");
753+
pub const ez80 = @import("Target/generic.zig");
743754
pub const hexagon = @import("Target/hexagon.zig");
744755
pub const hppa = @import("Target/generic.zig");
745756
pub const kalimba = @import("Target/generic.zig");
@@ -950,6 +961,7 @@ pub const Abi = enum {
950961
.opencl,
951962
.opengl,
952963
.vulkan,
964+
.tios,
953965
=> .none,
954966
};
955967
}
@@ -1106,6 +1118,7 @@ pub fn toElfMachine(target: *const Target) std.elf.EM {
11061118
.xcore => .XCORE,
11071119
.xtensa, .xtensaeb => .XTENSA,
11081120

1121+
.ez80,
11091122
.nvptx,
11101123
.nvptx64,
11111124
.spirv32,
@@ -1143,6 +1156,7 @@ pub fn toCoffMachine(target: *const Target) std.coff.IMAGE.FILE.MACHINE {
11431156
.bpfeb,
11441157
.bpfel,
11451158
.csky,
1159+
.ez80,
11461160
.hexagon,
11471161
.hppa,
11481162
.hppa64,
@@ -1355,6 +1369,7 @@ pub const Cpu = struct {
13551369
bpfeb,
13561370
bpfel,
13571371
csky,
1372+
ez80,
13581373
hexagon,
13591374
hppa,
13601375
hppa64,
@@ -1453,6 +1468,7 @@ pub const Cpu = struct {
14531468
x86,
14541469
xcore,
14551470
xtensa,
1471+
z80,
14561472
};
14571473

14581474
pub inline fn family(arch: Arch) Family {
@@ -1465,6 +1481,7 @@ pub const Cpu = struct {
14651481
.avr => .avr,
14661482
.bpfeb, .bpfel => .bpf,
14671483
.csky => .csky,
1484+
.ez80 => .z80,
14681485
.hexagon => .hexagon,
14691486
.hppa, .hppa64 => .hppa,
14701487
.kalimba => .kalimba,
@@ -1691,6 +1708,7 @@ pub const Cpu = struct {
16911708
.x86_64,
16921709
.xcore,
16931710
.xtensa,
1711+
.ez80,
16941712
=> .little,
16951713

16961714
.aarch64_be,
@@ -1730,13 +1748,15 @@ pub const Cpu = struct {
17301748
/// All CPU features Zig is aware of, sorted lexicographically by name.
17311749
pub fn allFeaturesList(arch: Arch) []const Cpu.Feature {
17321750
return switch (arch.family()) {
1751+
.z80 => &Target.ez80.all_features,
17331752
inline else => |f| &@field(Target, @tagName(f)).all_features,
17341753
};
17351754
}
17361755

17371756
/// All processors Zig is aware of, sorted lexicographically by name.
17381757
pub fn allCpuModels(arch: Arch) []const *const Cpu.Model {
17391758
return switch (arch.family()) {
1759+
.z80 => comptime allCpusFromDecls(Target.ez80.cpu),
17401760
inline else => |f| comptime allCpusFromDecls(@field(Target, @tagName(f)).cpu),
17411761
};
17421762
}
@@ -1951,6 +1971,10 @@ pub const Cpu = struct {
19511971
.spirv_fragment,
19521972
.spirv_vertex,
19531973
=> &.{ .spirv32, .spirv64 },
1974+
1975+
.ez80_ti,
1976+
.ez80_tiflags,
1977+
=> &.{.ez80},
19541978
};
19551979
}
19561980
};
@@ -1977,6 +2001,7 @@ pub const Cpu = struct {
19772001
return switch (arch) {
19782002
.amdgcn => &amdgcn.cpu.gfx600,
19792003
.avr => &avr.cpu.avr1,
2004+
.ez80 => &ez80.cpu.generic,
19802005
.loongarch32 => &loongarch.cpu.generic_la32,
19812006
.loongarch64 => &loongarch.cpu.generic_la64,
19822007
.mips, .mipsel => &mips.cpu.mips32,
@@ -2224,6 +2249,7 @@ pub fn requiresLibC(target: *const Target) bool {
22242249
.plan9,
22252250
.other,
22262251
.@"3ds",
2252+
.tios,
22272253
=> false,
22282254
};
22292255
}
@@ -2385,6 +2411,8 @@ pub const DynamicLinker = struct {
23852411
.ps4,
23862412
.ps5,
23872413
.vita,
2414+
2415+
.tios,
23882416
=> .none,
23892417
};
23902418
}
@@ -2802,6 +2830,8 @@ pub const DynamicLinker = struct {
28022830
.opencl,
28032831
.opengl,
28042832
.vulkan,
2833+
2834+
.tios,
28052835
=> none,
28062836

28072837
// TODO go over each item in this list and either move it to the above list, or
@@ -2835,6 +2865,9 @@ pub fn ptrBitWidth_arch_abi(cpu_arch: Cpu.Arch, abi: Abi) u16 {
28352865
.msp430,
28362866
=> 16,
28372867

2868+
.ez80,
2869+
=> 24,
2870+
28382871
.arc,
28392872
.arceb,
28402873
.arm,
@@ -2902,6 +2935,8 @@ pub fn ptrBitWidth(target: *const Target) u16 {
29022935
pub fn stackAlignment(target: *const Target) u16 {
29032936
// Overrides for when the stack alignment is not equal to the pointer width.
29042937
switch (target.cpu.arch) {
2938+
.ez80,
2939+
=> return 1,
29052940
.m68k,
29062941
=> return 2,
29072942
.amdgcn,
@@ -2981,6 +3016,7 @@ pub fn cCharSignedness(target: *const Target) std.builtin.Signedness {
29813016
.arc,
29823017
.arceb,
29833018
.csky,
3019+
.ez80,
29843020
.hexagon,
29853021
.msp430,
29863022
.powerpc,
@@ -3354,6 +3390,13 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
33543390
.long, .ulong => return 64,
33553391
.longlong, .ulonglong, .double, .longdouble => return 64,
33563392
},
3393+
.tios => switch (c_type) {
3394+
.char => return 8,
3395+
.short, .ushort => return 16,
3396+
.int, .uint => return 24,
3397+
.long, .ulong, .float, .double => return 32,
3398+
.longlong, .ulonglong, .longdouble => return 64,
3399+
},
33573400

33583401
.ps3,
33593402
.contiki,
@@ -3366,7 +3409,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
33663409
pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
33673410
// Overrides for unusual alignments
33683411
switch (target.cpu.arch) {
3369-
.avr => return 1,
3412+
.avr, .ez80 => return 1,
33703413
.x86 => switch (target.os.tag) {
33713414
.windows, .uefi => switch (c_type) {
33723415
.longlong, .ulonglong, .double => return 8,
@@ -3403,6 +3446,8 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
34033446
return @min(
34043447
std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
34053448
@as(u16, switch (target.cpu.arch) {
3449+
.ez80 => 1,
3450+
34063451
.msp430,
34073452
=> 2,
34083453

@@ -3479,7 +3524,7 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
34793524
.longdouble => return 4,
34803525
else => {},
34813526
},
3482-
.avr => return 1,
3527+
.avr, .ez80 => return 1,
34833528
.x86 => switch (target.os.tag) {
34843529
.windows, .uefi => switch (c_type) {
34853530
.longdouble => switch (target.abi) {
@@ -3511,6 +3556,8 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
35113556
return @min(
35123557
std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
35133558
@as(u16, switch (target.cpu.arch) {
3559+
.ez80 => 1,
3560+
35143561
.msp430 => 2,
35153562

35163563
.arc,
@@ -3581,7 +3628,9 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
35813628

35823629
pub fn cMaxIntAlignment(target: *const Target) u16 {
35833630
return switch (target.cpu.arch) {
3584-
.avr => 1,
3631+
.avr,
3632+
.ez80,
3633+
=> 1,
35853634

35863635
.msp430 => 2,
35873636

@@ -3717,6 +3766,7 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention
37173766
.amdgcn => .{ .amdgcn_device = .{} },
37183767
.nvptx, .nvptx64 => .nvptx_device,
37193768
.spirv32, .spirv64 => .spirv_device,
3769+
.ez80 => .ez80_ti,
37203770
};
37213771
}
37223772

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(20000);
212213
var dummy_diags: ParseOptions.Diagnostics = undefined;
213214
const diags = args.diagnostics orelse &dummy_diags;
214215

lib/std/builtin.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,10 @@ pub const CallingConvention = union(enum(u8)) {
370370
spirv_fragment,
371371
spirv_vertex,
372372

373+
// Calling conventions for the `ez80` architecture.
374+
ez80_ti,
375+
ez80_tiflags,
376+
373377
/// Options shared across most calling conventions.
374378
pub const CommonOptions = struct {
375379
/// 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: 5 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,13 @@ pub const Inst = struct {
21852185
i8_type,
21862186
u16_type,
21872187
i16_type,
2188+
u24_type,
2189+
i24_type,
21882190
u29_type,
21892191
u32_type,
21902192
i32_type,
2193+
u48_type,
2194+
i48_type,
21912195
u64_type,
21922196
i64_type,
21932197
u80_type,

0 commit comments

Comments
 (0)