[obj2yaml] - Fix BB after r373315.
[llvm-complete.git] / lib / Object / WindowsMachineFlag.cpp
blobf7f2b20ae1a2b4fd5bba206b75ac0574b833be80
1 //===- WindowsMachineFlag.cpp ---------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
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"
19 using namespace llvm;
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) {
32 switch (MT) {
33 case COFF::IMAGE_FILE_MACHINE_ARMNT:
34 return "arm";
35 case COFF::IMAGE_FILE_MACHINE_ARM64:
36 return "arm64";
37 case COFF::IMAGE_FILE_MACHINE_AMD64:
38 return "x64";
39 case COFF::IMAGE_FILE_MACHINE_I386:
40 return "x86";
41 default:
42 llvm_unreachable("unknown machine type");