Files
archived-llvm/include/llvm/TextAPI/MachO/Target.h
Cyndy Ishida 5496a24d4c [TextAPI] Arch&Platform to Target
Summary:
This is a patch for updating TextAPI/Macho to read in targets as opposed to arch/platform.
This is because in previous versions tbd files only supported a single platform but that is no longer the case,
so, now its tracked by unique triples.
This precedes a seperate patch that will add  the TBD-v4 format

Reviewers: ributzka, steven_wu, plotfi, compnerd, smeenai

Reviewed By: ributzka

Subscribers: mgorny, hiraditya, dexonsmith, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D67527

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372396 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-20 14:32:34 +00:00

67 lines
2.1 KiB
C++

//===- llvm/TextAPI/Target.h - TAPI Target ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TEXTAPI_MACHO_TARGET_H
#define LLVM_TEXTAPI_MACHO_TARGET_H
#include "llvm/ADT/Triple.h"
#include "llvm/Support/Error.h"
#include "llvm/TextAPI/MachO/Architecture.h"
#include "llvm/TextAPI/MachO/ArchitectureSet.h"
#include "llvm/TextAPI/MachO/Platform.h"
namespace llvm {
namespace MachO {
// This is similar to a llvm Triple, but the triple doesn't have all the
// information we need. For example there is no enum value for x86_64h. The
// only way to get that information is to parse the triple string.
class Target {
public:
Target() = default;
Target(Architecture Arch, PlatformKind Platform)
: Arch(Arch), Platform(Platform) {}
explicit Target(const llvm::Triple &Triple)
: Arch(mapToArchitecture(Triple)), Platform(mapToPlatformKind(Triple)) {}
operator std::string() const;
Architecture Arch;
PlatformKind Platform;
};
inline bool operator==(const Target &LHS, const Target &RHS) {
return std::tie(LHS.Arch, LHS.Platform) == std::tie(RHS.Arch, RHS.Platform);
}
inline bool operator!=(const Target &LHS, const Target &RHS) {
return std::tie(LHS.Arch, LHS.Platform) != std::tie(RHS.Arch, RHS.Platform);
}
inline bool operator<(const Target &LHS, const Target &RHS) {
return std::tie(LHS.Arch, LHS.Platform) < std::tie(RHS.Arch, RHS.Platform);
}
inline bool operator==(const Target &LHS, const Architecture &RHS) {
return LHS.Arch == RHS;
}
inline bool operator!=(const Target &LHS, const Architecture &RHS) {
return LHS.Arch != RHS;
}
PlatformSet mapToPlatformSet(ArrayRef<Target> Targets);
ArchitectureSet mapToArchitectureSet(ArrayRef<Target> Targets);
raw_ostream &operator<<(raw_ostream &OS, const Target &Target);
} // namespace MachO
} // namespace llvm
#endif // LLVM_TEXTAPI_MACHO_TARGET_H