authorgravatar for yangxudong@ymatrix.cnYANG Xudong <yangxudong@ymatrix.cn> 2024-07-12 15:47:32+08:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-07-12 00:47:32-07:00
log3bf0d2e5168c1722656a5eaa56e4bf16272df6d5
treea51cd3caceba38aea7cec4d5fd6c486871afab82
parent2b99b0428500ef880bc52e9f814f970e5fa29a7d
signaturebadge-check Signed by PGP key B5690EEEBB952194

std: Add loongarch support for coff. (#20583)

* std: Add loongarch support for coff. See: https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#machine-types * Update toCoffMachine.

2 files changed, 10 insertions(+), 2 deletions(-)

lib/std/Target.zig+2-2
...@@ -1276,8 +1276,8 @@ pub const Cpu = struct {...@@ -1276,8 +1276,8 @@ pub const Cpu = struct {
1276 .spirv => .Unknown,1276 .spirv => .Unknown,
1277 .spirv32 => .Unknown,1277 .spirv32 => .Unknown,
1278 .spirv64 => .Unknown,1278 .spirv64 => .Unknown,
1279 .loongarch32 => .Unknown,1279 .loongarch32 => .LOONGARCH32,
1280 .loongarch64 => .Unknown,1280 .loongarch64 => .LOONGARCH64,
1281 };1281 };
1282 }1282 }
12831283
lib/std/coff.zig+8
...@@ -1002,6 +1002,10 @@ pub const MachineType = enum(u16) {...@@ -1002,6 +1002,10 @@ pub const MachineType = enum(u16) {
1002 I386 = 0x14c,1002 I386 = 0x14c,
1003 /// Intel Itanium processor family1003 /// Intel Itanium processor family
1004 IA64 = 0x200,1004 IA64 = 0x200,
1005 /// LoongArch32
1006 LOONGARCH32 = 0x6232,
1007 /// LoongArch64
1008 LOONGARCH64 = 0x6264,
1005 /// Mitsubishi M32R little endian1009 /// Mitsubishi M32R little endian
1006 M32R = 0x9041,1010 M32R = 0x9041,
1007 /// MIPS161011 /// MIPS16
...@@ -1047,6 +1051,8 @@ pub const MachineType = enum(u16) {...@@ -1047,6 +1051,8 @@ pub const MachineType = enum(u16) {
1047 .aarch64 => .ARM64,1051 .aarch64 => .ARM64,
1048 .riscv64 => .RISCV64,1052 .riscv64 => .RISCV64,
1049 .x86_64 => .X64,1053 .x86_64 => .X64,
1054 .loongarch32 => .LOONGARCH32,
1055 .loongarch64 => .LOONGARCH64,
1050 // there's cases we don't (yet) handle1056 // there's cases we don't (yet) handle
1051 else => unreachable,1057 else => unreachable,
1052 };1058 };
...@@ -1062,6 +1068,8 @@ pub const MachineType = enum(u16) {...@@ -1062,6 +1068,8 @@ pub const MachineType = enum(u16) {
1062 .ARM64 => .aarch64,1068 .ARM64 => .aarch64,
1063 .RISCV64 => .riscv64,1069 .RISCV64 => .riscv64,
1064 .X64 => .x86_64,1070 .X64 => .x86_64,
1071 .LOONGARCH32 => .loongarch32,
1072 .LOONGARCH64 => .loongarch64,
1065 // there's cases we don't (yet) handle1073 // there's cases we don't (yet) handle
1066 else => null,1074 else => null,
1067 };1075 };