
Similar to D125411, but for ARM64X. ARM64X PE binaries are hybrids containing both ARM64EC and pure ARM64 variants in one file. They are usually linked by passing separate ARM64EC and ARM64 object files to linker. Linked binaries use ARM64 machine and contain additional CHPE metadata in their load config. CHPE metadata support is not part of this patch, I plan to send that later. Using ARM64X as a machine type of object files themselves is somewhat ambiguous, but such files are allowed by MSVC. It treats them as ARM64 or ARM64EC object, depending on the context. Such objects can be produced with cvtres.exe -machine:arm64x. Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D148517
52 lines
1.7 KiB
C++
52 lines
1.7 KiB
C++
//===- WindowsMachineFlag.cpp ---------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Functions for implementing the /machine: flag.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/Object/WindowsMachineFlag.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include "llvm/ADT/StringSwitch.h"
|
|
#include "llvm/BinaryFormat/COFF.h"
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
using namespace llvm;
|
|
|
|
// Returns /machine's value.
|
|
COFF::MachineTypes llvm::getMachineType(StringRef S) {
|
|
return StringSwitch<COFF::MachineTypes>(S.lower())
|
|
.Cases("x64", "amd64", COFF::IMAGE_FILE_MACHINE_AMD64)
|
|
.Cases("x86", "i386", COFF::IMAGE_FILE_MACHINE_I386)
|
|
.Case("arm", COFF::IMAGE_FILE_MACHINE_ARMNT)
|
|
.Case("arm64", COFF::IMAGE_FILE_MACHINE_ARM64)
|
|
.Case("arm64ec", COFF::IMAGE_FILE_MACHINE_ARM64EC)
|
|
.Case("arm64x", COFF::IMAGE_FILE_MACHINE_ARM64X)
|
|
.Default(COFF::IMAGE_FILE_MACHINE_UNKNOWN);
|
|
}
|
|
|
|
StringRef llvm::machineToStr(COFF::MachineTypes MT) {
|
|
switch (MT) {
|
|
case COFF::IMAGE_FILE_MACHINE_ARMNT:
|
|
return "arm";
|
|
case COFF::IMAGE_FILE_MACHINE_ARM64:
|
|
return "arm64";
|
|
case COFF::IMAGE_FILE_MACHINE_ARM64EC:
|
|
return "arm64ec";
|
|
case COFF::IMAGE_FILE_MACHINE_ARM64X:
|
|
return "arm64x";
|
|
case COFF::IMAGE_FILE_MACHINE_AMD64:
|
|
return "x64";
|
|
case COFF::IMAGE_FILE_MACHINE_I386:
|
|
return "x86";
|
|
default:
|
|
llvm_unreachable("unknown machine type");
|
|
}
|
|
}
|