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"
21 // Returns /machine's value.
22 COFF::MachineTypes
llvm::getMachineType(StringRef S
) {
23 return StringSwitch
<COFF::MachineTypes
>(S
.lower())
24 .Cases("x64", "amd64", COFF::IMAGE_FILE_MACHINE_AMD64
)
25 .Cases("x86", "i386", COFF::IMAGE_FILE_MACHINE_I386
)
26 .Case("arm", COFF::IMAGE_FILE_MACHINE_ARMNT
)
27 .Case("arm64", COFF::IMAGE_FILE_MACHINE_ARM64
)
28 .Default(COFF::IMAGE_FILE_MACHINE_UNKNOWN
);
31 StringRef
llvm::machineToStr(COFF::MachineTypes MT
) {
33 case COFF::IMAGE_FILE_MACHINE_ARMNT
:
35 case COFF::IMAGE_FILE_MACHINE_ARM64
:
37 case COFF::IMAGE_FILE_MACHINE_AMD64
:
39 case COFF::IMAGE_FILE_MACHINE_I386
:
42 llvm_unreachable("unknown machine type");