Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
Architecture.cpp
Go to the documentation of this file.
1//===- Architecture.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// Implements the architecture helper functions.
10//
11//===----------------------------------------------------------------------===//
12
13#include "llvm/TextAPI/Architecture.h"
14#include "llvm/ADT/StringSwitch.h"
15#include "llvm/BinaryFormat/MachO.h"
16#include "llvm/Support/ErrorHandling.h"
17#include "llvm/Support/raw_ostream.h"
18#include "llvm/TargetParser/Triple.h"
19
20namespacellvm {
21namespaceMachO {
22
23ArchitecturegetArchitectureFromCpuType(uint32_tCPUType,uint32_t CPUSubType) {
24#define ARCHINFO(Arch, Type, Subtype, NumBits) \
25 if (CPUType == (Type) && \
26 (CPUSubType & ~MachO::CPU_SUBTYPE_MASK) == (Subtype)) \
27 return AK_##Arch;
28#include "llvm/TextAPI/Architecture.def"
29#undef ARCHINFO
30
31returnAK_unknown;
32}
33
34ArchitecturegetArchitectureFromName(StringRefName) {
35returnStringSwitch<Architecture>(Name)
36#define ARCHINFO(Arch, Type, Subtype, NumBits) .Case(#Arch, AK_##Arch)
37#include "llvm/TextAPI/Architecture.def"
38#undef ARCHINFO
39 .Default(AK_unknown);
40}
41
42StringRefgetArchitectureName(Architecture Arch) {
43switch (Arch) {
44#define ARCHINFO(Arch, Type, Subtype, NumBits) \
45 case AK_##Arch: \
46 return #Arch;
47#include "llvm/TextAPI/Architecture.def"
48#undef ARCHINFO
49caseAK_unknown:
50return"unknown";
51 }
52
53// Appease some compilers that cannot figure out that this is a fully covered
54// switch statement.
55return"unknown";
56}
57
58std::pair<uint32_t, uint32_t>getCPUTypeFromArchitecture(Architecture Arch) {
59switch (Arch) {
60#define ARCHINFO(Arch, Type, Subtype, NumBits) \
61 case AK_##Arch: \
62 return std::make_pair(Type, Subtype);
63#include "llvm/TextAPI/Architecture.def"
64#undef ARCHINFO
65caseAK_unknown:
66return std::make_pair(0, 0);
67 }
68
69// Appease some compilers that cannot figure out that this is a fully covered
70// switch statement.
71return std::make_pair(0, 0);
72}
73
74ArchitecturemapToArchitecture(constTriple &Target) {
75returngetArchitectureFromName(Target.getArchName());
76}
77
78boolis64Bit(Architecture Arch) {
79switch (Arch) {
80#define ARCHINFO(Arch, Type, Subtype, NumBits) \
81 case AK_##Arch: \
82 return NumBits == 64;
83#include "llvm/TextAPI/Architecture.def"
84#undef ARCHINFO
85caseAK_unknown:
86returnfalse;
87 }
88
89llvm_unreachable("Fully handled switch case above.");
90}
91
92raw_ostream &operator<<(raw_ostream &OS,Architecture Arch) {
93OS <<getArchitectureName(Arch);
94returnOS;
95}
96
97}// end namespace MachO.
98}// end namespace llvm.
Architecture.h
MachO.h
Name
std::string Name
Definition:ELFObjHandler.cpp:77
OS
raw_pwrite_stream & OS
Definition:SampleProfWriter.cpp:51
StringSwitch.h
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
Triple.h
llvm::MachO::Target
Definition:Target.h:28
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::StringSwitch
A switch()-like statement whose cases are string literals.
Definition:StringSwitch.h:44
llvm::StringSwitch::Default
R Default(T Value)
Definition:StringSwitch.h:182
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition:Triple.h:44
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition:raw_ostream.h:52
uint32_t
ErrorHandling.h
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition:ErrorHandling.h:143
llvm::MachO::getArchitectureFromName
Architecture getArchitectureFromName(StringRef Name)
Convert a name to an architecture slice.
Definition:Architecture.cpp:34
llvm::MachO::getArchitectureName
StringRef getArchitectureName(Architecture Arch)
Convert an architecture slice to a string.
Definition:Architecture.cpp:42
llvm::MachO::getCPUTypeFromArchitecture
std::pair< uint32_t, uint32_t > getCPUTypeFromArchitecture(Architecture Arch)
Convert an architecture slice to a CPU Type and Subtype pair.
Definition:Architecture.cpp:58
llvm::MachO::is64Bit
bool is64Bit(Architecture)
Check if architecture is 64 bit.
Definition:Architecture.cpp:78
llvm::MachO::Architecture
Architecture
Defines the architecture slices that are supported by Text-based Stub files.
Definition:Architecture.h:27
llvm::MachO::AK_unknown
@ AK_unknown
Definition:Architecture.h:31
llvm::MachO::operator<<
raw_ostream & operator<<(raw_ostream &OS, Architecture Arch)
Definition:Architecture.cpp:92
llvm::MachO::mapToArchitecture
Architecture mapToArchitecture(const llvm::Triple &Target)
Convert a target to an architecture slice.
Definition:Architecture.cpp:74
llvm::MachO::getArchitectureFromCpuType
Architecture getArchitectureFromCpuType(uint32_t CPUType, uint32_t CPUSubType)
Convert a CPU Type and Subtype pair to an architecture slice.
Definition:Architecture.cpp:23
llvm::MachO::CPUType
CPUType
Definition:MachO.h:1562
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
raw_ostream.h

Generated on Sun Jul 20 2025 13:14:16 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp