本文整理汇总了C++中llvm::Triple::getOS方法的典型用法代码示例。如果您正苦于以下问题:C++ Triple::getOS方法的具体用法?C++ Triple::getOS怎么用?C++ Triple::getOS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::Triple
的用法示例。
在下文中一共展示了Triple::getOS方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddDefaultIncludePaths
void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
const llvm::Triple &triple,
const HeaderSearchOptions &HSOpts) {
// NB: This code path is going away. All of the logic is moving into the
// driver which has the information necessary to do target-specific
// selections of default include paths. Each target which moves there will be
// exempted from this logic here until we can delete the entire pile of code.
switch (triple.getOS()) {
default:
break; // Everything else continues to use this routine's logic.
case llvm::Triple::Linux:
case llvm::Triple::Win32:
return;
}
if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes &&
HSOpts.UseStandardSystemIncludes) {
if (HSOpts.UseLibcxx) {
if (triple.isOSDarwin()) {
// On Darwin, libc++ may be installed alongside the compiler in
// include/c++/v1.
if (!HSOpts.ResourceDir.empty()) {
// Remove version from foo/lib/clang/version
StringRef NoVer = llvm::sys::path::parent_path(HSOpts.ResourceDir);
// Remove clang from foo/lib/clang
StringRef Lib = llvm::sys::path::parent_path(NoVer);
// Remove lib from foo/lib
SmallString<128> P = llvm::sys::path::parent_path(Lib);
// Get foo/include/c++/v1
llvm::sys::path::append(P, "include", "c++", "v1");
AddUnmappedPath(P.str(), CXXSystem, false);
}
}
// On Solaris, include the support directory for things like xlocale and
// fudged system headers.
if (triple.getOS() == llvm::Triple::Solaris)
AddPath("/usr/include/c++/v1/support/solaris", CXXSystem, false);
AddPath("/usr/include/c++/v1", CXXSystem, false);
} else {
AddDefaultCPlusPlusIncludePaths(triple, HSOpts);
}
}
AddDefaultCIncludePaths(triple, HSOpts);
// Add the default framework include paths on Darwin.
if (HSOpts.UseStandardSystemIncludes) {
if (triple.isOSDarwin()) {
AddPath("/System/Library/Frameworks", System, true);
AddPath("/Library/Frameworks", System, true);
}
}
}
示例2: areCompatibleOSs
static bool areCompatibleOSs(const llvm::Triple &moduleTarget,
const llvm::Triple &ctxTarget) {
if (moduleTarget.getOS() == ctxTarget.getOS())
return true;
auto osPair = std::minmax(moduleTarget.getOS(), ctxTarget.getOS());
if (osPair == std::minmax(llvm::Triple::Darwin, llvm::Triple::MacOSX))
return true;
return false;
}
示例3: getOS
static std::string getOS(llvm::Triple const &triple) {
switch (triple.getOS()) {
case llvm::Triple::Darwin :
return "macosx";
case llvm::Triple::DragonFly :
return "dragonfly";
case llvm::Triple::FreeBSD :
return "freebsd";
case llvm::Triple::Linux :
return "linux";
case llvm::Triple::Cygwin :
case llvm::Triple::MinGW32 :
case llvm::Triple::MinGW64 :
case llvm::Triple::Win32 :
return "windows";
case llvm::Triple::NetBSD :
return "netbsd";
case llvm::Triple::OpenBSD :
return "openbsd";
case llvm::Triple::Solaris :
return "solaris";
case llvm::Triple::Haiku :
return "haiku";
case llvm::Triple::Minix :
return "minix";
default :
return triple.getOSName().str();
}
}
示例4: TargetInfo
AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: TargetInfo(Triple),
GPUKind(isAMDGCN(Triple) ?
llvm::AMDGPU::parseArchAMDGCN(Opts.CPU) :
llvm::AMDGPU::parseArchR600(Opts.CPU)),
GPUFeatures(isAMDGCN(Triple) ?
llvm::AMDGPU::getArchAttrAMDGCN(GPUKind) :
llvm::AMDGPU::getArchAttrR600(GPUKind)) {
resetDataLayout(isAMDGCN(getTriple()) ? DataLayoutStringAMDGCN
: DataLayoutStringR600);
assert(DataLayout->getAllocaAddrSpace() == Private);
setAddressSpaceMap(Triple.getOS() == llvm::Triple::Mesa3D ||
!isAMDGCN(Triple));
UseAddrSpaceMapMangling = true;
// Set pointer width and alignment for target address space 0.
PointerWidth = PointerAlign = DataLayout->getPointerSizeInBits();
if (getMaxPointerWidth() == 64) {
LongWidth = LongAlign = 64;
SizeType = UnsignedLong;
PtrDiffType = SignedLong;
IntPtrType = SignedLong;
}
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
}
示例5: AddDefaultCIncludePaths
void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple) {
// FIXME: temporary hack: hard-coded paths.
llvm::StringRef CIncludeDirs(C_INCLUDE_DIRS);
if (CIncludeDirs != "") {
llvm::SmallVector<llvm::StringRef, 5> dirs;
CIncludeDirs.split(dirs, ":");
for (llvm::SmallVectorImpl<llvm::StringRef>::iterator i = dirs.begin();
i != dirs.end();
++i)
AddPath(*i, System, false, false, false);
return;
}
llvm::Triple::OSType os = triple.getOS();
switch (os) {
case llvm::Triple::Win32:
{
std::string VSDir;
std::string WindowsSDKDir;
if (getVisualStudioDir(VSDir)) {
AddPath(VSDir + "\\VC\\include", System, false, false, false);
if (getWindowsSDKDir(WindowsSDKDir))
AddPath(WindowsSDKDir, System, false, false, false);
else
AddPath(VSDir + "\\VC\\PlatformSDK\\Include",
System, false, false, false);
}
else {
// Default install paths.
AddPath("C:/Program Files/Microsoft Visual Studio 9.0/VC/include",
System, false, false, false);
AddPath(
"C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include",
System, false, false, false);
AddPath("C:/Program Files/Microsoft Visual Studio 8/VC/include",
System, false, false, false);
AddPath(
"C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include",
System, false, false, false);
// For some clang developers.
AddPath("G:/Program Files/Microsoft Visual Studio 9.0/VC/include",
System, false, false, false);
AddPath(
"G:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include",
System, false, false, false);
}
}
break;
case llvm::Triple::MinGW64:
case llvm::Triple::MinGW32:
AddPath("c:/mingw/include", System, true, false, false);
break;
default:
break;
}
AddPath("/usr/local/include", System, true, false, false);
AddPath("/usr/include", System, false, false, false);
}
示例6: addPlatformSearchDirs
void GnuLdDriver::addPlatformSearchDirs(ELFLinkingContext &ctx,
llvm::Triple &triple,
llvm::Triple &baseTriple) {
if (triple.getOS() == llvm::Triple::NetBSD &&
triple.getArch() == llvm::Triple::x86 &&
baseTriple.getArch() == llvm::Triple::x86_64) {
ctx.addSearchPath("=/usr/lib/i386");
return;
}
ctx.addSearchPath("=/usr/lib");
}
示例7: AddDefaultSystemIncludePaths
void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang,
const llvm::Triple &triple) {
if (Lang.CPlusPlus)
AddDefaultCPlusPlusIncludePaths(triple);
AddDefaultCIncludePaths(triple);
// Add the default framework include paths on Darwin.
if (triple.getOS() == llvm::Triple::Darwin) {
AddPath("/System/Library/Frameworks", System, true, false, true);
AddPath("/Library/Frameworks", System, true, false, true);
}
}
示例8: getOSGroup
static std::string getOSGroup(llvm::Triple const &triple) {
switch (triple.getOS()) {
case llvm::Triple::Darwin :
case llvm::Triple::DragonFly :
case llvm::Triple::FreeBSD :
case llvm::Triple::Linux :
case llvm::Triple::NetBSD :
case llvm::Triple::OpenBSD :
case llvm::Triple::Solaris :
case llvm::Triple::Haiku :
case llvm::Triple::Minix :
return "unix";
default :
return "";
}
}
示例9: isARMBareMetal
/// Is the triple {arm,thumb}-none-none-{eabi,eabihf} ?
static bool isARMBareMetal(const llvm::Triple &Triple) {
if (Triple.getArch() != llvm::Triple::arm &&
Triple.getArch() != llvm::Triple::thumb)
return false;
if (Triple.getVendor() != llvm::Triple::UnknownVendor)
return false;
if (Triple.getOS() != llvm::Triple::UnknownOS)
return false;
if (Triple.getEnvironment() != llvm::Triple::EABI &&
Triple.getEnvironment() != llvm::Triple::EABIHF)
return false;
return true;
}
示例10: getARMFloatABI
static FloatABI::Type getARMFloatABI(const llvm::Triple &triple,
const char *llvmArchSuffix) {
switch (triple.getOS()) {
case llvm::Triple::Darwin:
case llvm::Triple::MacOSX:
case llvm::Triple::IOS: {
// Darwin defaults to "softfp" for v6 and v7.
if (llvm::StringRef(llvmArchSuffix).startswith("v6") ||
llvm::StringRef(llvmArchSuffix).startswith("v7")) {
return FloatABI::SoftFP;
}
return FloatABI::Soft;
}
case llvm::Triple::FreeBSD:
// FreeBSD defaults to soft float
return FloatABI::Soft;
default:
if (triple.getVendorName().startswith("hardfloat"))
return FloatABI::Hard;
if (triple.getVendorName().startswith("softfloat"))
return FloatABI::SoftFP;
switch (triple.getEnvironment()) {
case llvm::Triple::GNUEABIHF:
return FloatABI::Hard;
case llvm::Triple::GNUEABI:
return FloatABI::SoftFP;
case llvm::Triple::EABI:
// EABI is always AAPCS, and if it was not marked 'hard', it's softfp
return FloatABI::SoftFP;
case llvm::Triple::Android: {
if (llvm::StringRef(llvmArchSuffix).startswith("v7")) {
return FloatABI::SoftFP;
}
return FloatABI::Soft;
}
default:
// Assume "soft".
// TODO: Warn the user we are guessing.
return FloatABI::Soft;
}
}
}
示例11: AddDefaultIncludePaths
void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
const llvm::Triple &triple,
const HeaderSearchOptions &HSOpts) {
// NB: This code path is going away. All of the logic is moving into the
// driver which has the information necessary to do target-specific
// selections of default include paths. Each target which moves there will be
// exempted from this logic here until we can delete the entire pile of code.
switch (triple.getOS()) {
default:
break; // Everything else continues to use this routine's logic.
case llvm::Triple::Linux:
case llvm::Triple::Hurd:
case llvm::Triple::Solaris:
return;
case llvm::Triple::Win32:
if (triple.getEnvironment() != llvm::Triple::Cygnus ||
triple.isOSBinFormatMachO())
return;
break;
}
if (Lang.CPlusPlus && !Lang.AsmPreprocessor &&
HSOpts.UseStandardCXXIncludes && HSOpts.UseStandardSystemIncludes) {
if (HSOpts.UseLibcxx) {
AddPath("/usr/include/c++/v1", CXXSystem, false);
} else {
AddDefaultCPlusPlusIncludePaths(Lang, triple, HSOpts);
}
}
AddDefaultCIncludePaths(triple, HSOpts);
// Add the default framework include paths on Darwin.
if (HSOpts.UseStandardSystemIncludes) {
if (triple.isOSDarwin()) {
AddPath("/System/Library/Frameworks", System, true);
AddPath("/Library/Frameworks", System, true);
}
}
}
示例12: getPlatformNameForTriple
StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) {
switch (triple.getOS()) {
case llvm::Triple::UnknownOS:
llvm_unreachable("unknown OS");
case llvm::Triple::CloudABI:
case llvm::Triple::DragonFly:
case llvm::Triple::KFreeBSD:
case llvm::Triple::Lv2:
case llvm::Triple::NetBSD:
case llvm::Triple::OpenBSD:
case llvm::Triple::Solaris:
case llvm::Triple::Haiku:
case llvm::Triple::Minix:
case llvm::Triple::RTEMS:
case llvm::Triple::NaCl:
case llvm::Triple::CNK:
case llvm::Triple::Bitrig:
case llvm::Triple::AIX:
case llvm::Triple::CUDA:
case llvm::Triple::NVCL:
case llvm::Triple::AMDHSA:
case llvm::Triple::ELFIAMCU:
case llvm::Triple::Mesa3D:
return "";
case llvm::Triple::Darwin:
case llvm::Triple::MacOSX:
case llvm::Triple::IOS:
case llvm::Triple::TvOS:
case llvm::Triple::WatchOS:
return getPlatformNameForDarwin(getDarwinPlatformKind(triple));
case llvm::Triple::Linux:
return triple.isAndroid() ? "android" : "linux";
case llvm::Triple::FreeBSD:
return "freebsd";
case llvm::Triple::Win32:
return "windows";
case llvm::Triple::PS4:
return "ps4";
}
llvm_unreachable("unsupported OS");
}
示例13: TargetInfo
AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: TargetInfo(Triple),
GPU(isAMDGCN(Triple) ? GK_GFX6 : parseR600Name(Opts.CPU)),
hasFP64(false), hasFMAF(false), hasLDEXPF(false),
AS(isGenericZero(Triple)) {
if (getTriple().getArch() == llvm::Triple::amdgcn) {
hasFP64 = true;
hasFMAF = true;
hasLDEXPF = true;
}
if (getTriple().getArch() == llvm::Triple::r600) {
if (GPU == GK_EVERGREEN_DOUBLE_OPS || GPU == GK_CAYMAN) {
hasFMAF = true;
}
}
auto IsGenericZero = isGenericZero(Triple);
resetDataLayout(getTriple().getArch() == llvm::Triple::amdgcn
? (IsGenericZero ? DataLayoutStringSIGenericIsZero
: DataLayoutStringSIPrivateIsZero)
: DataLayoutStringR600);
assert(DataLayout->getAllocaAddrSpace() == AS.Private);
setAddressSpaceMap(Triple.getOS() == llvm::Triple::Mesa3D ||
Triple.getEnvironment() == llvm::Triple::OpenCL ||
Triple.getEnvironmentName() == "amdgizcl" ||
!isAMDGCN(Triple));
UseAddrSpaceMapMangling = true;
// Set pointer width and alignment for target address space 0.
PointerWidth = PointerAlign = DataLayout->getPointerSizeInBits();
if (getMaxPointerWidth() == 64) {
LongWidth = LongAlign = 64;
SizeType = UnsignedLong;
PtrDiffType = SignedLong;
IntPtrType = SignedLong;
}
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
}
示例14: useAAPCSForMachO
bool arm::useAAPCSForMachO(const llvm::Triple &T) {
// The backend is hardwired to assume AAPCS for M-class processors, ensure
// the frontend matches that.
return T.getEnvironment() == llvm::Triple::EABI ||
T.getOS() == llvm::Triple::UnknownOS || isARMMProfile(T);
}
示例15: switch
void InitHeaderSearch::
AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple, const HeaderSearchOptions &HSOpts) {
llvm::Triple::OSType os = triple.getOS();
// FIXME: temporary hack: hard-coded paths.
if (triple.isOSDarwin()) {
switch (triple.getArch()) {
default: break;
case llvm::Triple::ppc:
case llvm::Triple::ppc64:
AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
"powerpc-apple-darwin10", "", "ppc64",
triple);
AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0",
"powerpc-apple-darwin10", "", "ppc64",
triple);
break;
case llvm::Triple::x86:
case llvm::Triple::x86_64:
AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
"i686-apple-darwin10", "", "x86_64", triple);
AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0",
"i686-apple-darwin8", "", "", triple);
break;
case llvm::Triple::arm:
case llvm::Triple::thumb:
AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
"arm-apple-darwin10", "v7", "", triple);
AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
"arm-apple-darwin10", "v6", "", triple);
break;
case llvm::Triple::aarch64:
AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
"arm64-apple-darwin10", "", "", triple);
break;
}
return;
}
switch (os) {
case llvm::Triple::Linux:
case llvm::Triple::Solaris:
llvm_unreachable("Include management is handled in the driver.");
break;
case llvm::Triple::Win32:
switch (triple.getEnvironment()) {
default: llvm_unreachable("Include management is handled in the driver.");
case llvm::Triple::Cygnus:
// Cygwin-1.7
AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.7.3");
AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.5.3");
AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.4");
// g++-4 / Cygwin-1.5
AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.2");
break;
}
break;
case llvm::Triple::DragonFly:
AddPath("/usr/include/c++/5.0", CXXSystem, false);
break;
case llvm::Triple::OpenBSD: {
std::string t = triple.getTriple();
if (t.substr(0, 6) == "x86_64")
t.replace(0, 6, "amd64");
AddGnuCPlusPlusIncludePaths("/usr/include/g++",
t, "", "", triple);
break;
}
case llvm::Triple::Minix:
AddGnuCPlusPlusIncludePaths("/usr/gnu/include/c++/4.4.3",
"", "", "", triple);
break;
default:
break;
}
}