authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-05-02 21:32:14+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-05-03 11:22:27+02:00
logbf9b15ee67fb7577e30d66fda879b8af84f84b54
treec9f386546942e61d3d76dcd51100b8a24a6a0935
parentc0ec264f756476484051f9d16ac7bc20c0a45723

std.Target: Add Cpu.Arch.or1k and basic target info.


10 files changed, 30 insertions(+), 8 deletions(-)

lib/std/Target.zig+13
......@@ -1079,6 +1079,7 @@ pub fn toElfMachine(target: Target) std.elf.EM {
10791079 .m68k => .@"68K",
10801080 .mips, .mips64, .mipsel, .mips64el => .MIPS,
10811081 .msp430 => .MSP430,
1082 .or1k => .OR1K,
10821083 .powerpc, .powerpcle => .PPC,
10831084 .powerpc64, .powerpc64le => .PPC64,
10841085 .propeller => .PROPELLER,
......@@ -1133,6 +1134,7 @@ pub fn toCoffMachine(target: Target) std.coff.MachineType {
11331134 .mips64,
11341135 .mips64el,
11351136 .msp430,
1137 .or1k,
11361138 .nvptx,
11371139 .nvptx64,
11381140 .powerpc,
......@@ -1357,6 +1359,7 @@ pub const Cpu = struct {
13571359 mips64,
13581360 mips64el,
13591361 msp430,
1362 or1k,
13601363 nvptx,
13611364 nvptx64,
13621365 powerpc,
......@@ -1565,6 +1568,7 @@ pub const Cpu = struct {
15651568 .m68k,
15661569 .mips,
15671570 .mips64,
1571 .or1k,
15681572 .powerpc,
15691573 .powerpc64,
15701574 .thumbeb,
......@@ -1815,6 +1819,9 @@ pub const Cpu = struct {
18151819 .msp430_eabi,
18161820 => &.{.msp430},
18171821
1822 .or1k_sysv,
1823 => &.{.or1k},
1824
18181825 .propeller_sysv,
18191826 => &.{.propeller},
18201827
......@@ -1911,6 +1918,7 @@ pub const Cpu = struct {
19111918 .xtensa => &xtensa.cpu.generic,
19121919
19131920 .kalimba,
1921 .or1k,
19141922 => &S.generic_model,
19151923 };
19161924 }
......@@ -2598,6 +2606,7 @@ pub fn ptrBitWidth_cpu_abi(cpu: Cpu, abi: Abi) u16 {
25982606 .m68k,
25992607 .mips,
26002608 .mipsel,
2609 .or1k,
26012610 .powerpc,
26022611 .powerpcle,
26032612 .riscv32,
......@@ -3114,6 +3123,7 @@ pub fn cTypeAlignment(target: Target, c_type: CType) u16 {
31143123 .csky,
31153124 .x86,
31163125 .xcore,
3126 .or1k,
31173127 .kalimba,
31183128 .xtensa,
31193129 .propeller,
......@@ -3204,6 +3214,7 @@ pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 {
32043214
32053215 .csky,
32063216 .xcore,
3217 .or1k,
32073218 .kalimba,
32083219 .xtensa,
32093220 .propeller,
......@@ -3276,6 +3287,7 @@ pub fn cMaxIntAlignment(target: std.Target) u16 {
32763287 .hexagon,
32773288 .mips,
32783289 .mipsel,
3290 .or1k,
32793291 .powerpc,
32803292 .powerpcle,
32813293 .riscv32,
......@@ -3372,6 +3384,7 @@ pub fn cCallingConvention(target: Target) ?std.builtin.CallingConvention {
33723384 else
33733385 .{ .m68k_sysv = .{} },
33743386 .msp430 => .{ .msp430_eabi = .{} },
3387 .or1k => .{ .or1k_sysv = .{} },
33753388 .propeller => .{ .propeller_sysv = .{} },
33763389 .s390x => .{ .s390x_sysv = .{} },
33773390 .ve => .{ .ve_sysv = .{} },
lib/std/builtin.zig+3
......@@ -370,6 +370,9 @@ pub const CallingConvention = union(enum(u8)) {
370370 /// The standard `msp430` calling convention.
371371 msp430_eabi: CommonOptions,
372372
373 /// The standard `or1k` calling convention.
374 or1k_sysv: CommonOptions,
375
373376 /// The standard `propeller` calling convention.
374377 propeller_sysv: CommonOptions,
375378
src/Zcu.zig+1
......@@ -3687,6 +3687,7 @@ pub fn atomicPtrAlignment(
36873687 .mips,
36883688 .mipsel,
36893689 .nvptx,
3690 .or1k,
36903691 .powerpc,
36913692 .powerpcle,
36923693 .riscv32,
src/codegen/llvm.zig+4
......@@ -98,6 +98,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
9898 .ve => "ve",
9999
100100 .kalimba,
101 .or1k,
101102 .propeller,
102103 => unreachable, // Gated by hasLlvmSupport().
103104 };
......@@ -454,6 +455,7 @@ pub fn dataLayout(target: std.Target) []const u8 {
454455 .xtensa => "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32",
455456
456457 .kalimba,
458 .or1k,
457459 .propeller,
458460 => unreachable, // Gated by hasLlvmSupport().
459461 };
......@@ -11563,6 +11565,7 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: std.Targ
1156311565 .m68k_sysv,
1156411566 .m68k_gnu,
1156511567 .msp430_eabi,
11568 .or1k_sysv,
1156611569 .propeller_sysv,
1156711570 .s390x_sysv,
1156811571 .s390x_sysv_vx,
......@@ -12762,6 +12765,7 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {
1276212765
1276312766 // LLVM does does not have a backend for these.
1276412767 .kalimba,
12768 .or1k,
1276512769 .propeller,
1276612770 => unreachable,
1276712771 }
src/target.zig+1
......@@ -195,6 +195,7 @@ pub fn hasLlvmSupport(target: std.Target, ofmt: std.Target.ObjectFormat) bool {
195195
196196 // No LLVM backend exists.
197197 .kalimba,
198 .or1k,
198199 .propeller,
199200 => false,
200201 };
test/cases/compile_errors/@import_zon_bad_type.zig+3-3
......@@ -117,9 +117,9 @@ export fn testMutablePointer() void {
117117// tmp.zig:37:38: note: imported here
118118// neg_inf.zon:1:1: error: expected type '?u8'
119119// tmp.zig:57:28: note: imported here
120// neg_inf.zon:1:1: error: expected type 'tmp.testNonExhaustiveEnum__enum_491'
120// neg_inf.zon:1:1: error: expected type 'tmp.testNonExhaustiveEnum__enum_492'
121121// tmp.zig:62:39: note: imported here
122// neg_inf.zon:1:1: error: expected type 'tmp.testUntaggedUnion__union_493'
122// neg_inf.zon:1:1: error: expected type 'tmp.testUntaggedUnion__union_494'
123123// tmp.zig:67:44: note: imported here
124// neg_inf.zon:1:1: error: expected type 'tmp.testTaggedUnionVoid__union_496'
124// neg_inf.zon:1:1: error: expected type 'tmp.testTaggedUnionVoid__union_497'
125125// tmp.zig:72:50: note: imported here
test/cases/compile_errors/anytype_param_requires_comptime.zig+1-1
......@@ -15,6 +15,6 @@ pub export fn entry() void {
1515// error
1616//
1717// :7:25: error: unable to resolve comptime value
18// :7:25: note: initializer of comptime-only struct 'tmp.S.foo__anon_465.C' must be comptime-known
18// :7:25: note: initializer of comptime-only struct 'tmp.S.foo__anon_466.C' must be comptime-known
1919// :4:16: note: struct requires comptime because of this field
2020// :4:16: note: types are not available at runtime
test/cases/compile_errors/bogus_method_call_on_slice.zig+1-1
......@@ -16,5 +16,5 @@ pub export fn entry2() void {
1616//
1717// :3:6: error: no field or member function named 'copy' in '[]const u8'
1818// :9:8: error: no field or member function named 'bar' in '@TypeOf(.{})'
19// :12:18: error: no field or member function named 'bar' in 'tmp.entry2__struct_469'
19// :12:18: error: no field or member function named 'bar' in 'tmp.entry2__struct_470'
2020// :12:6: note: struct declared here
test/cases/compile_errors/coerce_anon_struct.zig+1-1
......@@ -6,6 +6,6 @@ export fn foo() void {
66
77// error
88//
9// :4:16: error: expected type 'tmp.T', found 'tmp.foo__struct_458'
9// :4:16: error: expected type 'tmp.T', found 'tmp.foo__struct_459'
1010// :3:16: note: struct declared here
1111// :1:11: note: struct declared here
test/cases/compile_errors/redundant_try.zig+2-2
......@@ -44,9 +44,9 @@ comptime {
4444//
4545// :5:23: error: expected error union type, found 'comptime_int'
4646// :10:23: error: expected error union type, found '@TypeOf(.{})'
47// :15:23: error: expected error union type, found 'tmp.test2__struct_495'
47// :15:23: error: expected error union type, found 'tmp.test2__struct_496'
4848// :15:23: note: struct declared here
49// :20:27: error: expected error union type, found 'tmp.test3__struct_497'
49// :20:27: error: expected error union type, found 'tmp.test3__struct_498'
5050// :20:27: note: struct declared here
5151// :25:23: error: expected error union type, found 'struct { comptime *const [5:0]u8 = "hello" }'
5252// :31:13: error: expected error union type, found 'u32'