Commit ac9ca7d30c

Alex Rønne Petersen <alex@alexrp.com>
2024-08-09 20:53:37
std.coff: Remove MachineType.fromTargetCpuArch().
This does the same thing as std.Target.Cpu.Arch.toCoffMachine(). Just use that.
1 parent 65affb1
Changed files (2)
lib
src
lib/std/coff.zig
@@ -1061,23 +1061,6 @@ pub const MachineType = enum(u16) {
 
     _,
 
-    pub fn fromTargetCpuArch(arch: std.Target.Cpu.Arch) MachineType {
-        return switch (arch) {
-            .arm => .ARM,
-            .powerpc => .POWERPC,
-            .riscv32 => .RISCV32,
-            .thumb => .Thumb,
-            .x86 => .I386,
-            .aarch64 => .ARM64,
-            .riscv64 => .RISCV64,
-            .x86_64 => .X64,
-            .loongarch32 => .LOONGARCH32,
-            .loongarch64 => .LOONGARCH64,
-            // there's cases we don't (yet) handle
-            else => unreachable,
-        };
-    }
-
     pub fn toTargetCpuArch(machine_type: MachineType) ?std.Target.Cpu.Arch {
         return switch (machine_type) {
             .ARM => .arm,
src/link/Coff.zig
@@ -2259,7 +2259,7 @@ fn writeHeader(self: *Coff) !void {
     const timestamp = if (self.repro) 0 else std.time.timestamp();
     const size_of_optional_header = @as(u16, @intCast(self.getOptionalHeaderSize() + self.getDataDirectoryHeadersSize()));
     var coff_header = coff.CoffHeader{
-        .machine = coff.MachineType.fromTargetCpuArch(target.cpu.arch),
+        .machine = target.cpu.arch.toCoffMachine(),
         .number_of_sections = @as(u16, @intCast(self.sections.slice().len)), // TODO what if we prune a section
         .time_date_stamp = @as(u32, @truncate(@as(u64, @bitCast(timestamp)))),
         .pointer_to_symbol_table = self.strtab_offset orelse 0,