[InstCombine] Signed saturation patterns
[llvm-core.git] / include / llvm / TextAPI / MachO / Target.h
blob5fe44cb7d366f5a954ab4bb99c36513d17346a5e
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_TEXTAPI_MACHO_TARGET_H
10 #define LLVM_TEXTAPI_MACHO_TARGET_H
12 #include "llvm/ADT/Triple.h"
13 #include "llvm/Support/Error.h"
14 #include "llvm/TextAPI/MachO/Architecture.h"
15 #include "llvm/TextAPI/MachO/ArchitectureSet.h"
16 #include "llvm/TextAPI/MachO/Platform.h"
18 namespace llvm {
19 namespace MachO {
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;
27 Target(Architecture Arch, PlatformKind Platform)
28 : Arch(Arch), Platform(Platform) {}
29 explicit Target(const llvm::Triple &Triple)
30 : Arch(mapToArchitecture(Triple)), Platform(mapToPlatformKind(Triple)) {}
32 static llvm::Expected<Target> create(StringRef Target);
34 operator std::string() const;
36 Architecture Arch;
37 PlatformKind Platform;
40 inline bool operator==(const Target &LHS, const Target &RHS) {
41 return std::tie(LHS.Arch, LHS.Platform) == std::tie(RHS.Arch, RHS.Platform);
44 inline bool operator!=(const Target &LHS, const Target &RHS) {
45 return std::tie(LHS.Arch, LHS.Platform) != std::tie(RHS.Arch, RHS.Platform);
48 inline bool operator<(const Target &LHS, const Target &RHS) {
49 return std::tie(LHS.Arch, LHS.Platform) < std::tie(RHS.Arch, RHS.Platform);
52 inline bool operator==(const Target &LHS, const Architecture &RHS) {
53 return LHS.Arch == RHS;
56 inline bool operator!=(const Target &LHS, const Architecture &RHS) {
57 return LHS.Arch != RHS;
60 PlatformSet mapToPlatformSet(ArrayRef<Target> Targets);
61 ArchitectureSet mapToArchitectureSet(ArrayRef<Target> Targets);
63 raw_ostream &operator<<(raw_ostream &OS, const Target &Target);
65 } // namespace MachO
66 } // namespace llvm
68 #endif // LLVM_TEXTAPI_MACHO_TARGET_H