ADT/Triple: Move a variety of clients to using isOSDarwin() and isOSWindows()

predicates.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129816 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2011-04-19 21:14:45 +00:00
parent e1fe09f682
commit 912225e185
11 changed files with 78 additions and 102 deletions

View File

@ -501,18 +501,16 @@ void DarwinARMAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data,
TargetAsmBackend *llvm::createARMAsmBackend(const Target &T,
const std::string &TT) {
Triple TheTriple(TT);
switch (TheTriple.getOS()) {
case Triple::Darwin: {
if (TheTriple.isOSDarwin()) {
if (TheTriple.getArchName() == "armv6" ||
TheTriple.getArchName() == "thumbv6")
return new DarwinARMAsmBackend(T, object::mach::CSARM_V6);
return new DarwinARMAsmBackend(T, object::mach::CSARM_V7);
}
case Triple::MinGW32:
case Triple::Cygwin:
case Triple::Win32:
if (TheTriple.isOSWindows())
assert(0 && "Windows not supported on ARM");
default:
return new ELFARMAsmBackend(T, Triple(TT).getOS());
}
return new ELFARMAsmBackend(T, Triple(TT).getOS());
}

View File

@ -201,7 +201,7 @@ protected:
bool hasFP16() const { return HasFP16; }
bool hasD16() const { return HasD16; }
bool isTargetDarwin() const { return TargetTriple.getOS() == Triple::Darwin; }
bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
bool isTargetELF() const { return !isTargetDarwin(); }
bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }

View File

@ -24,12 +24,11 @@ using namespace llvm;
static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
Triple TheTriple(TT);
switch (TheTriple.getOS()) {
case Triple::Darwin:
if (TheTriple.isOSDarwin())
return new ARMMCAsmInfoDarwin();
default:
return new ARMELFMCAsmInfo();
}
return new ARMELFMCAsmInfo();
}
// This is duplicated code. Refactor this.
@ -39,17 +38,17 @@ static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
MCCodeEmitter *Emitter,
bool RelaxAll,
bool NoExecStack) {
switch (Triple(TT).getOS()) {
case Triple::Darwin:
Triple TheTriple(TT);
if (TheTriple.isOSDarwin())
return createMachOStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
case Triple::MinGW32:
case Triple::Cygwin:
case Triple::Win32:
if (TheTriple.isOSWindows()) {
llvm_unreachable("ARM does not support Windows COFF format");
return NULL;
default:
return createELFStreamer(Ctx, TAB, OS, Emitter, RelaxAll, NoExecStack);
}
return createELFStreamer(Ctx, TAB, OS, Emitter, RelaxAll, NoExecStack);
}
extern "C" void LLVMInitializeARMTarget() {

View File

@ -150,14 +150,13 @@ void ELFMBlazeAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data,
TargetAsmBackend *llvm::createMBlazeAsmBackend(const Target &T,
const std::string &TT) {
switch (Triple(TT).getOS()) {
case Triple::Darwin:
Triple TheTriple(TT);
if (TheTriple.isOSDarwin())
assert(0 && "Mac not supported on MBlaze");
case Triple::MinGW32:
case Triple::Cygwin:
case Triple::Win32:
if (TheTriple.isOSWindows())
assert(0 && "Windows not supported on MBlaze");
default:
return new ELFMBlazeAsmBackend(T, Triple(TT).getOS());
}
return new ELFMBlazeAsmBackend(T, TheTriple.getOS());
}

View File

@ -36,19 +36,18 @@ static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
bool RelaxAll,
bool NoExecStack) {
Triple TheTriple(TT);
switch (TheTriple.getOS()) {
case Triple::Darwin:
if (TheTriple.isOSDarwin()) {
llvm_unreachable("MBlaze does not support Darwin MACH-O format");
return NULL;
case Triple::MinGW32:
case Triple::Cygwin:
case Triple::Win32:
}
if (TheTriple.isOSWindows()) {
llvm_unreachable("MBlaze does not support Windows COFF format");
return NULL;
default:
return createELFStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll,
NoExecStack);
}
return createELFStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll, NoExecStack);
}

View File

