llvm.org GIT mirror llvm / 912225e
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 Daniel Dunbar 9 years ago
11 changed file(s) with 80 addition(s) and 104 deletion(s). Raw diff Collapse all Expand all
500500 TargetAsmBackend *llvm::createARMAsmBackend(const Target &T,
501501 const std::string &TT) {
502502 Triple TheTriple(TT);
503 switch (TheTriple.getOS()) {
504 case Triple::Darwin: {
503
504 if (TheTriple.isOSDarwin()) {
505505 if (TheTriple.getArchName() == "armv6" ||
506506 TheTriple.getArchName() == "thumbv6")
507507 return new DarwinARMAsmBackend(T, object::mach::CSARM_V6);
508508 return new DarwinARMAsmBackend(T, object::mach::CSARM_V7);
509509 }
510 case Triple::MinGW32:
511 case Triple::Cygwin:
512 case Triple::Win32:
510
511 if (TheTriple.isOSWindows())
513512 assert(0 && "Windows not supported on ARM");
514 default:
515 return new ELFARMAsmBackend(T, Triple(TT).getOS());
516 }
517 }
513
514 return new ELFARMAsmBackend(T, Triple(TT).getOS());
515 }
200200 bool hasFP16() const { return HasFP16; }
201201 bool hasD16() const { return HasD16; }
202202
203 bool isTargetDarwin() const { return TargetTriple.getOS() == Triple::Darwin; }
203 bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
204204 bool isTargetELF() const { return !isTargetDarwin(); }
205205
206206 bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
2323
2424 static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
2525 Triple TheTriple(TT);
26 switch (TheTriple.getOS()) {
27 case Triple::Darwin:
26
27 if (TheTriple.isOSDarwin())
2828 return new ARMMCAsmInfoDarwin();
29 default:
30 return new ARMELFMCAsmInfo();
31 }
29
30 return new ARMELFMCAsmInfo();
3231 }
3332
3433 // This is duplicated code. Refactor this.
3837 MCCodeEmitter *Emitter,
3938 bool RelaxAll,
4039 bool NoExecStack) {
41 switch (Triple(TT).getOS()) {
42 case Triple::Darwin:
40 Triple TheTriple(TT);
41
42 if (TheTriple.isOSDarwin())
4343 return createMachOStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
44 case Triple::MinGW32:
45 case Triple::Cygwin:
46 case Triple::Win32:
44
45 if (TheTriple.isOSWindows()) {
4746 llvm_unreachable("ARM does not support Windows COFF format");
4847 return NULL;
49 default:
50 return createELFStreamer(Ctx, TAB, OS, Emitter, RelaxAll, NoExecStack);
5148 }
49
50 return createELFStreamer(Ctx, TAB, OS, Emitter, RelaxAll, NoExecStack);
5251 }
5352
5453 extern "C" void LLVMInitializeARMTarget() {
149149
150150 TargetAsmBackend *llvm::createMBlazeAsmBackend(const Target &T,
151151 const std::string &TT) {
152 switch (Triple(TT).getOS()) {
153 case Triple::Darwin:
152 Triple TheTriple(TT);
153
154 if (TheTriple.isOSDarwin())
154155 assert(0 && "Mac not supported on MBlaze");
155 case Triple::MinGW32:
156 case Triple::Cygwin:
157 case Triple::Win32:
156
157 if (TheTriple.isOSWindows())
158158 assert(0 && "Windows not supported on MBlaze");
159 default:
160 return new ELFMBlazeAsmBackend(T, Triple(TT).getOS());
161 }
159
160 return new ELFMBlazeAsmBackend(T, TheTriple.getOS());
162161 }
3535 bool RelaxAll,
3636 bool NoExecStack) {
3737 Triple TheTriple(TT);
38 switch (TheTriple.getOS()) {
39 case Triple::Darwin:
38
39 if (TheTriple.isOSDarwin()) {
4040 llvm_unreachable("MBlaze does not support Darwin MACH-O format");
4141 return NULL;
42 case Triple::MinGW32:
43 case Triple::Cygwin:
44 case Triple::Win32:
42 }
43
44 if (TheTriple.isOSWindows()) {
4545 llvm_unreachable("MBlaze does not support Windows COFF format");
4646 return NULL;
47 default:
48 return createELFStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll,
49 NoExecStack);
5047 }
48
49 return createELFStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll, NoExecStack);
5150 }
5251
5352
109109
110110 TargetAsmBackend *llvm::createPPCAsmBackend(const Target &T,
111111 const std::string &TT) {
112 switch (Triple(TT).getOS()) {
113 case Triple::Darwin:
112 if (Triple(TT).isOSDarwin())
114113 return new DarwinPPCAsmBackend(T);
115 default:
116 return 0;
117 }
114
115 return 0;
118116 }
2323 static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
2424 Triple TheTriple(TT);
2525 bool isPPC64 = TheTriple.getArch() == Triple::ppc64;
26 if (TheTriple.getOS() == Triple::Darwin)
26 if (TheTriple.isOSDarwin())
2727 return new PPCMCAsmInfoDarwin(isPPC64);
2828 return new PPCLinuxMCAsmInfo(isPPC64);
2929
3636 MCCodeEmitter *Emitter,
3737 bool RelaxAll,
3838 bool NoExecStack) {
39 switch (Triple(TT).getOS()) {
40 case Triple::Darwin:
39 if (Triple(TT).isOSDarwin())
4140 return createMachOStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
42 default:
43 return NULL;
44 }
41
42 return NULL;
4543 }
4644
4745 extern "C" void LLVMInitializePowerPCTarget() {
413413
414414 TargetAsmBackend *llvm::createX86_32AsmBackend(const Target &T,
415415 const std::string &TT) {
416 switch (Triple(TT).getOS()) {
417 case Triple::Darwin:
416 Triple TheTriple(TT);
417
418 if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
418419 return new DarwinX86_32AsmBackend(T);
419 case Triple::MinGW32:
420 case Triple::Cygwin:
421 case Triple::Win32:
422 if (Triple(TT).getEnvironment() == Triple::MachO)
423 return new DarwinX86_32AsmBackend(T);
424 else
425 return new WindowsX86AsmBackend(T, false);
426 default:
427 return new ELFX86_32AsmBackend(T, Triple(TT).getOS());
428 }
420
421 if (TheTriple.isOSWindows())
422 return new WindowsX86AsmBackend(T, false);
423
424 return new ELFX86_32AsmBackend(T, TheTriple.getOS());
429425 }
430426
431427 TargetAsmBackend *llvm::createX86_64AsmBackend(const Target &T,
432428 const std::string &TT) {
433 switch (Triple(TT).getOS()) {
434 case Triple::Darwin:
429 Triple TheTriple(TT);
430
431 if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
435432 return new DarwinX86_64AsmBackend(T);
436 case Triple::MinGW32:
437 case Triple::Cygwin:
438 case Triple::Win32:
439 if (Triple(TT).getEnvironment() == Triple::MachO)
440 return new DarwinX86_64AsmBackend(T);
441 else
442 return new WindowsX86AsmBackend(T, true);
443 default:
444 return new ELFX86_64AsmBackend(T, Triple(TT).getOS());
445 }
446 }
433
434 if (TheTriple.isOSWindows())
435 return new WindowsX86AsmBackend(T, true);
436
437 return new ELFX86_64AsmBackend(T, TheTriple.getOS());
438 }
166166
167167 const Triple &getTargetTriple() const { return TargetTriple; }
168168
169 bool isTargetDarwin() const { return TargetTriple.getOS() == Triple::Darwin; }
170 bool isTargetFreeBSD() const { return TargetTriple.getOS() == Triple::FreeBSD; }
171 bool isTargetSolaris() const { return TargetTriple.getOS() == Triple::Solaris; }
169 bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
170 bool isTargetFreeBSD() const {
171 return TargetTriple.getOS() == Triple::FreeBSD;
172 }
173 bool isTargetSolaris() const {
174 return TargetTriple.getOS() == Triple::Solaris;
175 }
172176
173177 // ELF is a reasonably sane default and the only other X86 targets we
174178 // support are Darwin and Windows. Just use "not those".
2525
2626 static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
2727 Triple TheTriple(TT);
28 switch (TheTriple.getOS()) {
29 case Triple::Darwin:
28
29 if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
3030 return new X86MCAsmInfoDarwin(TheTriple);
31 case Triple::MinGW32:
32 case Triple::Cygwin:
33 case Triple::Win32:
34 if (TheTriple.getEnvironment() == Triple::MachO)
35 return new X86MCAsmInfoDarwin(TheTriple);
36 else
37 return new X86MCAsmInfoCOFF(TheTriple);
38 default:
39 return new X86ELFMCAsmInfo(TheTriple);
40 }
31
32 if (TheTriple.isOSWindows())
33 return new X86MCAsmInfoCOFF(TheTriple);
34
35 return new X86ELFMCAsmInfo(TheTriple);
4136 }
4237
4338 static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
4742 bool RelaxAll,
4843 bool NoExecStack) {
4944 Triple TheTriple(TT);
50 switch (TheTriple.getOS()) {
51 case Triple::Darwin:
45
46 if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
5247 return createMachOStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll);
53 case Triple::MinGW32:
54 case Triple::Cygwin:
55 case Triple::Win32:
56 if (TheTriple.getEnvironment() == Triple::MachO)
57 return createMachOStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll);
58 else
59 return createWinCOFFStreamer(Ctx, TAB, *_Emitter, _OS, RelaxAll);
60 default:
61 return createELFStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll, NoExecStack);
62 }
48
49 if (TheTriple.isOSWindows())
50 return createWinCOFFStreamer(Ctx, TAB, *_Emitter, _OS, RelaxAll);
51
52 return createELFStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll, NoExecStack);
6353 }
6454
6555 extern "C" void LLVMInitializeX86Target() {
757757 // For ARM architectures we don't want this flag. bugpoint isn't
758758 // explicitly told what architecture it is working on, so we get
759759 // it from gcc flags
760 if ((TargetTriple.getOS() == Triple::Darwin) &&
761 !IsARMArchitecture(GCCArgs))
760 if (TargetTriple.isOSDarwin() && !IsARMArchitecture(GCCArgs))
762761 GCCArgs.push_back("-force_cpusubtype_ALL");
763762 }
764763 }
899898 GCCArgs.push_back("none");
900899 if (TargetTriple.getArch() == Triple::sparc)
901900 GCCArgs.push_back("-G"); // Compile a shared library, `-G' for Sparc
902 else if (TargetTriple.getOS() == Triple::Darwin) {
901 else if (TargetTriple.isOSDarwin()) {
903902 // link all source files into a single module in data segment, rather than
904903 // generating blocks. dynamic_lookup requires that you set
905904 // MACOSX_DEPLOYMENT_TARGET=10.3 in your env. FIXME: it would be better for