xref: /freebsd/contrib/llvm-project/llvm/include/llvm/TextAPI/Architecture.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 //===- llvm/TextAPI/Architecture.h - Architecture ---------------*- C++ -*-===//
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 // Defines the architecture enum and helper methods.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_TEXTAPI_ARCHITECTURE_H
14 #define LLVM_TEXTAPI_ARCHITECTURE_H
15 
16 #include "llvm/Support/Compiler.h"
17 #include <cstdint>
18 #include <utility>
19 
20 namespace llvm {
21 class raw_ostream;
22 class StringRef;
23 class Triple;
24 
25 namespace MachO {
26 
27 /// Defines the architecture slices that are supported by Text-based Stub files.
28 enum Architecture : uint8_t {
29 #define ARCHINFO(Arch, Type, SubType, NumBits) AK_##Arch,
30 #include "llvm/TextAPI/Architecture.def"
31 #undef ARCHINFO
32   AK_unknown, // this has to go last.
33 };
34 
35 /// Convert a CPU Type and Subtype pair to an architecture slice.
36 LLVM_ABI Architecture getArchitectureFromCpuType(uint32_t CPUType,
37                                                  uint32_t CPUSubType);
38 
39 /// Convert a name to an architecture slice.
40 LLVM_ABI Architecture getArchitectureFromName(StringRef Name);
41 
42 /// Convert an architecture slice to a string.
43 LLVM_ABI StringRef getArchitectureName(Architecture Arch);
44 
45 /// Convert an architecture slice to a CPU Type and Subtype pair.
46 LLVM_ABI std::pair<uint32_t, uint32_t>
47 getCPUTypeFromArchitecture(Architecture Arch);
48 
49 /// Convert a target to an architecture slice.
50 LLVM_ABI Architecture mapToArchitecture(const llvm::Triple &Target);
51 
52 /// Check if architecture is 64 bit.
53 LLVM_ABI bool is64Bit(Architecture);
54 
55 LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, Architecture Arch);
56 
57 } // end namespace MachO.
58 } // end namespace llvm.
59 
60 #endif // LLVM_TEXTAPI_ARCHITECTURE_H
61