本文整理汇总了C++中llvm::Triple::isOSLinux方法的典型用法代码示例。如果您正苦于以下问题:C++ Triple::isOSLinux方法的具体用法?C++ Triple::isOSLinux怎么用?C++ Triple::isOSLinux使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::Triple
的用法示例。
在下文中一共展示了Triple::isOSLinux方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPlatformNameForTriple
StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) {
if (triple.isiOS()) {
if (triple.isTvOS()) {
if (tripleIsAppleTVSimulator(triple))
return "appletvsimulator";
return "appletvos";
}
if (tripleIsiOSSimulator(triple))
return "iphonesimulator";
return "iphoneos";
}
if (triple.isWatchOS()) {
if (tripleIsWatchSimulator(triple))
return "watchsimulator";
return "watchos";
}
if (triple.isAndroid()) {
return "android";
}
if (triple.isMacOSX())
return "macosx";
if (triple.isOSLinux())
return "linux";
if (triple.isOSFreeBSD())
return "freebsd";
return "";
}
示例2: updateRuntimeLibraryPath
static void updateRuntimeLibraryPath(SearchPathOptions &SearchPathOpts,
llvm::Triple &Triple) {
llvm::SmallString<128> LibPath(SearchPathOpts.RuntimeResourcePath);
llvm::sys::path::append(LibPath, getPlatformNameForTriple(Triple));
SearchPathOpts.RuntimeLibraryPath = LibPath.str();
// The linux provided triple for ARM contains a trailing 'l'
// denoting little-endian. This is not used in the path for
// libraries. LLVM matches these SubArchTypes to the generic
// ARMSubArch_v7 (for example) type. If that is the case,
// use the base of the architecture type in the library path.
if (Triple.isOSLinux()) {
switch(Triple.getSubArch()) {
default:
llvm::sys::path::append(LibPath, Triple.getArchName());
break;
case llvm::Triple::SubArchType::ARMSubArch_v7:
llvm::sys::path::append(LibPath, "armv7");
break;
case llvm::Triple::SubArchType::ARMSubArch_v6:
llvm::sys::path::append(LibPath, "armv6");
break;
}
} else {
llvm::sys::path::append(LibPath, Triple.getArchName());
}
SearchPathOpts.RuntimeLibraryImportPath = LibPath.str();
}
示例3: if
OptionSet<SanitizerKind> swift::parseSanitizerArgValues(
const llvm::opt::ArgList &Args,
const llvm::opt::Arg *A,
const llvm::Triple &Triple,
DiagnosticEngine &Diags,
llvm::function_ref<bool(llvm::StringRef)> sanitizerRuntimeLibExists) {
OptionSet<SanitizerKind> sanitizerSet;
// Find the sanitizer kind.
for (int i = 0, n = A->getNumValues(); i != n; ++i) {
StringRef opt = A->getValue(i);
if (opt == "address") {
sanitizerSet |= SanitizerKind::Address;
} else if (opt == "thread") {
sanitizerSet |= SanitizerKind::Thread;
} else if (opt == "fuzzer") {
sanitizerSet |= SanitizerKind::Fuzzer;
} else {
Diags.diagnose(SourceLoc(), diag::error_unsupported_option_argument,
A->getOption().getPrefixedName(), A->getValue(i));
}
}
// Sanitizers are only supported on Linux or Darwin.
if (!(Triple.isOSDarwin() || Triple.isOSLinux())) {
SmallString<128> b;
Diags.diagnose(SourceLoc(), diag::error_unsupported_opt_for_target,
(A->getOption().getPrefixedName() +
StringRef(A->getAsString(Args))).toStringRef(b),
Triple.getTriple());
}
// Address and thread sanitizers can not be enabled concurrently.
if ((sanitizerSet & SanitizerKind::Thread)
&& (sanitizerSet & SanitizerKind::Address)) {
SmallString<128> b1;
SmallString<128> b2;
Diags.diagnose(SourceLoc(), diag::error_argument_not_allowed_with,
(A->getOption().getPrefixedName()
+ toStringRef(SanitizerKind::Address)).toStringRef(b1),
(A->getOption().getPrefixedName()
+ toStringRef(SanitizerKind::Thread)).toStringRef(b2));
}
// Thread Sanitizer only works on OS X and the simulators. It's only supported
// on 64 bit architectures.
if ((sanitizerSet & SanitizerKind::Thread) &&
!isTSanSupported(Triple, sanitizerRuntimeLibExists)) {
SmallString<128> b;
Diags.diagnose(SourceLoc(), diag::error_unsupported_opt_for_target,
(A->getOption().getPrefixedName()
+ toStringRef(SanitizerKind::Thread)).toStringRef(b),
Triple.getTriple());
}
return sanitizerSet;
}
示例4: getMajorArchitectureName
StringRef swift::getMajorArchitectureName(const llvm::Triple &Triple) {
if (Triple.isOSLinux()) {
switch(Triple.getSubArch()) {
default:
return Triple.getArchName();
break;
case llvm::Triple::SubArchType::ARMSubArch_v7:
return "armv7";
break;
case llvm::Triple::SubArchType::ARMSubArch_v6:
return "armv6";
break;
}
} else {
return Triple.getArchName();
}
}
示例5: switch
// This function maps triples to the architecture component of the path
// where the swift_begin.o and swift_end.o objects can be found. This
// is a stop-gap until full Triple support (ala Clang) exists within swiftc.
StringRef
getSectionMagicArch(const llvm::Triple &Triple) {
if (Triple.isOSLinux()) {
switch(Triple.getSubArch()) {
default:
return Triple.getArchName();
break;
case llvm::Triple::SubArchType::ARMSubArch_v7:
return "armv7";
break;
case llvm::Triple::SubArchType::ARMSubArch_v6:
return "armv6";
break;
}
} else {
return Triple.getArchName();
}
}
示例6: getPlatformNameForTriple
StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) {
if (triple.isOSDarwin())
return getPlatformNameForDarwin(getDarwinPlatformKind(triple));
if (triple.isAndroid())
return "android";
if (triple.isOSLinux())
return "linux";
if (triple.isOSFreeBSD())
return "freebsd";
if (triple.isOSWindows())
return "windows";
return "";
}
示例7: getPlatformNameForTriple
StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) {
if (triple.isOSDarwin())
return getPlatformNameForDarwin(getDarwinPlatformKind(triple));
if (triple.isAndroid())
return "android";
if (triple.isOSLinux())
return "linux";
if (triple.isOSFreeBSD())
return "freebsd";
if (triple.isKnownWindowsMSVCEnvironment())
return "windows";
if (triple.isWindowsCygwinEnvironment())
return "cygwin";
if (triple.isWindowsGNUEnvironment())
return "mingw";
return "";
}
示例8: osx
std::pair<bool, bool> LangOptions::setTarget(llvm::Triple triple) {
clearAllPlatformConditionValues();
if (triple.getOS() == llvm::Triple::Darwin &&
triple.getVendor() == llvm::Triple::Apple) {
// Rewrite darwinX.Y triples to macosx10.X'.Y ones.
// It affects code generation on our platform.
llvm::SmallString<16> osxBuf;
llvm::raw_svector_ostream osx(osxBuf);
osx << llvm::Triple::getOSTypeName(llvm::Triple::MacOSX);
unsigned major, minor, micro;
triple.getMacOSXVersion(major, minor, micro);
osx << major << "." << minor;
if (micro != 0)
osx << "." << micro;
triple.setOSName(osx.str());
}
Target = std::move(triple);
bool UnsupportedOS = false;
// Set the "os" platform condition.
if (Target.isMacOSX())
addPlatformConditionValue(PlatformConditionKind::OS, "OSX");
else if (triple.isTvOS())
addPlatformConditionValue(PlatformConditionKind::OS, "tvOS");
else if (triple.isWatchOS())
addPlatformConditionValue(PlatformConditionKind::OS, "watchOS");
else if (triple.isiOS())
addPlatformConditionValue(PlatformConditionKind::OS, "iOS");
else if (triple.isAndroid())
addPlatformConditionValue(PlatformConditionKind::OS, "Android");
else if (triple.isOSLinux())
addPlatformConditionValue(PlatformConditionKind::OS, "Linux");
else if (triple.isOSFreeBSD())
addPlatformConditionValue(PlatformConditionKind::OS, "FreeBSD");
else if (triple.isOSWindows())
addPlatformConditionValue(PlatformConditionKind::OS, "Windows");
else if (triple.isWindowsCygwinEnvironment())
addPlatformConditionValue(PlatformConditionKind::OS, "Cygwin");
else if (triple.isPS4())
addPlatformConditionValue(PlatformConditionKind::OS, "PS4");
else
UnsupportedOS = true;
bool UnsupportedArch = false;
// Set the "arch" platform condition.
switch (Target.getArch()) {
case llvm::Triple::ArchType::arm:
case llvm::Triple::ArchType::thumb:
addPlatformConditionValue(PlatformConditionKind::Arch, "arm");
break;
case llvm::Triple::ArchType::aarch64:
addPlatformConditionValue(PlatformConditionKind::Arch, "arm64");
break;
case llvm::Triple::ArchType::ppc64:
addPlatformConditionValue(PlatformConditionKind::Arch, "powerpc64");
break;
case llvm::Triple::ArchType::ppc64le:
addPlatformConditionValue(PlatformConditionKind::Arch, "powerpc64le");
break;
case llvm::Triple::ArchType::x86:
addPlatformConditionValue(PlatformConditionKind::Arch, "i386");
break;
case llvm::Triple::ArchType::x86_64:
addPlatformConditionValue(PlatformConditionKind::Arch, "x86_64");
break;
case llvm::Triple::ArchType::systemz:
addPlatformConditionValue(PlatformConditionKind::Arch, "s390x");
break;
default:
UnsupportedArch = true;
}
if (UnsupportedOS || UnsupportedArch)
return { UnsupportedOS, UnsupportedArch };
// Set the "_endian" platform condition.
switch (Target.getArch()) {
case llvm::Triple::ArchType::arm:
case llvm::Triple::ArchType::thumb:
addPlatformConditionValue(PlatformConditionKind::Endianness, "little");
break;
case llvm::Triple::ArchType::aarch64:
addPlatformConditionValue(PlatformConditionKind::Endianness, "little");
break;
case llvm::Triple::ArchType::ppc64:
addPlatformConditionValue(PlatformConditionKind::Endianness, "big");
break;
case llvm::Triple::ArchType::ppc64le:
addPlatformConditionValue(PlatformConditionKind::Endianness, "little");
break;
case llvm::Triple::ArchType::x86:
addPlatformConditionValue(PlatformConditionKind::Endianness, "little");
break;
case llvm::Triple::ArchType::x86_64:
addPlatformConditionValue(PlatformConditionKind::Endianness, "little");
//.........这里部分代码省略.........
示例9: sanitizerRuntimeLibExists
OptionSet<SanitizerKind> swift::parseSanitizerArgValues(
const llvm::opt::ArgList &Args,
const llvm::opt::Arg *A,
const llvm::Triple &Triple,
DiagnosticEngine &Diags,
llvm::function_ref<bool(llvm::StringRef, bool)> sanitizerRuntimeLibExists) {
OptionSet<SanitizerKind> sanitizerSet;
// Find the sanitizer kind.
for (int i = 0, n = A->getNumValues(); i != n; ++i) {
auto kind = llvm::StringSwitch<Optional<SanitizerKind>>(A->getValue(i))
.Case("address", SanitizerKind::Address)
.Case("thread", SanitizerKind::Thread)
.Case("fuzzer", SanitizerKind::Fuzzer)
.Default(None);
bool isShared = kind && *kind != SanitizerKind::Fuzzer;
if (!kind) {
Diags.diagnose(SourceLoc(), diag::error_unsupported_option_argument,
A->getOption().getPrefixedName(), A->getValue(i));
} else {
// Support is determined by existance of the sanitizer library.
bool sanitizerSupported =
sanitizerRuntimeLibExists(toFileName(*kind), isShared);
// TSan is explicitly not supported for 32 bits.
if (*kind == SanitizerKind::Thread && !Triple.isArch64Bit())
sanitizerSupported = false;
if (!sanitizerSupported) {
SmallString<128> b;
Diags.diagnose(SourceLoc(), diag::error_unsupported_opt_for_target,
(A->getOption().getPrefixedName() + toStringRef(*kind))
.toStringRef(b),
Triple.getTriple());
} else {
sanitizerSet |= *kind;
}
}
}
// Check that we're one of the known supported targets for sanitizers.
if (!(Triple.isOSDarwin() || Triple.isOSLinux() || Triple.isOSWindows())) {
SmallString<128> b;
Diags.diagnose(SourceLoc(), diag::error_unsupported_opt_for_target,
(A->getOption().getPrefixedName() +
StringRef(A->getAsString(Args))).toStringRef(b),
Triple.getTriple());
}
// Address and thread sanitizers can not be enabled concurrently.
if ((sanitizerSet & SanitizerKind::Thread)
&& (sanitizerSet & SanitizerKind::Address)) {
SmallString<128> b1;
SmallString<128> b2;
Diags.diagnose(SourceLoc(), diag::error_argument_not_allowed_with,
(A->getOption().getPrefixedName()
+ toStringRef(SanitizerKind::Address)).toStringRef(b1),
(A->getOption().getPrefixedName()
+ toStringRef(SanitizerKind::Thread)).toStringRef(b2));
}
return sanitizerSet;
}
示例10: osx
std::pair<bool, bool> LangOptions::setTarget(llvm::Triple triple) {
clearAllTargetConfigOptions();
if (triple.getOS() == llvm::Triple::Darwin &&
triple.getVendor() == llvm::Triple::Apple) {
// Rewrite darwinX.Y triples to macosx10.X'.Y ones.
// It affects code generation on our platform.
llvm::SmallString<16> osxBuf;
llvm::raw_svector_ostream osx(osxBuf);
osx << llvm::Triple::getOSTypeName(llvm::Triple::MacOSX);
unsigned major, minor, micro;
triple.getMacOSXVersion(major, minor, micro);
osx << major << "." << minor;
if (micro != 0)
osx << "." << micro;
triple.setOSName(osx.str());
}
Target = std::move(triple);
bool UnsupportedOS = false;
// Set the "os" target configuration.
if (Target.isMacOSX())
addTargetConfigOption("os", "OSX");
else if (triple.isTvOS())
addTargetConfigOption("os", "tvOS");
else if (triple.isWatchOS())
addTargetConfigOption("os", "watchOS");
else if (triple.isiOS())
addTargetConfigOption("os", "iOS");
else if (triple.isOSLinux())
addTargetConfigOption("os", "Linux");
else {
UnsupportedOS = true;
}
bool UnsupportedArch = false;
// Set the "arch" target configuration.
switch (Target.getArch()) {
case llvm::Triple::ArchType::arm:
addTargetConfigOption("arch", "arm");
break;
case llvm::Triple::ArchType::aarch64:
addTargetConfigOption("arch", "arm64");
break;
case llvm::Triple::ArchType::x86:
addTargetConfigOption("arch", "i386");
break;
case llvm::Triple::ArchType::x86_64:
addTargetConfigOption("arch", "x86_64");
break;
default:
UnsupportedArch = true;
}
if (UnsupportedOS || UnsupportedArch)
return { UnsupportedOS, UnsupportedArch };
// Set the "runtime" target configuration.
if (EnableObjCInterop)
addTargetConfigOption("_runtime", "_ObjC");
else
addTargetConfigOption("_runtime", "_Native");
return { false, false };
}
示例11: getARMTargetFeatures
//.........这里部分代码省略.........
}
// En/disable crc code generation.
if (Arg *A = Args.getLastArg(options::OPT_mcrc, options::OPT_mnocrc)) {
if (A->getOption().matches(options::OPT_mcrc))
Features.push_back("+crc");
else
Features.push_back("-crc");
}
// Look for the last occurrence of -mlong-calls or -mno-long-calls. If
// neither options are specified, see if we are compiling for kernel/kext and
// decide whether to pass "+long-calls" based on the OS and its version.
if (Arg *A = Args.getLastArg(options::OPT_mlong_calls,
options::OPT_mno_long_calls)) {
if (A->getOption().matches(options::OPT_mlong_calls))
Features.push_back("+long-calls");
} else if (KernelOrKext && (!Triple.isiOS() || Triple.isOSVersionLT(6)) &&
!Triple.isWatchOS()) {
Features.push_back("+long-calls");
}
// Generate execute-only output (no data access to code sections).
// This only makes sense for the compiler, not for the assembler.
if (!ForAS) {
// Supported only on ARMv6T2 and ARMv7 and above.
// Cannot be combined with -mno-movt or -mlong-calls
if (Arg *A = Args.getLastArg(options::OPT_mexecute_only, options::OPT_mno_execute_only)) {
if (A->getOption().matches(options::OPT_mexecute_only)) {
if (getARMSubArchVersionNumber(Triple) < 7 &&
llvm::ARM::parseArch(Triple.getArchName()) != llvm::ARM::ArchKind::ARMV6T2)
D.Diag(diag::err_target_unsupported_execute_only) << Triple.getArchName();
else if (Arg *B = Args.getLastArg(options::OPT_mno_movt))
D.Diag(diag::err_opt_not_valid_with_opt) << A->getAsString(Args) << B->getAsString(Args);
// Long calls create constant pool entries and have not yet been fixed up
// to play nicely with execute-only. Hence, they cannot be used in
// execute-only code for now
else if (Arg *B = Args.getLastArg(options::OPT_mlong_calls, options::OPT_mno_long_calls)) {
if (B->getOption().matches(options::OPT_mlong_calls))
D.Diag(diag::err_opt_not_valid_with_opt) << A->getAsString(Args) << B->getAsString(Args);
}
Features.push_back("+execute-only");
}
}
}
// Kernel code has more strict alignment requirements.
if (KernelOrKext)
Features.push_back("+strict-align");
else if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
options::OPT_munaligned_access)) {
if (A->getOption().matches(options::OPT_munaligned_access)) {
// No v6M core supports unaligned memory access (v6M ARM ARM A3.2).
if (Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
D.Diag(diag::err_target_unsupported_unaligned) << "v6m";
// v8M Baseline follows on from v6M, so doesn't support unaligned memory
// access either.
else if (Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v8m_baseline)
D.Diag(diag::err_target_unsupported_unaligned) << "v8m.base";
} else
Features.push_back("+strict-align");
} else {
// Assume pre-ARMv6 doesn't support unaligned accesses.
//
// ARMv6 may or may not support unaligned accesses depending on the
// SCTLR.U bit, which is architecture-specific. We assume ARMv6
// Darwin and NetBSD targets support unaligned accesses, and others don't.
//
// ARMv7 always has SCTLR.U set to 1, but it has a new SCTLR.A bit
// which raises an alignment fault on unaligned accesses. Linux
// defaults this bit to 0 and handles it as a system-wide (not
// per-process) setting. It is therefore safe to assume that ARMv7+
// Linux targets support unaligned accesses. The same goes for NaCl.
//
// The above behavior is consistent with GCC.
int VersionNum = getARMSubArchVersionNumber(Triple);
if (Triple.isOSDarwin() || Triple.isOSNetBSD()) {
if (VersionNum < 6 ||
Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
Features.push_back("+strict-align");
} else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
if (VersionNum < 7)
Features.push_back("+strict-align");
} else
Features.push_back("+strict-align");
}
// llvm does not support reserving registers in general. There is support
// for reserving r9 on ARM though (defined as a platform-specific register
// in ARM EABI).
if (Args.hasArg(options::OPT_ffixed_r9))
Features.push_back("+reserve-r9");
// The kext linker doesn't know how to deal with movw/movt.
if (KernelOrKext || Args.hasArg(options::OPT_mno_movt))
Features.push_back("+no-movt");
if (Args.hasArg(options::OPT_mno_neg_immediates))
Features.push_back("+no-neg-immediates");
}