Clean up some usage of Triple. The base class has methods for determining if the target is iOS and Linux.

llvm-svn: 189604
This commit is contained in:
Cameron Esfahani 2013-08-29 20:23:14 +00:00
parent 8d362a999e
commit 943908b78d
8 changed files with 17 additions and 15 deletions

View File

@ -323,7 +323,7 @@ public:
return getOS() == Triple::Win32 || getOS() == Triple::MinGW32;
}
/// isOSWindows - Is this a "Windows" OS.
/// \brief Tests whether the OS is Windows.
bool isOSWindows() const {
return getOS() == Triple::Win32 || isOSCygMing();
}
@ -333,6 +333,11 @@ public:
return getOS() == Triple::NaCl;
}
/// \brief Tests whether the OS is Linux.
bool isOSLinux() const {
return getOS() == Triple::Linux;
}
/// \brief Tests whether the OS uses the ELF binary format.
bool isOSBinFormatELF() const {
return !isOSDarwin() && !isOSWindows();

View File

@ -91,7 +91,7 @@ TargetMachine *EngineBuilder::selectTarget(const Triple &TargetTriple,
// FIXME: non-iOS ARM FastISel is broken with MCJIT.
if (UseMCJIT &&
TheTriple.getArch() == Triple::arm &&
TheTriple.getOS() != Triple::IOS &&
!TheTriple.isiOS() &&
OptLevel == CodeGenOpt::None) {
OptLevel = CodeGenOpt::Less;
}

View File

@ -46,7 +46,7 @@ public:
bool GVIsIndirectSymbol(const GlobalValue *GV, Reloc::Model RelocM) const;
bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
bool isTargetLinux() const { return TargetTriple.getOS() == Triple::Linux; }
bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
bool hasNEON() const { return HasNEON; }

View File

@ -421,7 +421,7 @@ ARMTargetLowering::ARMTargetLowering(TargetMachine &TM)
}
// Use divmod compiler-rt calls for iOS 5.0 and later.
if (Subtarget->getTargetTriple().getOS() == Triple::IOS &&
if (Subtarget->getTargetTriple().isiOS() &&
!Subtarget->getTargetTriple().isOSVersionLT(5, 0)) {
setLibcallName(RTLIB::SDIVREM_I32, "__divmodsi4");
setLibcallName(RTLIB::UDIVREM_I32, "__udivmodsi4");

View File

@ -275,10 +275,10 @@ public:
const Triple &getTargetTriple() const { return TargetTriple; }
bool isTargetIOS() const { return TargetTriple.getOS() == Triple::IOS; }
bool isTargetIOS() const { return TargetTriple.isiOS(); }
bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
bool isTargetNaCl() const { return TargetTriple.getOS() == Triple::NaCl; }
bool isTargetLinux() const { return TargetTriple.getOS() == Triple::Linux; }
bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
bool isTargetELF() const { return !isTargetDarwin(); }
// ARM EABI is the bare-metal EABI described in ARM ABI documents and
// can be accessed via -target arm-none-eabi. This is NOT GNUEABI.

View File

@ -58,8 +58,7 @@ public:
}
bool isTargetDarwin() const {
Triple TT(STI.getTargetTriple());
Triple::OSType OS = TT.getOS();
return OS == Triple::Darwin || OS == Triple::MacOSX || OS == Triple::IOS;
return TT.isOSDarwin();
}
unsigned getMachineSoImmOpValue(unsigned SoImm) const;

View File

@ -350,7 +350,7 @@ static void initialize(TargetLibraryInfo &TLI, const Triple &T,
if (T.isMacOSX()) {
if (T.isMacOSXVersionLT(10, 5))
TLI.setUnavailable(LibFunc::memset_pattern16);
} else if (T.getOS() == Triple::IOS) {
} else if (T.isiOS()) {
if (T.isOSVersionLT(3, 0))
TLI.setUnavailable(LibFunc::memset_pattern16);
} else {
@ -562,7 +562,7 @@ static void initialize(TargetLibraryInfo &TLI, const Triple &T,
}
// The following functions are available on at least Linux:
if (T.getOS() != Triple::Linux) {
if (!T.isOSLinux()) {
TLI.setUnavailable(LibFunc::dunder_strdup);
TLI.setUnavailable(LibFunc::dunder_strtok_r);
TLI.setUnavailable(LibFunc::dunder_isoc99_scanf);

View File

@ -311,10 +311,8 @@ public:
return (TargetTriple.getEnvironment() == Triple::ELF ||
TargetTriple.isOSBinFormatELF());
}
bool isTargetLinux() const { return TargetTriple.getOS() == Triple::Linux; }
bool isTargetNaCl() const {
return TargetTriple.getOS() == Triple::NaCl;
}
bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
bool isTargetNaCl32() const { return isTargetNaCl() && !is64Bit(); }
bool isTargetNaCl64() const { return isTargetNaCl() && is64Bit(); }
bool isTargetWindows() const { return TargetTriple.getOS() == Triple::Win32; }