LLVM  10.0.0svn
Target.h
Go to the documentation of this file.
1 //===- llvm/TextAPI/Target.h - TAPI Target ----------------------*- 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 #ifndef LLVM_TEXTAPI_MACHO_TARGET_H
10 #define LLVM_TEXTAPI_MACHO_TARGET_H
11 
12 #include "llvm/ADT/Triple.h"
13 #include "llvm/Support/Error.h"
17 
18 namespace llvm {
19 namespace MachO {
20 
21 // This is similar to a llvm Triple, but the triple doesn't have all the
22 // information we need. For example there is no enum value for x86_64h. The
23 // only way to get that information is to parse the triple string.
24 class Target {
25 public:
26  Target() = default;
28  : Arch(Arch), Platform(Platform) {}
29  explicit Target(const llvm::Triple &Triple)
30  : Arch(mapToArchitecture(Triple)), Platform(mapToPlatformKind(Triple)) {}
31 
33 
34  operator std::string() const;
35 
38 };
39 
40 inline bool operator==(const Target &LHS, const Target &RHS) {
41  return std::tie(LHS.Arch, LHS.Platform) == std::tie(RHS.Arch, RHS.Platform);
42 }
43 
44 inline bool operator!=(const Target &LHS, const Target &RHS) {
45  return std::tie(LHS.Arch, LHS.Platform) != std::tie(RHS.Arch, RHS.Platform);
46 }
47 
48 inline bool operator<(const Target &LHS, const Target &RHS) {
49  return std::tie(LHS.Arch, LHS.Platform) < std::tie(RHS.Arch, RHS.Platform);
50 }
51 
52 inline bool operator==(const Target &LHS, const Architecture &RHS) {
53  return LHS.Arch == RHS;
54 }
55 
56 inline bool operator!=(const Target &LHS, const Architecture &RHS) {
57  return LHS.Arch != RHS;
58 }
59 
62 
64 
65 } // namespace MachO
66 } // namespace llvm
67 
68 #endif // LLVM_TEXTAPI_MACHO_TARGET_H
PlatformKind
Defines the list of MachO platforms.
Definition: Platform.h:22
This class represents lattice values for constants.
Definition: AllocatorList.h:23
ArchitectureSet mapToArchitectureSet(ArrayRef< Target > Targets)
Definition: Target.cpp:67
Target(const llvm::Triple &Triple)
Definition: Target.h:29
bool operator<(const Target &LHS, const Target &RHS)
Definition: Target.h:48
Tagged union holding either a T or a Error.
Definition: yaml2obj.h:21
Target(Architecture Arch, PlatformKind Platform)
Definition: Target.h:27
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
bool operator!=(const Target &LHS, const Target &RHS)
Definition: Target.h:44
static llvm::Expected< Target > create(StringRef Target)
Definition: Target.cpp:20
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:134
PlatformKind mapToPlatformKind(PlatformKind Platform, bool WantSim)
Definition: Platform.cpp:20
raw_ostream & operator<<(raw_ostream &OS, Architecture Arch)
PlatformKind Platform
Definition: Target.h:37
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
Architecture
Defines the architecture slices that are supported by Text-based Stub files.
Definition: Architecture.h:24
bool operator==(const Target &LHS, const Target &RHS)
Definition: Target.h:40
PlatformSet mapToPlatformSet(ArrayRef< Triple > Targets)
Definition: Platform.cpp:57
Architecture Arch
Definition: Target.h:36
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
Architecture mapToArchitecture(const llvm::Triple &Target)
Convert a target to an architecture slice.