Skip to content

Commit 7a4b1ac

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

File tree

18 files changed

+310
-7
lines changed

18 files changed

+310
-7
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: 57 additions & 4 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 = 3 },
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/ez80.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,
@@ -1134,7 +1147,6 @@ pub fn toCoffMachine(target: *const Target) std.coff.IMAGE.FILE.MACHINE {
11341147
.x86 => .I386,
11351148
.x86_64 => .AMD64,
11361149

1137-
.aarch64_be,
11381150
.amdgcn,
11391151
.arc,
11401152
.arceb,
@@ -1143,6 +1155,7 @@ pub fn toCoffMachine(target: *const Target) std.coff.IMAGE.FILE.MACHINE {
11431155
.bpfeb,
11441156
.bpfel,
11451157
.csky,
1158+
.ez80,
11461159
.hexagon,
11471160
.hppa,
11481161
.hppa64,
@@ -1355,6 +1368,7 @@ pub const Cpu = struct {
13551368
bpfeb,
13561369
bpfel,
13571370
csky,
1371+
ez80,
13581372
hexagon,
13591373
hppa,
13601374
hppa64,
@@ -1430,6 +1444,7 @@ pub const Cpu = struct {
14301444
avr,
14311445
bpf,
14321446
csky,
1447+
ez80,
14331448
hexagon,
14341449
hppa,
14351450
kalimba,
@@ -1465,6 +1480,7 @@ pub const Cpu = struct {
14651480
.avr => .avr,
14661481
.bpfeb, .bpfel => .bpf,
14671482
.csky => .csky,
1483+
.ez80 => .ez80,
14681484
.hexagon => .hexagon,
14691485
.hppa, .hppa64 => .hppa,
14701486
.kalimba => .kalimba,
@@ -1691,6 +1707,14 @@ pub const Cpu = struct {
16911707
.x86_64,
16921708
.xcore,
16931709
.xtensa,
1710+
// GPU bitness is opaque. For now, assume little endian.
1711+
.spirv32,
1712+
.spirv64,
1713+
.loongarch32,
1714+
.loongarch64,
1715+
.arc,
1716+
.propeller,
1717+
.ez80,
16941718
=> .little,
16951719

16961720
.aarch64_be,
@@ -1951,6 +1975,10 @@ pub const Cpu = struct {
19511975
.spirv_fragment,
19521976
.spirv_vertex,
19531977
=> &.{ .spirv32, .spirv64 },
1978+
1979+
.ez80_sysv,
1980+
.ez80_tiflags,
1981+
=> &.{.ez80},
19541982
};
19551983
}
19561984
};
@@ -2224,6 +2252,7 @@ pub fn requiresLibC(target: *const Target) bool {
22242252
.plan9,
22252253
.other,
22262254
.@"3ds",
2255+
.tios,
22272256
=> false,
22282257
};
22292258
}
@@ -2385,6 +2414,8 @@ pub const DynamicLinker = struct {
23852414
.ps4,
23862415
.ps5,
23872416
.vita,
2417+
2418+
.tios,
23882419
=> .none,
23892420
};
23902421
}
@@ -2802,6 +2833,8 @@ pub const DynamicLinker = struct {
28022833
.opencl,
28032834
.opengl,
28042835
.vulkan,
2836+
2837+
.tios,
28052838
=> none,
28062839

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

2871+
.ez80,
2872+
=> 24,
2873+
28382874
.arc,
28392875
.arceb,
28402876
.arm,
@@ -2902,6 +2938,8 @@ pub fn ptrBitWidth(target: *const Target) u16 {
29022938
pub fn stackAlignment(target: *const Target) u16 {
29032939
// Overrides for when the stack alignment is not equal to the pointer width.
29042940
switch (target.cpu.arch) {
2941+
.ez80,
2942+
=> return 1,
29052943
.m68k,
29062944
=> return 2,
29072945
.amdgcn,
@@ -2981,6 +3019,7 @@ pub fn cCharSignedness(target: *const Target) std.builtin.Signedness {
29813019
.arc,
29823020
.arceb,
29833021
.csky,
3022+
.ez80,
29843023
.hexagon,
29853024
.msp430,
29863025
.powerpc,
@@ -3354,6 +3393,13 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
33543393
.long, .ulong => return 64,
33553394
.longlong, .ulonglong, .double, .longdouble => return 64,
33563395
},
3396+
.tios => switch (c_type) {
3397+
.char => return 8,
3398+
.short, .ushort => return 16,
3399+
.int, .uint => return 24,
3400+
.long, .ulong, .float, .double => return 32,
3401+
.longlong, .ulonglong, .longdouble => return 64,
3402+
},
33573403

33583404
.ps3,
33593405
.contiki,
@@ -3366,7 +3412,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
33663412
pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
33673413
// Overrides for unusual alignments
33683414
switch (target.cpu.arch) {
3369-
.avr => return 1,
3415+
.avr, .ez80 => return 1,
33703416
.x86 => switch (target.os.tag) {
33713417
.windows, .uefi => switch (c_type) {
33723418
.longlong, .ulonglong, .double => return 8,
@@ -3403,6 +3449,8 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
34033449
return @min(
34043450
std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
34053451
@as(u16, switch (target.cpu.arch) {
3452+
.ez80 => 1,
3453+
34063454
.msp430,
34073455
=> 2,
34083456

@@ -3479,7 +3527,7 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
34793527
.longdouble => return 4,
34803528
else => {},
34813529
},
3482-
.avr => return 1,
3530+
.avr, .ez80 => return 1,
34833531
.x86 => switch (target.os.tag) {
34843532
.windows, .uefi => switch (c_type) {
34853533
.longdouble => switch (target.abi) {
@@ -3511,6 +3559,8 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
35113559
return @min(
35123560
std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
35133561
@as(u16, switch (target.cpu.arch) {
3562+
.ez80 => 1,
3563+
35143564
.msp430 => 2,
35153565

35163566
.arc,
@@ -3581,7 +3631,9 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
35813631

35823632
pub fn cMaxIntAlignment(target: *const Target) u16 {
35833633
return switch (target.cpu.arch) {
3584-
.avr => 1,
3634+
.avr,
3635+
.ez80,
3636+
=> 1,
35853637

35863638
.msp430 => 2,
35873639

@@ -3717,6 +3769,7 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention
37173769
.amdgcn => .{ .amdgcn_device = .{} },
37183770
.nvptx, .nvptx64 => .nvptx_device,
37193771
.spirv32, .spirv64 => .spirv_device,
3772+
.ez80 => .ez80_sysv,
37203773
};
37213774
}
37223775

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

0 commit comments

Comments
 (0)