LLVM  13.0.0git
WindowsMachineFlag.cpp
Go to the documentation of this file.
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.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/ADT/StringSwitch.h"
17 #include "llvm/BinaryFormat/COFF.h"
18 
19 using namespace llvm;
20 
21 // Returns /machine's value.
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)
29 }
30 
32  switch (MT) {
34  return "arm";
36  return "arm64";
38  return "x64";
40  return "x86";
41  default:
42  llvm_unreachable("unknown machine type");
43  }
44 }
llvm::StringSwitch::Case
StringSwitch & Case(StringLiteral S, T Value)
Definition: StringSwitch.h:67
llvm
Definition: AllocatorList.h:23
llvm::machineToStr
StringRef machineToStr(COFF::MachineTypes MT)
Definition: WindowsMachineFlag.cpp:31
llvm::getMachineType
COFF::MachineTypes getMachineType(StringRef S)
Definition: WindowsMachineFlag.cpp:22
StringRef.h
llvm::StringSwitch::Default
LLVM_NODISCARD R Default(T Value)
Definition: StringSwitch.h:181
llvm::COFF::IMAGE_FILE_MACHINE_AMD64
@ IMAGE_FILE_MACHINE_AMD64
Definition: COFF.h:98
llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN
@ IMAGE_FILE_MACHINE_UNKNOWN
Definition: COFF.h:96
COFF.h
llvm::COFF::IMAGE_FILE_MACHINE_ARMNT
@ IMAGE_FILE_MACHINE_ARMNT
Definition: COFF.h:100
llvm::COFF::IMAGE_FILE_MACHINE_I386
@ IMAGE_FILE_MACHINE_I386
Definition: COFF.h:103
WindowsMachineFlag.h
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::StringSwitch::Cases
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, T Value)
Definition: StringSwitch.h:88
llvm::COFF::IMAGE_FILE_MACHINE_ARM64
@ IMAGE_FILE_MACHINE_ARM64
Definition: COFF.h:101
llvm::COFF::MachineTypes
MachineTypes
Definition: COFF.h:93
StringSwitch.h
llvm::StringSwitch
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:42