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 {...@@ -1079,6 +1079,7 @@ pub fn toElfMachine(target: Target) std.elf.EM {
1079 .m68k => .@"68K",1079 .m68k => .@"68K",
1080 .mips, .mips64, .mipsel, .mips64el => .MIPS,1080 .mips, .mips64, .mipsel, .mips64el => .MIPS,
1081 .msp430 => .MSP430,1081 .msp430 => .MSP430,
1082 .or1k => .OR1K,
1082 .powerpc, .powerpcle => .PPC,1083 .powerpc, .powerpcle => .PPC,
1083 .powerpc64, .powerpc64le => .PPC64,1084 .powerpc64, .powerpc64le => .PPC64,
1084 .propeller => .PROPELLER,1085 .propeller => .PROPELLER,
...@@ -1133,6 +1134,7 @@ pub fn toCoffMachine(target: Target) std.coff.MachineType {...@@ -1133,6 +1134,7 @@ pub fn toCoffMachine(target: Target) std.coff.MachineType {
1133 .mips64,1134 .mips64,
1134 .mips64el,1135 .mips64el,
1135 .msp430,1136 .msp430,
1137 .or1k,
1136 .nvptx,1138 .nvptx,
1137 .nvptx64,1139 .nvptx64,
1138 .powerpc,1140 .powerpc,
...@@ -1357,6 +1359,7 @@ pub const Cpu = struct {...@@ -1357,6 +1359,7 @@ pub const Cpu = struct {
1357 mips64,1359 mips64,
1358 mips64el,1360 mips64el,
1359 msp430,1361 msp430,
1362 or1k,
1360 nvptx,1363 nvptx,
1361 nvptx64,1364 nvptx64,
1362 powerpc,1365 powerpc,
...@@ -1565,6 +1568,7 @@ pub const Cpu = struct {...@@ -1565,6 +1568,7 @@ pub const Cpu = struct {
1565 .m68k,1568 .m68k,
1566 .mips,1569 .mips,
1567 .mips64,1570 .mips64,
1571 .or1k,
1568 .powerpc,1572 .powerpc,
1569 .powerpc64,1573 .powerpc64,
1570 .thumbeb,1574 .thumbeb,
...@@ -1815,6 +1819,9 @@ pub const Cpu = struct {...@@ -1815,6 +1819,9 @@ pub const Cpu = struct {
1815 .msp430_eabi,1819 .msp430_eabi,
1816 => &.{.msp430},1820 => &.{.msp430},
18171821
1822 .or1k_sysv,
1823 => &.{.or1k},
1824
1818 .propeller_sysv,1825 .propeller_sysv,
1819 => &.{.propeller},1826 => &.{.propeller},
18201827
...@@ -1911,6 +1918,7 @@ pub const Cpu = struct {...@@ -1911,6 +1918,7 @@ pub const Cpu = struct {
1911 .xtensa => &xtensa.cpu.generic,1918 .xtensa => &xtensa.cpu.generic,
19121919
1913 .kalimba,1920 .kalimba,
1921 .or1k,
1914 => &S.generic_model,1922 => &S.generic_model,
1915 };1923 };
1916 }1924 }
...@@ -2598,6 +2606,7 @@ pub fn ptrBitWidth_cpu_abi(cpu: Cpu, abi: Abi) u16 {...@@ -2598,6 +2606,7 @@ pub fn ptrBitWidth_cpu_abi(cpu: Cpu, abi: Abi) u16 {
2598 .m68k,2606 .m68k,
2599 .mips,2607 .mips,
2600 .mipsel,2608 .mipsel,
2609 .or1k,
2601 .powerpc,2610 .powerpc,
2602 .powerpcle,2611 .powerpcle,
2603 .riscv32,2612 .riscv32,
...@@ -3114,6 +3123,7 @@ pub fn cTypeAlignment(target: Target, c_type: CType) u16 {...@@ -3114,6 +3123,7 @@ pub fn cTypeAlignment(target: Target, c_type: CType) u16 {
3114 .csky,3123 .csky,
3115 .x86,3124 .x86,
3116 .xcore,3125 .xcore,
3126 .or1k,
3117 .kalimba,3127 .kalimba,
3118 .xtensa,3128 .xtensa,
3119 .propeller,3129 .propeller,
...@@ -3204,6 +3214,7 @@ pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 {...@@ -3204,6 +3214,7 @@ pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 {
32043214
3205 .csky,3215 .csky,
3206 .xcore,3216 .xcore,
3217 .or1k,
3207 .kalimba,3218 .kalimba,
3208 .xtensa,3219 .xtensa,
3209 .propeller,3220 .propeller,
...@@ -3276,6 +3287,7 @@ pub fn cMaxIntAlignment(target: std.Target) u16 {...@@ -3276,6 +3287,7 @@ pub fn cMaxIntAlignment(target: std.Target) u16 {
3276 .hexagon,3287 .hexagon,
3277 .mips,3288 .mips,
3278 .mipsel,3289 .mipsel,
3290 .or1k,
3279 .powerpc,3291 .powerpc,
3280 .powerpcle,3292 .powerpcle,
3281 .riscv32,3293 .riscv32,
...@@ -3372,6 +3384,7 @@ pub fn cCallingConvention(target: Target) ?std.builtin.CallingConvention {...@@ -3372,6 +3384,7 @@ pub fn cCallingConvention(target: Target) ?std.builtin.CallingConvention {
3372 else3384 else
3373 .{ .m68k_sysv = .{} },3385 .{ .m68k_sysv = .{} },
3374 .msp430 => .{ .msp430_eabi = .{} },3386 .msp430 => .{ .msp430_eabi = .{} },
3387 .or1k => .{ .or1k_sysv = .{} },
3375 .propeller => .{ .propeller_sysv = .{} },3388 .propeller => .{ .propeller_sysv = .{} },
3376 .s390x => .{ .s390x_sysv = .{} },3389 .s390x => .{ .s390x_sysv = .{} },
3377 .ve => .{ .ve_sysv = .{} },3390 .ve => .{ .ve_sysv = .{} },
lib/std/builtin.zig+3
...@@ -370,6 +370,9 @@ pub const CallingConvention = union(enum(u8)) {...@@ -370,6 +370,9 @@ pub const CallingConvention = union(enum(u8)) {
370 /// The standard `msp430` calling convention.370 /// The standard `msp430` calling convention.
371 msp430_eabi: CommonOptions,371 msp430_eabi: CommonOptions,
372372
373 /// The standard `or1k` calling convention.
374 or1k_sysv: CommonOptions,
375
373 /// The standard `propeller` calling convention.376 /// The standard `propeller` calling convention.
374 propeller_sysv: CommonOptions,377 propeller_sysv: CommonOptions,
375378
src/Zcu.zig+1
...@@ -3687,6 +3687,7 @@ pub fn atomicPtrAlignment(...@@ -3687,6 +3687,7 @@ pub fn atomicPtrAlignment(
3687 .mips,3687 .mips,
3688 .mipsel,3688 .mipsel,
3689 .nvptx,3689 .nvptx,
3690 .or1k,
3690 .powerpc,3691 .powerpc,
3691 .powerpcle,3692 .powerpcle,
3692 .riscv32,3693 .riscv32,
src/codegen/llvm.zig+4
...@@ -98,6 +98,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {...@@ -98,6 +98,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
98 .ve => "ve",98 .ve => "ve",
9999
100 .kalimba,100 .kalimba,
101 .or1k,
101 .propeller,102 .propeller,
102 => unreachable, // Gated by hasLlvmSupport().103 => unreachable, // Gated by hasLlvmSupport().
103 };104 };
...@@ -454,6 +455,7 @@ pub fn dataLayout(target: std.Target) []const u8 {...@@ -454,6 +455,7 @@ pub fn dataLayout(target: std.Target) []const u8 {
454 .xtensa => "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32",455 .xtensa => "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32",
455456
456 .kalimba,457 .kalimba,
458 .or1k,
457 .propeller,459 .propeller,
458 => unreachable, // Gated by hasLlvmSupport().460 => unreachable, // Gated by hasLlvmSupport().
459 };461 };
...@@ -11563,6 +11565,7 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: std.Targ...@@ -11563,6 +11565,7 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: std.Targ
11563 .m68k_sysv,11565 .m68k_sysv,
11564 .m68k_gnu,11566 .m68k_gnu,
11565 .msp430_eabi,11567 .msp430_eabi,
11568 .or1k_sysv,
11566 .propeller_sysv,11569 .propeller_sysv,
11567 .s390x_sysv,11570 .s390x_sysv,
11568 .s390x_sysv_vx,11571 .s390x_sysv_vx,
...@@ -12762,6 +12765,7 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {...@@ -12762,6 +12765,7 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {
1276212765
12763 // LLVM does does not have a backend for these.12766 // LLVM does does not have a backend for these.
12764 .kalimba,12767 .kalimba,
12768 .or1k,
12765 .propeller,12769 .propeller,
12766 => unreachable,12770 => unreachable,
12767 }12771 }
src/target.zig+1
...@@ -195,6 +195,7 @@ pub fn hasLlvmSupport(target: std.Target, ofmt: std.Target.ObjectFormat) bool {...@@ -195,6 +195,7 @@ pub fn hasLlvmSupport(target: std.Target, ofmt: std.Target.ObjectFormat) bool {
195195
196 // No LLVM backend exists.196 // No LLVM backend exists.
197 .kalimba,197 .kalimba,
198 .or1k,
198 .propeller,199 .propeller,
199 => false,200 => false,
200 };201 };
test/cases/compile_errors/@import_zon_bad_type.zig+3-3
...@@ -117,9 +117,9 @@ export fn testMutablePointer() void {...@@ -117,9 +117,9 @@ export fn testMutablePointer() void {
117// tmp.zig:37:38: note: imported here117// tmp.zig:37:38: note: imported here
118// neg_inf.zon:1:1: error: expected type '?u8'118// neg_inf.zon:1:1: error: expected type '?u8'
119// tmp.zig:57:28: note: imported here119// 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'
121// tmp.zig:62:39: note: imported here121// 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'
123// tmp.zig:67:44: note: imported here123// 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'
125// tmp.zig:72:50: note: imported here125// 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 {...@@ -15,6 +15,6 @@ pub export fn entry() void {
15// error15// error
16//16//
17// :7:25: error: unable to resolve comptime value17// :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-known18// :7:25: note: initializer of comptime-only struct 'tmp.S.foo__anon_466.C' must be comptime-known
19// :4:16: note: struct requires comptime because of this field19// :4:16: note: struct requires comptime because of this field
20// :4:16: note: types are not available at runtime20// :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 {...@@ -16,5 +16,5 @@ pub export fn entry2() void {
16//16//
17// :3:6: error: no field or member function named 'copy' in '[]const u8'17// :3:6: error: no field or member function named 'copy' in '[]const u8'
18// :9:8: error: no field or member function named 'bar' in '@TypeOf(.{})'18// :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'
20// :12:6: note: struct declared here20// :12:6: note: struct declared here
test/cases/compile_errors/coerce_anon_struct.zig+1-1
...@@ -6,6 +6,6 @@ export fn foo() void {...@@ -6,6 +6,6 @@ export fn foo() void {
66
7// error7// error
8//8//
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'
10// :3:16: note: struct declared here10// :3:16: note: struct declared here
11// :1:11: note: struct declared here11// :1:11: note: struct declared here
test/cases/compile_errors/redundant_try.zig+2-2
...@@ -44,9 +44,9 @@ comptime {...@@ -44,9 +44,9 @@ comptime {
44//44//
45// :5:23: error: expected error union type, found 'comptime_int'45// :5:23: error: expected error union type, found 'comptime_int'
46// :10:23: error: expected error union type, found '@TypeOf(.{})'46// :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'
48// :15:23: note: struct declared here48// :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'
50// :20:27: note: struct declared here50// :20:27: note: struct declared here
51// :25:23: error: expected error union type, found 'struct { comptime *const [5:0]u8 = "hello" }'51// :25:23: error: expected error union type, found 'struct { comptime *const [5:0]u8 = "hello" }'
52// :31:13: error: expected error union type, found 'u32'52// :31:13: error: expected error union type, found 'u32'