@ -110,10 +110,8 @@ namespace {
TargetAsmBackend *llvm::createPPCAsmBackend(const Target &T,
const std::string &TT) {
switch (Triple(TT).getOS()) {
case Triple::Darwin:
if (Triple(TT).isOSDarwin())
return new DarwinPPCAsmBackend(T);
default:
return 0;
}
return 0;
}

View File

@ -24,7 +24,7 @@ using namespace llvm;
static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
Triple TheTriple(TT);
bool isPPC64 = TheTriple.getArch() == Triple::ppc64;
if (TheTriple.getOS() == Triple::Darwin)
if (TheTriple.isOSDarwin())
return new PPCMCAsmInfoDarwin(isPPC64);
return new PPCLinuxMCAsmInfo(isPPC64);
@ -37,12 +37,10 @@ static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
MCCodeEmitter *Emitter,
bool RelaxAll,
bool NoExecStack) {
switch (Triple(TT).getOS()) {
case Triple::Darwin:
if (Triple(TT).isOSDarwin())
return createMachOStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
default:
return NULL;
}
return NULL;
}
extern "C" void LLVMInitializePowerPCTarget() {

View File

@ -414,34 +414,26 @@ public:
TargetAsmBackend *llvm::createX86_32AsmBackend(const Target &T,
const std::string &TT) {
switch (Triple(TT).getOS()) {
case Triple::Darwin:
Triple TheTriple(TT);
if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
return new DarwinX86_32AsmBackend(T);
case Triple::MinGW32:
case Triple::Cygwin:
case Triple::Win32:
if (Triple(TT).getEnvironment() == Triple::MachO)
return new DarwinX86_32AsmBackend(T);
else
return new WindowsX86AsmBackend(T, false);
default:
return new ELFX86_32AsmBackend(T, Triple(TT).getOS());
}
if (TheTriple.isOSWindows())
return new WindowsX86AsmBackend(T, false);
return new ELFX86_32AsmBackend(T, TheTriple.getOS());
}
TargetAsmBackend *llvm::createX86_64AsmBackend(const Target &T,
const std::string &TT) {
switch (Triple(TT).getOS()) {
case Triple::Darwin:
Triple TheTriple(TT);
if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
return new DarwinX86_64AsmBackend(T);
case Triple::MinGW32:
case Triple::Cygwin:
case Triple::Win32:
if (Triple(TT).getEnvironment() == Triple::MachO)
return new DarwinX86_64AsmBackend(T);
else
return new WindowsX86AsmBackend(T, true);
default:
return new ELFX86_64AsmBackend(T, Triple(TT).getOS());
}
if (TheTriple.isOSWindows())
return new WindowsX86AsmBackend(T, true);
return new ELFX86_64AsmBackend(T, TheTriple.getOS());
}

View File

@ -167,9 +167,13 @@ public:
const Triple &getTargetTriple() const { return TargetTriple; }
bool isTargetDarwin() const { return TargetTriple.getOS() == Triple::Darwin; }
bool isTargetFreeBSD() const { return TargetTriple.getOS() == Triple::FreeBSD; }
bool isTargetSolaris() const { return TargetTriple.getOS() == Triple::Solaris; }
bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
bool isTargetFreeBSD() const {
return TargetTriple.getOS() == Triple::FreeBSD;
}
bool isTargetSolaris() const {
return TargetTriple.getOS() == Triple::Solaris;
}
// ELF is a reasonably sane default and the only other X86 targets we
// support are Darwin and Windows. Just use "not those".

View File

@ -26,19 +26,14 @@ using namespace llvm;
static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
Triple TheTriple(TT);
switch (TheTriple.getOS()) {
case Triple::Darwin:
if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
return new X86MCAsmInfoDarwin(TheTriple);
case Triple::MinGW32:
case Triple::Cygwin:
case Triple::Win32:
if (TheTriple.getEnvironment() == Triple::MachO)
return new X86MCAsmInfoDarwin(TheTriple);
else
return new X86MCAsmInfoCOFF(TheTriple);
default:
return new X86ELFMCAsmInfo(TheTriple);
}
if (TheTriple.isOSWindows())
return new X86MCAsmInfoCOFF(TheTriple);
return new X86ELFMCAsmInfo(TheTriple);
}
static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
@ -48,19 +43,14 @@ static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
bool RelaxAll,
bool NoExecStack) {
Triple TheTriple(TT);
switch (TheTriple.getOS()) {
case Triple::Darwin:
if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
return createMachOStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll);
case Triple::MinGW32:
case Triple::Cygwin:
case Triple::Win32:
if (TheTriple.getEnvironment() == Triple::MachO)
return createMachOStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll);
else
return createWinCOFFStreamer(Ctx, TAB, *_Emitter, _OS, RelaxAll);
default:
return createELFStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll, NoExecStack);
}
if (TheTriple.isOSWindows())
return createWinCOFFStreamer(Ctx, TAB, *_Emitter, _OS, RelaxAll);
return createELFStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll, NoExecStack);
}
extern "C" void LLVMInitializeX86Target() {

View File

@ -758,8 +758,7 @@ int GCC::ExecuteProgram(const std::string &ProgramFile,
// For ARM architectures we don't want this flag. bugpoint isn't
// explicitly told what architecture it is working on, so we get
// it from gcc flags
if ((TargetTriple.getOS() == Triple::Darwin) &&
!IsARMArchitecture(GCCArgs))
if (TargetTriple.isOSDarwin() && !IsARMArchitecture(GCCArgs))
GCCArgs.push_back("-force_cpusubtype_ALL");
}
}
@ -900,7 +899,7 @@ int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType,
GCCArgs.push_back("none");
if (TargetTriple.getArch() == Triple::sparc)
GCCArgs.push_back("-G"); // Compile a shared library, `-G' for Sparc
else if (TargetTriple.getOS() == Triple::Darwin) {
else if (TargetTriple.isOSDarwin()) {
// link all source files into a single module in data segment, rather than
// generating blocks. dynamic_lookup requires that you set
// MACOSX_DEPLOYMENT_TARGET=10.3 in your env. FIXME: it would be better for