Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:38

0001 //===- llvm/TextAPI/Target.h - TAPI Target ----------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_TEXTAPI_TARGET_H
0010 #define LLVM_TEXTAPI_TARGET_H
0011 
0012 #include "llvm/Support/Error.h"
0013 #include "llvm/Support/VersionTuple.h"
0014 #include "llvm/TargetParser/Triple.h"
0015 #include "llvm/TextAPI/Architecture.h"
0016 #include "llvm/TextAPI/ArchitectureSet.h"
0017 #include "llvm/TextAPI/Platform.h"
0018 
0019 namespace llvm {
0020 
0021 class Triple;
0022 
0023 namespace MachO {
0024 
0025 // This is similar to a llvm Triple, but the triple doesn't have all the
0026 // information we need. For example there is no enum value for x86_64h. The
0027 // only way to get that information is to parse the triple string.
0028 class Target {
0029 public:
0030   Target() = default;
0031   Target(Architecture Arch, PlatformType Platform,
0032          VersionTuple MinDeployment = {})
0033       : Arch(Arch), Platform(Platform), MinDeployment(MinDeployment) {}
0034   explicit Target(const llvm::Triple &Triple)
0035       : Arch(mapToArchitecture(Triple)), Platform(mapToPlatformType(Triple)),
0036         MinDeployment(mapToSupportedOSVersion(Triple)) {}
0037 
0038   static llvm::Expected<Target> create(StringRef Target);
0039 
0040   operator std::string() const;
0041 
0042   Architecture Arch;
0043   PlatformType Platform;
0044   VersionTuple MinDeployment;
0045 };
0046 
0047 inline bool operator==(const Target &LHS, const Target &RHS) {
0048   // In most cases the deployment version is not useful to compare.
0049   return std::tie(LHS.Arch, LHS.Platform) == std::tie(RHS.Arch, RHS.Platform);
0050 }
0051 
0052 inline bool operator!=(const Target &LHS, const Target &RHS) {
0053   return !(LHS == RHS);
0054 }
0055 
0056 inline bool operator<(const Target &LHS, const Target &RHS) {
0057   // In most cases the deployment version is not useful to compare.
0058   return std::tie(LHS.Arch, LHS.Platform) < std::tie(RHS.Arch, RHS.Platform);
0059 }
0060 
0061 inline bool operator==(const Target &LHS, const Architecture &RHS) {
0062   return LHS.Arch == RHS;
0063 }
0064 
0065 inline bool operator!=(const Target &LHS, const Architecture &RHS) {
0066   return LHS.Arch != RHS;
0067 }
0068 
0069 PlatformVersionSet mapToPlatformVersionSet(ArrayRef<Target> Targets);
0070 PlatformSet mapToPlatformSet(ArrayRef<Target> Targets);
0071 ArchitectureSet mapToArchitectureSet(ArrayRef<Target> Targets);
0072 
0073 std::string getTargetTripleName(const Target &Targ);
0074 
0075 raw_ostream &operator<<(raw_ostream &OS, const Target &Target);
0076 
0077 } // namespace MachO
0078 } // namespace llvm
0079 
0080 #endif // LLVM_TEXTAPI_TARGET_H