1 //===- WindowsMachineFlag.cpp ---------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // Functions for implementing the /machine: flag.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/Object/WindowsMachineFlag.h"
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/ADT/StringSwitch.h"
17 #include "llvm/BinaryFormat/COFF.h"
18 #include "llvm/Support/ErrorHandling.h"
22 // Returns /machine's value.
23 COFF::MachineTypes
llvm::getMachineType(StringRef S
) {
24 return StringSwitch
<COFF::MachineTypes
>(S
.lower())
25 .Cases("x64", "amd64", COFF::IMAGE_FILE_MACHINE_AMD64
)
26 .Cases("x86", "i386", COFF::IMAGE_FILE_MACHINE_I386
)
27 .Case("arm", COFF::IMAGE_FILE_MACHINE_ARMNT
)
28 .Case("arm64", COFF::IMAGE_FILE_MACHINE_ARM64
)
29 .Case("arm64ec", COFF::IMAGE_FILE_MACHINE_ARM64EC
)
30 .Case("arm64x", COFF::IMAGE_FILE_MACHINE_ARM64X
)
31 .Default(COFF::IMAGE_FILE_MACHINE_UNKNOWN
);
34 StringRef
llvm::machineToStr(COFF::MachineTypes MT
) {
36 case COFF::IMAGE_FILE_MACHINE_ARMNT
:
38 case COFF::IMAGE_FILE_MACHINE_ARM64
:
40 case COFF::IMAGE_FILE_MACHINE_ARM64EC
:
42 case COFF::IMAGE_FILE_MACHINE_ARM64X
:
44 case COFF::IMAGE_FILE_MACHINE_AMD64
:
46 case COFF::IMAGE_FILE_MACHINE_I386
:
49 llvm_unreachable("unknown machine type");