19#include "llvm/Config/config.h"
22#include <sys/utsname.h>
30static std::string getOSVersion() {
39static std::string updateTripleOSVersion(std::string TargetTripleString) {
41 std::string::size_type DarwinDashIdx = TargetTripleString.find(
"-darwin");
42 if (DarwinDashIdx != std::string::npos) {
43 TargetTripleString.resize(DarwinDashIdx + strlen(
"-darwin"));
44 TargetTripleString += getOSVersion();
45 return TargetTripleString;
47 std::string::size_type MacOSDashIdx = TargetTripleString.find(
"-macos");
48 if (MacOSDashIdx != std::string::npos) {
49 TargetTripleString.resize(MacOSDashIdx);
52 TargetTripleString +=
"-darwin";
53 TargetTripleString += getOSVersion();
57 if (
Triple(LLVM_HOST_TRIPLE).getOS() == Triple::AIX) {
59 if (
TT.getOS() == Triple::AIX && !
TT.getOSMajorVersion()) {
61 if (uname(&
name) != -1) {
62 std::string NewOSName = std::string(Triple::getOSTypeName(Triple::AIX));
63 NewOSName +=
name.version;
65 NewOSName +=
name.release;
67 TT.setOSName(NewOSName);
72 return TargetTripleString;
75std::string sys::getDefaultTargetTriple() {
76 std::string TargetTripleString =
77 updateTripleOSVersion(LLVM_DEFAULT_TARGET_TRIPLE);
81#if defined(LLVM_TARGET_TRIPLE_ENV)
82 if (
const char *EnvTriple = std::getenv(LLVM_TARGET_TRIPLE_ENV))
83 TargetTripleString = EnvTriple;
86 return TargetTripleString;
Triple - Helper class for working with autoconf configuration names.
This is an optimization pass for GlobalISel generic memory operations.