Skip to content

Commit 97ff232

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

File tree

18 files changed

+226
-8
lines changed

18 files changed

+226
-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: 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
// - 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,
@@ -1430,6 +1445,7 @@ pub const Cpu = struct {
14301445
avr,
14311446
bpf,
14321447
csky,
1448+
ez80,
14331449
hexagon,
14341450
hppa,
14351451
kalimba,
@@ -1465,6 +1481,7 @@ pub const Cpu = struct {
14651481
.avr => .avr,
14661482
.bpfeb, .bpfel => .bpf,
14671483
.csky => .csky,
1484+
.ez80 => .ez80,
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,
@@ -1951,6 +1969,10 @@ pub const Cpu = struct {
19511969
.spirv_fragment,
19521970
.spirv_vertex,
19531971
=> &.{ .spirv32, .spirv64 },
1972+
1973+
.ez80_sysv,
1974+
.ez80_tiflags,
1975+
=> &.{.ez80},
19541976
};
19551977
}
19561978
};
@@ -2224,6 +2246,7 @@ pub fn requiresLibC(target: *const Target) bool {
22242246
.plan9,
22252247
.other,
22262248
.@"3ds",
2249+
.tios,
22272250
=> false,
22282251
};
22292252
}
@@ -2385,6 +2408,8 @@ pub const DynamicLinker = struct {
23852408
.ps4,
23862409
.ps5,
23872410
.vita,
2411+
2412+
.tios,
23882413
=> .none,
23892414
};
23902415
}
@@ -2802,6 +2827,8 @@ pub const DynamicLinker = struct {
28022827
.opencl,
28032828
.opengl,
28042829
.vulkan,
2830+
2831+
.tios,
28052832
=> none,
28062833

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

2865+
.ez80,
2866+
=> 24,
2867+
28382868
.arc,
28392869
.arceb,
28402870
.arm,
@@ -2902,6 +2932,8 @@ pub fn ptrBitWidth(target: *const Target) u16 {
29022932
pub fn stackAlignment(target: *const Target) u16 {
29032933
// Overrides for when the stack alignment is not equal to the pointer width.
29042934
switch (target.cpu.arch) {
2935+
.ez80,
2936+
=> return 1,
29052937
.m68k,
29062938
=> return 2,
29072939
.amdgcn,
@@ -2981,6 +3013,7 @@ pub fn cCharSignedness(target: *const Target) std.builtin.Signedness {
29813013
.arc,
29823014
.arceb,
29833015
.csky,
3016+
.ez80,
29843017
.hexagon,
29853018
.msp430,
29863019
.powerpc,
@@ -3354,6 +3387,13 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
33543387
.long, .ulong => return 64,
33553388
.longlong, .ulonglong, .double, .longdouble => return 64,
33563389
},
3390+
.tios => switch (c_type) {
3391+
.char => return 8,
3392+
.short, .ushort => return 16,
3393+
.int, .uint => return 24,
3394+
.long, .ulong, .float, .double => return 32,
3395+
.longlong, .ulonglong, .longdouble => return 64,
3396+
},
33573397

33583398
.ps3,
33593399
.contiki,
@@ -3366,7 +3406,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
33663406
pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
33673407
// Overrides for unusual alignments
33683408
switch (target.cpu.arch) {
3369-
.avr => return 1,
3409+
.avr, .ez80 => return 1,
33703410
.x86 => switch (target.os.tag) {
33713411
.windows, .uefi => switch (c_type) {
33723412
.longlong, .ulonglong, .double => return 8,
@@ -3403,6 +3443,8 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
34033443
return @min(
34043444
std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
34053445
@as(u16, switch (target.cpu.arch) {
3446+
.ez80 => 1,
3447+
34063448
.msp430,
34073449
=> 2,
34083450

@@ -3479,7 +3521,7 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
34793521
.longdouble => return 4,
34803522
else => {},
34813523
},
3482-
.avr => return 1,
3524+
.avr, .ez80 => return 1,
34833525
.x86 => switch (target.os.tag) {
34843526
.windows, .uefi => switch (c_type) {
34853527
.longdouble => switch (target.abi) {
@@ -3511,6 +3553,8 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
35113553
return @min(
35123554
std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
35133555
@as(u16, switch (target.cpu.arch) {
3556+
.ez80 => 1,
3557+
35143558
.msp430 => 2,
35153559

35163560
.arc,
@@ -3581,7 +3625,9 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
35813625

35823626
pub fn cMaxIntAlignment(target: *const Target) u16 {
35833627
return switch (target.cpu.arch) {
3584-
.avr => 1,
3628+
.avr,
3629+
.ez80,
3630+
=> 1,
35853631

35863632
.msp430 => 2,
35873633

@@ -3717,6 +3763,7 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention
37173763
.amdgcn => .{ .amdgcn_device = .{} },
37183764
.nvptx, .nvptx64 => .nvptx_device,
37193765
.spirv32, .spirv64 => .spirv_device,
3766+
.ez80 => .ez80_sysv,
37203767
};
37213768
}
37223769

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_sysv,
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)