std.coff: Remove MachineType.fromTargetCpuArch().

This does the same thing as std.Target.Cpu.Arch.toCoffMachine(). Just use that.
This commit is contained in:
Alex Rønne Petersen 2024-08-09 20:53:37 +02:00
parent 65affb1c22
commit ac9ca7d30c
No known key found for this signature in database
2 changed files with 1 additions and 18 deletions

View File

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

View File

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