blob: 7a9f951d031664b6af044b3f74bcbf7cabbb4f87 [file] [log] [blame]
Andrew Walbran3d2c1972020-04-07 12:24:26 +01001//===- llvm/TextAPI/MachO/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_MACHO_ARCHITECTURE_H
14#define LLVM_TEXTAPI_MACHO_ARCHITECTURE_H
15
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020016#include <cstdint>
17#include <utility>
Andrew Walbran3d2c1972020-04-07 12:24:26 +010018
19namespace llvm {
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020020class raw_ostream;
21class StringRef;
22class Triple;
23
Andrew Walbran3d2c1972020-04-07 12:24:26 +010024namespace MachO {
25
26/// Defines the architecture slices that are supported by Text-based Stub files.
27enum Architecture : uint8_t {
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020028#define ARCHINFO(Arch, Type, SubType, NumBits) AK_##Arch,
Andrew Walbran3d2c1972020-04-07 12:24:26 +010029#include "llvm/TextAPI/MachO/Architecture.def"
30#undef ARCHINFO
31 AK_unknown, // this has to go last.
32};
33
34/// Convert a CPU Type and Subtype pair to an architecture slice.
35Architecture getArchitectureFromCpuType(uint32_t CPUType, uint32_t CPUSubType);
36
37/// Convert a name to an architecture slice.
38Architecture getArchitectureFromName(StringRef Name);
39
40/// Convert an architecture slice to a string.
41StringRef getArchitectureName(Architecture Arch);
42
43/// Convert an architecture slice to a CPU Type and Subtype pair.
44std::pair<uint32_t, uint32_t> getCPUTypeFromArchitecture(Architecture Arch);
45
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020046/// Convert a target to an architecture slice.
47Architecture mapToArchitecture(const llvm::Triple &Target);
48
49/// Check if architecture is 64 bit.
50bool is64Bit(Architecture);
51
Andrew Walbran3d2c1972020-04-07 12:24:26 +010052raw_ostream &operator<<(raw_ostream &OS, Architecture Arch);
53
54} // end namespace MachO.
55} // end namespace llvm.
56
57#endif // LLVM_TEXTAPI_MACHO_ARCHITECTURE_H