Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1 | //===--- Targets.cpp - Implement -arch option and targets -----------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 0bc735f | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 10 | // This file implements construction of a TargetInfo object from a |
Ted Kremenek | bbced58 | 2007-12-12 18:05:32 +0000 | [diff] [blame] | 11 | // target triple. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 15 | #include "clang/Basic/TargetInfo.h" |
Daniel Dunbar | d58c03f | 2009-11-15 06:48:46 +0000 | [diff] [blame] | 16 | #include "clang/Basic/Builtins.h" |
| 17 | #include "clang/Basic/Diagnostic.h" |
Chris Lattner | 8fc4dfb | 2008-12-04 22:54:33 +0000 | [diff] [blame] | 18 | #include "clang/Basic/LangOptions.h" |
Chandler Carruth | 103b71c | 2010-01-20 06:13:02 +0000 | [diff] [blame] | 19 | #include "clang/Basic/MacroBuilder.h" |
Daniel Dunbar | d58c03f | 2009-11-15 06:48:46 +0000 | [diff] [blame] | 20 | #include "clang/Basic/TargetBuiltins.h" |
| 21 | #include "clang/Basic/TargetOptions.h" |
Eli Friedman | 2553126 | 2008-05-20 14:27:34 +0000 | [diff] [blame] | 22 | #include "llvm/ADT/APFloat.h" |
Daniel Dunbar | d58c03f | 2009-11-15 06:48:46 +0000 | [diff] [blame] | 23 | #include "llvm/ADT/OwningPtr.h" |
Daniel Dunbar | 29a790b | 2009-11-11 09:38:56 +0000 | [diff] [blame] | 24 | #include "llvm/ADT/STLExtras.h" |
Daniel Dunbar | 7765934 | 2009-08-19 20:04:03 +0000 | [diff] [blame] | 25 | #include "llvm/ADT/StringRef.h" |
Daniel Dunbar | 29a790b | 2009-11-11 09:38:56 +0000 | [diff] [blame] | 26 | #include "llvm/ADT/StringSwitch.h" |
Chris Lattner | 4c28b1c | 2009-08-12 06:24:27 +0000 | [diff] [blame] | 27 | #include "llvm/ADT/Triple.h" |
Chandler Carruth | 3b844ba | 2013-01-02 11:45:17 +0000 | [diff] [blame] | 28 | #include "llvm/IR/Type.h" |
Chris Lattner | 797c3c4 | 2009-08-10 19:03:04 +0000 | [diff] [blame] | 29 | #include "llvm/MC/MCSectionMachO.h" |
David Blaikie | 9fe8c74 | 2011-09-23 05:35:21 +0000 | [diff] [blame] | 30 | #include "llvm/Support/ErrorHandling.h" |
Benjamin Kramer | 4872508 | 2010-01-09 18:20:57 +0000 | [diff] [blame] | 31 | #include <algorithm> |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 32 | using namespace clang; |
| 33 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 34 | //===----------------------------------------------------------------------===// |
| 35 | // Common code shared among targets. |
| 36 | //===----------------------------------------------------------------------===// |
| 37 | |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 38 | /// DefineStd - Define a macro name and standard variants. For example if |
| 39 | /// MacroName is "unix", then this will define "__unix", "__unix__", and "unix" |
| 40 | /// when in GNU mode. |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 41 | static void DefineStd(MacroBuilder &Builder, StringRef MacroName, |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 42 | const LangOptions &Opts) { |
| 43 | assert(MacroName[0] != '_' && "Identifier should be in the user's namespace"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 44 | |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 45 | // If in GNU mode (e.g. -std=gnu99 but not -std=c99) define the raw identifier |
| 46 | // in the user's namespace. |
| 47 | if (Opts.GNUMode) |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 48 | Builder.defineMacro(MacroName); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 49 | |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 50 | // Define __unix. |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 51 | Builder.defineMacro("__" + MacroName); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 52 | |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 53 | // Define __unix__. |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 54 | Builder.defineMacro("__" + MacroName + "__"); |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 55 | } |
| 56 | |
Benjamin Kramer | 448f68d | 2012-01-10 11:50:09 +0000 | [diff] [blame] | 57 | static void defineCPUMacros(MacroBuilder &Builder, StringRef CPUName, |
| 58 | bool Tuning = true) { |
| 59 | Builder.defineMacro("__" + CPUName); |
| 60 | Builder.defineMacro("__" + CPUName + "__"); |
| 61 | if (Tuning) |
| 62 | Builder.defineMacro("__tune_" + CPUName + "__"); |
| 63 | } |
| 64 | |
Chris Lattner | d29b630 | 2008-10-05 21:50:58 +0000 | [diff] [blame] | 65 | //===----------------------------------------------------------------------===// |
| 66 | // Defines specific to certain operating systems. |
| 67 | //===----------------------------------------------------------------------===// |
Chris Lattner | 797c3c4 | 2009-08-10 19:03:04 +0000 | [diff] [blame] | 68 | |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 69 | namespace { |
Douglas Gregor | a384492 | 2009-07-01 15:12:53 +0000 | [diff] [blame] | 70 | template<typename TgtInfo> |
| 71 | class OSTargetInfo : public TgtInfo { |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 72 | protected: |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 73 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 74 | MacroBuilder &Builder) const=0; |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 75 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 76 | OSTargetInfo(const llvm::Triple &Triple) : TgtInfo(Triple) {} |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 77 | virtual void getTargetDefines(const LangOptions &Opts, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 78 | MacroBuilder &Builder) const { |
| 79 | TgtInfo::getTargetDefines(Opts, Builder); |
| 80 | getOSDefines(Opts, TgtInfo::getTriple(), Builder); |
Torok Edwin | b0a5b24 | 2009-06-30 17:00:25 +0000 | [diff] [blame] | 81 | } |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 82 | |
| 83 | }; |
Chris Lattner | 4c28b1c | 2009-08-12 06:24:27 +0000 | [diff] [blame] | 84 | } // end anonymous namespace |
Torok Edwin | b0a5b24 | 2009-06-30 17:00:25 +0000 | [diff] [blame] | 85 | |
Chris Lattner | 797c3c4 | 2009-08-10 19:03:04 +0000 | [diff] [blame] | 86 | |
Daniel Dunbar | 21ae319 | 2010-01-26 01:44:04 +0000 | [diff] [blame] | 87 | static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts, |
Douglas Gregor | 0a0d2b1 | 2011-03-23 00:50:03 +0000 | [diff] [blame] | 88 | const llvm::Triple &Triple, |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 89 | StringRef &PlatformName, |
Douglas Gregor | 0a0d2b1 | 2011-03-23 00:50:03 +0000 | [diff] [blame] | 90 | VersionTuple &PlatformMinVersion) { |
Bob Wilson | d588f5c | 2013-08-19 20:23:37 +0000 | [diff] [blame] | 91 | Builder.defineMacro("__APPLE_CC__", "6000"); |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 92 | Builder.defineMacro("__APPLE__"); |
| 93 | Builder.defineMacro("__MACH__"); |
| 94 | Builder.defineMacro("OBJC_NEW_PROPERTIES"); |
Alexander Potapenko | 087c65f | 2012-09-20 10:10:01 +0000 | [diff] [blame] | 95 | // AddressSanitizer doesn't play well with source fortification, which is on |
| 96 | // by default on Darwin. |
Will Dietz | 4f45bc0 | 2013-01-18 11:30:38 +0000 | [diff] [blame] | 97 | if (Opts.Sanitize.Address) Builder.defineMacro("_FORTIFY_SOURCE", "0"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 98 | |
John McCall | 098df7f | 2011-06-16 00:03:19 +0000 | [diff] [blame] | 99 | if (!Opts.ObjCAutoRefCount) { |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 100 | // __weak is always defined, for use in blocks and with objc pointers. |
| 101 | Builder.defineMacro("__weak", "__attribute__((objc_gc(weak)))"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 102 | |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 103 | // Darwin defines __strong even in C mode (just to nothing). |
Douglas Gregor | e289d81 | 2011-09-13 17:21:33 +0000 | [diff] [blame] | 104 | if (Opts.getGC() != LangOptions::NonGC) |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 105 | Builder.defineMacro("__strong", "__attribute__((objc_gc(strong)))"); |
| 106 | else |
| 107 | Builder.defineMacro("__strong", ""); |
Eric Christopher | 7c9adf9 | 2011-07-07 22:55:26 +0000 | [diff] [blame] | 108 | |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 109 | // __unsafe_unretained is defined to nothing in non-ARC mode. We even |
| 110 | // allow this in C, since one might have block pointers in structs that |
| 111 | // are used in pure C code and in Objective-C ARC. |
| 112 | Builder.defineMacro("__unsafe_unretained", ""); |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 113 | } |
Eric Christopher | 7c9adf9 | 2011-07-07 22:55:26 +0000 | [diff] [blame] | 114 | |
Eli Friedman | 2de4fee | 2009-06-04 23:00:29 +0000 | [diff] [blame] | 115 | if (Opts.Static) |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 116 | Builder.defineMacro("__STATIC__"); |
Eli Friedman | 2de4fee | 2009-06-04 23:00:29 +0000 | [diff] [blame] | 117 | else |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 118 | Builder.defineMacro("__DYNAMIC__"); |
Daniel Dunbar | 5345c39 | 2009-09-03 04:54:28 +0000 | [diff] [blame] | 119 | |
| 120 | if (Opts.POSIXThreads) |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 121 | Builder.defineMacro("_REENTRANT"); |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 122 | |
Daniel Dunbar | 0d027ba | 2011-04-19 21:40:34 +0000 | [diff] [blame] | 123 | // Get the platform type and version number from the triple. |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 124 | unsigned Maj, Min, Rev; |
Bob Wilson | 48b68a0 | 2012-01-31 23:52:58 +0000 | [diff] [blame] | 125 | if (Triple.isMacOSX()) { |
| 126 | Triple.getMacOSXVersion(Maj, Min, Rev); |
Daniel Dunbar | 0d027ba | 2011-04-19 21:40:34 +0000 | [diff] [blame] | 127 | PlatformName = "macosx"; |
Daniel Dunbar | 0d027ba | 2011-04-19 21:40:34 +0000 | [diff] [blame] | 128 | } else { |
Bob Wilson | 48b68a0 | 2012-01-31 23:52:58 +0000 | [diff] [blame] | 129 | Triple.getOSVersion(Maj, Min, Rev); |
| 130 | PlatformName = llvm::Triple::getOSTypeName(Triple.getOS()); |
Daniel Dunbar | 0d027ba | 2011-04-19 21:40:34 +0000 | [diff] [blame] | 131 | } |
Daniel Dunbar | 21ae319 | 2010-01-26 01:44:04 +0000 | [diff] [blame] | 132 | |
Sebastian Pop | 9ec60df | 2012-01-20 22:01:23 +0000 | [diff] [blame] | 133 | // If -target arch-pc-win32-macho option specified, we're |
Eric Christopher | 895d422 | 2011-07-29 21:20:35 +0000 | [diff] [blame] | 134 | // generating code for Win32 ABI. No need to emit |
Chad Rosier | d9259f3 | 2011-07-19 20:00:06 +0000 | [diff] [blame] | 135 | // __ENVIRONMENT_XX_OS_VERSION_MIN_REQUIRED__. |
| 136 | if (PlatformName == "win32") { |
| 137 | PlatformMinVersion = VersionTuple(Maj, Min, Rev); |
| 138 | return; |
| 139 | } |
| 140 | |
Daniel Dunbar | 21ae319 | 2010-01-26 01:44:04 +0000 | [diff] [blame] | 141 | // Set the appropriate OS version define. |
Bob Wilson | 48b68a0 | 2012-01-31 23:52:58 +0000 | [diff] [blame] | 142 | if (Triple.getOS() == llvm::Triple::IOS) { |
Daniel Dunbar | 8a3a7f3 | 2011-04-21 21:27:33 +0000 | [diff] [blame] | 143 | assert(Maj < 10 && Min < 100 && Rev < 100 && "Invalid version!"); |
Daniel Dunbar | 21ae319 | 2010-01-26 01:44:04 +0000 | [diff] [blame] | 144 | char Str[6]; |
| 145 | Str[0] = '0' + Maj; |
| 146 | Str[1] = '0' + (Min / 10); |
| 147 | Str[2] = '0' + (Min % 10); |
| 148 | Str[3] = '0' + (Rev / 10); |
| 149 | Str[4] = '0' + (Rev % 10); |
| 150 | Str[5] = '\0'; |
| 151 | Builder.defineMacro("__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__", Str); |
| 152 | } else { |
Daniel Dunbar | 8a3a7f3 | 2011-04-21 21:27:33 +0000 | [diff] [blame] | 153 | // Note that the Driver allows versions which aren't representable in the |
| 154 | // define (because we only get a single digit for the minor and micro |
| 155 | // revision numbers). So, we limit them to the maximum representable |
| 156 | // version. |
Daniel Dunbar | 21ae319 | 2010-01-26 01:44:04 +0000 | [diff] [blame] | 157 | assert(Triple.getEnvironmentName().empty() && "Invalid environment!"); |
Daniel Dunbar | 8a3a7f3 | 2011-04-21 21:27:33 +0000 | [diff] [blame] | 158 | assert(Maj < 100 && Min < 100 && Rev < 100 && "Invalid version!"); |
Daniel Dunbar | 21ae319 | 2010-01-26 01:44:04 +0000 | [diff] [blame] | 159 | char Str[5]; |
| 160 | Str[0] = '0' + (Maj / 10); |
| 161 | Str[1] = '0' + (Maj % 10); |
Daniel Dunbar | 8a3a7f3 | 2011-04-21 21:27:33 +0000 | [diff] [blame] | 162 | Str[2] = '0' + std::min(Min, 9U); |
| 163 | Str[3] = '0' + std::min(Rev, 9U); |
Daniel Dunbar | 21ae319 | 2010-01-26 01:44:04 +0000 | [diff] [blame] | 164 | Str[4] = '\0'; |
| 165 | Builder.defineMacro("__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__", Str); |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 166 | } |
Daniel Dunbar | 0d027ba | 2011-04-19 21:40:34 +0000 | [diff] [blame] | 167 | |
| 168 | PlatformMinVersion = VersionTuple(Maj, Min, Rev); |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 169 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 170 | |
Chris Lattner | 797c3c4 | 2009-08-10 19:03:04 +0000 | [diff] [blame] | 171 | namespace { |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 172 | template<typename Target> |
| 173 | class DarwinTargetInfo : public OSTargetInfo<Target> { |
| 174 | protected: |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 175 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 176 | MacroBuilder &Builder) const { |
Eric Christopher | 7c9adf9 | 2011-07-07 22:55:26 +0000 | [diff] [blame] | 177 | getDarwinDefines(Builder, Opts, Triple, this->PlatformName, |
Douglas Gregor | 0a0d2b1 | 2011-03-23 00:50:03 +0000 | [diff] [blame] | 178 | this->PlatformMinVersion); |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 179 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 180 | |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 181 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 182 | DarwinTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) { |
| 183 | this->TLSSupported = Triple.isMacOSX() && !Triple.isMacOSXVersionLT(10, 7); |
| 184 | this->MCountName = "\01mcount"; |
| 185 | } |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 186 | |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 187 | virtual std::string isValidSectionSpecifier(StringRef SR) const { |
Chris Lattner | 797c3c4 | 2009-08-10 19:03:04 +0000 | [diff] [blame] | 188 | // Let MCSectionMachO validate this. |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 189 | StringRef Segment, Section; |
Chris Lattner | 797c3c4 | 2009-08-10 19:03:04 +0000 | [diff] [blame] | 190 | unsigned TAA, StubSize; |
Daniel Dunbar | 9ae186f | 2011-03-19 02:06:21 +0000 | [diff] [blame] | 191 | bool HasTAA; |
Chris Lattner | 797c3c4 | 2009-08-10 19:03:04 +0000 | [diff] [blame] | 192 | return llvm::MCSectionMachO::ParseSectionSpecifier(SR, Segment, Section, |
Daniel Dunbar | 9ae186f | 2011-03-19 02:06:21 +0000 | [diff] [blame] | 193 | TAA, HasTAA, StubSize); |
Chris Lattner | 797c3c4 | 2009-08-10 19:03:04 +0000 | [diff] [blame] | 194 | } |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 195 | |
Anders Carlsson | 18af368 | 2010-06-08 22:47:50 +0000 | [diff] [blame] | 196 | virtual const char *getStaticInitSectionSpecifier() const { |
| 197 | // FIXME: We should return 0 when building kexts. |
| 198 | return "__TEXT,__StaticInit,regular,pure_instructions"; |
| 199 | } |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 200 | |
John McCall | 4188760 | 2012-01-29 01:20:30 +0000 | [diff] [blame] | 201 | /// Darwin does not support protected visibility. Darwin's "default" |
| 202 | /// is very similar to ELF's "protected"; Darwin requires a "weak" |
| 203 | /// attribute on declarations that can be dynamically replaced. |
| 204 | virtual bool hasProtectedVisibility() const { |
| 205 | return false; |
| 206 | } |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 207 | }; |
| 208 | |
Chris Lattner | 797c3c4 | 2009-08-10 19:03:04 +0000 | [diff] [blame] | 209 | |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 210 | // DragonFlyBSD Target |
| 211 | template<typename Target> |
| 212 | class DragonFlyBSDTargetInfo : public OSTargetInfo<Target> { |
| 213 | protected: |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 214 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 215 | MacroBuilder &Builder) const { |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 216 | // DragonFly defines; list based off of gcc output |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 217 | Builder.defineMacro("__DragonFly__"); |
| 218 | Builder.defineMacro("__DragonFly_cc_version", "100001"); |
| 219 | Builder.defineMacro("__ELF__"); |
| 220 | Builder.defineMacro("__KPRINTF_ATTRIBUTE__"); |
| 221 | Builder.defineMacro("__tune_i386__"); |
| 222 | DefineStd(Builder, "unix", Opts); |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 223 | } |
| 224 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 225 | DragonFlyBSDTargetInfo(const llvm::Triple &Triple) |
| 226 | : OSTargetInfo<Target>(Triple) { |
| 227 | this->UserLabelPrefix = ""; |
Eli Friedman | b089c4d | 2012-02-10 23:02:29 +0000 | [diff] [blame] | 228 | |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 229 | switch (Triple.getArch()) { |
| 230 | default: |
| 231 | case llvm::Triple::x86: |
| 232 | case llvm::Triple::x86_64: |
| 233 | this->MCountName = ".mcount"; |
| 234 | break; |
| 235 | } |
Eli Friedman | b089c4d | 2012-02-10 23:02:29 +0000 | [diff] [blame] | 236 | } |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 237 | }; |
| 238 | |
| 239 | // FreeBSD Target |
| 240 | template<typename Target> |
| 241 | class FreeBSDTargetInfo : public OSTargetInfo<Target> { |
| 242 | protected: |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 243 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 244 | MacroBuilder &Builder) const { |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 245 | // FreeBSD defines; list based off of gcc output |
| 246 | |
Benjamin Kramer | 474202f | 2011-10-18 10:10:08 +0000 | [diff] [blame] | 247 | unsigned Release = Triple.getOSMajorVersion(); |
| 248 | if (Release == 0U) |
| 249 | Release = 8; |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 250 | |
Benjamin Kramer | 474202f | 2011-10-18 10:10:08 +0000 | [diff] [blame] | 251 | Builder.defineMacro("__FreeBSD__", Twine(Release)); |
| 252 | Builder.defineMacro("__FreeBSD_cc_version", Twine(Release * 100000U + 1U)); |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 253 | Builder.defineMacro("__KPRINTF_ATTRIBUTE__"); |
| 254 | DefineStd(Builder, "unix", Opts); |
| 255 | Builder.defineMacro("__ELF__"); |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 256 | } |
| 257 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 258 | FreeBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) { |
| 259 | this->UserLabelPrefix = ""; |
Roman Divacky | be4c870 | 2011-02-10 16:52:03 +0000 | [diff] [blame] | 260 | |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 261 | switch (Triple.getArch()) { |
| 262 | default: |
| 263 | case llvm::Triple::x86: |
| 264 | case llvm::Triple::x86_64: |
| 265 | this->MCountName = ".mcount"; |
| 266 | break; |
| 267 | case llvm::Triple::mips: |
| 268 | case llvm::Triple::mipsel: |
| 269 | case llvm::Triple::ppc: |
| 270 | case llvm::Triple::ppc64: |
Bill Schmidt | ea7fb0c | 2013-07-26 01:36:11 +0000 | [diff] [blame] | 271 | case llvm::Triple::ppc64le: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 272 | this->MCountName = "_mcount"; |
| 273 | break; |
| 274 | case llvm::Triple::arm: |
| 275 | this->MCountName = "__mcount"; |
| 276 | break; |
Duncan Sands | 1e90faf | 2009-07-08 13:55:08 +0000 | [diff] [blame] | 277 | } |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 278 | } |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 279 | }; |
| 280 | |
Sylvestre Ledru | 3309a78 | 2013-09-05 13:47:07 +0000 | [diff] [blame] | 281 | // GNU/kFreeBSD Target |
| 282 | template<typename Target> |
| 283 | class KFreeBSDTargetInfo : public OSTargetInfo<Target> { |
| 284 | protected: |
| 285 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
| 286 | MacroBuilder &Builder) const { |
| 287 | // GNU/kFreeBSD defines; list based off of gcc output |
| 288 | |
| 289 | DefineStd(Builder, "unix", Opts); |
| 290 | Builder.defineMacro("__FreeBSD_kernel__"); |
| 291 | Builder.defineMacro("__GLIBC__"); |
| 292 | Builder.defineMacro("__ELF__"); |
| 293 | if (Opts.POSIXThreads) |
| 294 | Builder.defineMacro("_REENTRANT"); |
| 295 | if (Opts.CPlusPlus) |
| 296 | Builder.defineMacro("_GNU_SOURCE"); |
| 297 | } |
| 298 | public: |
Sylvestre Ledru | deb7799 | 2013-09-05 13:58:07 +0000 | [diff] [blame] | 299 | KFreeBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) { |
Sylvestre Ledru | 3309a78 | 2013-09-05 13:47:07 +0000 | [diff] [blame] | 300 | this->UserLabelPrefix = ""; |
| 301 | } |
| 302 | }; |
| 303 | |
Chris Lattner | 38e317d | 2010-07-07 16:01:42 +0000 | [diff] [blame] | 304 | // Minix Target |
| 305 | template<typename Target> |
| 306 | class MinixTargetInfo : public OSTargetInfo<Target> { |
| 307 | protected: |
| 308 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
| 309 | MacroBuilder &Builder) const { |
| 310 | // Minix defines |
| 311 | |
| 312 | Builder.defineMacro("__minix", "3"); |
| 313 | Builder.defineMacro("_EM_WSIZE", "4"); |
| 314 | Builder.defineMacro("_EM_PSIZE", "4"); |
| 315 | Builder.defineMacro("_EM_SSIZE", "2"); |
| 316 | Builder.defineMacro("_EM_LSIZE", "4"); |
| 317 | Builder.defineMacro("_EM_FSIZE", "4"); |
| 318 | Builder.defineMacro("_EM_DSIZE", "8"); |
Eli Friedman | 6d402dc | 2011-12-08 23:54:21 +0000 | [diff] [blame] | 319 | Builder.defineMacro("__ELF__"); |
Chris Lattner | 38e317d | 2010-07-07 16:01:42 +0000 | [diff] [blame] | 320 | DefineStd(Builder, "unix", Opts); |
| 321 | } |
| 322 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 323 | MinixTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) { |
| 324 | this->UserLabelPrefix = ""; |
| 325 | } |
Chris Lattner | 38e317d | 2010-07-07 16:01:42 +0000 | [diff] [blame] | 326 | }; |
| 327 | |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 328 | // Linux target |
| 329 | template<typename Target> |
| 330 | class LinuxTargetInfo : public OSTargetInfo<Target> { |
| 331 | protected: |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 332 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 333 | MacroBuilder &Builder) const { |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 334 | // Linux defines; list based off of gcc output |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 335 | DefineStd(Builder, "unix", Opts); |
| 336 | DefineStd(Builder, "linux", Opts); |
| 337 | Builder.defineMacro("__gnu_linux__"); |
| 338 | Builder.defineMacro("__ELF__"); |
Logan Chien | 94a7142 | 2012-09-02 09:30:11 +0000 | [diff] [blame] | 339 | if (Triple.getEnvironment() == llvm::Triple::Android) |
Evgeniy Stepanov | 3206403 | 2012-04-26 12:08:09 +0000 | [diff] [blame] | 340 | Builder.defineMacro("__ANDROID__", "1"); |
Daniel Dunbar | 5345c39 | 2009-09-03 04:54:28 +0000 | [diff] [blame] | 341 | if (Opts.POSIXThreads) |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 342 | Builder.defineMacro("_REENTRANT"); |
Douglas Gregor | 2b003fd | 2010-04-21 05:52:38 +0000 | [diff] [blame] | 343 | if (Opts.CPlusPlus) |
| 344 | Builder.defineMacro("_GNU_SOURCE"); |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 345 | } |
| 346 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 347 | LinuxTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) { |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 348 | this->UserLabelPrefix = ""; |
Douglas Gregor | 12e8464 | 2011-01-12 21:19:25 +0000 | [diff] [blame] | 349 | this->WIntType = TargetInfo::UnsignedInt; |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 350 | } |
Benjamin Kramer | 86d18c5 | 2011-10-15 17:53:33 +0000 | [diff] [blame] | 351 | |
| 352 | virtual const char *getStaticInitSectionSpecifier() const { |
| 353 | return ".text.startup"; |
| 354 | } |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 355 | }; |
| 356 | |
Chris Lattner | b62bb28 | 2009-07-13 20:29:08 +0000 | [diff] [blame] | 357 | // NetBSD Target |
| 358 | template<typename Target> |
| 359 | class NetBSDTargetInfo : public OSTargetInfo<Target> { |
| 360 | protected: |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 361 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 362 | MacroBuilder &Builder) const { |
Chris Lattner | b62bb28 | 2009-07-13 20:29:08 +0000 | [diff] [blame] | 363 | // NetBSD defines; list based off of gcc output |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 364 | Builder.defineMacro("__NetBSD__"); |
| 365 | Builder.defineMacro("__unix__"); |
| 366 | Builder.defineMacro("__ELF__"); |
Daniel Dunbar | 5345c39 | 2009-09-03 04:54:28 +0000 | [diff] [blame] | 367 | if (Opts.POSIXThreads) |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 368 | Builder.defineMacro("_POSIX_THREADS"); |
Chris Lattner | b62bb28 | 2009-07-13 20:29:08 +0000 | [diff] [blame] | 369 | } |
| 370 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 371 | NetBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) { |
| 372 | this->UserLabelPrefix = ""; |
| 373 | } |
Chris Lattner | b62bb28 | 2009-07-13 20:29:08 +0000 | [diff] [blame] | 374 | }; |
| 375 | |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 376 | // OpenBSD Target |
| 377 | template<typename Target> |
| 378 | class OpenBSDTargetInfo : public OSTargetInfo<Target> { |
| 379 | protected: |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 380 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 381 | MacroBuilder &Builder) const { |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 382 | // OpenBSD defines; list based off of gcc output |
| 383 | |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 384 | Builder.defineMacro("__OpenBSD__"); |
| 385 | DefineStd(Builder, "unix", Opts); |
| 386 | Builder.defineMacro("__ELF__"); |
Daniel Dunbar | 5345c39 | 2009-09-03 04:54:28 +0000 | [diff] [blame] | 387 | if (Opts.POSIXThreads) |
Chris Lattner | 4ddcf3b | 2012-04-25 06:12:24 +0000 | [diff] [blame] | 388 | Builder.defineMacro("_REENTRANT"); |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 389 | } |
| 390 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 391 | OpenBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) { |
| 392 | this->UserLabelPrefix = ""; |
| 393 | this->TLSSupported = false; |
Eli Friedman | 62d829a | 2011-12-15 02:15:56 +0000 | [diff] [blame] | 394 | |
Eli Friedman | 62d829a | 2011-12-15 02:15:56 +0000 | [diff] [blame] | 395 | switch (Triple.getArch()) { |
| 396 | default: |
| 397 | case llvm::Triple::x86: |
| 398 | case llvm::Triple::x86_64: |
| 399 | case llvm::Triple::arm: |
Eric Christopher | 825d386 | 2012-11-14 22:08:59 +0000 | [diff] [blame] | 400 | case llvm::Triple::sparc: |
Eli Friedman | 62d829a | 2011-12-15 02:15:56 +0000 | [diff] [blame] | 401 | this->MCountName = "__mcount"; |
| 402 | break; |
| 403 | case llvm::Triple::mips64: |
| 404 | case llvm::Triple::mips64el: |
| 405 | case llvm::Triple::ppc: |
Eric Christopher | 825d386 | 2012-11-14 22:08:59 +0000 | [diff] [blame] | 406 | case llvm::Triple::sparcv9: |
Eli Friedman | 62d829a | 2011-12-15 02:15:56 +0000 | [diff] [blame] | 407 | this->MCountName = "_mcount"; |
| 408 | break; |
| 409 | } |
| 410 | } |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 411 | }; |
| 412 | |
Eli Friedman | 42f74f2 | 2012-08-08 23:57:20 +0000 | [diff] [blame] | 413 | // Bitrig Target |
| 414 | template<typename Target> |
| 415 | class BitrigTargetInfo : public OSTargetInfo<Target> { |
| 416 | protected: |
| 417 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
| 418 | MacroBuilder &Builder) const { |
| 419 | // Bitrig defines; list based off of gcc output |
| 420 | |
| 421 | Builder.defineMacro("__Bitrig__"); |
| 422 | DefineStd(Builder, "unix", Opts); |
| 423 | Builder.defineMacro("__ELF__"); |
| 424 | if (Opts.POSIXThreads) |
| 425 | Builder.defineMacro("_REENTRANT"); |
| 426 | } |
| 427 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 428 | BitrigTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) { |
| 429 | this->UserLabelPrefix = ""; |
| 430 | this->TLSSupported = false; |
| 431 | this->MCountName = "__mcount"; |
Eli Friedman | 42f74f2 | 2012-08-08 23:57:20 +0000 | [diff] [blame] | 432 | } |
| 433 | }; |
| 434 | |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 435 | // PSP Target |
| 436 | template<typename Target> |
| 437 | class PSPTargetInfo : public OSTargetInfo<Target> { |
| 438 | protected: |
| 439 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 440 | MacroBuilder &Builder) const { |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 441 | // PSP defines; list based on the output of the pspdev gcc toolchain. |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 442 | Builder.defineMacro("PSP"); |
| 443 | Builder.defineMacro("_PSP"); |
| 444 | Builder.defineMacro("__psp__"); |
| 445 | Builder.defineMacro("__ELF__"); |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 446 | } |
| 447 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 448 | PSPTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) { |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 449 | this->UserLabelPrefix = ""; |
| 450 | } |
| 451 | }; |
| 452 | |
John Thompson | 3f6918a | 2009-11-19 17:18:50 +0000 | [diff] [blame] | 453 | // PS3 PPU Target |
| 454 | template<typename Target> |
| 455 | class PS3PPUTargetInfo : public OSTargetInfo<Target> { |
| 456 | protected: |
| 457 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 458 | MacroBuilder &Builder) const { |
John Thompson | 3f6918a | 2009-11-19 17:18:50 +0000 | [diff] [blame] | 459 | // PS3 PPU defines. |
John Thompson | fb45797 | 2010-03-25 16:18:32 +0000 | [diff] [blame] | 460 | Builder.defineMacro("__PPC__"); |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 461 | Builder.defineMacro("__PPU__"); |
| 462 | Builder.defineMacro("__CELLOS_LV2__"); |
| 463 | Builder.defineMacro("__ELF__"); |
| 464 | Builder.defineMacro("__LP32__"); |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 465 | Builder.defineMacro("_ARCH_PPC64"); |
| 466 | Builder.defineMacro("__powerpc64__"); |
John Thompson | 3f6918a | 2009-11-19 17:18:50 +0000 | [diff] [blame] | 467 | } |
| 468 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 469 | PS3PPUTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) { |
John Thompson | 3f6918a | 2009-11-19 17:18:50 +0000 | [diff] [blame] | 470 | this->UserLabelPrefix = ""; |
Nick Lewycky | 9952070 | 2011-12-16 22:32:39 +0000 | [diff] [blame] | 471 | this->LongWidth = this->LongAlign = 32; |
| 472 | this->PointerWidth = this->PointerAlign = 32; |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 473 | this->IntMaxType = TargetInfo::SignedLongLong; |
| 474 | this->UIntMaxType = TargetInfo::UnsignedLongLong; |
| 475 | this->Int64Type = TargetInfo::SignedLongLong; |
John Thompson | ec387af | 2009-12-18 14:21:08 +0000 | [diff] [blame] | 476 | this->SizeType = TargetInfo::UnsignedInt; |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 477 | this->DescriptionString = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
Nick Lewycky | 9952070 | 2011-12-16 22:32:39 +0000 | [diff] [blame] | 478 | "i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32"; |
John Thompson | 3f6918a | 2009-11-19 17:18:50 +0000 | [diff] [blame] | 479 | } |
| 480 | }; |
| 481 | |
| 482 | // FIXME: Need a real SPU target. |
| 483 | // PS3 SPU Target |
| 484 | template<typename Target> |
| 485 | class PS3SPUTargetInfo : public OSTargetInfo<Target> { |
| 486 | protected: |
| 487 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 488 | MacroBuilder &Builder) const { |
John Thompson | 3f6918a | 2009-11-19 17:18:50 +0000 | [diff] [blame] | 489 | // PS3 PPU defines. |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 490 | Builder.defineMacro("__SPU__"); |
| 491 | Builder.defineMacro("__ELF__"); |
John Thompson | 3f6918a | 2009-11-19 17:18:50 +0000 | [diff] [blame] | 492 | } |
| 493 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 494 | PS3SPUTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) { |
John Thompson | 3f6918a | 2009-11-19 17:18:50 +0000 | [diff] [blame] | 495 | this->UserLabelPrefix = ""; |
| 496 | } |
| 497 | }; |
| 498 | |
Edward O'Callaghan | 991f9a7 | 2009-10-18 13:33:59 +0000 | [diff] [blame] | 499 | // AuroraUX target |
| 500 | template<typename Target> |
| 501 | class AuroraUXTargetInfo : public OSTargetInfo<Target> { |
| 502 | protected: |
| 503 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 504 | MacroBuilder &Builder) const { |
| 505 | DefineStd(Builder, "sun", Opts); |
| 506 | DefineStd(Builder, "unix", Opts); |
| 507 | Builder.defineMacro("__ELF__"); |
| 508 | Builder.defineMacro("__svr4__"); |
| 509 | Builder.defineMacro("__SVR4"); |
Edward O'Callaghan | 991f9a7 | 2009-10-18 13:33:59 +0000 | [diff] [blame] | 510 | } |
| 511 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 512 | AuroraUXTargetInfo(const llvm::Triple &Triple) |
| 513 | : OSTargetInfo<Target>(Triple) { |
Edward O'Callaghan | 991f9a7 | 2009-10-18 13:33:59 +0000 | [diff] [blame] | 514 | this->UserLabelPrefix = ""; |
| 515 | this->WCharType = this->SignedLong; |
| 516 | // FIXME: WIntType should be SignedLong |
| 517 | } |
| 518 | }; |
| 519 | |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 520 | // Solaris target |
| 521 | template<typename Target> |
| 522 | class SolarisTargetInfo : public OSTargetInfo<Target> { |
| 523 | protected: |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 524 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 525 | MacroBuilder &Builder) const { |
| 526 | DefineStd(Builder, "sun", Opts); |
| 527 | DefineStd(Builder, "unix", Opts); |
| 528 | Builder.defineMacro("__ELF__"); |
| 529 | Builder.defineMacro("__svr4__"); |
| 530 | Builder.defineMacro("__SVR4"); |
David Chisnall | 165329c | 2012-02-28 17:10:04 +0000 | [diff] [blame] | 531 | // Solaris headers require _XOPEN_SOURCE to be set to 600 for C99 and |
| 532 | // newer, but to 500 for everything else. feature_test.h has a check to |
| 533 | // ensure that you are not using C99 with an old version of X/Open or C89 |
| 534 | // with a new version. |
| 535 | if (Opts.C99 || Opts.C11) |
| 536 | Builder.defineMacro("_XOPEN_SOURCE", "600"); |
| 537 | else |
| 538 | Builder.defineMacro("_XOPEN_SOURCE", "500"); |
David Chisnall | b4f0bd6 | 2012-03-02 10:49:52 +0000 | [diff] [blame] | 539 | if (Opts.CPlusPlus) |
David Chisnall | 165329c | 2012-02-28 17:10:04 +0000 | [diff] [blame] | 540 | Builder.defineMacro("__C99FEATURES__"); |
David Chisnall | 48fad49 | 2012-02-17 18:35:11 +0000 | [diff] [blame] | 541 | Builder.defineMacro("_LARGEFILE_SOURCE"); |
| 542 | Builder.defineMacro("_LARGEFILE64_SOURCE"); |
| 543 | Builder.defineMacro("__EXTENSIONS__"); |
David Chisnall | 165329c | 2012-02-28 17:10:04 +0000 | [diff] [blame] | 544 | Builder.defineMacro("_REENTRANT"); |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 545 | } |
| 546 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 547 | SolarisTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) { |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 548 | this->UserLabelPrefix = ""; |
David Chisnall | fb02784 | 2012-03-28 18:04:14 +0000 | [diff] [blame] | 549 | this->WCharType = this->SignedInt; |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 550 | // FIXME: WIntType should be SignedLong |
| 551 | } |
| 552 | }; |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 553 | |
| 554 | // Windows target |
| 555 | template<typename Target> |
| 556 | class WindowsTargetInfo : public OSTargetInfo<Target> { |
| 557 | protected: |
| 558 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
| 559 | MacroBuilder &Builder) const { |
Michael J. Spencer | a764e83 | 2010-10-21 08:22:51 +0000 | [diff] [blame] | 560 | Builder.defineMacro("_WIN32"); |
| 561 | } |
| 562 | void getVisualStudioDefines(const LangOptions &Opts, |
| 563 | MacroBuilder &Builder) const { |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 564 | if (Opts.CPlusPlus) { |
| 565 | if (Opts.RTTI) |
| 566 | Builder.defineMacro("_CPPRTTI"); |
| 567 | |
| 568 | if (Opts.Exceptions) |
| 569 | Builder.defineMacro("_CPPUNWIND"); |
| 570 | } |
| 571 | |
| 572 | if (!Opts.CharIsSigned) |
| 573 | Builder.defineMacro("_CHAR_UNSIGNED"); |
| 574 | |
| 575 | // FIXME: POSIXThreads isn't exactly the option this should be defined for, |
| 576 | // but it works for now. |
| 577 | if (Opts.POSIXThreads) |
| 578 | Builder.defineMacro("_MT"); |
Michael J. Spencer | a764e83 | 2010-10-21 08:22:51 +0000 | [diff] [blame] | 579 | |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 580 | if (Opts.MSCVersion != 0) |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 581 | Builder.defineMacro("_MSC_VER", Twine(Opts.MSCVersion)); |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 582 | |
Francois Pichet | 62ec1f2 | 2011-09-17 17:15:52 +0000 | [diff] [blame] | 583 | if (Opts.MicrosoftExt) { |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 584 | Builder.defineMacro("_MSC_EXTENSIONS"); |
| 585 | |
Richard Smith | 80ad52f | 2013-01-02 11:42:31 +0000 | [diff] [blame] | 586 | if (Opts.CPlusPlus11) { |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 587 | Builder.defineMacro("_RVALUE_REFERENCES_V2_SUPPORTED"); |
| 588 | Builder.defineMacro("_RVALUE_REFERENCES_SUPPORTED"); |
| 589 | Builder.defineMacro("_NATIVE_NULLPTR_SUPPORTED"); |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | Builder.defineMacro("_INTEGRAL_MAX_BITS", "64"); |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 594 | } |
| 595 | |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 596 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 597 | WindowsTargetInfo(const llvm::Triple &Triple) |
| 598 | : OSTargetInfo<Target>(Triple) {} |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 599 | }; |
| 600 | |
Derek Schuff | 7da46f9 | 2012-10-11 16:55:58 +0000 | [diff] [blame] | 601 | template <typename Target> |
| 602 | class NaClTargetInfo : public OSTargetInfo<Target> { |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 603 | protected: |
Derek Schuff | 7da46f9 | 2012-10-11 16:55:58 +0000 | [diff] [blame] | 604 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
| 605 | MacroBuilder &Builder) const { |
| 606 | if (Opts.POSIXThreads) |
| 607 | Builder.defineMacro("_REENTRANT"); |
| 608 | if (Opts.CPlusPlus) |
| 609 | Builder.defineMacro("_GNU_SOURCE"); |
| 610 | |
| 611 | DefineStd(Builder, "unix", Opts); |
| 612 | Builder.defineMacro("__ELF__"); |
| 613 | Builder.defineMacro("__native_client__"); |
| 614 | } |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 615 | |
| 616 | public: |
| 617 | NaClTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) { |
Derek Schuff | 7da46f9 | 2012-10-11 16:55:58 +0000 | [diff] [blame] | 618 | this->UserLabelPrefix = ""; |
| 619 | this->LongAlign = 32; |
| 620 | this->LongWidth = 32; |
| 621 | this->PointerAlign = 32; |
| 622 | this->PointerWidth = 32; |
| 623 | this->IntMaxType = TargetInfo::SignedLongLong; |
| 624 | this->UIntMaxType = TargetInfo::UnsignedLongLong; |
| 625 | this->Int64Type = TargetInfo::SignedLongLong; |
| 626 | this->DoubleAlign = 64; |
| 627 | this->LongDoubleWidth = 64; |
| 628 | this->LongDoubleAlign = 64; |
| 629 | this->SizeType = TargetInfo::UnsignedInt; |
| 630 | this->PtrDiffType = TargetInfo::SignedInt; |
| 631 | this->IntPtrType = TargetInfo::SignedInt; |
Eli Bendersky | c0783dc | 2013-04-08 21:31:01 +0000 | [diff] [blame] | 632 | // RegParmMax is inherited from the underlying architecture |
Derek Schuff | 7da46f9 | 2012-10-11 16:55:58 +0000 | [diff] [blame] | 633 | this->LongDoubleFormat = &llvm::APFloat::IEEEdouble; |
| 634 | this->DescriptionString = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-" |
| 635 | "f32:32:32-f64:64:64-p:32:32:32-v128:32:32"; |
| 636 | } |
Derek Schuff | 263366f | 2012-10-16 22:30:41 +0000 | [diff] [blame] | 637 | virtual typename Target::CallingConvCheckResult checkCallingConvention( |
| 638 | CallingConv CC) const { |
| 639 | return CC == CC_PnaclCall ? Target::CCCR_OK : |
| 640 | Target::checkCallingConvention(CC); |
| 641 | } |
Derek Schuff | 7da46f9 | 2012-10-11 16:55:58 +0000 | [diff] [blame] | 642 | }; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 643 | } // end anonymous namespace. |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 644 | |
Chris Lattner | d29b630 | 2008-10-05 21:50:58 +0000 | [diff] [blame] | 645 | //===----------------------------------------------------------------------===// |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 646 | // Specific target implementations. |
| 647 | //===----------------------------------------------------------------------===// |
Anders Carlsson | fb5e5ba | 2007-10-13 00:45:48 +0000 | [diff] [blame] | 648 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 649 | namespace { |
| 650 | // PPC abstract base class |
| 651 | class PPCTargetInfo : public TargetInfo { |
| 652 | static const Builtin::Info BuiltinInfo[]; |
| 653 | static const char * const GCCRegNames[]; |
| 654 | static const TargetInfo::GCCRegAlias GCCRegAliases[]; |
Hal Finkel | 02a8427 | 2012-06-11 22:35:19 +0000 | [diff] [blame] | 655 | std::string CPU; |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 656 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 657 | PPCTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) { |
Bill Schmidt | ea7fb0c | 2013-07-26 01:36:11 +0000 | [diff] [blame] | 658 | BigEndian = (Triple.getArch() != llvm::Triple::ppc64le); |
Nico Weber | 6e1d2ea | 2012-01-31 02:07:33 +0000 | [diff] [blame] | 659 | LongDoubleWidth = LongDoubleAlign = 128; |
| 660 | LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble; |
| 661 | } |
Eli Friedman | 15b9176 | 2009-06-05 07:05:05 +0000 | [diff] [blame] | 662 | |
Hal Finkel | 39d5fa1 | 2012-07-03 16:51:04 +0000 | [diff] [blame] | 663 | /// \brief Flags for architecture specific defines. |
| 664 | typedef enum { |
| 665 | ArchDefineNone = 0, |
| 666 | ArchDefineName = 1 << 0, // <name> is substituted for arch name. |
| 667 | ArchDefinePpcgr = 1 << 1, |
| 668 | ArchDefinePpcsq = 1 << 2, |
| 669 | ArchDefine440 = 1 << 3, |
| 670 | ArchDefine603 = 1 << 4, |
| 671 | ArchDefine604 = 1 << 5, |
| 672 | ArchDefinePwr4 = 1 << 6, |
Bill Schmidt | 2821e18 | 2013-02-01 20:23:10 +0000 | [diff] [blame] | 673 | ArchDefinePwr5 = 1 << 7, |
| 674 | ArchDefinePwr5x = 1 << 8, |
| 675 | ArchDefinePwr6 = 1 << 9, |
| 676 | ArchDefinePwr6x = 1 << 10, |
| 677 | ArchDefinePwr7 = 1 << 11, |
| 678 | ArchDefineA2 = 1 << 12, |
| 679 | ArchDefineA2q = 1 << 13 |
Hal Finkel | 39d5fa1 | 2012-07-03 16:51:04 +0000 | [diff] [blame] | 680 | } ArchDefineTypes; |
| 681 | |
Bill Schmidt | 2821e18 | 2013-02-01 20:23:10 +0000 | [diff] [blame] | 682 | // Note: GCC recognizes the following additional cpus: |
| 683 | // 401, 403, 405, 405fp, 440fp, 464, 464fp, 476, 476fp, 505, 740, 801, |
| 684 | // 821, 823, 8540, 8548, e300c2, e300c3, e500mc64, e6500, 860, cell, |
| 685 | // titan, rs64. |
Hal Finkel | 02a8427 | 2012-06-11 22:35:19 +0000 | [diff] [blame] | 686 | virtual bool setCPU(const std::string &Name) { |
| 687 | bool CPUKnown = llvm::StringSwitch<bool>(Name) |
| 688 | .Case("generic", true) |
| 689 | .Case("440", true) |
| 690 | .Case("450", true) |
| 691 | .Case("601", true) |
| 692 | .Case("602", true) |
| 693 | .Case("603", true) |
| 694 | .Case("603e", true) |
| 695 | .Case("603ev", true) |
| 696 | .Case("604", true) |
| 697 | .Case("604e", true) |
| 698 | .Case("620", true) |
Bill Schmidt | 2821e18 | 2013-02-01 20:23:10 +0000 | [diff] [blame] | 699 | .Case("630", true) |
Hal Finkel | 02a8427 | 2012-06-11 22:35:19 +0000 | [diff] [blame] | 700 | .Case("g3", true) |
| 701 | .Case("7400", true) |
| 702 | .Case("g4", true) |
| 703 | .Case("7450", true) |
| 704 | .Case("g4+", true) |
| 705 | .Case("750", true) |
| 706 | .Case("970", true) |
| 707 | .Case("g5", true) |
| 708 | .Case("a2", true) |
Hal Finkel | 5ccd3d0 | 2013-02-01 05:53:33 +0000 | [diff] [blame] | 709 | .Case("a2q", true) |
Hal Finkel | 7de3296 | 2012-09-18 22:25:03 +0000 | [diff] [blame] | 710 | .Case("e500mc", true) |
| 711 | .Case("e5500", true) |
Bill Schmidt | 2821e18 | 2013-02-01 20:23:10 +0000 | [diff] [blame] | 712 | .Case("power3", true) |
| 713 | .Case("pwr3", true) |
| 714 | .Case("power4", true) |
| 715 | .Case("pwr4", true) |
| 716 | .Case("power5", true) |
| 717 | .Case("pwr5", true) |
| 718 | .Case("power5x", true) |
| 719 | .Case("pwr5x", true) |
| 720 | .Case("power6", true) |
Hal Finkel | 02a8427 | 2012-06-11 22:35:19 +0000 | [diff] [blame] | 721 | .Case("pwr6", true) |
Bill Schmidt | 2821e18 | 2013-02-01 20:23:10 +0000 | [diff] [blame] | 722 | .Case("power6x", true) |
| 723 | .Case("pwr6x", true) |
| 724 | .Case("power7", true) |
Hal Finkel | 02a8427 | 2012-06-11 22:35:19 +0000 | [diff] [blame] | 725 | .Case("pwr7", true) |
Bill Schmidt | 2821e18 | 2013-02-01 20:23:10 +0000 | [diff] [blame] | 726 | .Case("powerpc", true) |
Hal Finkel | 02a8427 | 2012-06-11 22:35:19 +0000 | [diff] [blame] | 727 | .Case("ppc", true) |
Bill Schmidt | 2821e18 | 2013-02-01 20:23:10 +0000 | [diff] [blame] | 728 | .Case("powerpc64", true) |
Hal Finkel | 02a8427 | 2012-06-11 22:35:19 +0000 | [diff] [blame] | 729 | .Case("ppc64", true) |
Bill Schmidt | ea7fb0c | 2013-07-26 01:36:11 +0000 | [diff] [blame] | 730 | .Case("powerpc64le", true) |
| 731 | .Case("ppc64le", true) |
Hal Finkel | 02a8427 | 2012-06-11 22:35:19 +0000 | [diff] [blame] | 732 | .Default(false); |
| 733 | |
| 734 | if (CPUKnown) |
| 735 | CPU = Name; |
| 736 | |
| 737 | return CPUKnown; |
| 738 | } |
| 739 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 740 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 741 | unsigned &NumRecords) const { |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 742 | Records = BuiltinInfo; |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 743 | NumRecords = clang::PPC::LastTSBuiltin-Builtin::FirstTSBuiltin; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 744 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 745 | |
Bob Wilson | 9f1c49c | 2012-01-28 18:02:29 +0000 | [diff] [blame] | 746 | virtual bool isCLZForZeroUndef() const { return false; } |
| 747 | |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 748 | virtual void getTargetDefines(const LangOptions &Opts, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 749 | MacroBuilder &Builder) const; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 750 | |
Bill Schmidt | 199402b | 2013-02-01 02:14:03 +0000 | [diff] [blame] | 751 | virtual void getDefaultFeatures(llvm::StringMap<bool> &Features) const; |
| 752 | |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 753 | virtual bool hasFeature(StringRef Feature) const; |
| 754 | |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 755 | virtual void getGCCRegNames(const char * const *&Names, |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 756 | unsigned &NumNames) const; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 757 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 758 | unsigned &NumAliases) const; |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 759 | virtual bool validateAsmConstraint(const char *&Name, |
Chris Lattner | 44def07 | 2009-04-26 07:16:29 +0000 | [diff] [blame] | 760 | TargetInfo::ConstraintInfo &Info) const { |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 761 | switch (*Name) { |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 762 | default: return false; |
| 763 | case 'O': // Zero |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 764 | break; |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 765 | case 'b': // Base register |
| 766 | case 'f': // Floating point register |
Chris Lattner | 44def07 | 2009-04-26 07:16:29 +0000 | [diff] [blame] | 767 | Info.setAllowsRegister(); |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 768 | break; |
| 769 | // FIXME: The following are added to allow parsing. |
| 770 | // I just took a guess at what the actions should be. |
| 771 | // Also, is more specific checking needed? I.e. specific registers? |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 772 | case 'd': // Floating point register (containing 64-bit value) |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 773 | case 'v': // Altivec vector register |
| 774 | Info.setAllowsRegister(); |
| 775 | break; |
| 776 | case 'w': |
| 777 | switch (Name[1]) { |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 778 | case 'd':// VSX vector register to hold vector double data |
| 779 | case 'f':// VSX vector register to hold vector float data |
| 780 | case 's':// VSX vector register to hold scalar float data |
| 781 | case 'a':// Any VSX register |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 782 | break; |
| 783 | default: |
| 784 | return false; |
| 785 | } |
| 786 | Info.setAllowsRegister(); |
| 787 | Name++; // Skip over 'w'. |
| 788 | break; |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 789 | case 'h': // `MQ', `CTR', or `LINK' register |
| 790 | case 'q': // `MQ' register |
| 791 | case 'c': // `CTR' register |
| 792 | case 'l': // `LINK' register |
| 793 | case 'x': // `CR' register (condition register) number 0 |
| 794 | case 'y': // `CR' register (condition register) |
| 795 | case 'z': // `XER[CA]' carry bit (part of the XER register) |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 796 | Info.setAllowsRegister(); |
| 797 | break; |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 798 | case 'I': // Signed 16-bit constant |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 799 | case 'J': // Unsigned 16-bit constant shifted left 16 bits |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 800 | // (use `L' instead for SImode constants) |
| 801 | case 'K': // Unsigned 16-bit constant |
| 802 | case 'L': // Signed 16-bit constant shifted left 16 bits |
| 803 | case 'M': // Constant larger than 31 |
| 804 | case 'N': // Exact power of 2 |
| 805 | case 'P': // Constant whose negation is a signed 16-bit constant |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 806 | case 'G': // Floating point constant that can be loaded into a |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 807 | // register with one instruction per word |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 808 | case 'H': // Integer/Floating point constant that can be loaded |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 809 | // into a register using three instructions |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 810 | break; |
| 811 | case 'm': // Memory operand. Note that on PowerPC targets, m can |
| 812 | // include addresses that update the base register. It |
| 813 | // is therefore only safe to use `m' in an asm statement |
| 814 | // if that asm statement accesses the operand exactly once. |
| 815 | // The asm statement must also use `%U<opno>' as a |
Sebastian Redl | 5005a6c | 2010-08-17 22:42:34 +0000 | [diff] [blame] | 816 | // placeholder for the "update" flag in the corresponding |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 817 | // load or store instruction. For example: |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 818 | // asm ("st%U0 %1,%0" : "=m" (mem) : "r" (val)); |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 819 | // is correct but: |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 820 | // asm ("st %1,%0" : "=m" (mem) : "r" (val)); |
| 821 | // is not. Use es rather than m if you don't want the base |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 822 | // register to be updated. |
| 823 | case 'e': |
John Thompson | 56b6eca | 2010-06-25 00:02:05 +0000 | [diff] [blame] | 824 | if (Name[1] != 's') |
| 825 | return false; |
Sebastian Redl | 5005a6c | 2010-08-17 22:42:34 +0000 | [diff] [blame] | 826 | // es: A "stable" memory operand; that is, one which does not |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 827 | // include any automodification of the base register. Unlike |
| 828 | // `m', this constraint can be used in asm statements that |
| 829 | // might access the operand several times, or that might not |
John Thompson | 56b6eca | 2010-06-25 00:02:05 +0000 | [diff] [blame] | 830 | // access it at all. |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 831 | Info.setAllowsMemory(); |
John Thompson | 56b6eca | 2010-06-25 00:02:05 +0000 | [diff] [blame] | 832 | Name++; // Skip over 'e'. |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 833 | break; |
| 834 | case 'Q': // Memory operand that is an offset from a register (it is |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 835 | // usually better to use `m' or `es' in asm statements) |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 836 | case 'Z': // Memory operand that is an indexed or indirect from a |
| 837 | // register (it is usually better to use `m' or `es' in |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 838 | // asm statements) |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 839 | Info.setAllowsMemory(); |
| 840 | Info.setAllowsRegister(); |
| 841 | break; |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 842 | case 'R': // AIX TOC entry |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 843 | case 'a': // Address operand that is an indexed or indirect from a |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 844 | // register (`p' is preferable for asm statements) |
| 845 | case 'S': // Constant suitable as a 64-bit mask operand |
| 846 | case 'T': // Constant suitable as a 32-bit mask operand |
| 847 | case 'U': // System V Release 4 small data area reference |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 848 | case 't': // AND masks that can be performed by two rldic{l, r} |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 849 | // instructions |
| 850 | case 'W': // Vector constant that does not require memory |
| 851 | case 'j': // Vector constant that is all zeros. |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 852 | break; |
| 853 | // End FIXME. |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 854 | } |
John Thompson | 8e6065a | 2010-06-24 22:44:13 +0000 | [diff] [blame] | 855 | return true; |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 856 | } |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 857 | virtual const char *getClobbers() const { |
| 858 | return ""; |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 859 | } |
Adhemerval Zanella | b0fc94c | 2013-01-22 20:02:45 +0000 | [diff] [blame] | 860 | int getEHDataRegisterNumber(unsigned RegNo) const { |
| 861 | if (RegNo == 0) return 3; |
| 862 | if (RegNo == 1) return 4; |
| 863 | return -1; |
| 864 | } |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 865 | }; |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 866 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 867 | const Builtin::Info PPCTargetInfo::BuiltinInfo[] = { |
Eli Friedman | e7e66f7 | 2011-07-05 21:53:01 +0000 | [diff] [blame] | 868 | #define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, ALL_LANGUAGES }, |
Fariborz Jahanian | 67aba81 | 2010-11-30 17:35:24 +0000 | [diff] [blame] | 869 | #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER,\ |
Eli Friedman | e7e66f7 | 2011-07-05 21:53:01 +0000 | [diff] [blame] | 870 | ALL_LANGUAGES }, |
Chris Lattner | 6b15cdc | 2009-06-14 01:05:48 +0000 | [diff] [blame] | 871 | #include "clang/Basic/BuiltinsPPC.def" |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 872 | }; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 873 | |
| 874 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 875 | /// PPCTargetInfo::getTargetDefines - Return a set of the PowerPC-specific |
| 876 | /// #defines that are not tied to a specific subtarget. |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 877 | void PPCTargetInfo::getTargetDefines(const LangOptions &Opts, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 878 | MacroBuilder &Builder) const { |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 879 | // Target identification. |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 880 | Builder.defineMacro("__ppc__"); |
Chandler Carruth | c6fa115 | 2013-06-25 11:13:47 +0000 | [diff] [blame] | 881 | Builder.defineMacro("__PPC__"); |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 882 | Builder.defineMacro("_ARCH_PPC"); |
Chris Lattner | e03ae30 | 2010-02-16 18:14:57 +0000 | [diff] [blame] | 883 | Builder.defineMacro("__powerpc__"); |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 884 | Builder.defineMacro("__POWERPC__"); |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 885 | if (PointerWidth == 64) { |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 886 | Builder.defineMacro("_ARCH_PPC64"); |
Chris Lattner | e03ae30 | 2010-02-16 18:14:57 +0000 | [diff] [blame] | 887 | Builder.defineMacro("__powerpc64__"); |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 888 | Builder.defineMacro("__ppc64__"); |
Chandler Carruth | c6fa115 | 2013-06-25 11:13:47 +0000 | [diff] [blame] | 889 | Builder.defineMacro("__PPC64__"); |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 890 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 891 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 892 | // Target properties. |
Bill Schmidt | ea7fb0c | 2013-07-26 01:36:11 +0000 | [diff] [blame] | 893 | if (getTriple().getArch() == llvm::Triple::ppc64le) { |
| 894 | Builder.defineMacro("_LITTLE_ENDIAN"); |
| 895 | Builder.defineMacro("__LITTLE_ENDIAN__"); |
| 896 | } else { |
| 897 | if (getTriple().getOS() != llvm::Triple::NetBSD && |
| 898 | getTriple().getOS() != llvm::Triple::OpenBSD) |
| 899 | Builder.defineMacro("_BIG_ENDIAN"); |
| 900 | Builder.defineMacro("__BIG_ENDIAN__"); |
| 901 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 902 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 903 | // Subtarget options. |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 904 | Builder.defineMacro("__NATURAL_ALIGNMENT__"); |
| 905 | Builder.defineMacro("__REGISTER_PREFIX__", ""); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 906 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 907 | // FIXME: Should be controlled by command line option. |
Roman Divacky | b2f6f47 | 2013-07-03 19:45:54 +0000 | [diff] [blame] | 908 | if (LongDoubleWidth == 128) |
| 909 | Builder.defineMacro("__LONG_DOUBLE_128__"); |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 910 | |
John Thompson | 3f6918a | 2009-11-19 17:18:50 +0000 | [diff] [blame] | 911 | if (Opts.AltiVec) { |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 912 | Builder.defineMacro("__VEC__", "10206"); |
| 913 | Builder.defineMacro("__ALTIVEC__"); |
John Thompson | 3f6918a | 2009-11-19 17:18:50 +0000 | [diff] [blame] | 914 | } |
Hal Finkel | 02a8427 | 2012-06-11 22:35:19 +0000 | [diff] [blame] | 915 | |
| 916 | // CPU identification. |
Hal Finkel | 39d5fa1 | 2012-07-03 16:51:04 +0000 | [diff] [blame] | 917 | ArchDefineTypes defs = (ArchDefineTypes)llvm::StringSwitch<int>(CPU) |
| 918 | .Case("440", ArchDefineName) |
| 919 | .Case("450", ArchDefineName | ArchDefine440) |
| 920 | .Case("601", ArchDefineName) |
| 921 | .Case("602", ArchDefineName | ArchDefinePpcgr) |
| 922 | .Case("603", ArchDefineName | ArchDefinePpcgr) |
| 923 | .Case("603e", ArchDefineName | ArchDefine603 | ArchDefinePpcgr) |
| 924 | .Case("603ev", ArchDefineName | ArchDefine603 | ArchDefinePpcgr) |
| 925 | .Case("604", ArchDefineName | ArchDefinePpcgr) |
| 926 | .Case("604e", ArchDefineName | ArchDefine604 | ArchDefinePpcgr) |
| 927 | .Case("620", ArchDefineName | ArchDefinePpcgr) |
Bill Schmidt | 2821e18 | 2013-02-01 20:23:10 +0000 | [diff] [blame] | 928 | .Case("630", ArchDefineName | ArchDefinePpcgr) |
Hal Finkel | 39d5fa1 | 2012-07-03 16:51:04 +0000 | [diff] [blame] | 929 | .Case("7400", ArchDefineName | ArchDefinePpcgr) |
| 930 | .Case("7450", ArchDefineName | ArchDefinePpcgr) |
| 931 | .Case("750", ArchDefineName | ArchDefinePpcgr) |
| 932 | .Case("970", ArchDefineName | ArchDefinePwr4 | ArchDefinePpcgr |
| 933 | | ArchDefinePpcsq) |
Hal Finkel | 5ccd3d0 | 2013-02-01 05:53:33 +0000 | [diff] [blame] | 934 | .Case("a2", ArchDefineA2) |
| 935 | .Case("a2q", ArchDefineName | ArchDefineA2 | ArchDefineA2q) |
Bill Schmidt | 2821e18 | 2013-02-01 20:23:10 +0000 | [diff] [blame] | 936 | .Case("pwr3", ArchDefinePpcgr) |
| 937 | .Case("pwr4", ArchDefineName | ArchDefinePpcgr | ArchDefinePpcsq) |
| 938 | .Case("pwr5", ArchDefineName | ArchDefinePwr4 | ArchDefinePpcgr |
| 939 | | ArchDefinePpcsq) |
| 940 | .Case("pwr5x", ArchDefineName | ArchDefinePwr5 | ArchDefinePwr4 |
| 941 | | ArchDefinePpcgr | ArchDefinePpcsq) |
| 942 | .Case("pwr6", ArchDefineName | ArchDefinePwr5x | ArchDefinePwr5 |
| 943 | | ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq) |
| 944 | .Case("pwr6x", ArchDefineName | ArchDefinePwr6 | ArchDefinePwr5x |
| 945 | | ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
| 946 | | ArchDefinePpcsq) |
| 947 | .Case("pwr7", ArchDefineName | ArchDefinePwr6x | ArchDefinePwr6 |
| 948 | | ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
| 949 | | ArchDefinePwr6 | ArchDefinePpcgr | ArchDefinePpcsq) |
| 950 | .Case("power3", ArchDefinePpcgr) |
| 951 | .Case("power4", ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq) |
| 952 | .Case("power5", ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
| 953 | | ArchDefinePpcsq) |
| 954 | .Case("power5x", ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
| 955 | | ArchDefinePpcgr | ArchDefinePpcsq) |
| 956 | .Case("power6", ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
| 957 | | ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq) |
| 958 | .Case("power6x", ArchDefinePwr6x | ArchDefinePwr6 | ArchDefinePwr5x |
| 959 | | ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
| 960 | | ArchDefinePpcsq) |
| 961 | .Case("power7", ArchDefinePwr7 | ArchDefinePwr6x | ArchDefinePwr6 |
| 962 | | ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
| 963 | | ArchDefinePwr6 | ArchDefinePpcgr | ArchDefinePpcsq) |
Hal Finkel | 39d5fa1 | 2012-07-03 16:51:04 +0000 | [diff] [blame] | 964 | .Default(ArchDefineNone); |
| 965 | |
| 966 | if (defs & ArchDefineName) |
| 967 | Builder.defineMacro(Twine("_ARCH_", StringRef(CPU).upper())); |
| 968 | if (defs & ArchDefinePpcgr) |
| 969 | Builder.defineMacro("_ARCH_PPCGR"); |
| 970 | if (defs & ArchDefinePpcsq) |
| 971 | Builder.defineMacro("_ARCH_PPCSQ"); |
| 972 | if (defs & ArchDefine440) |
Hal Finkel | 02a8427 | 2012-06-11 22:35:19 +0000 | [diff] [blame] | 973 | Builder.defineMacro("_ARCH_440"); |
Hal Finkel | 39d5fa1 | 2012-07-03 16:51:04 +0000 | [diff] [blame] | 974 | if (defs & ArchDefine603) |
| 975 | Builder.defineMacro("_ARCH_603"); |
| 976 | if (defs & ArchDefine604) |
| 977 | Builder.defineMacro("_ARCH_604"); |
Bill Schmidt | 2821e18 | 2013-02-01 20:23:10 +0000 | [diff] [blame] | 978 | if (defs & ArchDefinePwr4) |
Hal Finkel | 39d5fa1 | 2012-07-03 16:51:04 +0000 | [diff] [blame] | 979 | Builder.defineMacro("_ARCH_PWR4"); |
Bill Schmidt | 2821e18 | 2013-02-01 20:23:10 +0000 | [diff] [blame] | 980 | if (defs & ArchDefinePwr5) |
Hal Finkel | 39d5fa1 | 2012-07-03 16:51:04 +0000 | [diff] [blame] | 981 | Builder.defineMacro("_ARCH_PWR5"); |
Bill Schmidt | 2821e18 | 2013-02-01 20:23:10 +0000 | [diff] [blame] | 982 | if (defs & ArchDefinePwr5x) |
| 983 | Builder.defineMacro("_ARCH_PWR5X"); |
| 984 | if (defs & ArchDefinePwr6) |
Hal Finkel | 02a8427 | 2012-06-11 22:35:19 +0000 | [diff] [blame] | 985 | Builder.defineMacro("_ARCH_PWR6"); |
Bill Schmidt | 2821e18 | 2013-02-01 20:23:10 +0000 | [diff] [blame] | 986 | if (defs & ArchDefinePwr6x) |
| 987 | Builder.defineMacro("_ARCH_PWR6X"); |
| 988 | if (defs & ArchDefinePwr7) |
| 989 | Builder.defineMacro("_ARCH_PWR7"); |
Hal Finkel | 5ccd3d0 | 2013-02-01 05:53:33 +0000 | [diff] [blame] | 990 | if (defs & ArchDefineA2) |
| 991 | Builder.defineMacro("_ARCH_A2"); |
| 992 | if (defs & ArchDefineA2q) { |
| 993 | Builder.defineMacro("_ARCH_A2Q"); |
| 994 | Builder.defineMacro("_ARCH_QP"); |
| 995 | } |
| 996 | |
| 997 | if (getTriple().getVendor() == llvm::Triple::BGQ) { |
| 998 | Builder.defineMacro("__bg__"); |
| 999 | Builder.defineMacro("__THW_BLUEGENE__"); |
| 1000 | Builder.defineMacro("__bgq__"); |
| 1001 | Builder.defineMacro("__TOS_BGQ__"); |
| 1002 | } |
Bill Schmidt | 2821e18 | 2013-02-01 20:23:10 +0000 | [diff] [blame] | 1003 | |
| 1004 | // FIXME: The following are not yet generated here by Clang, but are |
| 1005 | // generated by GCC: |
| 1006 | // |
| 1007 | // _SOFT_FLOAT_ |
| 1008 | // __RECIP_PRECISION__ |
| 1009 | // __APPLE_ALTIVEC__ |
| 1010 | // __VSX__ |
| 1011 | // __RECIP__ |
| 1012 | // __RECIPF__ |
| 1013 | // __RSQRTE__ |
| 1014 | // __RSQRTEF__ |
| 1015 | // _SOFT_DOUBLE_ |
| 1016 | // __NO_LWSYNC__ |
| 1017 | // __HAVE_BSWAP__ |
| 1018 | // __LONGDOUBLE128 |
| 1019 | // __CMODEL_MEDIUM__ |
| 1020 | // __CMODEL_LARGE__ |
| 1021 | // _CALL_SYSV |
| 1022 | // _CALL_DARWIN |
| 1023 | // __NO_FPRS__ |
Bill Schmidt | 199402b | 2013-02-01 02:14:03 +0000 | [diff] [blame] | 1024 | } |
| 1025 | |
| 1026 | void PPCTargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const { |
| 1027 | Features["altivec"] = llvm::StringSwitch<bool>(CPU) |
| 1028 | .Case("7400", true) |
| 1029 | .Case("g4", true) |
| 1030 | .Case("7450", true) |
| 1031 | .Case("g4+", true) |
| 1032 | .Case("970", true) |
| 1033 | .Case("g5", true) |
| 1034 | .Case("pwr6", true) |
| 1035 | .Case("pwr7", true) |
| 1036 | .Case("ppc64", true) |
Bill Schmidt | ea7fb0c | 2013-07-26 01:36:11 +0000 | [diff] [blame] | 1037 | .Case("ppc64le", true) |
Bill Schmidt | 199402b | 2013-02-01 02:14:03 +0000 | [diff] [blame] | 1038 | .Default(false); |
Hal Finkel | 3c6aaeb | 2013-02-01 18:44:19 +0000 | [diff] [blame] | 1039 | |
| 1040 | Features["qpx"] = (CPU == "a2q"); |
Bill Schmidt | 199402b | 2013-02-01 02:14:03 +0000 | [diff] [blame] | 1041 | } |
| 1042 | |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 1043 | bool PPCTargetInfo::hasFeature(StringRef Feature) const { |
| 1044 | return Feature == "powerpc"; |
| 1045 | } |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1046 | |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 1047 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 1048 | const char * const PPCTargetInfo::GCCRegNames[] = { |
Chris Lattner | e94e0d4 | 2009-09-16 05:05:27 +0000 | [diff] [blame] | 1049 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
| 1050 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", |
| 1051 | "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", |
| 1052 | "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", |
| 1053 | "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", |
| 1054 | "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", |
| 1055 | "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", |
| 1056 | "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 1057 | "mq", "lr", "ctr", "ap", |
Chris Lattner | e94e0d4 | 2009-09-16 05:05:27 +0000 | [diff] [blame] | 1058 | "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 1059 | "xer", |
Chris Lattner | e94e0d4 | 2009-09-16 05:05:27 +0000 | [diff] [blame] | 1060 | "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", |
| 1061 | "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", |
| 1062 | "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", |
| 1063 | "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31", |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 1064 | "vrsave", "vscr", |
| 1065 | "spe_acc", "spefscr", |
| 1066 | "sfp" |
| 1067 | }; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1068 | |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1069 | void PPCTargetInfo::getGCCRegNames(const char * const *&Names, |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 1070 | unsigned &NumNames) const { |
| 1071 | Names = GCCRegNames; |
| 1072 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 1073 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1074 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 1075 | const TargetInfo::GCCRegAlias PPCTargetInfo::GCCRegAliases[] = { |
| 1076 | // While some of these aliases do map to different registers |
| 1077 | // they still share the same register name. |
Daniel Dunbar | c1f2cdd | 2009-09-17 07:03:19 +0000 | [diff] [blame] | 1078 | { { "0" }, "r0" }, |
| 1079 | { { "1"}, "r1" }, |
| 1080 | { { "2" }, "r2" }, |
| 1081 | { { "3" }, "r3" }, |
| 1082 | { { "4" }, "r4" }, |
| 1083 | { { "5" }, "r5" }, |
| 1084 | { { "6" }, "r6" }, |
| 1085 | { { "7" }, "r7" }, |
| 1086 | { { "8" }, "r8" }, |
| 1087 | { { "9" }, "r9" }, |
| 1088 | { { "10" }, "r10" }, |
| 1089 | { { "11" }, "r11" }, |
| 1090 | { { "12" }, "r12" }, |
| 1091 | { { "13" }, "r13" }, |
| 1092 | { { "14" }, "r14" }, |
| 1093 | { { "15" }, "r15" }, |
| 1094 | { { "16" }, "r16" }, |
| 1095 | { { "17" }, "r17" }, |
| 1096 | { { "18" }, "r18" }, |
| 1097 | { { "19" }, "r19" }, |
| 1098 | { { "20" }, "r20" }, |
| 1099 | { { "21" }, "r21" }, |
| 1100 | { { "22" }, "r22" }, |
| 1101 | { { "23" }, "r23" }, |
| 1102 | { { "24" }, "r24" }, |
| 1103 | { { "25" }, "r25" }, |
| 1104 | { { "26" }, "r26" }, |
| 1105 | { { "27" }, "r27" }, |
| 1106 | { { "28" }, "r28" }, |
| 1107 | { { "29" }, "r29" }, |
| 1108 | { { "30" }, "r30" }, |
| 1109 | { { "31" }, "r31" }, |
| 1110 | { { "fr0" }, "f0" }, |
| 1111 | { { "fr1" }, "f1" }, |
| 1112 | { { "fr2" }, "f2" }, |
| 1113 | { { "fr3" }, "f3" }, |
| 1114 | { { "fr4" }, "f4" }, |
| 1115 | { { "fr5" }, "f5" }, |
| 1116 | { { "fr6" }, "f6" }, |
| 1117 | { { "fr7" }, "f7" }, |
| 1118 | { { "fr8" }, "f8" }, |
| 1119 | { { "fr9" }, "f9" }, |
Mike Stump | 1088039 | 2009-09-17 21:15:00 +0000 | [diff] [blame] | 1120 | { { "fr10" }, "f10" }, |
Daniel Dunbar | c1f2cdd | 2009-09-17 07:03:19 +0000 | [diff] [blame] | 1121 | { { "fr11" }, "f11" }, |
| 1122 | { { "fr12" }, "f12" }, |
| 1123 | { { "fr13" }, "f13" }, |
| 1124 | { { "fr14" }, "f14" }, |
| 1125 | { { "fr15" }, "f15" }, |
| 1126 | { { "fr16" }, "f16" }, |
| 1127 | { { "fr17" }, "f17" }, |
| 1128 | { { "fr18" }, "f18" }, |
| 1129 | { { "fr19" }, "f19" }, |
| 1130 | { { "fr20" }, "f20" }, |
| 1131 | { { "fr21" }, "f21" }, |
| 1132 | { { "fr22" }, "f22" }, |
| 1133 | { { "fr23" }, "f23" }, |
| 1134 | { { "fr24" }, "f24" }, |
| 1135 | { { "fr25" }, "f25" }, |
| 1136 | { { "fr26" }, "f26" }, |
| 1137 | { { "fr27" }, "f27" }, |
| 1138 | { { "fr28" }, "f28" }, |
| 1139 | { { "fr29" }, "f29" }, |
| 1140 | { { "fr30" }, "f30" }, |
| 1141 | { { "fr31" }, "f31" }, |
| 1142 | { { "cc" }, "cr0" }, |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 1143 | }; |
| 1144 | |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1145 | void PPCTargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases, |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 1146 | unsigned &NumAliases) const { |
| 1147 | Aliases = GCCRegAliases; |
| 1148 | NumAliases = llvm::array_lengthof(GCCRegAliases); |
| 1149 | } |
| 1150 | } // end anonymous namespace. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1151 | |
| 1152 | namespace { |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 1153 | class PPC32TargetInfo : public PPCTargetInfo { |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1154 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 1155 | PPC32TargetInfo(const llvm::Triple &Triple) : PPCTargetInfo(Triple) { |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1156 | DescriptionString = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
Chris Lattner | 1932e12 | 2009-11-07 18:59:41 +0000 | [diff] [blame] | 1157 | "i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32"; |
Chris Lattner | e03ae30 | 2010-02-16 18:14:57 +0000 | [diff] [blame] | 1158 | |
Joerg Sonnenberger | 6ac26fa | 2011-07-04 21:57:55 +0000 | [diff] [blame] | 1159 | switch (getTriple().getOS()) { |
Nico Weber | 6e1d2ea | 2012-01-31 02:07:33 +0000 | [diff] [blame] | 1160 | case llvm::Triple::Linux: |
Joerg Sonnenberger | 6ac26fa | 2011-07-04 21:57:55 +0000 | [diff] [blame] | 1161 | case llvm::Triple::FreeBSD: |
| 1162 | case llvm::Triple::NetBSD: |
Joerg Sonnenberger | 78542df | 2011-07-05 14:54:41 +0000 | [diff] [blame] | 1163 | SizeType = UnsignedInt; |
Hal Finkel | 178a9b8 | 2012-03-02 20:54:36 +0000 | [diff] [blame] | 1164 | PtrDiffType = SignedInt; |
| 1165 | IntPtrType = SignedInt; |
Joerg Sonnenberger | 78542df | 2011-07-05 14:54:41 +0000 | [diff] [blame] | 1166 | break; |
Joerg Sonnenberger | 1a83b43 | 2011-07-04 23:11:58 +0000 | [diff] [blame] | 1167 | default: |
Joerg Sonnenberger | 78542df | 2011-07-05 14:54:41 +0000 | [diff] [blame] | 1168 | break; |
Joerg Sonnenberger | 6ac26fa | 2011-07-04 21:57:55 +0000 | [diff] [blame] | 1169 | } |
Roman Divacky | e3d175d | 2012-03-13 16:53:54 +0000 | [diff] [blame] | 1170 | |
Roman Divacky | efe9c0d | 2012-03-13 19:20:17 +0000 | [diff] [blame] | 1171 | if (getTriple().getOS() == llvm::Triple::FreeBSD) { |
| 1172 | LongDoubleWidth = LongDoubleAlign = 64; |
Roman Divacky | e3d175d | 2012-03-13 16:53:54 +0000 | [diff] [blame] | 1173 | LongDoubleFormat = &llvm::APFloat::IEEEdouble; |
Roman Divacky | efe9c0d | 2012-03-13 19:20:17 +0000 | [diff] [blame] | 1174 | } |
Benjamin Kramer | 7baa711 | 2012-11-17 17:30:55 +0000 | [diff] [blame] | 1175 | |
| 1176 | // PPC32 supports atomics up to 4 bytes. |
| 1177 | MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32; |
Roman Divacky | c81f2a2 | 2011-01-06 08:27:10 +0000 | [diff] [blame] | 1178 | } |
| 1179 | |
Meador Inge | c5613b2 | 2012-06-16 03:34:49 +0000 | [diff] [blame] | 1180 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
Roman Divacky | c81f2a2 | 2011-01-06 08:27:10 +0000 | [diff] [blame] | 1181 | // This is the ELF definition, and is overridden by the Darwin sub-target |
Meador Inge | c5613b2 | 2012-06-16 03:34:49 +0000 | [diff] [blame] | 1182 | return TargetInfo::PowerABIBuiltinVaList; |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1183 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1184 | }; |
| 1185 | } // end anonymous namespace. |
| 1186 | |
Bill Schmidt | ea7fb0c | 2013-07-26 01:36:11 +0000 | [diff] [blame] | 1187 | // Note: ABI differences may eventually require us to have a separate |
| 1188 | // TargetInfo for little endian. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1189 | namespace { |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 1190 | class PPC64TargetInfo : public PPCTargetInfo { |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1191 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 1192 | PPC64TargetInfo(const llvm::Triple &Triple) : PPCTargetInfo(Triple) { |
Chris Lattner | f291b10 | 2008-05-09 06:17:04 +0000 | [diff] [blame] | 1193 | LongWidth = LongAlign = PointerWidth = PointerAlign = 64; |
Eli Friedman | 3c7b6e4 | 2009-07-01 03:36:11 +0000 | [diff] [blame] | 1194 | IntMaxType = SignedLong; |
| 1195 | UIntMaxType = UnsignedLong; |
| 1196 | Int64Type = SignedLong; |
Roman Divacky | e3d175d | 2012-03-13 16:53:54 +0000 | [diff] [blame] | 1197 | |
Roman Divacky | efe9c0d | 2012-03-13 19:20:17 +0000 | [diff] [blame] | 1198 | if (getTriple().getOS() == llvm::Triple::FreeBSD) { |
| 1199 | LongDoubleWidth = LongDoubleAlign = 64; |
Roman Divacky | e3d175d | 2012-03-13 16:53:54 +0000 | [diff] [blame] | 1200 | LongDoubleFormat = &llvm::APFloat::IEEEdouble; |
Bill Schmidt | dbaf4bc | 2012-10-29 14:59:24 +0000 | [diff] [blame] | 1201 | DescriptionString = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
Bill Schmidt | b1baad6 | 2013-07-03 21:03:06 +0000 | [diff] [blame] | 1202 | "i64:64:64-f32:32:32-f64:64:64-" |
Bill Schmidt | dbaf4bc | 2012-10-29 14:59:24 +0000 | [diff] [blame] | 1203 | "v128:128:128-n32:64"; |
| 1204 | } else |
| 1205 | DescriptionString = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 1206 | "i64:64:64-f32:32:32-f64:64:64-f128:128:128-" |
| 1207 | "v128:128:128-n32:64"; |
Benjamin Kramer | 7baa711 | 2012-11-17 17:30:55 +0000 | [diff] [blame] | 1208 | |
| 1209 | // PPC64 supports atomics up to 8 bytes. |
| 1210 | MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; |
Chris Lattner | f291b10 | 2008-05-09 06:17:04 +0000 | [diff] [blame] | 1211 | } |
Meador Inge | c5613b2 | 2012-06-16 03:34:49 +0000 | [diff] [blame] | 1212 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
| 1213 | return TargetInfo::CharPtrBuiltinVaList; |
Roman Divacky | c81f2a2 | 2011-01-06 08:27:10 +0000 | [diff] [blame] | 1214 | } |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 1215 | }; |
| 1216 | } // end anonymous namespace. |
| 1217 | |
Daniel Dunbar | 4c6a226 | 2010-05-30 00:07:30 +0000 | [diff] [blame] | 1218 | |
| 1219 | namespace { |
Roman Divacky | c81f2a2 | 2011-01-06 08:27:10 +0000 | [diff] [blame] | 1220 | class DarwinPPC32TargetInfo : |
| 1221 | public DarwinTargetInfo<PPC32TargetInfo> { |
Daniel Dunbar | 4c6a226 | 2010-05-30 00:07:30 +0000 | [diff] [blame] | 1222 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 1223 | DarwinPPC32TargetInfo(const llvm::Triple &Triple) |
| 1224 | : DarwinTargetInfo<PPC32TargetInfo>(Triple) { |
Daniel Dunbar | 4c6a226 | 2010-05-30 00:07:30 +0000 | [diff] [blame] | 1225 | HasAlignMac68kSupport = true; |
Roman Divacky | c81f2a2 | 2011-01-06 08:27:10 +0000 | [diff] [blame] | 1226 | BoolWidth = BoolAlign = 32; //XXX support -mone-byte-bool? |
David Fang | b5afadd | 2013-05-16 17:51:48 +0000 | [diff] [blame] | 1227 | PtrDiffType = SignedInt; // for http://llvm.org/bugs/show_bug.cgi?id=15726 |
Anton Yartsev | 9bc23ba | 2012-01-17 22:40:00 +0000 | [diff] [blame] | 1228 | LongLongAlign = 32; |
Nick Lewycky | 9bddf43 | 2011-12-21 04:25:47 +0000 | [diff] [blame] | 1229 | SuitableAlign = 128; |
Anton Yartsev | 9bc23ba | 2012-01-17 22:40:00 +0000 | [diff] [blame] | 1230 | DescriptionString = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 1231 | "i64:32:64-f32:32:32-f64:64:64-v128:128:128-n32"; |
Roman Divacky | c81f2a2 | 2011-01-06 08:27:10 +0000 | [diff] [blame] | 1232 | } |
Meador Inge | c5613b2 | 2012-06-16 03:34:49 +0000 | [diff] [blame] | 1233 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
| 1234 | return TargetInfo::CharPtrBuiltinVaList; |
Daniel Dunbar | 4c6a226 | 2010-05-30 00:07:30 +0000 | [diff] [blame] | 1235 | } |
| 1236 | }; |
| 1237 | |
| 1238 | class DarwinPPC64TargetInfo : |
| 1239 | public DarwinTargetInfo<PPC64TargetInfo> { |
| 1240 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 1241 | DarwinPPC64TargetInfo(const llvm::Triple &Triple) |
| 1242 | : DarwinTargetInfo<PPC64TargetInfo>(Triple) { |
Daniel Dunbar | 4c6a226 | 2010-05-30 00:07:30 +0000 | [diff] [blame] | 1243 | HasAlignMac68kSupport = true; |
Nick Lewycky | 9bddf43 | 2011-12-21 04:25:47 +0000 | [diff] [blame] | 1244 | SuitableAlign = 128; |
Bill Schmidt | dbaf4bc | 2012-10-29 14:59:24 +0000 | [diff] [blame] | 1245 | DescriptionString = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 1246 | "i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32:64"; |
Daniel Dunbar | 4c6a226 | 2010-05-30 00:07:30 +0000 | [diff] [blame] | 1247 | } |
| 1248 | }; |
| 1249 | } // end anonymous namespace. |
| 1250 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1251 | namespace { |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 1252 | static const unsigned NVPTXAddrSpaceMap[] = { |
| 1253 | 1, // opencl_global |
| 1254 | 3, // opencl_local |
| 1255 | 4, // opencl_constant |
| 1256 | 1, // cuda_device |
| 1257 | 4, // cuda_constant |
| 1258 | 3, // cuda_shared |
| 1259 | }; |
| 1260 | class NVPTXTargetInfo : public TargetInfo { |
| 1261 | static const char * const GCCRegNames[]; |
Justin Holewinski | 2c585b9 | 2012-05-24 17:43:12 +0000 | [diff] [blame] | 1262 | static const Builtin::Info BuiltinInfo[]; |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 1263 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 1264 | NVPTXTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) { |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 1265 | BigEndian = false; |
| 1266 | TLSSupported = false; |
| 1267 | LongWidth = LongAlign = 64; |
| 1268 | AddrSpaceMap = &NVPTXAddrSpaceMap; |
David Tweed | 1eef852 | 2013-09-13 12:04:22 +0000 | [diff] [blame] | 1269 | UseAddrSpaceMapMangling = true; |
Justin Holewinski | 2c585b9 | 2012-05-24 17:43:12 +0000 | [diff] [blame] | 1270 | // Define available target features |
| 1271 | // These must be defined in sorted order! |
Justin Holewinski | 9903e94 | 2012-07-11 15:34:55 +0000 | [diff] [blame] | 1272 | NoAsmVariants = true; |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 1273 | } |
| 1274 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1275 | MacroBuilder &Builder) const { |
| 1276 | Builder.defineMacro("__PTX__"); |
Justin Holewinski | 2c585b9 | 2012-05-24 17:43:12 +0000 | [diff] [blame] | 1277 | Builder.defineMacro("__NVPTX__"); |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 1278 | } |
| 1279 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 1280 | unsigned &NumRecords) const { |
Justin Holewinski | 2c585b9 | 2012-05-24 17:43:12 +0000 | [diff] [blame] | 1281 | Records = BuiltinInfo; |
| 1282 | NumRecords = clang::NVPTX::LastTSBuiltin-Builtin::FirstTSBuiltin; |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 1283 | } |
| 1284 | virtual bool hasFeature(StringRef Feature) const { |
Justin Holewinski | 2c585b9 | 2012-05-24 17:43:12 +0000 | [diff] [blame] | 1285 | return Feature == "ptx" || Feature == "nvptx"; |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 1286 | } |
| 1287 | |
| 1288 | virtual void getGCCRegNames(const char * const *&Names, |
| 1289 | unsigned &NumNames) const; |
| 1290 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 1291 | unsigned &NumAliases) const { |
| 1292 | // No aliases. |
| 1293 | Aliases = 0; |
| 1294 | NumAliases = 0; |
| 1295 | } |
| 1296 | virtual bool validateAsmConstraint(const char *&Name, |
Justin Holewinski | 0ac428e | 2013-06-21 18:51:24 +0000 | [diff] [blame] | 1297 | TargetInfo::ConstraintInfo &Info) const { |
| 1298 | switch (*Name) { |
| 1299 | default: return false; |
| 1300 | case 'c': |
| 1301 | case 'h': |
| 1302 | case 'r': |
| 1303 | case 'l': |
| 1304 | case 'f': |
| 1305 | case 'd': |
| 1306 | Info.setAllowsRegister(); |
| 1307 | return true; |
| 1308 | } |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 1309 | } |
| 1310 | virtual const char *getClobbers() const { |
| 1311 | // FIXME: Is this really right? |
| 1312 | return ""; |
| 1313 | } |
Meador Inge | c5613b2 | 2012-06-16 03:34:49 +0000 | [diff] [blame] | 1314 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 1315 | // FIXME: implement |
Meador Inge | c5613b2 | 2012-06-16 03:34:49 +0000 | [diff] [blame] | 1316 | return TargetInfo::CharPtrBuiltinVaList; |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 1317 | } |
| 1318 | virtual bool setCPU(const std::string &Name) { |
Justin Holewinski | affa3af | 2013-03-30 14:38:26 +0000 | [diff] [blame] | 1319 | bool Valid = llvm::StringSwitch<bool>(Name) |
| 1320 | .Case("sm_20", true) |
| 1321 | .Case("sm_21", true) |
| 1322 | .Case("sm_30", true) |
| 1323 | .Case("sm_35", true) |
| 1324 | .Default(false); |
| 1325 | |
| 1326 | return Valid; |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 1327 | } |
Justin Holewinski | 2c585b9 | 2012-05-24 17:43:12 +0000 | [diff] [blame] | 1328 | }; |
| 1329 | |
| 1330 | const Builtin::Info NVPTXTargetInfo::BuiltinInfo[] = { |
| 1331 | #define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, ALL_LANGUAGES }, |
| 1332 | #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER,\ |
| 1333 | ALL_LANGUAGES }, |
| 1334 | #include "clang/Basic/BuiltinsNVPTX.def" |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 1335 | }; |
| 1336 | |
| 1337 | const char * const NVPTXTargetInfo::GCCRegNames[] = { |
| 1338 | "r0" |
| 1339 | }; |
| 1340 | |
| 1341 | void NVPTXTargetInfo::getGCCRegNames(const char * const *&Names, |
| 1342 | unsigned &NumNames) const { |
| 1343 | Names = GCCRegNames; |
| 1344 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 1345 | } |
| 1346 | |
| 1347 | class NVPTX32TargetInfo : public NVPTXTargetInfo { |
| 1348 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 1349 | NVPTX32TargetInfo(const llvm::Triple &Triple) : NVPTXTargetInfo(Triple) { |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 1350 | PointerWidth = PointerAlign = 32; |
Justin Holewinski | 2c585b9 | 2012-05-24 17:43:12 +0000 | [diff] [blame] | 1351 | SizeType = PtrDiffType = IntPtrType = TargetInfo::UnsignedInt; |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 1352 | DescriptionString |
| 1353 | = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-" |
| 1354 | "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-" |
| 1355 | "n16:32:64"; |
Justin Holewinski | 2c585b9 | 2012-05-24 17:43:12 +0000 | [diff] [blame] | 1356 | } |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 1357 | }; |
| 1358 | |
| 1359 | class NVPTX64TargetInfo : public NVPTXTargetInfo { |
| 1360 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 1361 | NVPTX64TargetInfo(const llvm::Triple &Triple) : NVPTXTargetInfo(Triple) { |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 1362 | PointerWidth = PointerAlign = 64; |
Justin Holewinski | 2c585b9 | 2012-05-24 17:43:12 +0000 | [diff] [blame] | 1363 | SizeType = PtrDiffType = IntPtrType = TargetInfo::UnsignedLongLong; |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 1364 | DescriptionString |
| 1365 | = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-" |
| 1366 | "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-" |
| 1367 | "n16:32:64"; |
Justin Holewinski | 2c585b9 | 2012-05-24 17:43:12 +0000 | [diff] [blame] | 1368 | } |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 1369 | }; |
| 1370 | } |
| 1371 | |
| 1372 | namespace { |
Eli Friedman | 6505a29 | 2012-10-12 23:32:00 +0000 | [diff] [blame] | 1373 | |
| 1374 | static const unsigned R600AddrSpaceMap[] = { |
| 1375 | 1, // opencl_global |
| 1376 | 3, // opencl_local |
| 1377 | 2, // opencl_constant |
| 1378 | 1, // cuda_device |
| 1379 | 2, // cuda_constant |
| 1380 | 3 // cuda_shared |
| 1381 | }; |
| 1382 | |
Tom Stellard | fd07591 | 2013-03-04 17:40:53 +0000 | [diff] [blame] | 1383 | static const char *DescriptionStringR600 = |
| 1384 | "e" |
| 1385 | "-p:32:32:32" |
| 1386 | "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32" |
| 1387 | "-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128" |
| 1388 | "-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-v2048:2048:2048" |
| 1389 | "-n32:64"; |
| 1390 | |
| 1391 | static const char *DescriptionStringR600DoubleOps = |
| 1392 | "e" |
| 1393 | "-p:32:32:32" |
| 1394 | "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64" |
| 1395 | "-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128" |
| 1396 | "-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-v2048:2048:2048" |
| 1397 | "-n32:64"; |
| 1398 | |
| 1399 | static const char *DescriptionStringSI = |
| 1400 | "e" |
| 1401 | "-p:64:64:64" |
Tom Stellard | 9a3d2bd | 2013-08-27 00:55:26 +0000 | [diff] [blame] | 1402 | "-p3:32:32:32" |
Tom Stellard | fd07591 | 2013-03-04 17:40:53 +0000 | [diff] [blame] | 1403 | "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64" |
| 1404 | "-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128" |
| 1405 | "-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-v2048:2048:2048" |
| 1406 | "-n32:64"; |
| 1407 | |
Eli Friedman | 6505a29 | 2012-10-12 23:32:00 +0000 | [diff] [blame] | 1408 | class R600TargetInfo : public TargetInfo { |
Tom Stellard | fd07591 | 2013-03-04 17:40:53 +0000 | [diff] [blame] | 1409 | /// \brief The GPU profiles supported by the R600 target. |
| 1410 | enum GPUKind { |
| 1411 | GK_NONE, |
| 1412 | GK_R600, |
| 1413 | GK_R600_DOUBLE_OPS, |
| 1414 | GK_R700, |
| 1415 | GK_R700_DOUBLE_OPS, |
| 1416 | GK_EVERGREEN, |
| 1417 | GK_EVERGREEN_DOUBLE_OPS, |
| 1418 | GK_NORTHERN_ISLANDS, |
| 1419 | GK_CAYMAN, |
| 1420 | GK_SOUTHERN_ISLANDS |
| 1421 | } GPU; |
| 1422 | |
Eli Friedman | 6505a29 | 2012-10-12 23:32:00 +0000 | [diff] [blame] | 1423 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 1424 | R600TargetInfo(const llvm::Triple &Triple) |
| 1425 | : TargetInfo(Triple), GPU(GK_R600) { |
Tom Stellard | fd07591 | 2013-03-04 17:40:53 +0000 | [diff] [blame] | 1426 | DescriptionString = DescriptionStringR600; |
Eli Friedman | 6505a29 | 2012-10-12 23:32:00 +0000 | [diff] [blame] | 1427 | AddrSpaceMap = &R600AddrSpaceMap; |
David Tweed | 1eef852 | 2013-09-13 12:04:22 +0000 | [diff] [blame] | 1428 | UseAddrSpaceMapMangling = true; |
Eli Friedman | 6505a29 | 2012-10-12 23:32:00 +0000 | [diff] [blame] | 1429 | } |
| 1430 | |
| 1431 | virtual const char * getClobbers() const { |
| 1432 | return ""; |
| 1433 | } |
| 1434 | |
| 1435 | virtual void getGCCRegNames(const char * const *&Names, |
| 1436 | unsigned &numNames) const { |
| 1437 | Names = NULL; |
| 1438 | numNames = 0; |
| 1439 | } |
| 1440 | |
| 1441 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 1442 | unsigned &NumAliases) const { |
| 1443 | Aliases = NULL; |
| 1444 | NumAliases = 0; |
| 1445 | } |
| 1446 | |
| 1447 | virtual bool validateAsmConstraint(const char *&Name, |
| 1448 | TargetInfo::ConstraintInfo &info) const { |
| 1449 | return true; |
| 1450 | } |
| 1451 | |
| 1452 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 1453 | unsigned &NumRecords) const { |
| 1454 | Records = NULL; |
| 1455 | NumRecords = 0; |
| 1456 | } |
| 1457 | |
| 1458 | |
| 1459 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1460 | MacroBuilder &Builder) const { |
| 1461 | Builder.defineMacro("__R600__"); |
| 1462 | } |
| 1463 | |
| 1464 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
| 1465 | return TargetInfo::CharPtrBuiltinVaList; |
| 1466 | } |
| 1467 | |
Tom Stellard | fd07591 | 2013-03-04 17:40:53 +0000 | [diff] [blame] | 1468 | virtual bool setCPU(const std::string &Name) { |
| 1469 | GPU = llvm::StringSwitch<GPUKind>(Name) |
| 1470 | .Case("r600" , GK_R600) |
| 1471 | .Case("rv610", GK_R600) |
| 1472 | .Case("rv620", GK_R600) |
| 1473 | .Case("rv630", GK_R600) |
| 1474 | .Case("rv635", GK_R600) |
| 1475 | .Case("rs780", GK_R600) |
| 1476 | .Case("rs880", GK_R600) |
| 1477 | .Case("rv670", GK_R600_DOUBLE_OPS) |
| 1478 | .Case("rv710", GK_R700) |
| 1479 | .Case("rv730", GK_R700) |
| 1480 | .Case("rv740", GK_R700_DOUBLE_OPS) |
| 1481 | .Case("rv770", GK_R700_DOUBLE_OPS) |
| 1482 | .Case("palm", GK_EVERGREEN) |
| 1483 | .Case("cedar", GK_EVERGREEN) |
| 1484 | .Case("sumo", GK_EVERGREEN) |
| 1485 | .Case("sumo2", GK_EVERGREEN) |
| 1486 | .Case("redwood", GK_EVERGREEN) |
| 1487 | .Case("juniper", GK_EVERGREEN) |
| 1488 | .Case("hemlock", GK_EVERGREEN_DOUBLE_OPS) |
| 1489 | .Case("cypress", GK_EVERGREEN_DOUBLE_OPS) |
| 1490 | .Case("barts", GK_NORTHERN_ISLANDS) |
| 1491 | .Case("turks", GK_NORTHERN_ISLANDS) |
| 1492 | .Case("caicos", GK_NORTHERN_ISLANDS) |
| 1493 | .Case("cayman", GK_CAYMAN) |
| 1494 | .Case("aruba", GK_CAYMAN) |
Tom Stellard | 3b848ec | 2013-04-01 20:56:49 +0000 | [diff] [blame] | 1495 | .Case("tahiti", GK_SOUTHERN_ISLANDS) |
Tom Stellard | fd07591 | 2013-03-04 17:40:53 +0000 | [diff] [blame] | 1496 | .Case("pitcairn", GK_SOUTHERN_ISLANDS) |
| 1497 | .Case("verde", GK_SOUTHERN_ISLANDS) |
| 1498 | .Case("oland", GK_SOUTHERN_ISLANDS) |
| 1499 | .Default(GK_NONE); |
| 1500 | |
| 1501 | if (GPU == GK_NONE) { |
| 1502 | return false; |
| 1503 | } |
| 1504 | |
| 1505 | // Set the correct data layout |
| 1506 | switch (GPU) { |
| 1507 | case GK_NONE: |
| 1508 | case GK_R600: |
| 1509 | case GK_R700: |
| 1510 | case GK_EVERGREEN: |
| 1511 | case GK_NORTHERN_ISLANDS: |
| 1512 | DescriptionString = DescriptionStringR600; |
| 1513 | break; |
| 1514 | case GK_R600_DOUBLE_OPS: |
| 1515 | case GK_R700_DOUBLE_OPS: |
| 1516 | case GK_EVERGREEN_DOUBLE_OPS: |
| 1517 | case GK_CAYMAN: |
| 1518 | DescriptionString = DescriptionStringR600DoubleOps; |
| 1519 | break; |
| 1520 | case GK_SOUTHERN_ISLANDS: |
| 1521 | DescriptionString = DescriptionStringSI; |
| 1522 | break; |
| 1523 | } |
| 1524 | |
| 1525 | return true; |
| 1526 | } |
Eli Friedman | 6505a29 | 2012-10-12 23:32:00 +0000 | [diff] [blame] | 1527 | }; |
| 1528 | |
| 1529 | } // end anonymous namespace |
| 1530 | |
| 1531 | namespace { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 1532 | // Namespace for x86 abstract base class |
| 1533 | const Builtin::Info BuiltinInfo[] = { |
Eli Friedman | e7e66f7 | 2011-07-05 21:53:01 +0000 | [diff] [blame] | 1534 | #define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, ALL_LANGUAGES }, |
Fariborz Jahanian | 67aba81 | 2010-11-30 17:35:24 +0000 | [diff] [blame] | 1535 | #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER,\ |
Eli Friedman | e7e66f7 | 2011-07-05 21:53:01 +0000 | [diff] [blame] | 1536 | ALL_LANGUAGES }, |
Chris Lattner | 6b15cdc | 2009-06-14 01:05:48 +0000 | [diff] [blame] | 1537 | #include "clang/Basic/BuiltinsX86.def" |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 1538 | }; |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1539 | |
Nuno Lopes | 2550d70 | 2009-12-23 17:49:57 +0000 | [diff] [blame] | 1540 | static const char* const GCCRegNames[] = { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 1541 | "ax", "dx", "cx", "bx", "si", "di", "bp", "sp", |
| 1542 | "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)", |
Eric Christopher | 7c9adf9 | 2011-07-07 22:55:26 +0000 | [diff] [blame] | 1543 | "argp", "flags", "fpcr", "fpsr", "dirflag", "frame", |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 1544 | "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", |
| 1545 | "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7", |
| 1546 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", |
Eric Christopher | cfd323d | 2011-06-21 00:05:20 +0000 | [diff] [blame] | 1547 | "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15", |
Eric Christopher | c5f9a01 | 2011-12-02 02:12:16 +0000 | [diff] [blame] | 1548 | "ymm0", "ymm1", "ymm2", "ymm3", "ymm4", "ymm5", "ymm6", "ymm7", |
| 1549 | "ymm8", "ymm9", "ymm10", "ymm11", "ymm12", "ymm13", "ymm14", "ymm15", |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 1550 | }; |
| 1551 | |
Eric Christopher | cfd323d | 2011-06-21 00:05:20 +0000 | [diff] [blame] | 1552 | const TargetInfo::AddlRegName AddlRegNames[] = { |
| 1553 | { { "al", "ah", "eax", "rax" }, 0 }, |
| 1554 | { { "bl", "bh", "ebx", "rbx" }, 3 }, |
| 1555 | { { "cl", "ch", "ecx", "rcx" }, 2 }, |
| 1556 | { { "dl", "dh", "edx", "rdx" }, 1 }, |
| 1557 | { { "esi", "rsi" }, 4 }, |
| 1558 | { { "edi", "rdi" }, 5 }, |
| 1559 | { { "esp", "rsp" }, 7 }, |
| 1560 | { { "ebp", "rbp" }, 6 }, |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 1561 | }; |
| 1562 | |
| 1563 | // X86 target abstract base class; x86-32 and x86-64 are very close, so |
| 1564 | // most of the implementation can be shared. |
| 1565 | class X86TargetInfo : public TargetInfo { |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 1566 | enum X86SSEEnum { |
Craig Topper | b7a95d2 | 2013-08-21 03:59:22 +0000 | [diff] [blame] | 1567 | NoSSE, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42, AVX, AVX2, AVX512F |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 1568 | } SSELevel; |
Eli Friedman | c3e0fb4 | 2011-07-08 23:31:17 +0000 | [diff] [blame] | 1569 | enum MMX3DNowEnum { |
| 1570 | NoMMX3DNow, MMX, AMD3DNow, AMD3DNowAthlon |
| 1571 | } MMX3DNowLevel; |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 1572 | enum XOPEnum { |
| 1573 | NoXOP, |
| 1574 | SSE4A, |
| 1575 | FMA4, |
| 1576 | XOP |
| 1577 | } XOPLevel; |
Anders Carlsson | 9b0fb62 | 2010-01-27 03:47:49 +0000 | [diff] [blame] | 1578 | |
Eric Christopher | eea12d1 | 2010-04-02 23:50:19 +0000 | [diff] [blame] | 1579 | bool HasAES; |
Craig Topper | 3c0bc15 | 2012-05-31 05:18:48 +0000 | [diff] [blame] | 1580 | bool HasPCLMUL; |
Craig Topper | 31ceea0 | 2011-12-25 05:06:45 +0000 | [diff] [blame] | 1581 | bool HasLZCNT; |
Benjamin Kramer | 84f3080 | 2012-07-07 09:39:18 +0000 | [diff] [blame] | 1582 | bool HasRDRND; |
Craig Topper | 31ceea0 | 2011-12-25 05:06:45 +0000 | [diff] [blame] | 1583 | bool HasBMI; |
| 1584 | bool HasBMI2; |
Craig Topper | e14e08b | 2011-12-29 16:10:46 +0000 | [diff] [blame] | 1585 | bool HasPOPCNT; |
Michael Liao | 463eb89 | 2012-11-10 05:17:46 +0000 | [diff] [blame] | 1586 | bool HasRTM; |
Michael Liao | 72339a0 | 2013-03-26 17:52:08 +0000 | [diff] [blame] | 1587 | bool HasPRFCHW; |
Michael Liao | 1bfc28c | 2013-03-29 05:17:55 +0000 | [diff] [blame] | 1588 | bool HasRDSEED; |
Craig Topper | 2ae9507 | 2012-06-03 21:46:30 +0000 | [diff] [blame] | 1589 | bool HasFMA; |
Manman Ren | 146e5a4 | 2012-10-11 00:59:55 +0000 | [diff] [blame] | 1590 | bool HasF16C; |
Craig Topper | bca2c4f | 2013-08-21 05:29:10 +0000 | [diff] [blame] | 1591 | bool HasAVX512CD, HasAVX512ER, HasAVX512PF; |
Bruno Cardoso Lopes | 7377ed9 | 2010-08-04 22:29:13 +0000 | [diff] [blame] | 1592 | |
Chandler Carruth | 499d972 | 2011-09-28 08:55:34 +0000 | [diff] [blame] | 1593 | /// \brief Enumeration of all of the X86 CPUs supported by Clang. |
| 1594 | /// |
| 1595 | /// Each enumeration represents a particular CPU supported by Clang. These |
| 1596 | /// loosely correspond to the options passed to '-march' or '-mtune' flags. |
| 1597 | enum CPUKind { |
| 1598 | CK_Generic, |
| 1599 | |
| 1600 | /// \name i386 |
| 1601 | /// i386-generation processors. |
| 1602 | //@{ |
| 1603 | CK_i386, |
| 1604 | //@} |
| 1605 | |
| 1606 | /// \name i486 |
| 1607 | /// i486-generation processors. |
| 1608 | //@{ |
| 1609 | CK_i486, |
| 1610 | CK_WinChipC6, |
| 1611 | CK_WinChip2, |
| 1612 | CK_C3, |
| 1613 | //@} |
| 1614 | |
| 1615 | /// \name i586 |
| 1616 | /// i586-generation processors, P5 microarchitecture based. |
| 1617 | //@{ |
| 1618 | CK_i586, |
| 1619 | CK_Pentium, |
| 1620 | CK_PentiumMMX, |
| 1621 | //@} |
| 1622 | |
| 1623 | /// \name i686 |
| 1624 | /// i686-generation processors, P6 / Pentium M microarchitecture based. |
| 1625 | //@{ |
| 1626 | CK_i686, |
| 1627 | CK_PentiumPro, |
| 1628 | CK_Pentium2, |
| 1629 | CK_Pentium3, |
| 1630 | CK_Pentium3M, |
| 1631 | CK_PentiumM, |
| 1632 | CK_C3_2, |
| 1633 | |
| 1634 | /// This enumerator is a bit odd, as GCC no longer accepts -march=yonah. |
| 1635 | /// Clang however has some logic to suport this. |
| 1636 | // FIXME: Warn, deprecate, and potentially remove this. |
| 1637 | CK_Yonah, |
| 1638 | //@} |
| 1639 | |
| 1640 | /// \name Netburst |
Chandler Carruth | 83450aa | 2011-09-28 18:17:30 +0000 | [diff] [blame] | 1641 | /// Netburst microarchitecture based processors. |
Chandler Carruth | 499d972 | 2011-09-28 08:55:34 +0000 | [diff] [blame] | 1642 | //@{ |
| 1643 | CK_Pentium4, |
| 1644 | CK_Pentium4M, |
| 1645 | CK_Prescott, |
| 1646 | CK_Nocona, |
| 1647 | //@} |
| 1648 | |
| 1649 | /// \name Core |
| 1650 | /// Core microarchitecture based processors. |
| 1651 | //@{ |
| 1652 | CK_Core2, |
| 1653 | |
| 1654 | /// This enumerator, like \see CK_Yonah, is a bit odd. It is another |
| 1655 | /// codename which GCC no longer accepts as an option to -march, but Clang |
| 1656 | /// has some logic for recognizing it. |
| 1657 | // FIXME: Warn, deprecate, and potentially remove this. |
| 1658 | CK_Penryn, |
| 1659 | //@} |
| 1660 | |
| 1661 | /// \name Atom |
| 1662 | /// Atom processors |
| 1663 | //@{ |
| 1664 | CK_Atom, |
Benjamin Kramer | b98ce37 | 2013-08-30 14:05:34 +0000 | [diff] [blame] | 1665 | CK_SLM, |
Chandler Carruth | 499d972 | 2011-09-28 08:55:34 +0000 | [diff] [blame] | 1666 | //@} |
| 1667 | |
| 1668 | /// \name Nehalem |
| 1669 | /// Nehalem microarchitecture based processors. |
| 1670 | //@{ |
| 1671 | CK_Corei7, |
| 1672 | CK_Corei7AVX, |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 1673 | CK_CoreAVXi, |
Craig Topper | 2b03bb0 | 2011-12-17 19:55:21 +0000 | [diff] [blame] | 1674 | CK_CoreAVX2, |
Chandler Carruth | 499d972 | 2011-09-28 08:55:34 +0000 | [diff] [blame] | 1675 | //@} |
| 1676 | |
Craig Topper | 10c2c68 | 2013-08-20 07:09:39 +0000 | [diff] [blame] | 1677 | /// \name Knights Landing |
| 1678 | /// Knights Landing processor. |
| 1679 | CK_KNL, |
| 1680 | |
Chandler Carruth | 499d972 | 2011-09-28 08:55:34 +0000 | [diff] [blame] | 1681 | /// \name K6 |
| 1682 | /// K6 architecture processors. |
| 1683 | //@{ |
| 1684 | CK_K6, |
| 1685 | CK_K6_2, |
| 1686 | CK_K6_3, |
| 1687 | //@} |
| 1688 | |
| 1689 | /// \name K7 |
| 1690 | /// K7 architecture processors. |
| 1691 | //@{ |
| 1692 | CK_Athlon, |
| 1693 | CK_AthlonThunderbird, |
| 1694 | CK_Athlon4, |
| 1695 | CK_AthlonXP, |
| 1696 | CK_AthlonMP, |
| 1697 | //@} |
| 1698 | |
| 1699 | /// \name K8 |
| 1700 | /// K8 architecture processors. |
| 1701 | //@{ |
| 1702 | CK_Athlon64, |
| 1703 | CK_Athlon64SSE3, |
| 1704 | CK_AthlonFX, |
| 1705 | CK_K8, |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 1706 | CK_K8SSE3, |
Chandler Carruth | 499d972 | 2011-09-28 08:55:34 +0000 | [diff] [blame] | 1707 | CK_Opteron, |
| 1708 | CK_OpteronSSE3, |
Roman Divacky | 01c770d | 2011-10-30 07:48:46 +0000 | [diff] [blame] | 1709 | CK_AMDFAM10, |
Benjamin Kramer | 5660aa6 | 2012-01-10 11:50:18 +0000 | [diff] [blame] | 1710 | //@} |
Chandler Carruth | 499d972 | 2011-09-28 08:55:34 +0000 | [diff] [blame] | 1711 | |
Benjamin Kramer | 5660aa6 | 2012-01-10 11:50:18 +0000 | [diff] [blame] | 1712 | /// \name Bobcat |
| 1713 | /// Bobcat architecture processors. |
| 1714 | //@{ |
| 1715 | CK_BTVER1, |
Benjamin Kramer | 63063f5 | 2013-05-03 10:47:15 +0000 | [diff] [blame] | 1716 | CK_BTVER2, |
Benjamin Kramer | 5660aa6 | 2012-01-10 11:50:18 +0000 | [diff] [blame] | 1717 | //@} |
| 1718 | |
| 1719 | /// \name Bulldozer |
| 1720 | /// Bulldozer architecture processors. |
Benjamin Kramer | 61ea4fe | 2011-12-01 18:23:59 +0000 | [diff] [blame] | 1721 | //@{ |
| 1722 | CK_BDVER1, |
| 1723 | CK_BDVER2, |
Benjamin Kramer | 5660aa6 | 2012-01-10 11:50:18 +0000 | [diff] [blame] | 1724 | //@} |
Benjamin Kramer | 61ea4fe | 2011-12-01 18:23:59 +0000 | [diff] [blame] | 1725 | |
Chandler Carruth | 499d972 | 2011-09-28 08:55:34 +0000 | [diff] [blame] | 1726 | /// This specification is deprecated and will be removed in the future. |
| 1727 | /// Users should prefer \see CK_K8. |
| 1728 | // FIXME: Warn on this when the CPU is set to it. |
| 1729 | CK_x86_64, |
| 1730 | //@} |
| 1731 | |
| 1732 | /// \name Geode |
| 1733 | /// Geode processors. |
| 1734 | //@{ |
| 1735 | CK_Geode |
| 1736 | //@} |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 1737 | } CPU; |
Chandler Carruth | 499d972 | 2011-09-28 08:55:34 +0000 | [diff] [blame] | 1738 | |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 1739 | enum FPMathKind { |
| 1740 | FP_Default, |
| 1741 | FP_SSE, |
| 1742 | FP_387 |
| 1743 | } FPMath; |
| 1744 | |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 1745 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 1746 | X86TargetInfo(const llvm::Triple &Triple) |
| 1747 | : TargetInfo(Triple), SSELevel(NoSSE), MMX3DNowLevel(NoMMX3DNow), |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 1748 | XOPLevel(NoXOP), HasAES(false), HasPCLMUL(false), HasLZCNT(false), |
| 1749 | HasRDRND(false), HasBMI(false), HasBMI2(false), HasPOPCNT(false), |
| 1750 | HasRTM(false), HasPRFCHW(false), HasRDSEED(false), HasFMA(false), |
Craig Topper | bca2c4f | 2013-08-21 05:29:10 +0000 | [diff] [blame] | 1751 | HasF16C(false), HasAVX512CD(false), HasAVX512ER(false), |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 1752 | HasAVX512PF(false), CPU(CK_Generic), FPMath(FP_Default) { |
Eli Friedman | e6a24e8 | 2011-12-22 03:51:45 +0000 | [diff] [blame] | 1753 | BigEndian = false; |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 1754 | LongDoubleFormat = &llvm::APFloat::x87DoubleExtended; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1755 | } |
Benjamin Kramer | b406669 | 2011-12-28 15:47:06 +0000 | [diff] [blame] | 1756 | virtual unsigned getFloatEvalMethod() const { |
| 1757 | // X87 evaluates with 80 bits "long double" precision. |
| 1758 | return SSELevel == NoSSE ? 2 : 0; |
| 1759 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1760 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 1761 | unsigned &NumRecords) const { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 1762 | Records = BuiltinInfo; |
| 1763 | NumRecords = clang::X86::LastTSBuiltin-Builtin::FirstTSBuiltin; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1764 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1765 | virtual void getGCCRegNames(const char * const *&Names, |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 1766 | unsigned &NumNames) const { |
| 1767 | Names = GCCRegNames; |
| 1768 | NumNames = llvm::array_lengthof(GCCRegNames); |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 1769 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1770 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 1771 | unsigned &NumAliases) const { |
Eric Christopher | cfd323d | 2011-06-21 00:05:20 +0000 | [diff] [blame] | 1772 | Aliases = 0; |
| 1773 | NumAliases = 0; |
| 1774 | } |
| 1775 | virtual void getGCCAddlRegNames(const AddlRegName *&Names, |
Eric Christopher | 825d386 | 2012-11-14 22:08:59 +0000 | [diff] [blame] | 1776 | unsigned &NumNames) const { |
Eric Christopher | cfd323d | 2011-06-21 00:05:20 +0000 | [diff] [blame] | 1777 | Names = AddlRegNames; |
| 1778 | NumNames = llvm::array_lengthof(AddlRegNames); |
Anders Carlsson | fb5e5ba | 2007-10-13 00:45:48 +0000 | [diff] [blame] | 1779 | } |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 1780 | virtual bool validateAsmConstraint(const char *&Name, |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 1781 | TargetInfo::ConstraintInfo &info) const; |
Stuart Hastings | 002333f | 2011-06-07 23:45:05 +0000 | [diff] [blame] | 1782 | virtual std::string convertConstraint(const char *&Constraint) const; |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 1783 | virtual const char *getClobbers() const { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 1784 | return "~{dirflag},~{fpsr},~{flags}"; |
| 1785 | } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 1786 | virtual void getTargetDefines(const LangOptions &Opts, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 1787 | MacroBuilder &Builder) const; |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 1788 | void setSSELevel(llvm::StringMap<bool> &Features, X86SSEEnum Level, |
| 1789 | bool Enabled) const; |
| 1790 | void setMMXLevel(llvm::StringMap<bool> &Features, MMX3DNowEnum Level, |
| 1791 | bool Enabled) const; |
| 1792 | void setXOPLevel(llvm::StringMap<bool> &Features, XOPEnum Level, |
| 1793 | bool Enabled) const; |
Rafael Espindola | ade7cd4 | 2013-08-20 15:30:32 +0000 | [diff] [blame] | 1794 | virtual void setFeatureEnabled(llvm::StringMap<bool> &Features, |
Benjamin Kramer | 713575a | 2012-03-05 15:10:44 +0000 | [diff] [blame] | 1795 | StringRef Name, |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 1796 | bool Enabled) const; |
Chandler Carruth | c3a2e65 | 2011-09-28 05:56:05 +0000 | [diff] [blame] | 1797 | virtual void getDefaultFeatures(llvm::StringMap<bool> &Features) const; |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 1798 | virtual bool hasFeature(StringRef Feature) const; |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 1799 | virtual bool HandleTargetFeatures(std::vector<std::string> &Features, |
| 1800 | DiagnosticsEngine &Diags); |
Eli Friedman | c3e0fb4 | 2011-07-08 23:31:17 +0000 | [diff] [blame] | 1801 | virtual const char* getABI() const { |
Derek Schuff | babaf31 | 2012-10-11 15:52:22 +0000 | [diff] [blame] | 1802 | if (getTriple().getArch() == llvm::Triple::x86_64 && SSELevel >= AVX) |
Eli Friedman | ee1ad99 | 2011-12-02 00:11:43 +0000 | [diff] [blame] | 1803 | return "avx"; |
Derek Schuff | babaf31 | 2012-10-11 15:52:22 +0000 | [diff] [blame] | 1804 | else if (getTriple().getArch() == llvm::Triple::x86 && |
| 1805 | MMX3DNowLevel == NoMMX3DNow) |
Eli Friedman | ee1ad99 | 2011-12-02 00:11:43 +0000 | [diff] [blame] | 1806 | return "no-mmx"; |
| 1807 | return ""; |
Eli Friedman | c3e0fb4 | 2011-07-08 23:31:17 +0000 | [diff] [blame] | 1808 | } |
Chandler Carruth | f6cf1c2 | 2011-09-28 02:59:25 +0000 | [diff] [blame] | 1809 | virtual bool setCPU(const std::string &Name) { |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 1810 | CPU = llvm::StringSwitch<CPUKind>(Name) |
| 1811 | .Case("i386", CK_i386) |
| 1812 | .Case("i486", CK_i486) |
| 1813 | .Case("winchip-c6", CK_WinChipC6) |
| 1814 | .Case("winchip2", CK_WinChip2) |
| 1815 | .Case("c3", CK_C3) |
| 1816 | .Case("i586", CK_i586) |
| 1817 | .Case("pentium", CK_Pentium) |
| 1818 | .Case("pentium-mmx", CK_PentiumMMX) |
| 1819 | .Case("i686", CK_i686) |
| 1820 | .Case("pentiumpro", CK_PentiumPro) |
| 1821 | .Case("pentium2", CK_Pentium2) |
| 1822 | .Case("pentium3", CK_Pentium3) |
| 1823 | .Case("pentium3m", CK_Pentium3M) |
| 1824 | .Case("pentium-m", CK_PentiumM) |
| 1825 | .Case("c3-2", CK_C3_2) |
| 1826 | .Case("yonah", CK_Yonah) |
| 1827 | .Case("pentium4", CK_Pentium4) |
| 1828 | .Case("pentium4m", CK_Pentium4M) |
| 1829 | .Case("prescott", CK_Prescott) |
| 1830 | .Case("nocona", CK_Nocona) |
| 1831 | .Case("core2", CK_Core2) |
| 1832 | .Case("penryn", CK_Penryn) |
| 1833 | .Case("atom", CK_Atom) |
Benjamin Kramer | b98ce37 | 2013-08-30 14:05:34 +0000 | [diff] [blame] | 1834 | .Case("slm", CK_SLM) |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 1835 | .Case("corei7", CK_Corei7) |
| 1836 | .Case("corei7-avx", CK_Corei7AVX) |
| 1837 | .Case("core-avx-i", CK_CoreAVXi) |
Craig Topper | 2b03bb0 | 2011-12-17 19:55:21 +0000 | [diff] [blame] | 1838 | .Case("core-avx2", CK_CoreAVX2) |
Craig Topper | 10c2c68 | 2013-08-20 07:09:39 +0000 | [diff] [blame] | 1839 | .Case("knl", CK_KNL) |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 1840 | .Case("k6", CK_K6) |
| 1841 | .Case("k6-2", CK_K6_2) |
| 1842 | .Case("k6-3", CK_K6_3) |
| 1843 | .Case("athlon", CK_Athlon) |
| 1844 | .Case("athlon-tbird", CK_AthlonThunderbird) |
| 1845 | .Case("athlon-4", CK_Athlon4) |
| 1846 | .Case("athlon-xp", CK_AthlonXP) |
| 1847 | .Case("athlon-mp", CK_AthlonMP) |
| 1848 | .Case("athlon64", CK_Athlon64) |
| 1849 | .Case("athlon64-sse3", CK_Athlon64SSE3) |
| 1850 | .Case("athlon-fx", CK_AthlonFX) |
| 1851 | .Case("k8", CK_K8) |
| 1852 | .Case("k8-sse3", CK_K8SSE3) |
| 1853 | .Case("opteron", CK_Opteron) |
| 1854 | .Case("opteron-sse3", CK_OpteronSSE3) |
Roman Divacky | 01c770d | 2011-10-30 07:48:46 +0000 | [diff] [blame] | 1855 | .Case("amdfam10", CK_AMDFAM10) |
Benjamin Kramer | 5660aa6 | 2012-01-10 11:50:18 +0000 | [diff] [blame] | 1856 | .Case("btver1", CK_BTVER1) |
Benjamin Kramer | 63063f5 | 2013-05-03 10:47:15 +0000 | [diff] [blame] | 1857 | .Case("btver2", CK_BTVER2) |
Benjamin Kramer | 61ea4fe | 2011-12-01 18:23:59 +0000 | [diff] [blame] | 1858 | .Case("bdver1", CK_BDVER1) |
| 1859 | .Case("bdver2", CK_BDVER2) |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 1860 | .Case("x86-64", CK_x86_64) |
| 1861 | .Case("geode", CK_Geode) |
| 1862 | .Default(CK_Generic); |
| 1863 | |
Chandler Carruth | 26a3914 | 2011-09-28 09:45:08 +0000 | [diff] [blame] | 1864 | // Perform any per-CPU checks necessary to determine if this CPU is |
| 1865 | // acceptable. |
| 1866 | // FIXME: This results in terrible diagnostics. Clang just says the CPU is |
| 1867 | // invalid without explaining *why*. |
| 1868 | switch (CPU) { |
| 1869 | case CK_Generic: |
| 1870 | // No processor selected! |
| 1871 | return false; |
| 1872 | |
| 1873 | case CK_i386: |
| 1874 | case CK_i486: |
| 1875 | case CK_WinChipC6: |
| 1876 | case CK_WinChip2: |
| 1877 | case CK_C3: |
| 1878 | case CK_i586: |
| 1879 | case CK_Pentium: |
| 1880 | case CK_PentiumMMX: |
| 1881 | case CK_i686: |
| 1882 | case CK_PentiumPro: |
| 1883 | case CK_Pentium2: |
| 1884 | case CK_Pentium3: |
| 1885 | case CK_Pentium3M: |
| 1886 | case CK_PentiumM: |
| 1887 | case CK_Yonah: |
| 1888 | case CK_C3_2: |
| 1889 | case CK_Pentium4: |
| 1890 | case CK_Pentium4M: |
| 1891 | case CK_Prescott: |
| 1892 | case CK_K6: |
| 1893 | case CK_K6_2: |
| 1894 | case CK_K6_3: |
| 1895 | case CK_Athlon: |
| 1896 | case CK_AthlonThunderbird: |
| 1897 | case CK_Athlon4: |
| 1898 | case CK_AthlonXP: |
| 1899 | case CK_AthlonMP: |
| 1900 | case CK_Geode: |
| 1901 | // Only accept certain architectures when compiling in 32-bit mode. |
Derek Schuff | babaf31 | 2012-10-11 15:52:22 +0000 | [diff] [blame] | 1902 | if (getTriple().getArch() != llvm::Triple::x86) |
Chandler Carruth | 26a3914 | 2011-09-28 09:45:08 +0000 | [diff] [blame] | 1903 | return false; |
| 1904 | |
| 1905 | // Fallthrough |
| 1906 | case CK_Nocona: |
| 1907 | case CK_Core2: |
| 1908 | case CK_Penryn: |
| 1909 | case CK_Atom: |
Benjamin Kramer | b98ce37 | 2013-08-30 14:05:34 +0000 | [diff] [blame] | 1910 | case CK_SLM: |
Chandler Carruth | 26a3914 | 2011-09-28 09:45:08 +0000 | [diff] [blame] | 1911 | case CK_Corei7: |
| 1912 | case CK_Corei7AVX: |
| 1913 | case CK_CoreAVXi: |
Craig Topper | 2b03bb0 | 2011-12-17 19:55:21 +0000 | [diff] [blame] | 1914 | case CK_CoreAVX2: |
Craig Topper | 10c2c68 | 2013-08-20 07:09:39 +0000 | [diff] [blame] | 1915 | case CK_KNL: |
Chandler Carruth | 26a3914 | 2011-09-28 09:45:08 +0000 | [diff] [blame] | 1916 | case CK_Athlon64: |
| 1917 | case CK_Athlon64SSE3: |
| 1918 | case CK_AthlonFX: |
| 1919 | case CK_K8: |
| 1920 | case CK_K8SSE3: |
| 1921 | case CK_Opteron: |
| 1922 | case CK_OpteronSSE3: |
Roman Divacky | 01c770d | 2011-10-30 07:48:46 +0000 | [diff] [blame] | 1923 | case CK_AMDFAM10: |
Benjamin Kramer | 5660aa6 | 2012-01-10 11:50:18 +0000 | [diff] [blame] | 1924 | case CK_BTVER1: |
Benjamin Kramer | 63063f5 | 2013-05-03 10:47:15 +0000 | [diff] [blame] | 1925 | case CK_BTVER2: |
Benjamin Kramer | 61ea4fe | 2011-12-01 18:23:59 +0000 | [diff] [blame] | 1926 | case CK_BDVER1: |
| 1927 | case CK_BDVER2: |
Chandler Carruth | 26a3914 | 2011-09-28 09:45:08 +0000 | [diff] [blame] | 1928 | case CK_x86_64: |
| 1929 | return true; |
| 1930 | } |
Chandler Carruth | 5b7803d | 2011-09-28 10:49:06 +0000 | [diff] [blame] | 1931 | llvm_unreachable("Unhandled CPU kind"); |
Chandler Carruth | f6cf1c2 | 2011-09-28 02:59:25 +0000 | [diff] [blame] | 1932 | } |
Aaron Ballman | 82bfa19 | 2012-10-02 14:26:08 +0000 | [diff] [blame] | 1933 | |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 1934 | virtual bool setFPMath(StringRef Name); |
| 1935 | |
Aaron Ballman | 82bfa19 | 2012-10-02 14:26:08 +0000 | [diff] [blame] | 1936 | virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const { |
| 1937 | // We accept all non-ARM calling conventions |
| 1938 | return (CC == CC_X86ThisCall || |
| 1939 | CC == CC_X86FastCall || |
Peter Collingbourne | 7728cdd | 2013-02-23 00:06:18 +0000 | [diff] [blame] | 1940 | CC == CC_X86StdCall || |
| 1941 | CC == CC_C || |
Guy Benyei | 3898008 | 2012-12-25 08:53:55 +0000 | [diff] [blame] | 1942 | CC == CC_X86Pascal || |
| 1943 | CC == CC_IntelOclBicc) ? CCCR_OK : CCCR_Warning; |
Aaron Ballman | 82bfa19 | 2012-10-02 14:26:08 +0000 | [diff] [blame] | 1944 | } |
| 1945 | |
Aaron Ballman | fff3248 | 2012-12-09 17:45:41 +0000 | [diff] [blame] | 1946 | virtual CallingConv getDefaultCallingConv(CallingConvMethodType MT) const { |
| 1947 | return MT == CCMT_Member ? CC_X86ThisCall : CC_C; |
Aaron Ballman | 82bfa19 | 2012-10-02 14:26:08 +0000 | [diff] [blame] | 1948 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1949 | }; |
Chris Lattner | 3daed52 | 2009-03-02 22:20:04 +0000 | [diff] [blame] | 1950 | |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 1951 | bool X86TargetInfo::setFPMath(StringRef Name) { |
| 1952 | if (Name == "387") { |
| 1953 | FPMath = FP_387; |
| 1954 | return true; |
| 1955 | } |
| 1956 | if (Name == "sse") { |
| 1957 | FPMath = FP_SSE; |
| 1958 | return true; |
| 1959 | } |
| 1960 | return false; |
| 1961 | } |
| 1962 | |
Chandler Carruth | c3a2e65 | 2011-09-28 05:56:05 +0000 | [diff] [blame] | 1963 | void X86TargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const { |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 1964 | // FIXME: This *really* should not be here. |
| 1965 | |
| 1966 | // X86_64 always has SSE2. |
Derek Schuff | babaf31 | 2012-10-11 15:52:22 +0000 | [diff] [blame] | 1967 | if (getTriple().getArch() == llvm::Triple::x86_64) |
Eli Friedman | 612db2a | 2012-11-17 01:16:19 +0000 | [diff] [blame] | 1968 | setFeatureEnabled(Features, "sse2", true); |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 1969 | |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 1970 | switch (CPU) { |
| 1971 | case CK_Generic: |
| 1972 | case CK_i386: |
| 1973 | case CK_i486: |
| 1974 | case CK_i586: |
| 1975 | case CK_Pentium: |
| 1976 | case CK_i686: |
| 1977 | case CK_PentiumPro: |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 1978 | break; |
| 1979 | case CK_PentiumMMX: |
| 1980 | case CK_Pentium2: |
Daniel Dunbar | 3ac7904 | 2009-05-06 21:56:32 +0000 | [diff] [blame] | 1981 | setFeatureEnabled(Features, "mmx", true); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 1982 | break; |
| 1983 | case CK_Pentium3: |
| 1984 | case CK_Pentium3M: |
Daniel Dunbar | 3ac7904 | 2009-05-06 21:56:32 +0000 | [diff] [blame] | 1985 | setFeatureEnabled(Features, "sse", true); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 1986 | break; |
| 1987 | case CK_PentiumM: |
| 1988 | case CK_Pentium4: |
| 1989 | case CK_Pentium4M: |
| 1990 | case CK_x86_64: |
Daniel Dunbar | 3ac7904 | 2009-05-06 21:56:32 +0000 | [diff] [blame] | 1991 | setFeatureEnabled(Features, "sse2", true); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 1992 | break; |
| 1993 | case CK_Yonah: |
| 1994 | case CK_Prescott: |
| 1995 | case CK_Nocona: |
Daniel Dunbar | 3ac7904 | 2009-05-06 21:56:32 +0000 | [diff] [blame] | 1996 | setFeatureEnabled(Features, "sse3", true); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 1997 | break; |
| 1998 | case CK_Core2: |
Daniel Dunbar | 3ac7904 | 2009-05-06 21:56:32 +0000 | [diff] [blame] | 1999 | setFeatureEnabled(Features, "ssse3", true); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2000 | break; |
| 2001 | case CK_Penryn: |
Benjamin Kramer | b3453a8 | 2012-01-04 14:36:57 +0000 | [diff] [blame] | 2002 | setFeatureEnabled(Features, "sse4.1", true); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2003 | break; |
| 2004 | case CK_Atom: |
Chandler Carruth | 49defe6 | 2011-09-28 10:36:46 +0000 | [diff] [blame] | 2005 | setFeatureEnabled(Features, "ssse3", true); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2006 | break; |
| 2007 | case CK_Corei7: |
Benjamin Kramer | b98ce37 | 2013-08-30 14:05:34 +0000 | [diff] [blame] | 2008 | case CK_SLM: |
Rafael Espindola | 81cde9e | 2013-08-23 20:21:37 +0000 | [diff] [blame] | 2009 | setFeatureEnabled(Features, "sse4.2", true); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2010 | break; |
| 2011 | case CK_Corei7AVX: |
Benjamin Kramer | 84f3080 | 2012-07-07 09:39:18 +0000 | [diff] [blame] | 2012 | setFeatureEnabled(Features, "avx", true); |
| 2013 | setFeatureEnabled(Features, "aes", true); |
| 2014 | setFeatureEnabled(Features, "pclmul", true); |
| 2015 | break; |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2016 | case CK_CoreAVXi: |
Craig Topper | fd93630 | 2012-04-26 07:31:30 +0000 | [diff] [blame] | 2017 | setFeatureEnabled(Features, "avx", true); |
Roman Divacky | bcaa3b8 | 2011-04-05 20:32:44 +0000 | [diff] [blame] | 2018 | setFeatureEnabled(Features, "aes", true); |
Craig Topper | 3c0bc15 | 2012-05-31 05:18:48 +0000 | [diff] [blame] | 2019 | setFeatureEnabled(Features, "pclmul", true); |
Benjamin Kramer | 84f3080 | 2012-07-07 09:39:18 +0000 | [diff] [blame] | 2020 | setFeatureEnabled(Features, "rdrnd", true); |
Eli Friedman | faf3538 | 2012-11-17 01:43:10 +0000 | [diff] [blame] | 2021 | setFeatureEnabled(Features, "f16c", true); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2022 | break; |
Craig Topper | 2b03bb0 | 2011-12-17 19:55:21 +0000 | [diff] [blame] | 2023 | case CK_CoreAVX2: |
Craig Topper | fd93630 | 2012-04-26 07:31:30 +0000 | [diff] [blame] | 2024 | setFeatureEnabled(Features, "avx2", true); |
Craig Topper | 2b03bb0 | 2011-12-17 19:55:21 +0000 | [diff] [blame] | 2025 | setFeatureEnabled(Features, "aes", true); |
Craig Topper | 3c0bc15 | 2012-05-31 05:18:48 +0000 | [diff] [blame] | 2026 | setFeatureEnabled(Features, "pclmul", true); |
Craig Topper | 31ceea0 | 2011-12-25 05:06:45 +0000 | [diff] [blame] | 2027 | setFeatureEnabled(Features, "lzcnt", true); |
Benjamin Kramer | 84f3080 | 2012-07-07 09:39:18 +0000 | [diff] [blame] | 2028 | setFeatureEnabled(Features, "rdrnd", true); |
Eli Friedman | faf3538 | 2012-11-17 01:43:10 +0000 | [diff] [blame] | 2029 | setFeatureEnabled(Features, "f16c", true); |
Craig Topper | 31ceea0 | 2011-12-25 05:06:45 +0000 | [diff] [blame] | 2030 | setFeatureEnabled(Features, "bmi", true); |
| 2031 | setFeatureEnabled(Features, "bmi2", true); |
Michael Liao | 463eb89 | 2012-11-10 05:17:46 +0000 | [diff] [blame] | 2032 | setFeatureEnabled(Features, "rtm", true); |
Craig Topper | 2ae9507 | 2012-06-03 21:46:30 +0000 | [diff] [blame] | 2033 | setFeatureEnabled(Features, "fma", true); |
Craig Topper | 2b03bb0 | 2011-12-17 19:55:21 +0000 | [diff] [blame] | 2034 | break; |
Craig Topper | 10c2c68 | 2013-08-20 07:09:39 +0000 | [diff] [blame] | 2035 | case CK_KNL: |
Craig Topper | bca2c4f | 2013-08-21 05:29:10 +0000 | [diff] [blame] | 2036 | setFeatureEnabled(Features, "avx512f", true); |
| 2037 | setFeatureEnabled(Features, "avx512cd", true); |
| 2038 | setFeatureEnabled(Features, "avx512er", true); |
| 2039 | setFeatureEnabled(Features, "avx512pf", true); |
Craig Topper | 10c2c68 | 2013-08-20 07:09:39 +0000 | [diff] [blame] | 2040 | setFeatureEnabled(Features, "aes", true); |
| 2041 | setFeatureEnabled(Features, "pclmul", true); |
| 2042 | setFeatureEnabled(Features, "lzcnt", true); |
| 2043 | setFeatureEnabled(Features, "rdrnd", true); |
| 2044 | setFeatureEnabled(Features, "f16c", true); |
| 2045 | setFeatureEnabled(Features, "bmi", true); |
| 2046 | setFeatureEnabled(Features, "bmi2", true); |
| 2047 | setFeatureEnabled(Features, "rtm", true); |
| 2048 | setFeatureEnabled(Features, "fma", true); |
| 2049 | break; |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2050 | case CK_K6: |
| 2051 | case CK_WinChipC6: |
Daniel Dunbar | 3ac7904 | 2009-05-06 21:56:32 +0000 | [diff] [blame] | 2052 | setFeatureEnabled(Features, "mmx", true); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2053 | break; |
| 2054 | case CK_K6_2: |
| 2055 | case CK_K6_3: |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2056 | case CK_WinChip2: |
| 2057 | case CK_C3: |
Daniel Dunbar | 3ac7904 | 2009-05-06 21:56:32 +0000 | [diff] [blame] | 2058 | setFeatureEnabled(Features, "3dnow", true); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2059 | break; |
Chandler Carruth | 49defe6 | 2011-09-28 10:36:46 +0000 | [diff] [blame] | 2060 | case CK_Athlon: |
| 2061 | case CK_AthlonThunderbird: |
| 2062 | case CK_Geode: |
| 2063 | setFeatureEnabled(Features, "3dnowa", true); |
| 2064 | break; |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2065 | case CK_Athlon4: |
| 2066 | case CK_AthlonXP: |
| 2067 | case CK_AthlonMP: |
Daniel Dunbar | 3ac7904 | 2009-05-06 21:56:32 +0000 | [diff] [blame] | 2068 | setFeatureEnabled(Features, "sse", true); |
| 2069 | setFeatureEnabled(Features, "3dnowa", true); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2070 | break; |
| 2071 | case CK_K8: |
| 2072 | case CK_Opteron: |
| 2073 | case CK_Athlon64: |
| 2074 | case CK_AthlonFX: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2075 | setFeatureEnabled(Features, "sse2", true); |
Daniel Dunbar | 3ac7904 | 2009-05-06 21:56:32 +0000 | [diff] [blame] | 2076 | setFeatureEnabled(Features, "3dnowa", true); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2077 | break; |
| 2078 | case CK_K8SSE3: |
| 2079 | case CK_OpteronSSE3: |
| 2080 | case CK_Athlon64SSE3: |
Roman Divacky | 80b32b8 | 2011-10-30 13:47:56 +0000 | [diff] [blame] | 2081 | setFeatureEnabled(Features, "sse3", true); |
| 2082 | setFeatureEnabled(Features, "3dnowa", true); |
| 2083 | break; |
Roman Divacky | 01c770d | 2011-10-30 07:48:46 +0000 | [diff] [blame] | 2084 | case CK_AMDFAM10: |
Roman Divacky | c8b09a1 | 2010-12-29 13:28:29 +0000 | [diff] [blame] | 2085 | setFeatureEnabled(Features, "sse3", true); |
Roman Divacky | 80b32b8 | 2011-10-30 13:47:56 +0000 | [diff] [blame] | 2086 | setFeatureEnabled(Features, "sse4a", true); |
Roman Divacky | c8b09a1 | 2010-12-29 13:28:29 +0000 | [diff] [blame] | 2087 | setFeatureEnabled(Features, "3dnowa", true); |
Eli Friedman | faf3538 | 2012-11-17 01:43:10 +0000 | [diff] [blame] | 2088 | setFeatureEnabled(Features, "lzcnt", true); |
| 2089 | setFeatureEnabled(Features, "popcnt", true); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2090 | break; |
Benjamin Kramer | 5660aa6 | 2012-01-10 11:50:18 +0000 | [diff] [blame] | 2091 | case CK_BTVER1: |
| 2092 | setFeatureEnabled(Features, "ssse3", true); |
| 2093 | setFeatureEnabled(Features, "sse4a", true); |
Eli Friedman | faf3538 | 2012-11-17 01:43:10 +0000 | [diff] [blame] | 2094 | setFeatureEnabled(Features, "lzcnt", true); |
| 2095 | setFeatureEnabled(Features, "popcnt", true); |
Craig Topper | 90ea036 | 2012-05-30 05:54:54 +0000 | [diff] [blame] | 2096 | break; |
Benjamin Kramer | 63063f5 | 2013-05-03 10:47:15 +0000 | [diff] [blame] | 2097 | case CK_BTVER2: |
| 2098 | setFeatureEnabled(Features, "avx", true); |
| 2099 | setFeatureEnabled(Features, "sse4a", true); |
| 2100 | setFeatureEnabled(Features, "lzcnt", true); |
| 2101 | setFeatureEnabled(Features, "aes", true); |
| 2102 | setFeatureEnabled(Features, "pclmul", true); |
| 2103 | setFeatureEnabled(Features, "bmi", true); |
| 2104 | setFeatureEnabled(Features, "f16c", true); |
| 2105 | break; |
Benjamin Kramer | 61ea4fe | 2011-12-01 18:23:59 +0000 | [diff] [blame] | 2106 | case CK_BDVER1: |
Craig Topper | b6af69e | 2012-06-09 22:24:14 +0000 | [diff] [blame] | 2107 | setFeatureEnabled(Features, "xop", true); |
Eli Friedman | faf3538 | 2012-11-17 01:43:10 +0000 | [diff] [blame] | 2108 | setFeatureEnabled(Features, "lzcnt", true); |
Benjamin Kramer | 61ea4fe | 2011-12-01 18:23:59 +0000 | [diff] [blame] | 2109 | setFeatureEnabled(Features, "aes", true); |
Craig Topper | 3c0bc15 | 2012-05-31 05:18:48 +0000 | [diff] [blame] | 2110 | setFeatureEnabled(Features, "pclmul", true); |
Eli Friedman | f582499 | 2012-11-26 21:57:28 +0000 | [diff] [blame] | 2111 | break; |
Eli Friedman | faf3538 | 2012-11-17 01:43:10 +0000 | [diff] [blame] | 2112 | case CK_BDVER2: |
| 2113 | setFeatureEnabled(Features, "xop", true); |
| 2114 | setFeatureEnabled(Features, "lzcnt", true); |
| 2115 | setFeatureEnabled(Features, "aes", true); |
| 2116 | setFeatureEnabled(Features, "pclmul", true); |
| 2117 | setFeatureEnabled(Features, "bmi", true); |
| 2118 | setFeatureEnabled(Features, "fma", true); |
| 2119 | setFeatureEnabled(Features, "f16c", true); |
Benjamin Kramer | 61ea4fe | 2011-12-01 18:23:59 +0000 | [diff] [blame] | 2120 | break; |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2121 | case CK_C3_2: |
Daniel Dunbar | 3ac7904 | 2009-05-06 21:56:32 +0000 | [diff] [blame] | 2122 | setFeatureEnabled(Features, "sse", true); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2123 | break; |
Eli Friedman | c3e0fb4 | 2011-07-08 23:31:17 +0000 | [diff] [blame] | 2124 | } |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 2125 | } |
| 2126 | |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2127 | void X86TargetInfo::setSSELevel(llvm::StringMap<bool> &Features, |
| 2128 | X86SSEEnum Level, bool Enabled) const { |
| 2129 | if (Enabled) { |
| 2130 | switch (Level) { |
Craig Topper | b7a95d2 | 2013-08-21 03:59:22 +0000 | [diff] [blame] | 2131 | case AVX512F: |
| 2132 | Features["avx512f"] = true; |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2133 | case AVX2: |
| 2134 | Features["avx2"] = true; |
| 2135 | case AVX: |
| 2136 | Features["avx"] = true; |
| 2137 | case SSE42: |
Craig Topper | 89a5e79 | 2013-09-10 06:55:47 +0000 | [diff] [blame] | 2138 | Features["sse4.2"] = true; |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2139 | case SSE41: |
Rafael Espindola | 81cde9e | 2013-08-23 20:21:37 +0000 | [diff] [blame] | 2140 | Features["sse4.1"] = true; |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2141 | case SSSE3: |
| 2142 | Features["ssse3"] = true; |
| 2143 | case SSE3: |
| 2144 | Features["sse3"] = true; |
| 2145 | case SSE2: |
| 2146 | Features["sse2"] = true; |
| 2147 | case SSE1: |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2148 | Features["sse"] = true; |
| 2149 | case NoSSE: |
| 2150 | break; |
| 2151 | } |
| 2152 | return; |
| 2153 | } |
| 2154 | |
| 2155 | switch (Level) { |
| 2156 | case NoSSE: |
| 2157 | case SSE1: |
| 2158 | Features["sse"] = false; |
| 2159 | case SSE2: |
| 2160 | Features["sse2"] = false; |
| 2161 | case SSE3: |
| 2162 | Features["sse3"] = false; |
| 2163 | setXOPLevel(Features, NoXOP, false); |
| 2164 | case SSSE3: |
| 2165 | Features["ssse3"] = false; |
| 2166 | case SSE41: |
Rafael Espindola | 81cde9e | 2013-08-23 20:21:37 +0000 | [diff] [blame] | 2167 | Features["sse4.1"] = false; |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2168 | case SSE42: |
Craig Topper | 89a5e79 | 2013-09-10 06:55:47 +0000 | [diff] [blame] | 2169 | Features["sse4.2"] = false; |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2170 | case AVX: |
| 2171 | Features["fma"] = Features["avx"] = false; |
Rafael Espindola | 29f26de | 2013-08-21 13:28:02 +0000 | [diff] [blame] | 2172 | setXOPLevel(Features, FMA4, false); |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2173 | case AVX2: |
| 2174 | Features["avx2"] = false; |
Craig Topper | b7a95d2 | 2013-08-21 03:59:22 +0000 | [diff] [blame] | 2175 | case AVX512F: |
Craig Topper | bca2c4f | 2013-08-21 05:29:10 +0000 | [diff] [blame] | 2176 | Features["avx512f"] = Features["avx512cd"] = Features["avx512er"] = |
| 2177 | Features["avx512pf"] = false; |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2178 | } |
| 2179 | } |
| 2180 | |
| 2181 | void X86TargetInfo::setMMXLevel(llvm::StringMap<bool> &Features, |
| 2182 | MMX3DNowEnum Level, bool Enabled) const { |
| 2183 | if (Enabled) { |
| 2184 | switch (Level) { |
| 2185 | case AMD3DNowAthlon: |
| 2186 | Features["3dnowa"] = true; |
| 2187 | case AMD3DNow: |
| 2188 | Features["3dnow"] = true; |
| 2189 | case MMX: |
| 2190 | Features["mmx"] = true; |
| 2191 | case NoMMX3DNow: |
| 2192 | break; |
| 2193 | } |
| 2194 | return; |
| 2195 | } |
| 2196 | |
| 2197 | switch (Level) { |
| 2198 | case NoMMX3DNow: |
| 2199 | case MMX: |
| 2200 | Features["mmx"] = false; |
| 2201 | case AMD3DNow: |
| 2202 | Features["3dnow"] = false; |
| 2203 | case AMD3DNowAthlon: |
| 2204 | Features["3dnowa"] = false; |
| 2205 | } |
| 2206 | } |
| 2207 | |
| 2208 | void X86TargetInfo::setXOPLevel(llvm::StringMap<bool> &Features, XOPEnum Level, |
| 2209 | bool Enabled) const { |
| 2210 | if (Enabled) { |
| 2211 | switch (Level) { |
| 2212 | case XOP: |
| 2213 | Features["xop"] = true; |
| 2214 | case FMA4: |
| 2215 | Features["fma4"] = true; |
| 2216 | setSSELevel(Features, AVX, true); |
| 2217 | case SSE4A: |
| 2218 | Features["sse4a"] = true; |
| 2219 | setSSELevel(Features, SSE3, true); |
| 2220 | case NoXOP: |
| 2221 | break; |
| 2222 | } |
| 2223 | return; |
| 2224 | } |
| 2225 | |
| 2226 | switch (Level) { |
| 2227 | case NoXOP: |
| 2228 | case SSE4A: |
| 2229 | Features["sse4a"] = false; |
| 2230 | case FMA4: |
| 2231 | Features["fma4"] = false; |
| 2232 | case XOP: |
| 2233 | Features["xop"] = false; |
| 2234 | } |
| 2235 | } |
| 2236 | |
Rafael Espindola | ade7cd4 | 2013-08-20 15:30:32 +0000 | [diff] [blame] | 2237 | void X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features, |
Benjamin Kramer | 713575a | 2012-03-05 15:10:44 +0000 | [diff] [blame] | 2238 | StringRef Name, |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 2239 | bool Enabled) const { |
Eric Christopher | d39ebe2 | 2010-03-04 02:26:37 +0000 | [diff] [blame] | 2240 | // FIXME: This *really* should not be here. We need some way of translating |
| 2241 | // options into llvm subtarget features. |
Rafael Espindola | 81cde9e | 2013-08-23 20:21:37 +0000 | [diff] [blame] | 2242 | if (Name == "sse4") |
| 2243 | Name = "sse4.2"; |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 2244 | |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2245 | Features[Name] = Enabled; |
Rafael Espindola | 53ac3d8 | 2011-11-27 20:00:43 +0000 | [diff] [blame] | 2246 | |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2247 | if (Name == "mmx") |
| 2248 | setMMXLevel(Features, MMX, Enabled); |
| 2249 | else if (Name == "sse") |
| 2250 | setSSELevel(Features, SSE1, Enabled); |
| 2251 | else if (Name == "sse2") |
| 2252 | setSSELevel(Features, SSE2, Enabled); |
| 2253 | else if (Name == "sse3") |
| 2254 | setSSELevel(Features, SSE3, Enabled); |
| 2255 | else if (Name == "ssse3") |
| 2256 | setSSELevel(Features, SSSE3, Enabled); |
Rafael Espindola | 81cde9e | 2013-08-23 20:21:37 +0000 | [diff] [blame] | 2257 | else if (Name == "sse4.2") |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2258 | setSSELevel(Features, SSE42, Enabled); |
Rafael Espindola | 81cde9e | 2013-08-23 20:21:37 +0000 | [diff] [blame] | 2259 | else if (Name == "sse4.1") |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2260 | setSSELevel(Features, SSE41, Enabled); |
| 2261 | else if (Name == "3dnow") |
| 2262 | setMMXLevel(Features, AMD3DNow, Enabled); |
| 2263 | else if (Name == "3dnowa") |
| 2264 | setMMXLevel(Features, AMD3DNowAthlon, Enabled); |
| 2265 | else if (Name == "aes") { |
| 2266 | if (Enabled) |
| 2267 | setSSELevel(Features, SSE2, Enabled); |
| 2268 | } else if (Name == "pclmul") { |
| 2269 | if (Enabled) |
| 2270 | setSSELevel(Features, SSE2, Enabled); |
| 2271 | } else if (Name == "avx") |
| 2272 | setSSELevel(Features, AVX, Enabled); |
| 2273 | else if (Name == "avx2") |
| 2274 | setSSELevel(Features, AVX2, Enabled); |
Craig Topper | bca2c4f | 2013-08-21 05:29:10 +0000 | [diff] [blame] | 2275 | else if (Name == "avx512f") |
Craig Topper | b7a95d2 | 2013-08-21 03:59:22 +0000 | [diff] [blame] | 2276 | setSSELevel(Features, AVX512F, Enabled); |
Craig Topper | bca2c4f | 2013-08-21 05:29:10 +0000 | [diff] [blame] | 2277 | else if (Name == "avx512cd" || Name == "avx512er" || Name == "avx512pf") { |
| 2278 | if (Enabled) |
| 2279 | setSSELevel(Features, AVX512F, Enabled); |
| 2280 | } else if (Name == "fma") { |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2281 | if (Enabled) |
| 2282 | setSSELevel(Features, AVX, Enabled); |
| 2283 | } else if (Name == "fma4") { |
| 2284 | setXOPLevel(Features, FMA4, Enabled); |
| 2285 | } else if (Name == "xop") { |
| 2286 | setXOPLevel(Features, XOP, Enabled); |
| 2287 | } else if (Name == "sse4a") { |
| 2288 | setXOPLevel(Features, SSE4A, Enabled); |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 2289 | } |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 2290 | } |
| 2291 | |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 2292 | /// HandleTargetOptions - Perform initialization based on the user |
| 2293 | /// configured set of features. |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 2294 | bool X86TargetInfo::HandleTargetFeatures(std::vector<std::string> &Features, |
| 2295 | DiagnosticsEngine &Diags) { |
Daniel Dunbar | 29a790b | 2009-11-11 09:38:56 +0000 | [diff] [blame] | 2296 | // Remember the maximum enabled sselevel. |
| 2297 | for (unsigned i = 0, e = Features.size(); i !=e; ++i) { |
| 2298 | // Ignore disabled features. |
| 2299 | if (Features[i][0] == '-') |
| 2300 | continue; |
| 2301 | |
Benjamin Kramer | 713575a | 2012-03-05 15:10:44 +0000 | [diff] [blame] | 2302 | StringRef Feature = StringRef(Features[i]).substr(1); |
| 2303 | |
| 2304 | if (Feature == "aes") { |
Eric Christopher | eea12d1 | 2010-04-02 23:50:19 +0000 | [diff] [blame] | 2305 | HasAES = true; |
| 2306 | continue; |
| 2307 | } |
| 2308 | |
Craig Topper | 3c0bc15 | 2012-05-31 05:18:48 +0000 | [diff] [blame] | 2309 | if (Feature == "pclmul") { |
| 2310 | HasPCLMUL = true; |
| 2311 | continue; |
| 2312 | } |
| 2313 | |
Benjamin Kramer | 713575a | 2012-03-05 15:10:44 +0000 | [diff] [blame] | 2314 | if (Feature == "lzcnt") { |
Craig Topper | 31ceea0 | 2011-12-25 05:06:45 +0000 | [diff] [blame] | 2315 | HasLZCNT = true; |
| 2316 | continue; |
| 2317 | } |
| 2318 | |
Rafael Espindola | 81cde9e | 2013-08-23 20:21:37 +0000 | [diff] [blame] | 2319 | if (Feature == "rdrnd") { |
Benjamin Kramer | 84f3080 | 2012-07-07 09:39:18 +0000 | [diff] [blame] | 2320 | HasRDRND = true; |
| 2321 | continue; |
| 2322 | } |
| 2323 | |
Benjamin Kramer | 713575a | 2012-03-05 15:10:44 +0000 | [diff] [blame] | 2324 | if (Feature == "bmi") { |
Craig Topper | 31ceea0 | 2011-12-25 05:06:45 +0000 | [diff] [blame] | 2325 | HasBMI = true; |
| 2326 | continue; |
| 2327 | } |
| 2328 | |
Benjamin Kramer | 713575a | 2012-03-05 15:10:44 +0000 | [diff] [blame] | 2329 | if (Feature == "bmi2") { |
Craig Topper | 31ceea0 | 2011-12-25 05:06:45 +0000 | [diff] [blame] | 2330 | HasBMI2 = true; |
| 2331 | continue; |
| 2332 | } |
| 2333 | |
Benjamin Kramer | 713575a | 2012-03-05 15:10:44 +0000 | [diff] [blame] | 2334 | if (Feature == "popcnt") { |
Craig Topper | e14e08b | 2011-12-29 16:10:46 +0000 | [diff] [blame] | 2335 | HasPOPCNT = true; |
| 2336 | continue; |
| 2337 | } |
| 2338 | |
Michael Liao | 463eb89 | 2012-11-10 05:17:46 +0000 | [diff] [blame] | 2339 | if (Feature == "rtm") { |
| 2340 | HasRTM = true; |
| 2341 | continue; |
| 2342 | } |
| 2343 | |
Michael Liao | 72339a0 | 2013-03-26 17:52:08 +0000 | [diff] [blame] | 2344 | if (Feature == "prfchw") { |
| 2345 | HasPRFCHW = true; |
| 2346 | continue; |
| 2347 | } |
| 2348 | |
Michael Liao | 1bfc28c | 2013-03-29 05:17:55 +0000 | [diff] [blame] | 2349 | if (Feature == "rdseed") { |
| 2350 | HasRDSEED = true; |
| 2351 | continue; |
| 2352 | } |
| 2353 | |
Craig Topper | 2ae9507 | 2012-06-03 21:46:30 +0000 | [diff] [blame] | 2354 | if (Feature == "fma") { |
| 2355 | HasFMA = true; |
| 2356 | continue; |
| 2357 | } |
| 2358 | |
Manman Ren | 146e5a4 | 2012-10-11 00:59:55 +0000 | [diff] [blame] | 2359 | if (Feature == "f16c") { |
| 2360 | HasF16C = true; |
| 2361 | continue; |
| 2362 | } |
| 2363 | |
Craig Topper | bca2c4f | 2013-08-21 05:29:10 +0000 | [diff] [blame] | 2364 | if (Feature == "avx512cd") { |
| 2365 | HasAVX512CD = true; |
| 2366 | continue; |
| 2367 | } |
| 2368 | |
| 2369 | if (Feature == "avx512er") { |
| 2370 | HasAVX512ER = true; |
| 2371 | continue; |
| 2372 | } |
| 2373 | |
| 2374 | if (Feature == "avx512pf") { |
| 2375 | HasAVX512PF = true; |
| 2376 | continue; |
| 2377 | } |
| 2378 | |
Daniel Dunbar | 29a790b | 2009-11-11 09:38:56 +0000 | [diff] [blame] | 2379 | assert(Features[i][0] == '+' && "Invalid target feature!"); |
Benjamin Kramer | 713575a | 2012-03-05 15:10:44 +0000 | [diff] [blame] | 2380 | X86SSEEnum Level = llvm::StringSwitch<X86SSEEnum>(Feature) |
Craig Topper | bca2c4f | 2013-08-21 05:29:10 +0000 | [diff] [blame] | 2381 | .Case("avx512f", AVX512F) |
Craig Topper | 05fe4b5 | 2012-01-09 09:19:09 +0000 | [diff] [blame] | 2382 | .Case("avx2", AVX2) |
| 2383 | .Case("avx", AVX) |
Rafael Espindola | 81cde9e | 2013-08-23 20:21:37 +0000 | [diff] [blame] | 2384 | .Case("sse4.2", SSE42) |
| 2385 | .Case("sse4.1", SSE41) |
Daniel Dunbar | 29a790b | 2009-11-11 09:38:56 +0000 | [diff] [blame] | 2386 | .Case("ssse3", SSSE3) |
Nuno Lopes | 33d3bca | 2010-03-12 10:20:09 +0000 | [diff] [blame] | 2387 | .Case("sse3", SSE3) |
Daniel Dunbar | 29a790b | 2009-11-11 09:38:56 +0000 | [diff] [blame] | 2388 | .Case("sse2", SSE2) |
| 2389 | .Case("sse", SSE1) |
Eli Friedman | c3e0fb4 | 2011-07-08 23:31:17 +0000 | [diff] [blame] | 2390 | .Default(NoSSE); |
Daniel Dunbar | 29a790b | 2009-11-11 09:38:56 +0000 | [diff] [blame] | 2391 | SSELevel = std::max(SSELevel, Level); |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 2392 | |
Eli Friedman | c3e0fb4 | 2011-07-08 23:31:17 +0000 | [diff] [blame] | 2393 | MMX3DNowEnum ThreeDNowLevel = |
Benjamin Kramer | 713575a | 2012-03-05 15:10:44 +0000 | [diff] [blame] | 2394 | llvm::StringSwitch<MMX3DNowEnum>(Feature) |
Anders Carlsson | 9b0fb62 | 2010-01-27 03:47:49 +0000 | [diff] [blame] | 2395 | .Case("3dnowa", AMD3DNowAthlon) |
| 2396 | .Case("3dnow", AMD3DNow) |
Eli Friedman | c3e0fb4 | 2011-07-08 23:31:17 +0000 | [diff] [blame] | 2397 | .Case("mmx", MMX) |
| 2398 | .Default(NoMMX3DNow); |
Eli Friedman | c3e0fb4 | 2011-07-08 23:31:17 +0000 | [diff] [blame] | 2399 | MMX3DNowLevel = std::max(MMX3DNowLevel, ThreeDNowLevel); |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2400 | |
| 2401 | XOPEnum XLevel = llvm::StringSwitch<XOPEnum>(Feature) |
| 2402 | .Case("xop", XOP) |
| 2403 | .Case("fma4", FMA4) |
| 2404 | .Case("sse4a", SSE4A) |
| 2405 | .Default(NoXOP); |
| 2406 | XOPLevel = std::max(XOPLevel, XLevel); |
Daniel Dunbar | 29a790b | 2009-11-11 09:38:56 +0000 | [diff] [blame] | 2407 | } |
Eli Friedman | c3e0fb4 | 2011-07-08 23:31:17 +0000 | [diff] [blame] | 2408 | |
Craig Topper | 89a5e79 | 2013-09-10 06:55:47 +0000 | [diff] [blame] | 2409 | // Enable popcnt if sse4.2 is enabled and popcnt is not explicitly disabled. |
| 2410 | // Can't do this earlier because we need to be able to explicitly enable |
| 2411 | // popcnt and still disable sse4.2. |
| 2412 | if (!HasPOPCNT && SSELevel >= SSE42 && |
| 2413 | std::find(Features.begin(), Features.end(), "-popcnt") == Features.end()){ |
| 2414 | HasPOPCNT = true; |
| 2415 | Features.push_back("+popcnt"); |
| 2416 | } |
| 2417 | |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 2418 | // LLVM doesn't have a separate switch for fpmath, so only accept it if it |
| 2419 | // matches the selected sse level. |
| 2420 | if (FPMath == FP_SSE && SSELevel < SSE1) { |
| 2421 | Diags.Report(diag::err_target_unsupported_fpmath) << "sse"; |
| 2422 | return false; |
| 2423 | } else if (FPMath == FP_387 && SSELevel >= SSE1) { |
| 2424 | Diags.Report(diag::err_target_unsupported_fpmath) << "387"; |
| 2425 | return false; |
| 2426 | } |
| 2427 | |
Eli Friedman | c3e0fb4 | 2011-07-08 23:31:17 +0000 | [diff] [blame] | 2428 | // Don't tell the backend if we're turning off mmx; it will end up disabling |
| 2429 | // SSE, which we don't want. |
Craig Topper | 56bed97 | 2013-09-11 06:48:53 +0000 | [diff] [blame] | 2430 | // Additionally, if SSE is enabled and mmx is not explicitly disabled, |
| 2431 | // then enable MMX. |
Eli Friedman | c3e0fb4 | 2011-07-08 23:31:17 +0000 | [diff] [blame] | 2432 | std::vector<std::string>::iterator it; |
| 2433 | it = std::find(Features.begin(), Features.end(), "-mmx"); |
| 2434 | if (it != Features.end()) |
| 2435 | Features.erase(it); |
Craig Topper | 56bed97 | 2013-09-11 06:48:53 +0000 | [diff] [blame] | 2436 | else if (SSELevel > NoSSE) |
| 2437 | MMX3DNowLevel = std::max(MMX3DNowLevel, MMX); |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 2438 | return true; |
Chris Lattner | 3daed52 | 2009-03-02 22:20:04 +0000 | [diff] [blame] | 2439 | } |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 2440 | |
Chandler Carruth | f6cf1c2 | 2011-09-28 02:59:25 +0000 | [diff] [blame] | 2441 | /// X86TargetInfo::getTargetDefines - Return the set of the X86-specific macro |
| 2442 | /// definitions for this particular subtarget. |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 2443 | void X86TargetInfo::getTargetDefines(const LangOptions &Opts, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 2444 | MacroBuilder &Builder) const { |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 2445 | // Target identification. |
Derek Schuff | babaf31 | 2012-10-11 15:52:22 +0000 | [diff] [blame] | 2446 | if (getTriple().getArch() == llvm::Triple::x86_64) { |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 2447 | Builder.defineMacro("__amd64__"); |
| 2448 | Builder.defineMacro("__amd64"); |
| 2449 | Builder.defineMacro("__x86_64"); |
| 2450 | Builder.defineMacro("__x86_64__"); |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 2451 | } else { |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 2452 | DefineStd(Builder, "i386", Opts); |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 2453 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 2454 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 2455 | // Subtarget options. |
Chandler Carruth | f6cf1c2 | 2011-09-28 02:59:25 +0000 | [diff] [blame] | 2456 | // FIXME: We are hard-coding the tune parameters based on the CPU, but they |
| 2457 | // truly should be based on -mtune options. |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2458 | switch (CPU) { |
| 2459 | case CK_Generic: |
| 2460 | break; |
| 2461 | case CK_i386: |
Chandler Carruth | f6cf1c2 | 2011-09-28 02:59:25 +0000 | [diff] [blame] | 2462 | // The rest are coming from the i386 define above. |
| 2463 | Builder.defineMacro("__tune_i386__"); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2464 | break; |
| 2465 | case CK_i486: |
| 2466 | case CK_WinChipC6: |
| 2467 | case CK_WinChip2: |
| 2468 | case CK_C3: |
Benjamin Kramer | 448f68d | 2012-01-10 11:50:09 +0000 | [diff] [blame] | 2469 | defineCPUMacros(Builder, "i486"); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2470 | break; |
Chandler Carruth | f17ba33 | 2011-09-28 09:45:05 +0000 | [diff] [blame] | 2471 | case CK_PentiumMMX: |
| 2472 | Builder.defineMacro("__pentium_mmx__"); |
| 2473 | Builder.defineMacro("__tune_pentium_mmx__"); |
| 2474 | // Fallthrough |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2475 | case CK_i586: |
| 2476 | case CK_Pentium: |
Benjamin Kramer | 448f68d | 2012-01-10 11:50:09 +0000 | [diff] [blame] | 2477 | defineCPUMacros(Builder, "i586"); |
| 2478 | defineCPUMacros(Builder, "pentium"); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2479 | break; |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2480 | case CK_Pentium3: |
| 2481 | case CK_Pentium3M: |
| 2482 | case CK_PentiumM: |
Chandler Carruth | f17ba33 | 2011-09-28 09:45:05 +0000 | [diff] [blame] | 2483 | Builder.defineMacro("__tune_pentium3__"); |
| 2484 | // Fallthrough |
| 2485 | case CK_Pentium2: |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2486 | case CK_C3_2: |
Chandler Carruth | f17ba33 | 2011-09-28 09:45:05 +0000 | [diff] [blame] | 2487 | Builder.defineMacro("__tune_pentium2__"); |
| 2488 | // Fallthrough |
| 2489 | case CK_PentiumPro: |
| 2490 | Builder.defineMacro("__tune_i686__"); |
| 2491 | Builder.defineMacro("__tune_pentiumpro__"); |
| 2492 | // Fallthrough |
| 2493 | case CK_i686: |
Chandler Carruth | f6cf1c2 | 2011-09-28 02:59:25 +0000 | [diff] [blame] | 2494 | Builder.defineMacro("__i686"); |
| 2495 | Builder.defineMacro("__i686__"); |
| 2496 | // Strangely, __tune_i686__ isn't defined by GCC when CPU == i686. |
| 2497 | Builder.defineMacro("__pentiumpro"); |
| 2498 | Builder.defineMacro("__pentiumpro__"); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2499 | break; |
| 2500 | case CK_Pentium4: |
| 2501 | case CK_Pentium4M: |
Benjamin Kramer | 448f68d | 2012-01-10 11:50:09 +0000 | [diff] [blame] | 2502 | defineCPUMacros(Builder, "pentium4"); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2503 | break; |
| 2504 | case CK_Yonah: |
| 2505 | case CK_Prescott: |
| 2506 | case CK_Nocona: |
Benjamin Kramer | 448f68d | 2012-01-10 11:50:09 +0000 | [diff] [blame] | 2507 | defineCPUMacros(Builder, "nocona"); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2508 | break; |
| 2509 | case CK_Core2: |
| 2510 | case CK_Penryn: |
Benjamin Kramer | 448f68d | 2012-01-10 11:50:09 +0000 | [diff] [blame] | 2511 | defineCPUMacros(Builder, "core2"); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2512 | break; |
| 2513 | case CK_Atom: |
Benjamin Kramer | 448f68d | 2012-01-10 11:50:09 +0000 | [diff] [blame] | 2514 | defineCPUMacros(Builder, "atom"); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2515 | break; |
Benjamin Kramer | b98ce37 | 2013-08-30 14:05:34 +0000 | [diff] [blame] | 2516 | case CK_SLM: |
| 2517 | defineCPUMacros(Builder, "slm"); |
| 2518 | break; |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2519 | case CK_Corei7: |
| 2520 | case CK_Corei7AVX: |
| 2521 | case CK_CoreAVXi: |
Craig Topper | 2b03bb0 | 2011-12-17 19:55:21 +0000 | [diff] [blame] | 2522 | case CK_CoreAVX2: |
Benjamin Kramer | 448f68d | 2012-01-10 11:50:09 +0000 | [diff] [blame] | 2523 | defineCPUMacros(Builder, "corei7"); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2524 | break; |
Craig Topper | 10c2c68 | 2013-08-20 07:09:39 +0000 | [diff] [blame] | 2525 | case CK_KNL: |
| 2526 | defineCPUMacros(Builder, "knl"); |
| 2527 | break; |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2528 | case CK_K6_2: |
Chandler Carruth | f17ba33 | 2011-09-28 09:45:05 +0000 | [diff] [blame] | 2529 | Builder.defineMacro("__k6_2__"); |
| 2530 | Builder.defineMacro("__tune_k6_2__"); |
| 2531 | // Fallthrough |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2532 | case CK_K6_3: |
Chandler Carruth | f17ba33 | 2011-09-28 09:45:05 +0000 | [diff] [blame] | 2533 | if (CPU != CK_K6_2) { // In case of fallthrough |
| 2534 | // FIXME: GCC may be enabling these in cases where some other k6 |
| 2535 | // architecture is specified but -m3dnow is explicitly provided. The |
| 2536 | // exact semantics need to be determined and emulated here. |
Chandler Carruth | f6cf1c2 | 2011-09-28 02:59:25 +0000 | [diff] [blame] | 2537 | Builder.defineMacro("__k6_3__"); |
| 2538 | Builder.defineMacro("__tune_k6_3__"); |
| 2539 | } |
Chandler Carruth | f17ba33 | 2011-09-28 09:45:05 +0000 | [diff] [blame] | 2540 | // Fallthrough |
| 2541 | case CK_K6: |
Benjamin Kramer | 448f68d | 2012-01-10 11:50:09 +0000 | [diff] [blame] | 2542 | defineCPUMacros(Builder, "k6"); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2543 | break; |
| 2544 | case CK_Athlon: |
| 2545 | case CK_AthlonThunderbird: |
| 2546 | case CK_Athlon4: |
| 2547 | case CK_AthlonXP: |
| 2548 | case CK_AthlonMP: |
Benjamin Kramer | 448f68d | 2012-01-10 11:50:09 +0000 | [diff] [blame] | 2549 | defineCPUMacros(Builder, "athlon"); |
Chandler Carruth | 53bf4f9 | 2011-09-28 09:54:11 +0000 | [diff] [blame] | 2550 | if (SSELevel != NoSSE) { |
Chandler Carruth | f6cf1c2 | 2011-09-28 02:59:25 +0000 | [diff] [blame] | 2551 | Builder.defineMacro("__athlon_sse__"); |
Chandler Carruth | 53bf4f9 | 2011-09-28 09:54:11 +0000 | [diff] [blame] | 2552 | Builder.defineMacro("__tune_athlon_sse__"); |
| 2553 | } |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2554 | break; |
| 2555 | case CK_K8: |
| 2556 | case CK_K8SSE3: |
| 2557 | case CK_x86_64: |
| 2558 | case CK_Opteron: |
| 2559 | case CK_OpteronSSE3: |
| 2560 | case CK_Athlon64: |
| 2561 | case CK_Athlon64SSE3: |
| 2562 | case CK_AthlonFX: |
Benjamin Kramer | 448f68d | 2012-01-10 11:50:09 +0000 | [diff] [blame] | 2563 | defineCPUMacros(Builder, "k8"); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2564 | break; |
Roman Divacky | 01c770d | 2011-10-30 07:48:46 +0000 | [diff] [blame] | 2565 | case CK_AMDFAM10: |
Benjamin Kramer | 448f68d | 2012-01-10 11:50:09 +0000 | [diff] [blame] | 2566 | defineCPUMacros(Builder, "amdfam10"); |
Roman Divacky | 01c770d | 2011-10-30 07:48:46 +0000 | [diff] [blame] | 2567 | break; |
Benjamin Kramer | 5660aa6 | 2012-01-10 11:50:18 +0000 | [diff] [blame] | 2568 | case CK_BTVER1: |
| 2569 | defineCPUMacros(Builder, "btver1"); |
| 2570 | break; |
Benjamin Kramer | 63063f5 | 2013-05-03 10:47:15 +0000 | [diff] [blame] | 2571 | case CK_BTVER2: |
| 2572 | defineCPUMacros(Builder, "btver2"); |
| 2573 | break; |
Benjamin Kramer | 61ea4fe | 2011-12-01 18:23:59 +0000 | [diff] [blame] | 2574 | case CK_BDVER1: |
Benjamin Kramer | 448f68d | 2012-01-10 11:50:09 +0000 | [diff] [blame] | 2575 | defineCPUMacros(Builder, "bdver1"); |
Benjamin Kramer | 61ea4fe | 2011-12-01 18:23:59 +0000 | [diff] [blame] | 2576 | break; |
| 2577 | case CK_BDVER2: |
Benjamin Kramer | 448f68d | 2012-01-10 11:50:09 +0000 | [diff] [blame] | 2578 | defineCPUMacros(Builder, "bdver2"); |
Benjamin Kramer | 61ea4fe | 2011-12-01 18:23:59 +0000 | [diff] [blame] | 2579 | break; |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2580 | case CK_Geode: |
Benjamin Kramer | 448f68d | 2012-01-10 11:50:09 +0000 | [diff] [blame] | 2581 | defineCPUMacros(Builder, "geode"); |
Chandler Carruth | d9d3ddf | 2011-09-28 08:55:37 +0000 | [diff] [blame] | 2582 | break; |
Chandler Carruth | f6cf1c2 | 2011-09-28 02:59:25 +0000 | [diff] [blame] | 2583 | } |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 2584 | |
Chandler Carruth | 88c75b0 | 2011-09-28 09:54:07 +0000 | [diff] [blame] | 2585 | // Target properties. |
| 2586 | Builder.defineMacro("__LITTLE_ENDIAN__"); |
| 2587 | Builder.defineMacro("__REGISTER_PREFIX__", ""); |
| 2588 | |
Chris Lattner | 5417544 | 2009-04-19 17:32:33 +0000 | [diff] [blame] | 2589 | // Define __NO_MATH_INLINES on linux/x86 so that we don't get inline |
| 2590 | // functions in glibc header files that use FP Stack inline asm which the |
| 2591 | // backend can't deal with (PR879). |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 2592 | Builder.defineMacro("__NO_MATH_INLINES"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 2593 | |
Chandler Carruth | 88c75b0 | 2011-09-28 09:54:07 +0000 | [diff] [blame] | 2594 | if (HasAES) |
| 2595 | Builder.defineMacro("__AES__"); |
| 2596 | |
Craig Topper | 3c0bc15 | 2012-05-31 05:18:48 +0000 | [diff] [blame] | 2597 | if (HasPCLMUL) |
| 2598 | Builder.defineMacro("__PCLMUL__"); |
| 2599 | |
Craig Topper | 31ceea0 | 2011-12-25 05:06:45 +0000 | [diff] [blame] | 2600 | if (HasLZCNT) |
| 2601 | Builder.defineMacro("__LZCNT__"); |
| 2602 | |
Benjamin Kramer | 84f3080 | 2012-07-07 09:39:18 +0000 | [diff] [blame] | 2603 | if (HasRDRND) |
| 2604 | Builder.defineMacro("__RDRND__"); |
| 2605 | |
Craig Topper | 31ceea0 | 2011-12-25 05:06:45 +0000 | [diff] [blame] | 2606 | if (HasBMI) |
| 2607 | Builder.defineMacro("__BMI__"); |
| 2608 | |
| 2609 | if (HasBMI2) |
| 2610 | Builder.defineMacro("__BMI2__"); |
| 2611 | |
Craig Topper | e14e08b | 2011-12-29 16:10:46 +0000 | [diff] [blame] | 2612 | if (HasPOPCNT) |
| 2613 | Builder.defineMacro("__POPCNT__"); |
| 2614 | |
Michael Liao | 463eb89 | 2012-11-10 05:17:46 +0000 | [diff] [blame] | 2615 | if (HasRTM) |
| 2616 | Builder.defineMacro("__RTM__"); |
| 2617 | |
Michael Liao | 72339a0 | 2013-03-26 17:52:08 +0000 | [diff] [blame] | 2618 | if (HasPRFCHW) |
| 2619 | Builder.defineMacro("__PRFCHW__"); |
| 2620 | |
Michael Liao | 1bfc28c | 2013-03-29 05:17:55 +0000 | [diff] [blame] | 2621 | if (HasRDSEED) |
| 2622 | Builder.defineMacro("__RDSEED__"); |
| 2623 | |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2624 | switch (XOPLevel) { |
| 2625 | case XOP: |
| 2626 | Builder.defineMacro("__XOP__"); |
| 2627 | case FMA4: |
Craig Topper | 6a511e1 | 2011-12-30 07:33:42 +0000 | [diff] [blame] | 2628 | Builder.defineMacro("__FMA4__"); |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2629 | case SSE4A: |
| 2630 | Builder.defineMacro("__SSE4A__"); |
| 2631 | case NoXOP: |
| 2632 | break; |
| 2633 | } |
Craig Topper | 6a511e1 | 2011-12-30 07:33:42 +0000 | [diff] [blame] | 2634 | |
Craig Topper | 2ae9507 | 2012-06-03 21:46:30 +0000 | [diff] [blame] | 2635 | if (HasFMA) |
| 2636 | Builder.defineMacro("__FMA__"); |
| 2637 | |
Manman Ren | 146e5a4 | 2012-10-11 00:59:55 +0000 | [diff] [blame] | 2638 | if (HasF16C) |
| 2639 | Builder.defineMacro("__F16C__"); |
| 2640 | |
Craig Topper | bca2c4f | 2013-08-21 05:29:10 +0000 | [diff] [blame] | 2641 | if (HasAVX512CD) |
| 2642 | Builder.defineMacro("__AVX512CD__"); |
| 2643 | if (HasAVX512ER) |
| 2644 | Builder.defineMacro("__AVX512ER__"); |
| 2645 | if (HasAVX512PF) |
| 2646 | Builder.defineMacro("__AVX512PF__"); |
| 2647 | |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 2648 | // Each case falls through to the previous one here. |
| 2649 | switch (SSELevel) { |
Craig Topper | b7a95d2 | 2013-08-21 03:59:22 +0000 | [diff] [blame] | 2650 | case AVX512F: |
Craig Topper | 42f9873 | 2013-08-20 07:39:54 +0000 | [diff] [blame] | 2651 | Builder.defineMacro("__AVX512F__"); |
Craig Topper | 05fe4b5 | 2012-01-09 09:19:09 +0000 | [diff] [blame] | 2652 | case AVX2: |
| 2653 | Builder.defineMacro("__AVX2__"); |
| 2654 | case AVX: |
| 2655 | Builder.defineMacro("__AVX__"); |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 2656 | case SSE42: |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 2657 | Builder.defineMacro("__SSE4_2__"); |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 2658 | case SSE41: |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 2659 | Builder.defineMacro("__SSE4_1__"); |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 2660 | case SSSE3: |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 2661 | Builder.defineMacro("__SSSE3__"); |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 2662 | case SSE3: |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 2663 | Builder.defineMacro("__SSE3__"); |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 2664 | case SSE2: |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 2665 | Builder.defineMacro("__SSE2__"); |
| 2666 | Builder.defineMacro("__SSE2_MATH__"); // -mfp-math=sse always implied. |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 2667 | case SSE1: |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 2668 | Builder.defineMacro("__SSE__"); |
| 2669 | Builder.defineMacro("__SSE_MATH__"); // -mfp-math=sse always implied. |
Eli Friedman | c3e0fb4 | 2011-07-08 23:31:17 +0000 | [diff] [blame] | 2670 | case NoSSE: |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 2671 | break; |
| 2672 | } |
Michael J. Spencer | 237cf58 | 2010-10-18 07:10:59 +0000 | [diff] [blame] | 2673 | |
Derek Schuff | babaf31 | 2012-10-11 15:52:22 +0000 | [diff] [blame] | 2674 | if (Opts.MicrosoftExt && getTriple().getArch() == llvm::Triple::x86) { |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 2675 | switch (SSELevel) { |
Craig Topper | b7a95d2 | 2013-08-21 03:59:22 +0000 | [diff] [blame] | 2676 | case AVX512F: |
Craig Topper | 05fe4b5 | 2012-01-09 09:19:09 +0000 | [diff] [blame] | 2677 | case AVX2: |
| 2678 | case AVX: |
Michael J. Spencer | a764e83 | 2010-10-21 08:22:51 +0000 | [diff] [blame] | 2679 | case SSE42: |
| 2680 | case SSE41: |
| 2681 | case SSSE3: |
| 2682 | case SSE3: |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 2683 | case SSE2: |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 2684 | Builder.defineMacro("_M_IX86_FP", Twine(2)); |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 2685 | break; |
| 2686 | case SSE1: |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 2687 | Builder.defineMacro("_M_IX86_FP", Twine(1)); |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 2688 | break; |
| 2689 | default: |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 2690 | Builder.defineMacro("_M_IX86_FP", Twine(0)); |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 2691 | } |
| 2692 | } |
| 2693 | |
Anders Carlsson | 9b0fb62 | 2010-01-27 03:47:49 +0000 | [diff] [blame] | 2694 | // Each case falls through to the previous one here. |
Eli Friedman | c3e0fb4 | 2011-07-08 23:31:17 +0000 | [diff] [blame] | 2695 | switch (MMX3DNowLevel) { |
Anders Carlsson | 9b0fb62 | 2010-01-27 03:47:49 +0000 | [diff] [blame] | 2696 | case AMD3DNowAthlon: |
| 2697 | Builder.defineMacro("__3dNOW_A__"); |
| 2698 | case AMD3DNow: |
| 2699 | Builder.defineMacro("__3dNOW__"); |
Eli Friedman | c3e0fb4 | 2011-07-08 23:31:17 +0000 | [diff] [blame] | 2700 | case MMX: |
| 2701 | Builder.defineMacro("__MMX__"); |
| 2702 | case NoMMX3DNow: |
Anders Carlsson | 9b0fb62 | 2010-01-27 03:47:49 +0000 | [diff] [blame] | 2703 | break; |
| 2704 | } |
Michael J. Spencer | d1b3394 | 2013-04-04 23:53:43 +0000 | [diff] [blame] | 2705 | |
| 2706 | if (CPU >= CK_i486) { |
| 2707 | Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1"); |
| 2708 | Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2"); |
| 2709 | Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4"); |
| 2710 | } |
| 2711 | if (CPU >= CK_i586) |
| 2712 | Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8"); |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 2713 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 2714 | |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 2715 | bool X86TargetInfo::hasFeature(StringRef Feature) const { |
| 2716 | return llvm::StringSwitch<bool>(Feature) |
| 2717 | .Case("aes", HasAES) |
| 2718 | .Case("avx", SSELevel >= AVX) |
| 2719 | .Case("avx2", SSELevel >= AVX2) |
Craig Topper | b7a95d2 | 2013-08-21 03:59:22 +0000 | [diff] [blame] | 2720 | .Case("avx512f", SSELevel >= AVX512F) |
Craig Topper | bca2c4f | 2013-08-21 05:29:10 +0000 | [diff] [blame] | 2721 | .Case("avx512cd", HasAVX512CD) |
| 2722 | .Case("avx512er", HasAVX512ER) |
| 2723 | .Case("avx512pf", HasAVX512PF) |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 2724 | .Case("bmi", HasBMI) |
| 2725 | .Case("bmi2", HasBMI2) |
Craig Topper | 2ae9507 | 2012-06-03 21:46:30 +0000 | [diff] [blame] | 2726 | .Case("fma", HasFMA) |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2727 | .Case("fma4", XOPLevel >= FMA4) |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 2728 | .Case("lzcnt", HasLZCNT) |
Benjamin Kramer | 84f3080 | 2012-07-07 09:39:18 +0000 | [diff] [blame] | 2729 | .Case("rdrnd", HasRDRND) |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 2730 | .Case("mm3dnow", MMX3DNowLevel >= AMD3DNow) |
| 2731 | .Case("mm3dnowa", MMX3DNowLevel >= AMD3DNowAthlon) |
| 2732 | .Case("mmx", MMX3DNowLevel >= MMX) |
Craig Topper | 3c0bc15 | 2012-05-31 05:18:48 +0000 | [diff] [blame] | 2733 | .Case("pclmul", HasPCLMUL) |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 2734 | .Case("popcnt", HasPOPCNT) |
Michael Liao | 463eb89 | 2012-11-10 05:17:46 +0000 | [diff] [blame] | 2735 | .Case("rtm", HasRTM) |
Michael Liao | 72339a0 | 2013-03-26 17:52:08 +0000 | [diff] [blame] | 2736 | .Case("prfchw", HasPRFCHW) |
Michael Liao | 1bfc28c | 2013-03-29 05:17:55 +0000 | [diff] [blame] | 2737 | .Case("rdseed", HasRDSEED) |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 2738 | .Case("sse", SSELevel >= SSE1) |
| 2739 | .Case("sse2", SSELevel >= SSE2) |
| 2740 | .Case("sse3", SSELevel >= SSE3) |
| 2741 | .Case("ssse3", SSELevel >= SSSE3) |
Rafael Espindola | 81cde9e | 2013-08-23 20:21:37 +0000 | [diff] [blame] | 2742 | .Case("sse4.1", SSELevel >= SSE41) |
| 2743 | .Case("sse4.2", SSELevel >= SSE42) |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2744 | .Case("sse4a", XOPLevel >= SSE4A) |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 2745 | .Case("x86", true) |
Derek Schuff | babaf31 | 2012-10-11 15:52:22 +0000 | [diff] [blame] | 2746 | .Case("x86_32", getTriple().getArch() == llvm::Triple::x86) |
| 2747 | .Case("x86_64", getTriple().getArch() == llvm::Triple::x86_64) |
Rafael Espindola | f6fe72b | 2013-08-20 13:44:29 +0000 | [diff] [blame] | 2748 | .Case("xop", XOPLevel >= XOP) |
Manman Ren | 146e5a4 | 2012-10-11 00:59:55 +0000 | [diff] [blame] | 2749 | .Case("f16c", HasF16C) |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 2750 | .Default(false); |
| 2751 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 2752 | |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2753 | bool |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 2754 | X86TargetInfo::validateAsmConstraint(const char *&Name, |
Chris Lattner | 44def07 | 2009-04-26 07:16:29 +0000 | [diff] [blame] | 2755 | TargetInfo::ConstraintInfo &Info) const { |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 2756 | switch (*Name) { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2757 | default: return false; |
Dale Johannesen | 545be51 | 2010-08-24 22:33:12 +0000 | [diff] [blame] | 2758 | case 'Y': // first letter of a pair: |
| 2759 | switch (*(Name+1)) { |
| 2760 | default: return false; |
| 2761 | case '0': // First SSE register. |
| 2762 | case 't': // Any SSE register, when SSE2 is enabled. |
| 2763 | case 'i': // Any SSE register, when SSE2 and inter-unit moves enabled. |
| 2764 | case 'm': // any MMX register, when inter-unit moves enabled. |
| 2765 | break; // falls through to setAllowsRegister. |
| 2766 | } |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2767 | case 'a': // eax. |
| 2768 | case 'b': // ebx. |
| 2769 | case 'c': // ecx. |
| 2770 | case 'd': // edx. |
| 2771 | case 'S': // esi. |
| 2772 | case 'D': // edi. |
| 2773 | case 'A': // edx:eax. |
Dale Johannesen | 545be51 | 2010-08-24 22:33:12 +0000 | [diff] [blame] | 2774 | case 'f': // any x87 floating point stack register. |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2775 | case 't': // top of floating point stack. |
| 2776 | case 'u': // second from top of floating point stack. |
| 2777 | case 'q': // Any register accessible as [r]l: a, b, c, and d. |
Anders Carlsson | fce0934 | 2008-10-06 00:41:45 +0000 | [diff] [blame] | 2778 | case 'y': // Any MMX register. |
Anders Carlsson | a7406d4 | 2008-10-06 19:17:39 +0000 | [diff] [blame] | 2779 | case 'x': // Any SSE register. |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2780 | case 'Q': // Any register accessible as [r]h: a, b, c, and d. |
Dale Johannesen | 545be51 | 2010-08-24 22:33:12 +0000 | [diff] [blame] | 2781 | case 'R': // "Legacy" registers: ax, bx, cx, dx, di, si, sp, bp. |
| 2782 | case 'l': // "Index" registers: any general register that can be used as an |
| 2783 | // index in a base+index memory access. |
| 2784 | Info.setAllowsRegister(); |
| 2785 | return true; |
| 2786 | case 'C': // SSE floating point constant. |
| 2787 | case 'G': // x87 floating point constant. |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 2788 | case 'e': // 32-bit signed integer constant for use with zero-extending |
Anders Carlsson | 79bc64c | 2009-01-24 18:03:09 +0000 | [diff] [blame] | 2789 | // x86_64 instructions. |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 2790 | case 'Z': // 32-bit unsigned integer constant for use with zero-extending |
Anders Carlsson | 79bc64c | 2009-01-24 18:03:09 +0000 | [diff] [blame] | 2791 | // x86_64 instructions. |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2792 | return true; |
| 2793 | } |
| 2794 | } |
| 2795 | |
Dale Johannesen | f6e2c20 | 2010-10-29 23:12:32 +0000 | [diff] [blame] | 2796 | |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2797 | std::string |
Stuart Hastings | 002333f | 2011-06-07 23:45:05 +0000 | [diff] [blame] | 2798 | X86TargetInfo::convertConstraint(const char *&Constraint) const { |
| 2799 | switch (*Constraint) { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2800 | case 'a': return std::string("{ax}"); |
| 2801 | case 'b': return std::string("{bx}"); |
| 2802 | case 'c': return std::string("{cx}"); |
| 2803 | case 'd': return std::string("{dx}"); |
| 2804 | case 'S': return std::string("{si}"); |
| 2805 | case 'D': return std::string("{di}"); |
Dale Johannesen | cee5501 | 2010-10-22 21:07:10 +0000 | [diff] [blame] | 2806 | case 'p': // address |
| 2807 | return std::string("im"); |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2808 | case 't': // top of floating point stack. |
| 2809 | return std::string("{st}"); |
| 2810 | case 'u': // second from top of floating point stack. |
| 2811 | return std::string("{st(1)}"); // second from top of floating point stack. |
| 2812 | default: |
Stuart Hastings | 002333f | 2011-06-07 23:45:05 +0000 | [diff] [blame] | 2813 | return std::string(1, *Constraint); |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2814 | } |
| 2815 | } |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2816 | } // end anonymous namespace |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2817 | |
| 2818 | namespace { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2819 | // X86-32 generic target |
| 2820 | class X86_32TargetInfo : public X86TargetInfo { |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2821 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 2822 | X86_32TargetInfo(const llvm::Triple &Triple) : X86TargetInfo(Triple) { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2823 | DoubleAlign = LongLongAlign = 32; |
| 2824 | LongDoubleWidth = 96; |
| 2825 | LongDoubleAlign = 32; |
Nick Lewycky | 9bddf43 | 2011-12-21 04:25:47 +0000 | [diff] [blame] | 2826 | SuitableAlign = 128; |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 2827 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 2828 | "i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-" |
Lang Hames | 567c600 | 2011-10-11 00:52:51 +0000 | [diff] [blame] | 2829 | "a0:0:64-f80:32:32-n8:16:32-S128"; |
Eli Friedman | 1afabd9 | 2009-03-29 20:31:09 +0000 | [diff] [blame] | 2830 | SizeType = UnsignedInt; |
| 2831 | PtrDiffType = SignedInt; |
| 2832 | IntPtrType = SignedInt; |
Anton Korobeynikov | 264a76c | 2009-04-03 23:38:25 +0000 | [diff] [blame] | 2833 | RegParmMax = 3; |
Daniel Dunbar | dacf9dd | 2010-07-14 23:39:36 +0000 | [diff] [blame] | 2834 | |
| 2835 | // Use fpret for all types. |
| 2836 | RealTypeUsesObjCFPRet = ((1 << TargetInfo::Float) | |
| 2837 | (1 << TargetInfo::Double) | |
| 2838 | (1 << TargetInfo::LongDouble)); |
Eli Friedman | 2be4607 | 2011-10-14 20:59:01 +0000 | [diff] [blame] | 2839 | |
| 2840 | // x86-32 has atomics up to 8 bytes |
| 2841 | // FIXME: Check that we actually have cmpxchg8b before setting |
| 2842 | // MaxAtomicInlineWidth. (cmpxchg8b is an i586 instruction.) |
| 2843 | MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2844 | } |
Meador Inge | c5613b2 | 2012-06-16 03:34:49 +0000 | [diff] [blame] | 2845 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
| 2846 | return TargetInfo::CharPtrBuiltinVaList; |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2847 | } |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 2848 | |
Chris Lattner | 21fb98e | 2009-09-23 06:06:36 +0000 | [diff] [blame] | 2849 | int getEHDataRegisterNumber(unsigned RegNo) const { |
| 2850 | if (RegNo == 0) return 0; |
| 2851 | if (RegNo == 1) return 2; |
| 2852 | return -1; |
| 2853 | } |
Bill Wendling | 68fd608 | 2012-11-12 06:42:51 +0000 | [diff] [blame] | 2854 | virtual bool validateInputSize(StringRef Constraint, |
| 2855 | unsigned Size) const { |
| 2856 | switch (Constraint[0]) { |
| 2857 | default: break; |
| 2858 | case 'a': |
| 2859 | case 'b': |
| 2860 | case 'c': |
| 2861 | case 'd': |
Bill Wendling | f634bdf | 2012-11-12 18:52:32 +0000 | [diff] [blame] | 2862 | return Size <= 32; |
Bill Wendling | 68fd608 | 2012-11-12 06:42:51 +0000 | [diff] [blame] | 2863 | } |
| 2864 | |
| 2865 | return true; |
| 2866 | } |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2867 | }; |
| 2868 | } // end anonymous namespace |
| 2869 | |
| 2870 | namespace { |
Joerg Sonnenberger | 42378be | 2012-01-06 18:32:26 +0000 | [diff] [blame] | 2871 | class NetBSDI386TargetInfo : public NetBSDTargetInfo<X86_32TargetInfo> { |
| 2872 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 2873 | NetBSDI386TargetInfo(const llvm::Triple &Triple) |
| 2874 | : NetBSDTargetInfo<X86_32TargetInfo>(Triple) {} |
Joerg Sonnenberger | 42378be | 2012-01-06 18:32:26 +0000 | [diff] [blame] | 2875 | |
| 2876 | virtual unsigned getFloatEvalMethod() const { |
| 2877 | // NetBSD defaults to "double" rounding |
| 2878 | return 1; |
| 2879 | } |
| 2880 | }; |
| 2881 | } // end anonymous namespace |
| 2882 | |
| 2883 | namespace { |
Eli Friedman | 624c146 | 2009-07-05 18:47:56 +0000 | [diff] [blame] | 2884 | class OpenBSDI386TargetInfo : public OpenBSDTargetInfo<X86_32TargetInfo> { |
| 2885 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 2886 | OpenBSDI386TargetInfo(const llvm::Triple &Triple) |
| 2887 | : OpenBSDTargetInfo<X86_32TargetInfo>(Triple) { |
Eli Friedman | 624c146 | 2009-07-05 18:47:56 +0000 | [diff] [blame] | 2888 | SizeType = UnsignedLong; |
| 2889 | IntPtrType = SignedLong; |
Eli Friedman | 6036ebe | 2009-07-05 22:31:18 +0000 | [diff] [blame] | 2890 | PtrDiffType = SignedLong; |
Eli Friedman | 624c146 | 2009-07-05 18:47:56 +0000 | [diff] [blame] | 2891 | } |
| 2892 | }; |
| 2893 | } // end anonymous namespace |
| 2894 | |
| 2895 | namespace { |
Eli Friedman | 42f74f2 | 2012-08-08 23:57:20 +0000 | [diff] [blame] | 2896 | class BitrigI386TargetInfo : public BitrigTargetInfo<X86_32TargetInfo> { |
| 2897 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 2898 | BitrigI386TargetInfo(const llvm::Triple &Triple) |
| 2899 | : BitrigTargetInfo<X86_32TargetInfo>(Triple) { |
Eli Friedman | 42f74f2 | 2012-08-08 23:57:20 +0000 | [diff] [blame] | 2900 | SizeType = UnsignedLong; |
| 2901 | IntPtrType = SignedLong; |
| 2902 | PtrDiffType = SignedLong; |
| 2903 | } |
| 2904 | }; |
| 2905 | } // end anonymous namespace |
| 2906 | |
| 2907 | namespace { |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 2908 | class DarwinI386TargetInfo : public DarwinTargetInfo<X86_32TargetInfo> { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2909 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 2910 | DarwinI386TargetInfo(const llvm::Triple &Triple) |
| 2911 | : DarwinTargetInfo<X86_32TargetInfo>(Triple) { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2912 | LongDoubleWidth = 128; |
| 2913 | LongDoubleAlign = 128; |
Nick Lewycky | 7ec59c7 | 2011-12-16 22:34:14 +0000 | [diff] [blame] | 2914 | SuitableAlign = 128; |
Chad Rosier | f9e9af7 | 2012-07-13 23:57:43 +0000 | [diff] [blame] | 2915 | MaxVectorAlign = 256; |
Eli Friedman | 1afabd9 | 2009-03-29 20:31:09 +0000 | [diff] [blame] | 2916 | SizeType = UnsignedLong; |
| 2917 | IntPtrType = SignedLong; |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 2918 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 2919 | "i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-" |
Lang Hames | f4f5003 | 2011-10-10 23:44:43 +0000 | [diff] [blame] | 2920 | "a0:0:64-f80:128:128-n8:16:32-S128"; |
Daniel Dunbar | 613fd67 | 2010-05-27 00:35:16 +0000 | [diff] [blame] | 2921 | HasAlignMac68kSupport = true; |
Torok Edwin | b0a5b24 | 2009-06-30 17:00:25 +0000 | [diff] [blame] | 2922 | } |
| 2923 | |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 2924 | }; |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 2925 | } // end anonymous namespace |
| 2926 | |
| 2927 | namespace { |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 2928 | // x86-32 Windows target |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 2929 | class WindowsX86_32TargetInfo : public WindowsTargetInfo<X86_32TargetInfo> { |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 2930 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 2931 | WindowsX86_32TargetInfo(const llvm::Triple &Triple) |
| 2932 | : WindowsTargetInfo<X86_32TargetInfo>(Triple) { |
Eli Friedman | b030f02 | 2009-04-19 21:38:35 +0000 | [diff] [blame] | 2933 | TLSSupported = false; |
Chris Lattner | 85de9e7 | 2009-06-24 17:12:15 +0000 | [diff] [blame] | 2934 | WCharType = UnsignedShort; |
Eli Friedman | 9c2f84e | 2009-06-08 21:16:17 +0000 | [diff] [blame] | 2935 | DoubleAlign = LongLongAlign = 64; |
| 2936 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
Anton Korobeynikov | b381441 | 2009-12-19 02:05:07 +0000 | [diff] [blame] | 2937 | "i64:64:64-f32:32:32-f64:64:64-f80:128:128-v64:64:64-" |
Lang Hames | f4f5003 | 2011-10-10 23:44:43 +0000 | [diff] [blame] | 2938 | "v128:128:128-a0:0:64-f80:32:32-n8:16:32-S32"; |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 2939 | } |
Michael J. Spencer | a764e83 | 2010-10-21 08:22:51 +0000 | [diff] [blame] | 2940 | virtual void getTargetDefines(const LangOptions &Opts, |
| 2941 | MacroBuilder &Builder) const { |
| 2942 | WindowsTargetInfo<X86_32TargetInfo>::getTargetDefines(Opts, Builder); |
| 2943 | } |
| 2944 | }; |
| 2945 | } // end anonymous namespace |
| 2946 | |
| 2947 | namespace { |
| 2948 | |
| 2949 | // x86-32 Windows Visual Studio target |
| 2950 | class VisualStudioWindowsX86_32TargetInfo : public WindowsX86_32TargetInfo { |
| 2951 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 2952 | VisualStudioWindowsX86_32TargetInfo(const llvm::Triple &Triple) |
| 2953 | : WindowsX86_32TargetInfo(Triple) { |
Eli Friedman | d9c3fa3 | 2011-03-22 21:25:11 +0000 | [diff] [blame] | 2954 | LongDoubleWidth = LongDoubleAlign = 64; |
Michael J. Spencer | a764e83 | 2010-10-21 08:22:51 +0000 | [diff] [blame] | 2955 | LongDoubleFormat = &llvm::APFloat::IEEEdouble; |
| 2956 | } |
| 2957 | virtual void getTargetDefines(const LangOptions &Opts, |
| 2958 | MacroBuilder &Builder) const { |
| 2959 | WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder); |
| 2960 | WindowsX86_32TargetInfo::getVisualStudioDefines(Opts, Builder); |
| 2961 | // The value of the following reflects processor type. |
| 2962 | // 300=386, 400=486, 500=Pentium, 600=Blend (default) |
| 2963 | // We lost the original triple, so we use the default. |
| 2964 | Builder.defineMacro("_M_IX86", "600"); |
| 2965 | } |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 2966 | }; |
| 2967 | } // end anonymous namespace |
| 2968 | |
| 2969 | namespace { |
| 2970 | // x86-32 MinGW target |
| 2971 | class MinGWX86_32TargetInfo : public WindowsX86_32TargetInfo { |
| 2972 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 2973 | MinGWX86_32TargetInfo(const llvm::Triple &Triple) |
| 2974 | : WindowsX86_32TargetInfo(Triple) {} |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 2975 | virtual void getTargetDefines(const LangOptions &Opts, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 2976 | MacroBuilder &Builder) const { |
| 2977 | WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder); |
Michael J. Spencer | a764e83 | 2010-10-21 08:22:51 +0000 | [diff] [blame] | 2978 | DefineStd(Builder, "WIN32", Opts); |
| 2979 | DefineStd(Builder, "WINNT", Opts); |
| 2980 | Builder.defineMacro("_X86_"); |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 2981 | Builder.defineMacro("__MSVCRT__"); |
| 2982 | Builder.defineMacro("__MINGW32__"); |
NAKAMURA Takumi | 853134a | 2011-03-15 02:32:50 +0000 | [diff] [blame] | 2983 | |
| 2984 | // mingw32-gcc provides __declspec(a) as alias of __attribute__((a)). |
| 2985 | // In contrast, clang-cc1 provides __declspec(a) with -fms-extensions. |
Francois Pichet | 62ec1f2 | 2011-09-17 17:15:52 +0000 | [diff] [blame] | 2986 | if (Opts.MicrosoftExt) |
NAKAMURA Takumi | 853134a | 2011-03-15 02:32:50 +0000 | [diff] [blame] | 2987 | // Provide "as-is" __declspec. |
| 2988 | Builder.defineMacro("__declspec", "__declspec"); |
| 2989 | else |
| 2990 | // Provide alias of __attribute__ like mingw32-gcc. |
| 2991 | Builder.defineMacro("__declspec(a)", "__attribute__((a))"); |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 2992 | } |
| 2993 | }; |
| 2994 | } // end anonymous namespace |
| 2995 | |
| 2996 | namespace { |
| 2997 | // x86-32 Cygwin target |
| 2998 | class CygwinX86_32TargetInfo : public X86_32TargetInfo { |
| 2999 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 3000 | CygwinX86_32TargetInfo(const llvm::Triple &Triple) |
| 3001 | : X86_32TargetInfo(Triple) { |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 3002 | TLSSupported = false; |
| 3003 | WCharType = UnsignedShort; |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 3004 | DoubleAlign = LongLongAlign = 64; |
| 3005 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 3006 | "i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-" |
Lang Hames | f4f5003 | 2011-10-10 23:44:43 +0000 | [diff] [blame] | 3007 | "a0:0:64-f80:32:32-n8:16:32-S32"; |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 3008 | } |
| 3009 | virtual void getTargetDefines(const LangOptions &Opts, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3010 | MacroBuilder &Builder) const { |
| 3011 | X86_32TargetInfo::getTargetDefines(Opts, Builder); |
NAKAMURA Takumi | e72f4d9 | 2012-12-14 10:17:26 +0000 | [diff] [blame] | 3012 | Builder.defineMacro("_X86_"); |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3013 | Builder.defineMacro("__CYGWIN__"); |
| 3014 | Builder.defineMacro("__CYGWIN32__"); |
| 3015 | DefineStd(Builder, "unix", Opts); |
Douglas Gregor | 2b003fd | 2010-04-21 05:52:38 +0000 | [diff] [blame] | 3016 | if (Opts.CPlusPlus) |
| 3017 | Builder.defineMacro("_GNU_SOURCE"); |
Eli Friedman | abc4e32 | 2009-06-08 06:11:14 +0000 | [diff] [blame] | 3018 | } |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 3019 | }; |
| 3020 | } // end anonymous namespace |
| 3021 | |
| 3022 | namespace { |
Chris Lattner | 86ed3a3 | 2010-04-11 19:29:39 +0000 | [diff] [blame] | 3023 | // x86-32 Haiku target |
| 3024 | class HaikuX86_32TargetInfo : public X86_32TargetInfo { |
| 3025 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 3026 | HaikuX86_32TargetInfo(const llvm::Triple &Triple) : X86_32TargetInfo(Triple) { |
Chris Lattner | 86ed3a3 | 2010-04-11 19:29:39 +0000 | [diff] [blame] | 3027 | SizeType = UnsignedLong; |
Chris Lattner | fe1ea7b | 2010-04-22 17:48:00 +0000 | [diff] [blame] | 3028 | IntPtrType = SignedLong; |
| 3029 | PtrDiffType = SignedLong; |
Eli Friedman | 6902e41 | 2012-11-27 02:58:24 +0000 | [diff] [blame] | 3030 | ProcessIDType = SignedLong; |
Rafael Espindola | 19ddda8 | 2010-11-09 16:41:02 +0000 | [diff] [blame] | 3031 | this->UserLabelPrefix = ""; |
Benjamin Kramer | ef7bcea | 2012-11-08 12:59:15 +0000 | [diff] [blame] | 3032 | this->TLSSupported = false; |
Eli Friedman | a7e6845 | 2010-08-22 01:00:03 +0000 | [diff] [blame] | 3033 | } |
Chris Lattner | 86ed3a3 | 2010-04-11 19:29:39 +0000 | [diff] [blame] | 3034 | virtual void getTargetDefines(const LangOptions &Opts, |
| 3035 | MacroBuilder &Builder) const { |
| 3036 | X86_32TargetInfo::getTargetDefines(Opts, Builder); |
| 3037 | Builder.defineMacro("__INTEL__"); |
| 3038 | Builder.defineMacro("__HAIKU__"); |
| 3039 | } |
| 3040 | }; |
| 3041 | } // end anonymous namespace |
| 3042 | |
Douglas Gregor | dca5226 | 2011-07-01 22:41:14 +0000 | [diff] [blame] | 3043 | // RTEMS Target |
| 3044 | template<typename Target> |
| 3045 | class RTEMSTargetInfo : public OSTargetInfo<Target> { |
| 3046 | protected: |
| 3047 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
| 3048 | MacroBuilder &Builder) const { |
| 3049 | // RTEMS defines; list based off of gcc output |
| 3050 | |
Douglas Gregor | dca5226 | 2011-07-01 22:41:14 +0000 | [diff] [blame] | 3051 | Builder.defineMacro("__rtems__"); |
| 3052 | Builder.defineMacro("__ELF__"); |
| 3053 | } |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 3054 | |
Douglas Gregor | dca5226 | 2011-07-01 22:41:14 +0000 | [diff] [blame] | 3055 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 3056 | RTEMSTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) { |
| 3057 | this->UserLabelPrefix = ""; |
Douglas Gregor | dca5226 | 2011-07-01 22:41:14 +0000 | [diff] [blame] | 3058 | |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 3059 | switch (Triple.getArch()) { |
| 3060 | default: |
| 3061 | case llvm::Triple::x86: |
| 3062 | // this->MCountName = ".mcount"; |
| 3063 | break; |
| 3064 | case llvm::Triple::mips: |
| 3065 | case llvm::Triple::mipsel: |
| 3066 | case llvm::Triple::ppc: |
| 3067 | case llvm::Triple::ppc64: |
Bill Schmidt | ea7fb0c | 2013-07-26 01:36:11 +0000 | [diff] [blame] | 3068 | case llvm::Triple::ppc64le: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 3069 | // this->MCountName = "_mcount"; |
| 3070 | break; |
| 3071 | case llvm::Triple::arm: |
| 3072 | // this->MCountName = "__mcount"; |
| 3073 | break; |
Douglas Gregor | dca5226 | 2011-07-01 22:41:14 +0000 | [diff] [blame] | 3074 | } |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 3075 | } |
Douglas Gregor | dca5226 | 2011-07-01 22:41:14 +0000 | [diff] [blame] | 3076 | }; |
| 3077 | |
| 3078 | namespace { |
| 3079 | // x86-32 RTEMS target |
| 3080 | class RTEMSX86_32TargetInfo : public X86_32TargetInfo { |
| 3081 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 3082 | RTEMSX86_32TargetInfo(const llvm::Triple &Triple) : X86_32TargetInfo(Triple) { |
Douglas Gregor | dca5226 | 2011-07-01 22:41:14 +0000 | [diff] [blame] | 3083 | SizeType = UnsignedLong; |
| 3084 | IntPtrType = SignedLong; |
| 3085 | PtrDiffType = SignedLong; |
| 3086 | this->UserLabelPrefix = ""; |
| 3087 | } |
| 3088 | virtual void getTargetDefines(const LangOptions &Opts, |
| 3089 | MacroBuilder &Builder) const { |
| 3090 | X86_32TargetInfo::getTargetDefines(Opts, Builder); |
| 3091 | Builder.defineMacro("__INTEL__"); |
| 3092 | Builder.defineMacro("__rtems__"); |
| 3093 | } |
| 3094 | }; |
| 3095 | } // end anonymous namespace |
| 3096 | |
Chris Lattner | 86ed3a3 | 2010-04-11 19:29:39 +0000 | [diff] [blame] | 3097 | namespace { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 3098 | // x86-64 generic target |
| 3099 | class X86_64TargetInfo : public X86TargetInfo { |
| 3100 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 3101 | X86_64TargetInfo(const llvm::Triple &Triple) : X86TargetInfo(Triple) { |
Chris Lattner | f291b10 | 2008-05-09 06:17:04 +0000 | [diff] [blame] | 3102 | LongWidth = LongAlign = PointerWidth = PointerAlign = 64; |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 3103 | LongDoubleWidth = 128; |
| 3104 | LongDoubleAlign = 128; |
Rafael Espindola | 6deecb0 | 2010-06-04 23:15:27 +0000 | [diff] [blame] | 3105 | LargeArrayMinWidth = 128; |
| 3106 | LargeArrayAlign = 128; |
Nick Lewycky | 7ec59c7 | 2011-12-16 22:34:14 +0000 | [diff] [blame] | 3107 | SuitableAlign = 128; |
Chris Lattner | 06ebe86 | 2009-02-05 07:32:46 +0000 | [diff] [blame] | 3108 | IntMaxType = SignedLong; |
| 3109 | UIntMaxType = UnsignedLong; |
Eli Friedman | 3c7b6e4 | 2009-07-01 03:36:11 +0000 | [diff] [blame] | 3110 | Int64Type = SignedLong; |
Anton Korobeynikov | 264a76c | 2009-04-03 23:38:25 +0000 | [diff] [blame] | 3111 | RegParmMax = 6; |
Chris Lattner | 06ebe86 | 2009-02-05 07:32:46 +0000 | [diff] [blame] | 3112 | |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 3113 | DescriptionString = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 3114 | "i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-" |
Lang Hames | f4f5003 | 2011-10-10 23:44:43 +0000 | [diff] [blame] | 3115 | "a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"; |
Daniel Dunbar | dacf9dd | 2010-07-14 23:39:36 +0000 | [diff] [blame] | 3116 | |
| 3117 | // Use fpret only for long double. |
| 3118 | RealTypeUsesObjCFPRet = (1 << TargetInfo::LongDouble); |
Eli Friedman | 2be4607 | 2011-10-14 20:59:01 +0000 | [diff] [blame] | 3119 | |
Anders Carlsson | eea6480 | 2011-10-31 16:27:11 +0000 | [diff] [blame] | 3120 | // Use fp2ret for _Complex long double. |
| 3121 | ComplexLongDoubleUsesFP2Ret = true; |
| 3122 | |
Eli Friedman | 2be4607 | 2011-10-14 20:59:01 +0000 | [diff] [blame] | 3123 | // x86-64 has atomics up to 16 bytes. |
| 3124 | // FIXME: Once the backend is fixed, increase MaxAtomicInlineWidth to 128 |
| 3125 | // on CPUs with cmpxchg16b |
| 3126 | MaxAtomicPromoteWidth = 128; |
| 3127 | MaxAtomicInlineWidth = 64; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 3128 | } |
Meador Inge | c5613b2 | 2012-06-16 03:34:49 +0000 | [diff] [blame] | 3129 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
| 3130 | return TargetInfo::X86_64ABIBuiltinVaList; |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 3131 | } |
Michael J. Spencer | 237cf58 | 2010-10-18 07:10:59 +0000 | [diff] [blame] | 3132 | |
Chris Lattner | 21fb98e | 2009-09-23 06:06:36 +0000 | [diff] [blame] | 3133 | int getEHDataRegisterNumber(unsigned RegNo) const { |
| 3134 | if (RegNo == 0) return 0; |
| 3135 | if (RegNo == 1) return 1; |
| 3136 | return -1; |
| 3137 | } |
Aaron Ballman | 82bfa19 | 2012-10-02 14:26:08 +0000 | [diff] [blame] | 3138 | |
| 3139 | virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const { |
Charles Davis | e8519c3 | 2013-08-30 04:39:01 +0000 | [diff] [blame] | 3140 | return (CC == CC_C || |
| 3141 | CC == CC_IntelOclBicc || |
| 3142 | CC == CC_X86_64Win64) ? CCCR_OK : CCCR_Warning; |
Aaron Ballman | 82bfa19 | 2012-10-02 14:26:08 +0000 | [diff] [blame] | 3143 | } |
| 3144 | |
Aaron Ballman | fff3248 | 2012-12-09 17:45:41 +0000 | [diff] [blame] | 3145 | virtual CallingConv getDefaultCallingConv(CallingConvMethodType MT) const { |
| 3146 | return CC_C; |
Aaron Ballman | 82bfa19 | 2012-10-02 14:26:08 +0000 | [diff] [blame] | 3147 | } |
| 3148 | |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 3149 | }; |
| 3150 | } // end anonymous namespace |
| 3151 | |
| 3152 | namespace { |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 3153 | // x86-64 Windows target |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 3154 | class WindowsX86_64TargetInfo : public WindowsTargetInfo<X86_64TargetInfo> { |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 3155 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 3156 | WindowsX86_64TargetInfo(const llvm::Triple &Triple) |
| 3157 | : WindowsTargetInfo<X86_64TargetInfo>(Triple) { |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 3158 | TLSSupported = false; |
| 3159 | WCharType = UnsignedShort; |
Mike Stump | a55cce8 | 2009-10-08 23:00:00 +0000 | [diff] [blame] | 3160 | LongWidth = LongAlign = 32; |
Michael J. Spencer | 237cf58 | 2010-10-18 07:10:59 +0000 | [diff] [blame] | 3161 | DoubleAlign = LongLongAlign = 64; |
Nate Begeman | dbf8ea4 | 2010-07-21 02:02:56 +0000 | [diff] [blame] | 3162 | IntMaxType = SignedLongLong; |
| 3163 | UIntMaxType = UnsignedLongLong; |
| 3164 | Int64Type = SignedLongLong; |
Cameron Esfahani | 1484e0d | 2010-09-15 00:28:12 +0000 | [diff] [blame] | 3165 | SizeType = UnsignedLongLong; |
| 3166 | PtrDiffType = SignedLongLong; |
| 3167 | IntPtrType = SignedLongLong; |
NAKAMURA Takumi | 8c959d9 | 2011-01-17 22:56:08 +0000 | [diff] [blame] | 3168 | this->UserLabelPrefix = ""; |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 3169 | } |
| 3170 | virtual void getTargetDefines(const LangOptions &Opts, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3171 | MacroBuilder &Builder) const { |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 3172 | WindowsTargetInfo<X86_64TargetInfo>::getTargetDefines(Opts, Builder); |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 3173 | Builder.defineMacro("_WIN64"); |
Michael J. Spencer | a764e83 | 2010-10-21 08:22:51 +0000 | [diff] [blame] | 3174 | } |
Meador Inge | c5613b2 | 2012-06-16 03:34:49 +0000 | [diff] [blame] | 3175 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
| 3176 | return TargetInfo::CharPtrBuiltinVaList; |
NAKAMURA Takumi | 7952199 | 2011-01-17 22:56:23 +0000 | [diff] [blame] | 3177 | } |
Charles Davis | e8519c3 | 2013-08-30 04:39:01 +0000 | [diff] [blame] | 3178 | virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const { |
| 3179 | return (CC == CC_C || |
| 3180 | CC == CC_IntelOclBicc || |
| 3181 | CC == CC_X86_64SysV) ? CCCR_OK : CCCR_Warning; |
| 3182 | } |
Michael J. Spencer | a764e83 | 2010-10-21 08:22:51 +0000 | [diff] [blame] | 3183 | }; |
| 3184 | } // end anonymous namespace |
| 3185 | |
| 3186 | namespace { |
| 3187 | // x86-64 Windows Visual Studio target |
| 3188 | class VisualStudioWindowsX86_64TargetInfo : public WindowsX86_64TargetInfo { |
| 3189 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 3190 | VisualStudioWindowsX86_64TargetInfo(const llvm::Triple &Triple) |
| 3191 | : WindowsX86_64TargetInfo(Triple) { |
Eli Friedman | d9c3fa3 | 2011-03-22 21:25:11 +0000 | [diff] [blame] | 3192 | LongDoubleWidth = LongDoubleAlign = 64; |
| 3193 | LongDoubleFormat = &llvm::APFloat::IEEEdouble; |
Michael J. Spencer | a764e83 | 2010-10-21 08:22:51 +0000 | [diff] [blame] | 3194 | } |
| 3195 | virtual void getTargetDefines(const LangOptions &Opts, |
| 3196 | MacroBuilder &Builder) const { |
| 3197 | WindowsX86_64TargetInfo::getTargetDefines(Opts, Builder); |
| 3198 | WindowsX86_64TargetInfo::getVisualStudioDefines(Opts, Builder); |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3199 | Builder.defineMacro("_M_X64"); |
Michael J. Spencer | dae4ac4 | 2010-10-21 05:21:48 +0000 | [diff] [blame] | 3200 | Builder.defineMacro("_M_AMD64"); |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 3201 | } |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 3202 | }; |
| 3203 | } // end anonymous namespace |
| 3204 | |
| 3205 | namespace { |
| 3206 | // x86-64 MinGW target |
| 3207 | class MinGWX86_64TargetInfo : public WindowsX86_64TargetInfo { |
| 3208 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 3209 | MinGWX86_64TargetInfo(const llvm::Triple &Triple) |
| 3210 | : WindowsX86_64TargetInfo(Triple) {} |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 3211 | virtual void getTargetDefines(const LangOptions &Opts, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3212 | MacroBuilder &Builder) const { |
| 3213 | WindowsX86_64TargetInfo::getTargetDefines(Opts, Builder); |
Michael J. Spencer | a764e83 | 2010-10-21 08:22:51 +0000 | [diff] [blame] | 3214 | DefineStd(Builder, "WIN64", Opts); |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3215 | Builder.defineMacro("__MSVCRT__"); |
NAKAMURA Takumi | 17c964a | 2011-03-08 12:06:46 +0000 | [diff] [blame] | 3216 | Builder.defineMacro("__MINGW32__"); |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3217 | Builder.defineMacro("__MINGW64__"); |
NAKAMURA Takumi | 853134a | 2011-03-15 02:32:50 +0000 | [diff] [blame] | 3218 | |
| 3219 | // mingw32-gcc provides __declspec(a) as alias of __attribute__((a)). |
| 3220 | // In contrast, clang-cc1 provides __declspec(a) with -fms-extensions. |
Francois Pichet | 62ec1f2 | 2011-09-17 17:15:52 +0000 | [diff] [blame] | 3221 | if (Opts.MicrosoftExt) |
NAKAMURA Takumi | 853134a | 2011-03-15 02:32:50 +0000 | [diff] [blame] | 3222 | // Provide "as-is" __declspec. |
| 3223 | Builder.defineMacro("__declspec", "__declspec"); |
| 3224 | else |
| 3225 | // Provide alias of __attribute__ like mingw32-gcc. |
| 3226 | Builder.defineMacro("__declspec(a)", "__attribute__((a))"); |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 3227 | } |
| 3228 | }; |
| 3229 | } // end anonymous namespace |
| 3230 | |
| 3231 | namespace { |
Eli Friedman | 3c7b6e4 | 2009-07-01 03:36:11 +0000 | [diff] [blame] | 3232 | class DarwinX86_64TargetInfo : public DarwinTargetInfo<X86_64TargetInfo> { |
| 3233 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 3234 | DarwinX86_64TargetInfo(const llvm::Triple &Triple) |
| 3235 | : DarwinTargetInfo<X86_64TargetInfo>(Triple) { |
Eli Friedman | 3c7b6e4 | 2009-07-01 03:36:11 +0000 | [diff] [blame] | 3236 | Int64Type = SignedLongLong; |
Chad Rosier | f9e9af7 | 2012-07-13 23:57:43 +0000 | [diff] [blame] | 3237 | MaxVectorAlign = 256; |
Eli Friedman | 3c7b6e4 | 2009-07-01 03:36:11 +0000 | [diff] [blame] | 3238 | } |
| 3239 | }; |
| 3240 | } // end anonymous namespace |
| 3241 | |
| 3242 | namespace { |
Eli Friedman | 6036ebe | 2009-07-05 22:31:18 +0000 | [diff] [blame] | 3243 | class OpenBSDX86_64TargetInfo : public OpenBSDTargetInfo<X86_64TargetInfo> { |
| 3244 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 3245 | OpenBSDX86_64TargetInfo(const llvm::Triple &Triple) |
| 3246 | : OpenBSDTargetInfo<X86_64TargetInfo>(Triple) { |
Eli Friedman | 6036ebe | 2009-07-05 22:31:18 +0000 | [diff] [blame] | 3247 | IntMaxType = SignedLongLong; |
| 3248 | UIntMaxType = UnsignedLongLong; |
| 3249 | Int64Type = SignedLongLong; |
| 3250 | } |
| 3251 | }; |
| 3252 | } // end anonymous namespace |
| 3253 | |
| 3254 | namespace { |
Eli Friedman | 42f74f2 | 2012-08-08 23:57:20 +0000 | [diff] [blame] | 3255 | class BitrigX86_64TargetInfo : public BitrigTargetInfo<X86_64TargetInfo> { |
| 3256 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 3257 | BitrigX86_64TargetInfo(const llvm::Triple &Triple) |
| 3258 | : BitrigTargetInfo<X86_64TargetInfo>(Triple) { |
| 3259 | IntMaxType = SignedLongLong; |
| 3260 | UIntMaxType = UnsignedLongLong; |
| 3261 | Int64Type = SignedLongLong; |
Eli Friedman | 42f74f2 | 2012-08-08 23:57:20 +0000 | [diff] [blame] | 3262 | } |
| 3263 | }; |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 3264 | } |
| 3265 | |
| 3266 | namespace { |
| 3267 | class AArch64TargetInfo : public TargetInfo { |
| 3268 | static const char * const GCCRegNames[]; |
| 3269 | static const TargetInfo::GCCRegAlias GCCRegAliases[]; |
Tim Northover | ff920ee | 2013-05-04 07:15:13 +0000 | [diff] [blame] | 3270 | |
Tim Northover | b793f0d | 2013-08-01 09:23:19 +0000 | [diff] [blame] | 3271 | enum FPUModeEnum { |
| 3272 | FPUMode, |
| 3273 | NeonMode |
| 3274 | }; |
| 3275 | |
| 3276 | unsigned FPU; |
Tim Northover | ff920ee | 2013-05-04 07:15:13 +0000 | [diff] [blame] | 3277 | static const Builtin::Info BuiltinInfo[]; |
Tim Northover | b793f0d | 2013-08-01 09:23:19 +0000 | [diff] [blame] | 3278 | |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 3279 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 3280 | AArch64TargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) { |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 3281 | BigEndian = false; |
| 3282 | LongWidth = LongAlign = 64; |
| 3283 | LongDoubleWidth = LongDoubleAlign = 128; |
| 3284 | PointerWidth = PointerAlign = 64; |
| 3285 | SuitableAlign = 128; |
| 3286 | DescriptionString = "e-p:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 3287 | "i64:64:64-i128:128:128-f32:32:32-f64:64:64-" |
| 3288 | "f128:128:128-n32:64-S128"; |
| 3289 | |
| 3290 | WCharType = UnsignedInt; |
| 3291 | LongDoubleFormat = &llvm::APFloat::IEEEquad; |
| 3292 | |
Tim Northover | 6a93c86 | 2013-02-18 12:11:32 +0000 | [diff] [blame] | 3293 | // AArch64 backend supports 64-bit operations at the moment. In principle |
| 3294 | // 128-bit is possible if register-pairs are used. |
| 3295 | MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; |
| 3296 | |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 3297 | TheCXXABI.set(TargetCXXABI::GenericAArch64); |
| 3298 | } |
| 3299 | virtual void getTargetDefines(const LangOptions &Opts, |
| 3300 | MacroBuilder &Builder) const { |
| 3301 | // GCC defines theses currently |
| 3302 | Builder.defineMacro("__aarch64__"); |
| 3303 | Builder.defineMacro("__AARCH64EL__"); |
| 3304 | |
| 3305 | // ACLE predefines. Many can only have one possible value on v8 AArch64. |
| 3306 | |
| 3307 | // FIXME: these were written based on an unreleased version of a 32-bit ACLE |
| 3308 | // which was intended to be compatible with a 64-bit implementation. They |
| 3309 | // will need updating when a real 64-bit ACLE exists. Particularly pressing |
Tim Northover | dabcbf9 | 2013-04-05 14:08:55 +0000 | [diff] [blame] | 3310 | // instances are: __ARM_ARCH_ISA_ARM, __ARM_ARCH_ISA_THUMB, __ARM_PCS. |
| 3311 | Builder.defineMacro("__ARM_ACLE", "101"); |
| 3312 | Builder.defineMacro("__ARM_ARCH", "8"); |
| 3313 | Builder.defineMacro("__ARM_ARCH_PROFILE", "'A'"); |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 3314 | |
Tim Northover | dabcbf9 | 2013-04-05 14:08:55 +0000 | [diff] [blame] | 3315 | Builder.defineMacro("__ARM_FEATURE_UNALIGNED"); |
| 3316 | Builder.defineMacro("__ARM_FEATURE_CLZ"); |
| 3317 | Builder.defineMacro("__ARM_FEATURE_FMA"); |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 3318 | |
| 3319 | // FIXME: ACLE 1.1 reserves bit 4. Will almost certainly come to mean |
| 3320 | // 128-bit LDXP present, at which point this becomes 0x1f. |
Tim Northover | dabcbf9 | 2013-04-05 14:08:55 +0000 | [diff] [blame] | 3321 | Builder.defineMacro("__ARM_FEATURE_LDREX", "0xf"); |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 3322 | |
| 3323 | // 0xe implies support for half, single and double precision operations. |
Tim Northover | dabcbf9 | 2013-04-05 14:08:55 +0000 | [diff] [blame] | 3324 | Builder.defineMacro("__ARM_FP", "0xe"); |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 3325 | |
| 3326 | // PCS specifies this for SysV variants, which is all we support. Other ABIs |
Tim Northover | dabcbf9 | 2013-04-05 14:08:55 +0000 | [diff] [blame] | 3327 | // may choose __ARM_FP16_FORMAT_ALTERNATIVE. |
| 3328 | Builder.defineMacro("__ARM_FP16_FORMAT_IEEE"); |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 3329 | |
| 3330 | if (Opts.FastMath || Opts.FiniteMathOnly) |
Tim Northover | dabcbf9 | 2013-04-05 14:08:55 +0000 | [diff] [blame] | 3331 | Builder.defineMacro("__ARM_FP_FAST"); |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 3332 | |
| 3333 | if ((Opts.C99 || Opts.C11) && !Opts.Freestanding) |
Tim Northover | dabcbf9 | 2013-04-05 14:08:55 +0000 | [diff] [blame] | 3334 | Builder.defineMacro("__ARM_FP_FENV_ROUNDING"); |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 3335 | |
Tim Northover | dabcbf9 | 2013-04-05 14:08:55 +0000 | [diff] [blame] | 3336 | Builder.defineMacro("__ARM_SIZEOF_WCHAR_T", |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 3337 | Opts.ShortWChar ? "2" : "4"); |
| 3338 | |
Tim Northover | dabcbf9 | 2013-04-05 14:08:55 +0000 | [diff] [blame] | 3339 | Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM", |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 3340 | Opts.ShortEnums ? "1" : "4"); |
| 3341 | |
| 3342 | if (BigEndian) |
Tim Northover | b793f0d | 2013-08-01 09:23:19 +0000 | [diff] [blame] | 3343 | Builder.defineMacro("__AARCH_BIG_ENDIAN"); |
| 3344 | |
| 3345 | if (FPU == NeonMode) { |
| 3346 | Builder.defineMacro("__AARCH_FEATURE_ADVSIMD"); |
| 3347 | |
| 3348 | // 64-bit NEON supports half, single and double precision operations. |
| 3349 | Builder.defineMacro("__AARCH_ADVSIMD_FP", "0xe"); |
| 3350 | } |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 3351 | } |
| 3352 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 3353 | unsigned &NumRecords) const { |
Tim Northover | ff920ee | 2013-05-04 07:15:13 +0000 | [diff] [blame] | 3354 | Records = BuiltinInfo; |
| 3355 | NumRecords = clang::AArch64::LastTSBuiltin-Builtin::FirstTSBuiltin; |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 3356 | } |
| 3357 | virtual bool hasFeature(StringRef Feature) const { |
Tim Northover | b793f0d | 2013-08-01 09:23:19 +0000 | [diff] [blame] | 3358 | return Feature == "aarch64" || (Feature == "neon" && FPU == NeonMode); |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 3359 | } |
Tim Northover | b793f0d | 2013-08-01 09:23:19 +0000 | [diff] [blame] | 3360 | |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 3361 | virtual bool HandleTargetFeatures(std::vector<std::string> &Features, |
| 3362 | DiagnosticsEngine &Diags) { |
Tim Northover | b793f0d | 2013-08-01 09:23:19 +0000 | [diff] [blame] | 3363 | FPU = FPUMode; |
| 3364 | for (unsigned i = 0, e = Features.size(); i != e; ++i) { |
| 3365 | if (Features[i] == "+neon") |
| 3366 | FPU = NeonMode; |
| 3367 | } |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 3368 | return true; |
Tim Northover | b793f0d | 2013-08-01 09:23:19 +0000 | [diff] [blame] | 3369 | } |
| 3370 | |
| 3371 | virtual void getGCCRegNames(const char *const *&Names, |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 3372 | unsigned &NumNames) const; |
| 3373 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 3374 | unsigned &NumAliases) const; |
| 3375 | |
| 3376 | virtual bool isCLZForZeroUndef() const { return false; } |
| 3377 | |
| 3378 | virtual bool validateAsmConstraint(const char *&Name, |
| 3379 | TargetInfo::ConstraintInfo &Info) const { |
| 3380 | switch (*Name) { |
| 3381 | default: return false; |
| 3382 | case 'w': // An FP/SIMD vector register |
| 3383 | Info.setAllowsRegister(); |
| 3384 | return true; |
| 3385 | case 'I': // Constant that can be used with an ADD instruction |
| 3386 | case 'J': // Constant that can be used with a SUB instruction |
| 3387 | case 'K': // Constant that can be used with a 32-bit logical instruction |
| 3388 | case 'L': // Constant that can be used with a 64-bit logical instruction |
| 3389 | case 'M': // Constant that can be used as a 32-bit MOV immediate |
| 3390 | case 'N': // Constant that can be used as a 64-bit MOV immediate |
| 3391 | case 'Y': // Floating point constant zero |
| 3392 | case 'Z': // Integer constant zero |
| 3393 | return true; |
| 3394 | case 'Q': // A memory reference with base register and no offset |
| 3395 | Info.setAllowsMemory(); |
| 3396 | return true; |
| 3397 | case 'S': // A symbolic address |
| 3398 | Info.setAllowsRegister(); |
| 3399 | return true; |
| 3400 | case 'U': |
| 3401 | // Ump: A memory address suitable for ldp/stp in SI, DI, SF and DF modes, whatever they may be |
| 3402 | // Utf: A memory address suitable for ldp/stp in TF mode, whatever it may be |
| 3403 | // Usa: An absolute symbolic address |
| 3404 | // Ush: The high part (bits 32:12) of a pc-relative symbolic address |
| 3405 | llvm_unreachable("FIXME: Unimplemented support for bizarre constraints"); |
| 3406 | } |
| 3407 | } |
| 3408 | |
| 3409 | virtual const char *getClobbers() const { |
| 3410 | // There are no AArch64 clobbers shared by all asm statements. |
| 3411 | return ""; |
| 3412 | } |
| 3413 | |
| 3414 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
| 3415 | return TargetInfo::AArch64ABIBuiltinVaList; |
| 3416 | } |
| 3417 | }; |
| 3418 | |
| 3419 | const char * const AArch64TargetInfo::GCCRegNames[] = { |
| 3420 | "w0", "w1", "w2", "w3", "w4", "w5", "w6", "w7", |
| 3421 | "w8", "w9", "w10", "w11", "w12", "w13", "w14", "w15", |
| 3422 | "w16", "w17", "w18", "w19", "w20", "w21", "w22", "w23", |
| 3423 | "w24", "w25", "w26", "w27", "w28", "w29", "w30", "wsp", "wzr", |
| 3424 | |
| 3425 | "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", |
| 3426 | "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15", |
| 3427 | "x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23", |
| 3428 | "x24", "x25", "x26", "x27", "x28", "x29", "x30", "sp", "xzr", |
| 3429 | |
| 3430 | "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", |
| 3431 | "b8", "b9", "b10", "b11", "b12", "b13", "b14", "b15", |
| 3432 | "b16", "b17", "b18", "b19", "b20", "b21", "b22", "b23", |
| 3433 | "b24", "b25", "b26", "b27", "b28", "b29", "b30", "b31", |
| 3434 | |
| 3435 | "h0", "h1", "h2", "h3", "h4", "h5", "h6", "h7", |
| 3436 | "h8", "h9", "h10", "h11", "h12", "h13", "h14", "h15", |
| 3437 | "h16", "h17", "h18", "h19", "h20", "h21", "h22", "h23", |
| 3438 | "h24", "h25", "h26", "h27", "h28", "h29", "h30", "h31", |
| 3439 | |
| 3440 | "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", |
| 3441 | "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", |
| 3442 | "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", |
| 3443 | "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31", |
| 3444 | |
| 3445 | "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", |
| 3446 | "d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15", |
| 3447 | "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23", |
| 3448 | "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31", |
| 3449 | |
| 3450 | "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", |
| 3451 | "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15", |
| 3452 | "q16", "q17", "q18", "q19", "q20", "q21", "q22", "q23", |
| 3453 | "q24", "q25", "q26", "q27", "q28", "q29", "q30", "q31" |
| 3454 | }; |
| 3455 | |
| 3456 | void AArch64TargetInfo::getGCCRegNames(const char * const *&Names, |
| 3457 | unsigned &NumNames) const { |
| 3458 | Names = GCCRegNames; |
| 3459 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 3460 | } |
| 3461 | |
| 3462 | const TargetInfo::GCCRegAlias AArch64TargetInfo::GCCRegAliases[] = { |
| 3463 | { { "x16" }, "ip0"}, |
| 3464 | { { "x17" }, "ip1"}, |
| 3465 | { { "x29" }, "fp" }, |
| 3466 | { { "x30" }, "lr" } |
| 3467 | }; |
| 3468 | |
| 3469 | void AArch64TargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 3470 | unsigned &NumAliases) const { |
| 3471 | Aliases = GCCRegAliases; |
| 3472 | NumAliases = llvm::array_lengthof(GCCRegAliases); |
| 3473 | |
| 3474 | } |
Tim Northover | ff920ee | 2013-05-04 07:15:13 +0000 | [diff] [blame] | 3475 | |
| 3476 | const Builtin::Info AArch64TargetInfo::BuiltinInfo[] = { |
| 3477 | #define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, ALL_LANGUAGES }, |
| 3478 | #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER,\ |
| 3479 | ALL_LANGUAGES }, |
| 3480 | #include "clang/Basic/BuiltinsAArch64.def" |
| 3481 | }; |
| 3482 | |
Eli Friedman | 42f74f2 | 2012-08-08 23:57:20 +0000 | [diff] [blame] | 3483 | } // end anonymous namespace |
| 3484 | |
| 3485 | namespace { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 3486 | class ARMTargetInfo : public TargetInfo { |
Daniel Dunbar | a91320b | 2009-12-21 23:28:17 +0000 | [diff] [blame] | 3487 | // Possible FPU choices. |
| 3488 | enum FPUMode { |
Bob Wilson | cfaab00 | 2012-09-29 23:52:52 +0000 | [diff] [blame] | 3489 | VFP2FPU = (1 << 0), |
| 3490 | VFP3FPU = (1 << 1), |
| 3491 | VFP4FPU = (1 << 2), |
| 3492 | NeonFPU = (1 << 3) |
Daniel Dunbar | a91320b | 2009-12-21 23:28:17 +0000 | [diff] [blame] | 3493 | }; |
| 3494 | |
| 3495 | static bool FPUModeIsVFP(FPUMode Mode) { |
Bob Wilson | cfaab00 | 2012-09-29 23:52:52 +0000 | [diff] [blame] | 3496 | return Mode & (VFP2FPU | VFP3FPU | VFP4FPU | NeonFPU); |
Daniel Dunbar | a91320b | 2009-12-21 23:28:17 +0000 | [diff] [blame] | 3497 | } |
| 3498 | |
| 3499 | static const TargetInfo::GCCRegAlias GCCRegAliases[]; |
| 3500 | static const char * const GCCRegNames[]; |
Daniel Dunbar | c1f2cdd | 2009-09-17 07:03:19 +0000 | [diff] [blame] | 3501 | |
Daniel Dunbar | eac7c53 | 2009-12-18 18:42:37 +0000 | [diff] [blame] | 3502 | std::string ABI, CPU; |
Daniel Dunbar | a91320b | 2009-12-21 23:28:17 +0000 | [diff] [blame] | 3503 | |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 3504 | enum { |
| 3505 | FP_Default, |
| 3506 | FP_VFP, |
| 3507 | FP_Neon |
| 3508 | } FPMath; |
| 3509 | |
Bob Wilson | cfaab00 | 2012-09-29 23:52:52 +0000 | [diff] [blame] | 3510 | unsigned FPU : 4; |
Daniel Dunbar | a91320b | 2009-12-21 23:28:17 +0000 | [diff] [blame] | 3511 | |
Logan Chien | eae5a820 | 2012-10-10 06:56:20 +0000 | [diff] [blame] | 3512 | unsigned IsAAPCS : 1; |
Daniel Dunbar | 97f52ac | 2009-12-19 04:15:38 +0000 | [diff] [blame] | 3513 | unsigned IsThumb : 1; |
| 3514 | |
| 3515 | // Initialized via features. |
| 3516 | unsigned SoftFloat : 1; |
| 3517 | unsigned SoftFloatABI : 1; |
Daniel Dunbar | 018ba5a | 2009-09-14 00:35:03 +0000 | [diff] [blame] | 3518 | |
Chris Lattner | 2752c01 | 2010-03-03 19:03:45 +0000 | [diff] [blame] | 3519 | static const Builtin::Info BuiltinInfo[]; |
| 3520 | |
Rafael Espindola | 620c0af | 2013-05-13 20:09:47 +0000 | [diff] [blame] | 3521 | static bool shouldUseInlineAtomic(const llvm::Triple &T) { |
| 3522 | // On linux, binaries targeting old cpus call functions in libgcc to |
| 3523 | // perform atomic operations. The implementation in libgcc then calls into |
| 3524 | // the kernel which on armv6 and newer uses ldrex and strex. The net result |
| 3525 | // is that if we assume the kernel is at least as recent as the hardware, |
| 3526 | // it is safe to use atomic instructions on armv6 and newer. |
Rafael Espindola | e1e0342 | 2013-06-17 20:00:15 +0000 | [diff] [blame] | 3527 | if (T.getOS() != llvm::Triple::Linux && |
| 3528 | T.getOS() != llvm::Triple::FreeBSD && |
| 3529 | T.getOS() != llvm::Triple::Bitrig) |
Ed Schouten | 0449163 | 2013-06-15 09:40:14 +0000 | [diff] [blame] | 3530 | return false; |
Rafael Espindola | 620c0af | 2013-05-13 20:09:47 +0000 | [diff] [blame] | 3531 | StringRef ArchName = T.getArchName(); |
Rafael Espindola | 69db555 | 2013-05-14 00:44:24 +0000 | [diff] [blame] | 3532 | if (T.getArch() == llvm::Triple::arm) { |
| 3533 | if (!ArchName.startswith("armv")) |
| 3534 | return false; |
| 3535 | StringRef VersionStr = ArchName.substr(4); |
| 3536 | unsigned Version; |
| 3537 | if (VersionStr.getAsInteger(10, Version)) |
| 3538 | return false; |
| 3539 | return Version >= 6; |
| 3540 | } |
| 3541 | assert(T.getArch() == llvm::Triple::thumb); |
| 3542 | if (!ArchName.startswith("thumbv")) |
| 3543 | return false; |
| 3544 | StringRef VersionStr = ArchName.substr(6); |
| 3545 | unsigned Version; |
| 3546 | if (VersionStr.getAsInteger(10, Version)) |
| 3547 | return false; |
| 3548 | return Version >= 7; |
Rafael Espindola | 620c0af | 2013-05-13 20:09:47 +0000 | [diff] [blame] | 3549 | } |
| 3550 | |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 3551 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 3552 | ARMTargetInfo(const llvm::Triple &Triple) |
| 3553 | : TargetInfo(Triple), ABI("aapcs-linux"), CPU("arm1136j-s"), |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 3554 | FPMath(FP_Default), IsAAPCS(true) { |
Eli Friedman | e6a24e8 | 2011-12-22 03:51:45 +0000 | [diff] [blame] | 3555 | BigEndian = false; |
Daniel Dunbar | a2a4161 | 2009-09-14 00:02:24 +0000 | [diff] [blame] | 3556 | SizeType = UnsignedInt; |
| 3557 | PtrDiffType = SignedInt; |
James Molloy | a6d81f9 | 2011-11-23 13:35:08 +0000 | [diff] [blame] | 3558 | // AAPCS 7.1.1, ARM-Linux ABI 2.4: type of wchar_t is unsigned int. |
| 3559 | WCharType = UnsignedInt; |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 3560 | |
Chris Lattner | 9bffb07 | 2010-04-23 16:29:58 +0000 | [diff] [blame] | 3561 | // {} in inline assembly are neon specifiers, not assembly variant |
| 3562 | // specifiers. |
| 3563 | NoAsmVariants = true; |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 3564 | |
Daniel Dunbar | eac7c53 | 2009-12-18 18:42:37 +0000 | [diff] [blame] | 3565 | // FIXME: Should we just treat this as a feature? |
Daniel Dunbar | 0791aa5 | 2009-12-18 19:57:13 +0000 | [diff] [blame] | 3566 | IsThumb = getTriple().getArchName().startswith("thumb"); |
Daniel Dunbar | dff10dc | 2009-09-22 21:44:58 +0000 | [diff] [blame] | 3567 | if (IsThumb) { |
Sandeep Patel | 3a41d14 | 2011-04-04 22:58:12 +0000 | [diff] [blame] | 3568 | // Thumb1 add sp, #imm requires the immediate value be multiple of 4, |
| 3569 | // so set preferred for small types to 32. |
Daniel Dunbar | dff10dc | 2009-09-22 21:44:58 +0000 | [diff] [blame] | 3570 | DescriptionString = ("e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-" |
| 3571 | "i64:64:64-f32:32:32-f64:64:64-" |
Lang Hames | f4f5003 | 2011-10-10 23:44:43 +0000 | [diff] [blame] | 3572 | "v64:64:64-v128:64:128-a0:0:32-n32-S64"); |
Daniel Dunbar | dff10dc | 2009-09-22 21:44:58 +0000 | [diff] [blame] | 3573 | } else { |
| 3574 | DescriptionString = ("e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 3575 | "i64:64:64-f32:32:32-f64:64:64-" |
Lang Hames | f4f5003 | 2011-10-10 23:44:43 +0000 | [diff] [blame] | 3576 | "v64:64:64-v128:64:128-a0:0:64-n32-S64"); |
Daniel Dunbar | dff10dc | 2009-09-22 21:44:58 +0000 | [diff] [blame] | 3577 | } |
John McCall | ee79a4c | 2010-08-21 22:46:04 +0000 | [diff] [blame] | 3578 | |
| 3579 | // ARM targets default to using the ARM C++ ABI. |
John McCall | b8b2c9d | 2013-01-25 22:30:49 +0000 | [diff] [blame] | 3580 | TheCXXABI.set(TargetCXXABI::GenericARM); |
Eli Friedman | 2be4607 | 2011-10-14 20:59:01 +0000 | [diff] [blame] | 3581 | |
| 3582 | // ARM has atomics up to 8 bytes |
Eli Friedman | 2be4607 | 2011-10-14 20:59:01 +0000 | [diff] [blame] | 3583 | MaxAtomicPromoteWidth = 64; |
Rafael Espindola | 620c0af | 2013-05-13 20:09:47 +0000 | [diff] [blame] | 3584 | if (shouldUseInlineAtomic(getTriple())) |
| 3585 | MaxAtomicInlineWidth = 64; |
James Molloy | e45b9b7 | 2012-03-12 09:14:10 +0000 | [diff] [blame] | 3586 | |
| 3587 | // Do force alignment of members that follow zero length bitfields. If |
| 3588 | // the alignment of the zero-length bitfield is greater than the member |
| 3589 | // that follows it, `bar', `bar' will be aligned as the type of the |
| 3590 | // zero length bitfield. |
| 3591 | UseZeroLengthBitfieldAlignment = true; |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 3592 | } |
Daniel Dunbar | 018ba5a | 2009-09-14 00:35:03 +0000 | [diff] [blame] | 3593 | virtual const char *getABI() const { return ABI.c_str(); } |
Daniel Dunbar | a2a4161 | 2009-09-14 00:02:24 +0000 | [diff] [blame] | 3594 | virtual bool setABI(const std::string &Name) { |
Daniel Dunbar | 018ba5a | 2009-09-14 00:35:03 +0000 | [diff] [blame] | 3595 | ABI = Name; |
| 3596 | |
Daniel Dunbar | a2a4161 | 2009-09-14 00:02:24 +0000 | [diff] [blame] | 3597 | // The defaults (above) are for AAPCS, check if we need to change them. |
| 3598 | // |
| 3599 | // FIXME: We need support for -meabi... we could just mangle it into the |
| 3600 | // name. |
| 3601 | if (Name == "apcs-gnu") { |
Nick Lewycky | 7ec59c7 | 2011-12-16 22:34:14 +0000 | [diff] [blame] | 3602 | DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 32; |
Rafael Espindola | 27fa236 | 2012-12-13 04:17:14 +0000 | [diff] [blame] | 3603 | // size_t is unsigned int on FreeBSD. |
| 3604 | if (getTriple().getOS() != llvm::Triple::FreeBSD) |
| 3605 | SizeType = UnsignedLong; |
Daniel Dunbar | a2a4161 | 2009-09-14 00:02:24 +0000 | [diff] [blame] | 3606 | |
James Molloy | a6d81f9 | 2011-11-23 13:35:08 +0000 | [diff] [blame] | 3607 | // Revert to using SignedInt on apcs-gnu to comply with existing behaviour. |
| 3608 | WCharType = SignedInt; |
| 3609 | |
Daniel Dunbar | 684de63 | 2010-04-22 16:14:54 +0000 | [diff] [blame] | 3610 | // Do not respect the alignment of bit-field types when laying out |
| 3611 | // structures. This corresponds to PCC_BITFIELD_TYPE_MATTERS in gcc. |
| 3612 | UseBitFieldTypeAlignment = false; |
| 3613 | |
Chad Rosier | 61a6221 | 2011-08-04 01:21:14 +0000 | [diff] [blame] | 3614 | /// gcc forces the alignment to 4 bytes, regardless of the type of the |
Chad Rosier | 6e43f3f | 2011-08-04 17:52:43 +0000 | [diff] [blame] | 3615 | /// zero length bitfield. This corresponds to EMPTY_FIELD_BOUNDARY in |
| 3616 | /// gcc. |
Chad Rosier | 61a6221 | 2011-08-04 01:21:14 +0000 | [diff] [blame] | 3617 | ZeroLengthBitfieldBoundary = 32; |
| 3618 | |
Logan Chien | eae5a820 | 2012-10-10 06:56:20 +0000 | [diff] [blame] | 3619 | IsAAPCS = false; |
| 3620 | |
Daniel Dunbar | dff10dc | 2009-09-22 21:44:58 +0000 | [diff] [blame] | 3621 | if (IsThumb) { |
Sandeep Patel | 3a41d14 | 2011-04-04 22:58:12 +0000 | [diff] [blame] | 3622 | // Thumb1 add sp, #imm requires the immediate value be multiple of 4, |
| 3623 | // so set preferred for small types to 32. |
Daniel Dunbar | dff10dc | 2009-09-22 21:44:58 +0000 | [diff] [blame] | 3624 | DescriptionString = ("e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-" |
Bob Wilson | 949fd1a | 2011-06-29 16:09:20 +0000 | [diff] [blame] | 3625 | "i64:32:64-f32:32:32-f64:32:64-" |
Lang Hames | f4f5003 | 2011-10-10 23:44:43 +0000 | [diff] [blame] | 3626 | "v64:32:64-v128:32:128-a0:0:32-n32-S32"); |
Daniel Dunbar | dff10dc | 2009-09-22 21:44:58 +0000 | [diff] [blame] | 3627 | } else { |
| 3628 | DescriptionString = ("e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
Bob Wilson | cd5ce09 | 2011-04-04 16:53:11 +0000 | [diff] [blame] | 3629 | "i64:32:64-f32:32:32-f64:32:64-" |
Lang Hames | f4f5003 | 2011-10-10 23:44:43 +0000 | [diff] [blame] | 3630 | "v64:32:64-v128:32:128-a0:0:32-n32-S32"); |
Daniel Dunbar | dff10dc | 2009-09-22 21:44:58 +0000 | [diff] [blame] | 3631 | } |
| 3632 | |
Chad Rosier | 9f1210c | 2011-07-26 07:03:04 +0000 | [diff] [blame] | 3633 | // FIXME: Override "preferred align" for double and long long. |
David Tweed | b16abb1 | 2012-10-25 13:33:01 +0000 | [diff] [blame] | 3634 | } else if (Name == "aapcs" || Name == "aapcs-vfp") { |
Bob Wilson | e4bce7a | 2013-06-18 05:36:04 +0000 | [diff] [blame] | 3635 | // size_t is unsigned long on Darwin. |
| 3636 | if (getTriple().isOSDarwin()) |
| 3637 | SizeType = UnsignedLong; |
Logan Chien | eae5a820 | 2012-10-10 06:56:20 +0000 | [diff] [blame] | 3638 | IsAAPCS = true; |
Daniel Dunbar | a2a4161 | 2009-09-14 00:02:24 +0000 | [diff] [blame] | 3639 | // FIXME: Enumerated types are variable width in straight AAPCS. |
| 3640 | } else if (Name == "aapcs-linux") { |
Logan Chien | eae5a820 | 2012-10-10 06:56:20 +0000 | [diff] [blame] | 3641 | IsAAPCS = true; |
Daniel Dunbar | a2a4161 | 2009-09-14 00:02:24 +0000 | [diff] [blame] | 3642 | } else |
| 3643 | return false; |
| 3644 | |
| 3645 | return true; |
| 3646 | } |
Daniel Dunbar | 97f52ac | 2009-12-19 04:15:38 +0000 | [diff] [blame] | 3647 | |
Chandler Carruth | c3a2e65 | 2011-09-28 05:56:05 +0000 | [diff] [blame] | 3648 | void getDefaultFeatures(llvm::StringMap<bool> &Features) const { |
Daniel Dunbar | a91320b | 2009-12-21 23:28:17 +0000 | [diff] [blame] | 3649 | if (CPU == "arm1136jf-s" || CPU == "arm1176jzf-s" || CPU == "mpcore") |
| 3650 | Features["vfp2"] = true; |
Bob Wilson | cfaab00 | 2012-09-29 23:52:52 +0000 | [diff] [blame] | 3651 | else if (CPU == "cortex-a8" || CPU == "cortex-a15" || |
| 3652 | CPU == "cortex-a9" || CPU == "cortex-a9-mp") |
Daniel Dunbar | a91320b | 2009-12-21 23:28:17 +0000 | [diff] [blame] | 3653 | Features["neon"] = true; |
Bob Wilson | fc55345 | 2013-03-04 22:37:46 +0000 | [diff] [blame] | 3654 | else if (CPU == "swift" || CPU == "cortex-a7") { |
Bob Wilson | cfaab00 | 2012-09-29 23:52:52 +0000 | [diff] [blame] | 3655 | Features["vfp4"] = true; |
| 3656 | Features["neon"] = true; |
| 3657 | } |
Daniel Dunbar | a91320b | 2009-12-21 23:28:17 +0000 | [diff] [blame] | 3658 | } |
Michael J. Spencer | 20249a1 | 2010-10-21 03:16:25 +0000 | [diff] [blame] | 3659 | |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 3660 | virtual bool HandleTargetFeatures(std::vector<std::string> &Features, |
| 3661 | DiagnosticsEngine &Diags) { |
Bob Wilson | cfaab00 | 2012-09-29 23:52:52 +0000 | [diff] [blame] | 3662 | FPU = 0; |
Daniel Dunbar | 97f52ac | 2009-12-19 04:15:38 +0000 | [diff] [blame] | 3663 | SoftFloat = SoftFloatABI = false; |
| 3664 | for (unsigned i = 0, e = Features.size(); i != e; ++i) { |
| 3665 | if (Features[i] == "+soft-float") |
| 3666 | SoftFloat = true; |
| 3667 | else if (Features[i] == "+soft-float-abi") |
| 3668 | SoftFloatABI = true; |
Daniel Dunbar | a91320b | 2009-12-21 23:28:17 +0000 | [diff] [blame] | 3669 | else if (Features[i] == "+vfp2") |
Bob Wilson | cfaab00 | 2012-09-29 23:52:52 +0000 | [diff] [blame] | 3670 | FPU |= VFP2FPU; |
Daniel Dunbar | a91320b | 2009-12-21 23:28:17 +0000 | [diff] [blame] | 3671 | else if (Features[i] == "+vfp3") |
Bob Wilson | cfaab00 | 2012-09-29 23:52:52 +0000 | [diff] [blame] | 3672 | FPU |= VFP3FPU; |
| 3673 | else if (Features[i] == "+vfp4") |
| 3674 | FPU |= VFP4FPU; |
Daniel Dunbar | a91320b | 2009-12-21 23:28:17 +0000 | [diff] [blame] | 3675 | else if (Features[i] == "+neon") |
Bob Wilson | cfaab00 | 2012-09-29 23:52:52 +0000 | [diff] [blame] | 3676 | FPU |= NeonFPU; |
Daniel Dunbar | 97f52ac | 2009-12-19 04:15:38 +0000 | [diff] [blame] | 3677 | } |
| 3678 | |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 3679 | if (!(FPU & NeonFPU) && FPMath == FP_Neon) { |
| 3680 | Diags.Report(diag::err_target_unsupported_fpmath) << "neon"; |
| 3681 | return false; |
| 3682 | } |
| 3683 | |
| 3684 | if (FPMath == FP_Neon) |
| 3685 | Features.push_back("+neonfp"); |
| 3686 | else if (FPMath == FP_VFP) |
| 3687 | Features.push_back("-neonfp"); |
| 3688 | |
Daniel Dunbar | 97f52ac | 2009-12-19 04:15:38 +0000 | [diff] [blame] | 3689 | // Remove front-end specific options which the backend handles differently. |
| 3690 | std::vector<std::string>::iterator it; |
| 3691 | it = std::find(Features.begin(), Features.end(), "+soft-float"); |
| 3692 | if (it != Features.end()) |
| 3693 | Features.erase(it); |
| 3694 | it = std::find(Features.begin(), Features.end(), "+soft-float-abi"); |
| 3695 | if (it != Features.end()) |
| 3696 | Features.erase(it); |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 3697 | return true; |
Daniel Dunbar | 97f52ac | 2009-12-19 04:15:38 +0000 | [diff] [blame] | 3698 | } |
| 3699 | |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 3700 | virtual bool hasFeature(StringRef Feature) const { |
| 3701 | return llvm::StringSwitch<bool>(Feature) |
| 3702 | .Case("arm", true) |
| 3703 | .Case("softfloat", SoftFloat) |
| 3704 | .Case("thumb", IsThumb) |
| 3705 | .Case("neon", FPU == NeonFPU && !SoftFloat && |
| 3706 | StringRef(getCPUDefineSuffix(CPU)).startswith("7")) |
| 3707 | .Default(false); |
| 3708 | } |
Anton Korobeynikov | 70a5cca | 2012-09-08 08:08:27 +0000 | [diff] [blame] | 3709 | // FIXME: Should we actually have some table instead of these switches? |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 3710 | static const char *getCPUDefineSuffix(StringRef Name) { |
Daniel Dunbar | eac7c53 | 2009-12-18 18:42:37 +0000 | [diff] [blame] | 3711 | return llvm::StringSwitch<const char*>(Name) |
| 3712 | .Cases("arm8", "arm810", "4") |
| 3713 | .Cases("strongarm", "strongarm110", "strongarm1100", "strongarm1110", "4") |
| 3714 | .Cases("arm7tdmi", "arm7tdmi-s", "arm710t", "arm720t", "arm9", "4T") |
| 3715 | .Cases("arm9tdmi", "arm920", "arm920t", "arm922t", "arm940t", "4T") |
| 3716 | .Case("ep9312", "4T") |
| 3717 | .Cases("arm10tdmi", "arm1020t", "5T") |
| 3718 | .Cases("arm9e", "arm946e-s", "arm966e-s", "arm968e-s", "5TE") |
| 3719 | .Case("arm926ej-s", "5TEJ") |
| 3720 | .Cases("arm10e", "arm1020e", "arm1022e", "5TE") |
| 3721 | .Cases("xscale", "iwmmxt", "5TE") |
Daniel Dunbar | a91320b | 2009-12-21 23:28:17 +0000 | [diff] [blame] | 3722 | .Case("arm1136j-s", "6J") |
Daniel Dunbar | eac7c53 | 2009-12-18 18:42:37 +0000 | [diff] [blame] | 3723 | .Cases("arm1176jz-s", "arm1176jzf-s", "6ZK") |
Daniel Dunbar | a91320b | 2009-12-21 23:28:17 +0000 | [diff] [blame] | 3724 | .Cases("arm1136jf-s", "mpcorenovfp", "mpcore", "6K") |
Daniel Dunbar | eac7c53 | 2009-12-18 18:42:37 +0000 | [diff] [blame] | 3725 | .Cases("arm1156t2-s", "arm1156t2f-s", "6T2") |
Bob Wilson | fc55345 | 2013-03-04 22:37:46 +0000 | [diff] [blame] | 3726 | .Cases("cortex-a5", "cortex-a7", "cortex-a8", "7A") |
| 3727 | .Cases("cortex-a9", "cortex-a15", "7A") |
Quentin Colombet | ab13751 | 2012-12-21 17:57:47 +0000 | [diff] [blame] | 3728 | .Case("cortex-r5", "7R") |
Bob Wilson | 336bfa3 | 2012-09-29 23:52:50 +0000 | [diff] [blame] | 3729 | .Case("cortex-a9-mp", "7F") |
| 3730 | .Case("swift", "7S") |
Anton Korobeynikov | 70a5cca | 2012-09-08 08:08:27 +0000 | [diff] [blame] | 3731 | .Cases("cortex-m3", "cortex-m4", "7M") |
Bob Wilson | a291d5f | 2011-03-21 21:55:25 +0000 | [diff] [blame] | 3732 | .Case("cortex-m0", "6M") |
Joey Gouly | 4ec8d5b | 2013-06-26 17:19:48 +0000 | [diff] [blame] | 3733 | .Case("cortex-a53", "8A") |
Daniel Dunbar | eac7c53 | 2009-12-18 18:42:37 +0000 | [diff] [blame] | 3734 | .Default(0); |
| 3735 | } |
Anton Korobeynikov | 70a5cca | 2012-09-08 08:08:27 +0000 | [diff] [blame] | 3736 | static const char *getCPUProfile(StringRef Name) { |
| 3737 | return llvm::StringSwitch<const char*>(Name) |
| 3738 | .Cases("cortex-a8", "cortex-a9", "A") |
| 3739 | .Cases("cortex-m3", "cortex-m4", "cortex-m0", "M") |
Quentin Colombet | ab13751 | 2012-12-21 17:57:47 +0000 | [diff] [blame] | 3740 | .Case("cortex-r5", "R") |
Anton Korobeynikov | 8b0703d | 2012-09-08 08:22:13 +0000 | [diff] [blame] | 3741 | .Default(""); |
Anton Korobeynikov | 70a5cca | 2012-09-08 08:08:27 +0000 | [diff] [blame] | 3742 | } |
Daniel Dunbar | eac7c53 | 2009-12-18 18:42:37 +0000 | [diff] [blame] | 3743 | virtual bool setCPU(const std::string &Name) { |
| 3744 | if (!getCPUDefineSuffix(Name)) |
| 3745 | return false; |
| 3746 | |
| 3747 | CPU = Name; |
| 3748 | return true; |
| 3749 | } |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 3750 | virtual bool setFPMath(StringRef Name); |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 3751 | virtual void getTargetDefines(const LangOptions &Opts, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3752 | MacroBuilder &Builder) const { |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 3753 | // Target identification. |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3754 | Builder.defineMacro("__arm"); |
| 3755 | Builder.defineMacro("__arm__"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 3756 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 3757 | // Target properties. |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3758 | Builder.defineMacro("__ARMEL__"); |
| 3759 | Builder.defineMacro("__LITTLE_ENDIAN__"); |
| 3760 | Builder.defineMacro("__REGISTER_PREFIX__", ""); |
Daniel Dunbar | eac7c53 | 2009-12-18 18:42:37 +0000 | [diff] [blame] | 3761 | |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 3762 | StringRef CPUArch = getCPUDefineSuffix(CPU); |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3763 | Builder.defineMacro("__ARM_ARCH_" + CPUArch + "__"); |
Anton Korobeynikov | 70a5cca | 2012-09-08 08:08:27 +0000 | [diff] [blame] | 3764 | Builder.defineMacro("__ARM_ARCH", CPUArch.substr(0, 1)); |
| 3765 | StringRef CPUProfile = getCPUProfile(CPU); |
| 3766 | if (!CPUProfile.empty()) |
| 3767 | Builder.defineMacro("__ARM_ARCH_PROFILE", CPUProfile); |
| 3768 | |
Mike Stump | 437bb4b | 2009-04-08 02:07:04 +0000 | [diff] [blame] | 3769 | // Subtarget options. |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 3770 | |
Daniel Dunbar | eac7c53 | 2009-12-18 18:42:37 +0000 | [diff] [blame] | 3771 | // FIXME: It's more complicated than this and we don't really support |
| 3772 | // interworking. |
| 3773 | if ('5' <= CPUArch[0] && CPUArch[0] <= '7') |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3774 | Builder.defineMacro("__THUMB_INTERWORK__"); |
Daniel Dunbar | eac7c53 | 2009-12-18 18:42:37 +0000 | [diff] [blame] | 3775 | |
David Tweed | b16abb1 | 2012-10-25 13:33:01 +0000 | [diff] [blame] | 3776 | if (ABI == "aapcs" || ABI == "aapcs-linux" || ABI == "aapcs-vfp") { |
Daniel Dunbar | 849289e | 2012-10-22 18:51:13 +0000 | [diff] [blame] | 3777 | // M-class CPUs on Darwin follow AAPCS, but not EABI. |
Daniel Dunbar | 4d3ee9b | 2012-10-22 18:56:43 +0000 | [diff] [blame] | 3778 | if (!(getTriple().isOSDarwin() && CPUProfile == "M")) |
Daniel Dunbar | 849289e | 2012-10-22 18:51:13 +0000 | [diff] [blame] | 3779 | Builder.defineMacro("__ARM_EABI__"); |
Anton Korobeynikov | 70a5cca | 2012-09-08 08:08:27 +0000 | [diff] [blame] | 3780 | Builder.defineMacro("__ARM_PCS", "1"); |
| 3781 | |
David Tweed | b16abb1 | 2012-10-25 13:33:01 +0000 | [diff] [blame] | 3782 | if ((!SoftFloat && !SoftFloatABI) || ABI == "aapcs-vfp") |
Anton Korobeynikov | 70a5cca | 2012-09-08 08:08:27 +0000 | [diff] [blame] | 3783 | Builder.defineMacro("__ARM_PCS_VFP", "1"); |
| 3784 | } |
Daniel Dunbar | eac7c53 | 2009-12-18 18:42:37 +0000 | [diff] [blame] | 3785 | |
Daniel Dunbar | 97f52ac | 2009-12-19 04:15:38 +0000 | [diff] [blame] | 3786 | if (SoftFloat) |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3787 | Builder.defineMacro("__SOFTFP__"); |
Daniel Dunbar | eac7c53 | 2009-12-18 18:42:37 +0000 | [diff] [blame] | 3788 | |
| 3789 | if (CPU == "xscale") |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3790 | Builder.defineMacro("__XSCALE__"); |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 3791 | |
Bob Wilson | 84f95cf | 2011-05-13 18:56:03 +0000 | [diff] [blame] | 3792 | bool IsARMv7 = CPUArch.startswith("7"); |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 3793 | if (IsThumb) { |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3794 | Builder.defineMacro("__THUMBEL__"); |
| 3795 | Builder.defineMacro("__thumb__"); |
Bob Wilson | 84f95cf | 2011-05-13 18:56:03 +0000 | [diff] [blame] | 3796 | if (CPUArch == "6T2" || IsARMv7) |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3797 | Builder.defineMacro("__thumb2__"); |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 3798 | } |
| 3799 | |
| 3800 | // Note, this is always on in gcc, even though it doesn't make sense. |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3801 | Builder.defineMacro("__APCS_32__"); |
Daniel Dunbar | a91320b | 2009-12-21 23:28:17 +0000 | [diff] [blame] | 3802 | |
Bob Wilson | cfaab00 | 2012-09-29 23:52:52 +0000 | [diff] [blame] | 3803 | if (FPUModeIsVFP((FPUMode) FPU)) { |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3804 | Builder.defineMacro("__VFP_FP__"); |
Bob Wilson | cfaab00 | 2012-09-29 23:52:52 +0000 | [diff] [blame] | 3805 | if (FPU & VFP2FPU) |
| 3806 | Builder.defineMacro("__ARM_VFPV2__"); |
| 3807 | if (FPU & VFP3FPU) |
| 3808 | Builder.defineMacro("__ARM_VFPV3__"); |
| 3809 | if (FPU & VFP4FPU) |
| 3810 | Builder.defineMacro("__ARM_VFPV4__"); |
| 3811 | } |
| 3812 | |
Daniel Dunbar | a91320b | 2009-12-21 23:28:17 +0000 | [diff] [blame] | 3813 | // This only gets set when Neon instructions are actually available, unlike |
| 3814 | // the VFP define, hence the soft float and arch check. This is subtly |
| 3815 | // different from gcc, we follow the intent which was that it should be set |
| 3816 | // when Neon instructions are actually available. |
Bob Wilson | cfaab00 | 2012-09-29 23:52:52 +0000 | [diff] [blame] | 3817 | if ((FPU & NeonFPU) && !SoftFloat && IsARMv7) |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 3818 | Builder.defineMacro("__ARM_NEON__"); |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 3819 | } |
| 3820 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 3821 | unsigned &NumRecords) const { |
Chris Lattner | 2752c01 | 2010-03-03 19:03:45 +0000 | [diff] [blame] | 3822 | Records = BuiltinInfo; |
| 3823 | NumRecords = clang::ARM::LastTSBuiltin-Builtin::FirstTSBuiltin; |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 3824 | } |
Bob Wilson | 8b30a93 | 2012-01-26 22:14:27 +0000 | [diff] [blame] | 3825 | virtual bool isCLZForZeroUndef() const { return false; } |
Meador Inge | c5613b2 | 2012-06-16 03:34:49 +0000 | [diff] [blame] | 3826 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
Logan Chien | eae5a820 | 2012-10-10 06:56:20 +0000 | [diff] [blame] | 3827 | return IsAAPCS ? AAPCSABIBuiltinVaList : TargetInfo::VoidPtrBuiltinVaList; |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 3828 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 3829 | virtual void getGCCRegNames(const char * const *&Names, |
Daniel Dunbar | c1f2cdd | 2009-09-17 07:03:19 +0000 | [diff] [blame] | 3830 | unsigned &NumNames) const; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 3831 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
Daniel Dunbar | c1f2cdd | 2009-09-17 07:03:19 +0000 | [diff] [blame] | 3832 | unsigned &NumAliases) const; |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 3833 | virtual bool validateAsmConstraint(const char *&Name, |
Chris Lattner | 44def07 | 2009-04-26 07:16:29 +0000 | [diff] [blame] | 3834 | TargetInfo::ConstraintInfo &Info) const { |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 3835 | switch (*Name) { |
Eric Christopher | a0dfca1 | 2012-08-16 23:50:41 +0000 | [diff] [blame] | 3836 | default: break; |
Nate Begeman | ad487f4 | 2008-04-22 05:03:19 +0000 | [diff] [blame] | 3837 | case 'l': // r0-r7 |
| 3838 | case 'h': // r8-r15 |
| 3839 | case 'w': // VFP Floating point register single precision |
| 3840 | case 'P': // VFP Floating point register double precision |
Chris Lattner | 44def07 | 2009-04-26 07:16:29 +0000 | [diff] [blame] | 3841 | Info.setAllowsRegister(); |
Nate Begeman | ad487f4 | 2008-04-22 05:03:19 +0000 | [diff] [blame] | 3842 | return true; |
Eric Christopher | 895d422 | 2011-07-29 21:20:35 +0000 | [diff] [blame] | 3843 | case 'Q': // A memory address that is a single base register. |
| 3844 | Info.setAllowsMemory(); |
| 3845 | return true; |
Stuart Hastings | 002333f | 2011-06-07 23:45:05 +0000 | [diff] [blame] | 3846 | case 'U': // a memory reference... |
| 3847 | switch (Name[1]) { |
| 3848 | case 'q': // ...ARMV4 ldrsb |
| 3849 | case 'v': // ...VFP load/store (reg+constant offset) |
| 3850 | case 'y': // ...iWMMXt load/store |
Eric Christopher | dda231a | 2011-06-17 01:40:49 +0000 | [diff] [blame] | 3851 | case 't': // address valid for load/store opaque types wider |
Eric Christopher | 825d386 | 2012-11-14 22:08:59 +0000 | [diff] [blame] | 3852 | // than 128-bits |
Eric Christopher | dda231a | 2011-06-17 01:40:49 +0000 | [diff] [blame] | 3853 | case 'n': // valid address for Neon doubleword vector load/store |
| 3854 | case 'm': // valid address for Neon element and structure load/store |
| 3855 | case 's': // valid address for non-offset loads/stores of quad-word |
Eric Christopher | 825d386 | 2012-11-14 22:08:59 +0000 | [diff] [blame] | 3856 | // values in four ARM registers |
Stuart Hastings | 002333f | 2011-06-07 23:45:05 +0000 | [diff] [blame] | 3857 | Info.setAllowsMemory(); |
| 3858 | Name++; |
| 3859 | return true; |
| 3860 | } |
Nate Begeman | ad487f4 | 2008-04-22 05:03:19 +0000 | [diff] [blame] | 3861 | } |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 3862 | return false; |
| 3863 | } |
Evan Cheng | 8bfa257 | 2011-06-16 19:13:15 +0000 | [diff] [blame] | 3864 | virtual std::string convertConstraint(const char *&Constraint) const { |
Stuart Hastings | 002333f | 2011-06-07 23:45:05 +0000 | [diff] [blame] | 3865 | std::string R; |
| 3866 | switch (*Constraint) { |
| 3867 | case 'U': // Two-character constraint; add "^" hint for later parsing. |
Stuart Hastings | 6ce33d6 | 2011-06-08 16:06:31 +0000 | [diff] [blame] | 3868 | R = std::string("^") + std::string(Constraint, 2); |
Stuart Hastings | 002333f | 2011-06-07 23:45:05 +0000 | [diff] [blame] | 3869 | Constraint++; |
| 3870 | break; |
Eric Christopher | 283f447 | 2011-06-17 00:40:18 +0000 | [diff] [blame] | 3871 | case 'p': // 'p' should be translated to 'r' by default. |
| 3872 | R = std::string("r"); |
| 3873 | break; |
Stuart Hastings | 002333f | 2011-06-07 23:45:05 +0000 | [diff] [blame] | 3874 | default: |
| 3875 | return std::string(1, *Constraint); |
| 3876 | } |
| 3877 | return R; |
| 3878 | } |
Bill Wendling | 50d46ca | 2012-10-25 23:28:48 +0000 | [diff] [blame] | 3879 | virtual bool validateConstraintModifier(StringRef Constraint, |
| 3880 | const char Modifier, |
| 3881 | unsigned Size) const { |
Bill Wendling | e2dbaa9 | 2012-11-30 23:18:12 +0000 | [diff] [blame] | 3882 | bool isOutput = (Constraint[0] == '='); |
Bill Wendling | 6e6330c | 2012-11-30 23:46:56 +0000 | [diff] [blame] | 3883 | bool isInOut = (Constraint[0] == '+'); |
Bill Wendling | e2dbaa9 | 2012-11-30 23:18:12 +0000 | [diff] [blame] | 3884 | |
Bill Wendling | 50d46ca | 2012-10-25 23:28:48 +0000 | [diff] [blame] | 3885 | // Strip off constraint modifiers. |
| 3886 | while (Constraint[0] == '=' || |
| 3887 | Constraint[0] == '+' || |
| 3888 | Constraint[0] == '&') |
| 3889 | Constraint = Constraint.substr(1); |
| 3890 | |
| 3891 | switch (Constraint[0]) { |
| 3892 | default: break; |
| 3893 | case 'r': { |
| 3894 | switch (Modifier) { |
| 3895 | default: |
Bob Wilson | 221a890 | 2013-06-03 23:57:13 +0000 | [diff] [blame] | 3896 | return (isInOut || isOutput || Size <= 32); |
Bill Wendling | 50d46ca | 2012-10-25 23:28:48 +0000 | [diff] [blame] | 3897 | case 'q': |
| 3898 | // A register of size 32 cannot fit a vector type. |
| 3899 | return false; |
| 3900 | } |
| 3901 | } |
| 3902 | } |
| 3903 | |
| 3904 | return true; |
| 3905 | } |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 3906 | virtual const char *getClobbers() const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 3907 | // FIXME: Is this really right? |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 3908 | return ""; |
| 3909 | } |
Aaron Ballman | 82bfa19 | 2012-10-02 14:26:08 +0000 | [diff] [blame] | 3910 | |
| 3911 | virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const { |
| 3912 | return (CC == CC_AAPCS || CC == CC_AAPCS_VFP) ? CCCR_OK : CCCR_Warning; |
| 3913 | } |
Logan Chien | a8f7a97 | 2013-02-23 04:24:36 +0000 | [diff] [blame] | 3914 | |
| 3915 | virtual int getEHDataRegisterNumber(unsigned RegNo) const { |
| 3916 | if (RegNo == 0) return 0; |
| 3917 | if (RegNo == 1) return 1; |
| 3918 | return -1; |
| 3919 | } |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 3920 | }; |
Daniel Dunbar | c1f2cdd | 2009-09-17 07:03:19 +0000 | [diff] [blame] | 3921 | |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 3922 | bool ARMTargetInfo::setFPMath(StringRef Name) { |
| 3923 | if (Name == "neon") { |
| 3924 | FPMath = FP_Neon; |
| 3925 | return true; |
| 3926 | } else if (Name == "vfp" || Name == "vfp2" || Name == "vfp3" || |
| 3927 | Name == "vfp4") { |
| 3928 | FPMath = FP_VFP; |
| 3929 | return true; |
| 3930 | } |
| 3931 | return false; |
| 3932 | } |
| 3933 | |
Daniel Dunbar | c1f2cdd | 2009-09-17 07:03:19 +0000 | [diff] [blame] | 3934 | const char * const ARMTargetInfo::GCCRegNames[] = { |
Daniel Dunbar | bf3d552 | 2010-08-11 02:17:20 +0000 | [diff] [blame] | 3935 | // Integer registers |
Daniel Dunbar | c1f2cdd | 2009-09-17 07:03:19 +0000 | [diff] [blame] | 3936 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
Daniel Dunbar | bf3d552 | 2010-08-11 02:17:20 +0000 | [diff] [blame] | 3937 | "r8", "r9", "r10", "r11", "r12", "sp", "lr", "pc", |
| 3938 | |
| 3939 | // Float registers |
| 3940 | "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", |
| 3941 | "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", |
| 3942 | "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", |
Dale Johannesen | 20eb49b | 2010-10-27 23:34:42 +0000 | [diff] [blame] | 3943 | "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31", |
Daniel Dunbar | bf3d552 | 2010-08-11 02:17:20 +0000 | [diff] [blame] | 3944 | |
Dale Johannesen | 20eb49b | 2010-10-27 23:34:42 +0000 | [diff] [blame] | 3945 | // Double registers |
| 3946 | "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", |
| 3947 | "d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15", |
Dale Johannesen | d145535 | 2010-10-28 01:05:37 +0000 | [diff] [blame] | 3948 | "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23", |
| 3949 | "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31", |
Dale Johannesen | 20eb49b | 2010-10-27 23:34:42 +0000 | [diff] [blame] | 3950 | |
| 3951 | // Quad registers |
Dale Johannesen | d145535 | 2010-10-28 01:05:37 +0000 | [diff] [blame] | 3952 | "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", |
| 3953 | "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15" |
Daniel Dunbar | c1f2cdd | 2009-09-17 07:03:19 +0000 | [diff] [blame] | 3954 | }; |
| 3955 | |
| 3956 | void ARMTargetInfo::getGCCRegNames(const char * const *&Names, |
Daniel Dunbar | 1fd7171 | 2010-08-11 02:17:11 +0000 | [diff] [blame] | 3957 | unsigned &NumNames) const { |
Daniel Dunbar | c1f2cdd | 2009-09-17 07:03:19 +0000 | [diff] [blame] | 3958 | Names = GCCRegNames; |
| 3959 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 3960 | } |
| 3961 | |
| 3962 | const TargetInfo::GCCRegAlias ARMTargetInfo::GCCRegAliases[] = { |
Daniel Dunbar | c1f2cdd | 2009-09-17 07:03:19 +0000 | [diff] [blame] | 3963 | { { "a1" }, "r0" }, |
| 3964 | { { "a2" }, "r1" }, |
| 3965 | { { "a3" }, "r2" }, |
| 3966 | { { "a4" }, "r3" }, |
| 3967 | { { "v1" }, "r4" }, |
| 3968 | { { "v2" }, "r5" }, |
| 3969 | { { "v3" }, "r6" }, |
| 3970 | { { "v4" }, "r7" }, |
| 3971 | { { "v5" }, "r8" }, |
| 3972 | { { "v6", "rfp" }, "r9" }, |
| 3973 | { { "sl" }, "r10" }, |
| 3974 | { { "fp" }, "r11" }, |
| 3975 | { { "ip" }, "r12" }, |
Daniel Dunbar | 1fd7171 | 2010-08-11 02:17:11 +0000 | [diff] [blame] | 3976 | { { "r13" }, "sp" }, |
| 3977 | { { "r14" }, "lr" }, |
| 3978 | { { "r15" }, "pc" }, |
Dale Johannesen | 20eb49b | 2010-10-27 23:34:42 +0000 | [diff] [blame] | 3979 | // The S, D and Q registers overlap, but aren't really aliases; we |
| 3980 | // don't want to substitute one of these for a different-sized one. |
Daniel Dunbar | c1f2cdd | 2009-09-17 07:03:19 +0000 | [diff] [blame] | 3981 | }; |
| 3982 | |
| 3983 | void ARMTargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 3984 | unsigned &NumAliases) const { |
| 3985 | Aliases = GCCRegAliases; |
| 3986 | NumAliases = llvm::array_lengthof(GCCRegAliases); |
| 3987 | } |
Chris Lattner | 2752c01 | 2010-03-03 19:03:45 +0000 | [diff] [blame] | 3988 | |
| 3989 | const Builtin::Info ARMTargetInfo::BuiltinInfo[] = { |
Eli Friedman | e7e66f7 | 2011-07-05 21:53:01 +0000 | [diff] [blame] | 3990 | #define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, ALL_LANGUAGES }, |
Fariborz Jahanian | 67aba81 | 2010-11-30 17:35:24 +0000 | [diff] [blame] | 3991 | #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER,\ |
Eli Friedman | e7e66f7 | 2011-07-05 21:53:01 +0000 | [diff] [blame] | 3992 | ALL_LANGUAGES }, |
Chris Lattner | 2752c01 | 2010-03-03 19:03:45 +0000 | [diff] [blame] | 3993 | #include "clang/Basic/BuiltinsARM.def" |
| 3994 | }; |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 3995 | } // end anonymous namespace. |
| 3996 | |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 3997 | namespace { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3998 | class DarwinARMTargetInfo : |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 3999 | public DarwinTargetInfo<ARMTargetInfo> { |
| 4000 | protected: |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 4001 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 4002 | MacroBuilder &Builder) const { |
Douglas Gregor | 0a0d2b1 | 2011-03-23 00:50:03 +0000 | [diff] [blame] | 4003 | getDarwinDefines(Builder, Opts, Triple, PlatformName, PlatformMinVersion); |
Eli Friedman | b030f02 | 2009-04-19 21:38:35 +0000 | [diff] [blame] | 4004 | } |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 4005 | |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 4006 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 4007 | DarwinARMTargetInfo(const llvm::Triple &Triple) |
| 4008 | : DarwinTargetInfo<ARMTargetInfo>(Triple) { |
Daniel Dunbar | 350b9f3 | 2010-05-27 07:00:26 +0000 | [diff] [blame] | 4009 | HasAlignMac68kSupport = true; |
Eli Friedman | 2be4607 | 2011-10-14 20:59:01 +0000 | [diff] [blame] | 4010 | // iOS always has 64-bit atomic instructions. |
| 4011 | // FIXME: This should be based off of the target features in ARMTargetInfo. |
| 4012 | MaxAtomicInlineWidth = 64; |
John McCall | b8b2c9d | 2013-01-25 22:30:49 +0000 | [diff] [blame] | 4013 | |
| 4014 | // Darwin on iOS uses a variant of the ARM C++ ABI. |
| 4015 | TheCXXABI.set(TargetCXXABI::iOS); |
Daniel Dunbar | 350b9f3 | 2010-05-27 07:00:26 +0000 | [diff] [blame] | 4016 | } |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 4017 | }; |
| 4018 | } // end anonymous namespace. |
| 4019 | |
Tony Linthicum | 9631939 | 2011-12-12 21:14:55 +0000 | [diff] [blame] | 4020 | |
| 4021 | namespace { |
| 4022 | // Hexagon abstract base class |
| 4023 | class HexagonTargetInfo : public TargetInfo { |
| 4024 | static const Builtin::Info BuiltinInfo[]; |
| 4025 | static const char * const GCCRegNames[]; |
| 4026 | static const TargetInfo::GCCRegAlias GCCRegAliases[]; |
| 4027 | std::string CPU; |
| 4028 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 4029 | HexagonTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) { |
Eli Friedman | e6a24e8 | 2011-12-22 03:51:45 +0000 | [diff] [blame] | 4030 | BigEndian = false; |
Tony Linthicum | 9631939 | 2011-12-12 21:14:55 +0000 | [diff] [blame] | 4031 | DescriptionString = ("e-p:32:32:32-" |
Anshuman Dasgupta | 1a090f1 | 2013-01-02 21:25:57 +0000 | [diff] [blame] | 4032 | "i64:64:64-i32:32:32-i16:16:16-i1:32:32-" |
Sirish Pande | 5f9688b | 2012-05-10 20:19:54 +0000 | [diff] [blame] | 4033 | "f64:64:64-f32:32:32-a0:0-n32"); |
Tony Linthicum | 9631939 | 2011-12-12 21:14:55 +0000 | [diff] [blame] | 4034 | |
| 4035 | // {} in inline assembly are packet specifiers, not assembly variant |
| 4036 | // specifiers. |
| 4037 | NoAsmVariants = true; |
| 4038 | } |
| 4039 | |
| 4040 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 4041 | unsigned &NumRecords) const { |
| 4042 | Records = BuiltinInfo; |
| 4043 | NumRecords = clang::Hexagon::LastTSBuiltin-Builtin::FirstTSBuiltin; |
| 4044 | } |
| 4045 | |
| 4046 | virtual bool validateAsmConstraint(const char *&Name, |
| 4047 | TargetInfo::ConstraintInfo &Info) const { |
| 4048 | return true; |
| 4049 | } |
| 4050 | |
| 4051 | virtual void getTargetDefines(const LangOptions &Opts, |
| 4052 | MacroBuilder &Builder) const; |
| 4053 | |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 4054 | virtual bool hasFeature(StringRef Feature) const { |
| 4055 | return Feature == "hexagon"; |
| 4056 | } |
| 4057 | |
Meador Inge | c5613b2 | 2012-06-16 03:34:49 +0000 | [diff] [blame] | 4058 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
| 4059 | return TargetInfo::CharPtrBuiltinVaList; |
Tony Linthicum | 9631939 | 2011-12-12 21:14:55 +0000 | [diff] [blame] | 4060 | } |
| 4061 | virtual void getGCCRegNames(const char * const *&Names, |
| 4062 | unsigned &NumNames) const; |
| 4063 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 4064 | unsigned &NumAliases) const; |
| 4065 | virtual const char *getClobbers() const { |
| 4066 | return ""; |
| 4067 | } |
Sebastian Pop | 43115d4 | 2012-01-13 20:37:10 +0000 | [diff] [blame] | 4068 | |
| 4069 | static const char *getHexagonCPUSuffix(StringRef Name) { |
| 4070 | return llvm::StringSwitch<const char*>(Name) |
Sebastian Pop | 43115d4 | 2012-01-13 20:37:10 +0000 | [diff] [blame] | 4071 | .Case("hexagonv4", "4") |
Sirish Pande | 5f9688b | 2012-05-10 20:19:54 +0000 | [diff] [blame] | 4072 | .Case("hexagonv5", "5") |
Sebastian Pop | 43115d4 | 2012-01-13 20:37:10 +0000 | [diff] [blame] | 4073 | .Default(0); |
| 4074 | } |
| 4075 | |
Tony Linthicum | 9631939 | 2011-12-12 21:14:55 +0000 | [diff] [blame] | 4076 | virtual bool setCPU(const std::string &Name) { |
Sebastian Pop | 43115d4 | 2012-01-13 20:37:10 +0000 | [diff] [blame] | 4077 | if (!getHexagonCPUSuffix(Name)) |
| 4078 | return false; |
| 4079 | |
Tony Linthicum | 9631939 | 2011-12-12 21:14:55 +0000 | [diff] [blame] | 4080 | CPU = Name; |
| 4081 | return true; |
| 4082 | } |
| 4083 | }; |
| 4084 | |
| 4085 | void HexagonTargetInfo::getTargetDefines(const LangOptions &Opts, |
| 4086 | MacroBuilder &Builder) const { |
| 4087 | Builder.defineMacro("qdsp6"); |
| 4088 | Builder.defineMacro("__qdsp6", "1"); |
| 4089 | Builder.defineMacro("__qdsp6__", "1"); |
| 4090 | |
| 4091 | Builder.defineMacro("hexagon"); |
| 4092 | Builder.defineMacro("__hexagon", "1"); |
| 4093 | Builder.defineMacro("__hexagon__", "1"); |
| 4094 | |
| 4095 | if(CPU == "hexagonv1") { |
| 4096 | Builder.defineMacro("__HEXAGON_V1__"); |
| 4097 | Builder.defineMacro("__HEXAGON_ARCH__", "1"); |
| 4098 | if(Opts.HexagonQdsp6Compat) { |
| 4099 | Builder.defineMacro("__QDSP6_V1__"); |
| 4100 | Builder.defineMacro("__QDSP6_ARCH__", "1"); |
| 4101 | } |
| 4102 | } |
| 4103 | else if(CPU == "hexagonv2") { |
| 4104 | Builder.defineMacro("__HEXAGON_V2__"); |
| 4105 | Builder.defineMacro("__HEXAGON_ARCH__", "2"); |
| 4106 | if(Opts.HexagonQdsp6Compat) { |
| 4107 | Builder.defineMacro("__QDSP6_V2__"); |
| 4108 | Builder.defineMacro("__QDSP6_ARCH__", "2"); |
| 4109 | } |
| 4110 | } |
| 4111 | else if(CPU == "hexagonv3") { |
| 4112 | Builder.defineMacro("__HEXAGON_V3__"); |
| 4113 | Builder.defineMacro("__HEXAGON_ARCH__", "3"); |
| 4114 | if(Opts.HexagonQdsp6Compat) { |
| 4115 | Builder.defineMacro("__QDSP6_V3__"); |
| 4116 | Builder.defineMacro("__QDSP6_ARCH__", "3"); |
| 4117 | } |
| 4118 | } |
| 4119 | else if(CPU == "hexagonv4") { |
| 4120 | Builder.defineMacro("__HEXAGON_V4__"); |
| 4121 | Builder.defineMacro("__HEXAGON_ARCH__", "4"); |
| 4122 | if(Opts.HexagonQdsp6Compat) { |
| 4123 | Builder.defineMacro("__QDSP6_V4__"); |
| 4124 | Builder.defineMacro("__QDSP6_ARCH__", "4"); |
| 4125 | } |
| 4126 | } |
Sirish Pande | 5f9688b | 2012-05-10 20:19:54 +0000 | [diff] [blame] | 4127 | else if(CPU == "hexagonv5") { |
| 4128 | Builder.defineMacro("__HEXAGON_V5__"); |
| 4129 | Builder.defineMacro("__HEXAGON_ARCH__", "5"); |
| 4130 | if(Opts.HexagonQdsp6Compat) { |
| 4131 | Builder.defineMacro("__QDSP6_V5__"); |
| 4132 | Builder.defineMacro("__QDSP6_ARCH__", "5"); |
| 4133 | } |
| 4134 | } |
Tony Linthicum | 9631939 | 2011-12-12 21:14:55 +0000 | [diff] [blame] | 4135 | } |
| 4136 | |
| 4137 | const char * const HexagonTargetInfo::GCCRegNames[] = { |
| 4138 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
| 4139 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", |
| 4140 | "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", |
| 4141 | "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", |
| 4142 | "p0", "p1", "p2", "p3", |
| 4143 | "sa0", "lc0", "sa1", "lc1", "m0", "m1", "usr", "ugp" |
| 4144 | }; |
| 4145 | |
| 4146 | void HexagonTargetInfo::getGCCRegNames(const char * const *&Names, |
| 4147 | unsigned &NumNames) const { |
| 4148 | Names = GCCRegNames; |
| 4149 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 4150 | } |
| 4151 | |
| 4152 | |
| 4153 | const TargetInfo::GCCRegAlias HexagonTargetInfo::GCCRegAliases[] = { |
| 4154 | { { "sp" }, "r29" }, |
| 4155 | { { "fp" }, "r30" }, |
| 4156 | { { "lr" }, "r31" }, |
| 4157 | }; |
| 4158 | |
| 4159 | void HexagonTargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 4160 | unsigned &NumAliases) const { |
| 4161 | Aliases = GCCRegAliases; |
| 4162 | NumAliases = llvm::array_lengthof(GCCRegAliases); |
| 4163 | } |
| 4164 | |
| 4165 | |
| 4166 | const Builtin::Info HexagonTargetInfo::BuiltinInfo[] = { |
| 4167 | #define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, ALL_LANGUAGES }, |
| 4168 | #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER,\ |
| 4169 | ALL_LANGUAGES }, |
| 4170 | #include "clang/Basic/BuiltinsHexagon.def" |
| 4171 | }; |
| 4172 | } |
| 4173 | |
| 4174 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 4175 | namespace { |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 4176 | // Shared base class for SPARC v8 (32-bit) and SPARC v9 (64-bit). |
| 4177 | class SparcTargetInfo : public TargetInfo { |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 4178 | static const TargetInfo::GCCRegAlias GCCRegAliases[]; |
| 4179 | static const char * const GCCRegNames[]; |
Bruno Cardoso Lopes | 9284d21 | 2010-11-09 17:21:19 +0000 | [diff] [blame] | 4180 | bool SoftFloat; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 4181 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 4182 | SparcTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {} |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 4183 | |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 4184 | virtual bool HandleTargetFeatures(std::vector<std::string> &Features, |
| 4185 | DiagnosticsEngine &Diags) { |
Bruno Cardoso Lopes | 9284d21 | 2010-11-09 17:21:19 +0000 | [diff] [blame] | 4186 | SoftFloat = false; |
| 4187 | for (unsigned i = 0, e = Features.size(); i != e; ++i) |
| 4188 | if (Features[i] == "+soft-float") |
| 4189 | SoftFloat = true; |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 4190 | return true; |
Bruno Cardoso Lopes | 9284d21 | 2010-11-09 17:21:19 +0000 | [diff] [blame] | 4191 | } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 4192 | virtual void getTargetDefines(const LangOptions &Opts, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 4193 | MacroBuilder &Builder) const { |
| 4194 | DefineStd(Builder, "sparc", Opts); |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 4195 | Builder.defineMacro("__REGISTER_PREFIX__", ""); |
Bruno Cardoso Lopes | 9284d21 | 2010-11-09 17:21:19 +0000 | [diff] [blame] | 4196 | |
| 4197 | if (SoftFloat) |
| 4198 | Builder.defineMacro("SOFT_FLOAT", "1"); |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 4199 | } |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 4200 | |
| 4201 | virtual bool hasFeature(StringRef Feature) const { |
| 4202 | return llvm::StringSwitch<bool>(Feature) |
| 4203 | .Case("softfloat", SoftFloat) |
| 4204 | .Case("sparc", true) |
| 4205 | .Default(false); |
| 4206 | } |
| 4207 | |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 4208 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 4209 | unsigned &NumRecords) const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 4210 | // FIXME: Implement! |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 4211 | } |
Meador Inge | c5613b2 | 2012-06-16 03:34:49 +0000 | [diff] [blame] | 4212 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
| 4213 | return TargetInfo::VoidPtrBuiltinVaList; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 4214 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 4215 | virtual void getGCCRegNames(const char * const *&Names, |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 4216 | unsigned &NumNames) const; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 4217 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 4218 | unsigned &NumAliases) const; |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 4219 | virtual bool validateAsmConstraint(const char *&Name, |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 4220 | TargetInfo::ConstraintInfo &info) const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 4221 | // FIXME: Implement! |
| 4222 | return false; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 4223 | } |
| 4224 | virtual const char *getClobbers() const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 4225 | // FIXME: Implement! |
| 4226 | return ""; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 4227 | } |
| 4228 | }; |
| 4229 | |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 4230 | const char * const SparcTargetInfo::GCCRegNames[] = { |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 4231 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
| 4232 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", |
| 4233 | "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", |
| 4234 | "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31" |
| 4235 | }; |
| 4236 | |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 4237 | void SparcTargetInfo::getGCCRegNames(const char * const *&Names, |
| 4238 | unsigned &NumNames) const { |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 4239 | Names = GCCRegNames; |
| 4240 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 4241 | } |
| 4242 | |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 4243 | const TargetInfo::GCCRegAlias SparcTargetInfo::GCCRegAliases[] = { |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 4244 | { { "g0" }, "r0" }, |
| 4245 | { { "g1" }, "r1" }, |
| 4246 | { { "g2" }, "r2" }, |
| 4247 | { { "g3" }, "r3" }, |
| 4248 | { { "g4" }, "r4" }, |
| 4249 | { { "g5" }, "r5" }, |
| 4250 | { { "g6" }, "r6" }, |
| 4251 | { { "g7" }, "r7" }, |
| 4252 | { { "o0" }, "r8" }, |
| 4253 | { { "o1" }, "r9" }, |
| 4254 | { { "o2" }, "r10" }, |
| 4255 | { { "o3" }, "r11" }, |
| 4256 | { { "o4" }, "r12" }, |
| 4257 | { { "o5" }, "r13" }, |
| 4258 | { { "o6", "sp" }, "r14" }, |
| 4259 | { { "o7" }, "r15" }, |
| 4260 | { { "l0" }, "r16" }, |
| 4261 | { { "l1" }, "r17" }, |
| 4262 | { { "l2" }, "r18" }, |
| 4263 | { { "l3" }, "r19" }, |
| 4264 | { { "l4" }, "r20" }, |
| 4265 | { { "l5" }, "r21" }, |
| 4266 | { { "l6" }, "r22" }, |
| 4267 | { { "l7" }, "r23" }, |
| 4268 | { { "i0" }, "r24" }, |
| 4269 | { { "i1" }, "r25" }, |
| 4270 | { { "i2" }, "r26" }, |
| 4271 | { { "i3" }, "r27" }, |
| 4272 | { { "i4" }, "r28" }, |
| 4273 | { { "i5" }, "r29" }, |
| 4274 | { { "i6", "fp" }, "r30" }, |
| 4275 | { { "i7" }, "r31" }, |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 4276 | }; |
| 4277 | |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 4278 | void SparcTargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 4279 | unsigned &NumAliases) const { |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 4280 | Aliases = GCCRegAliases; |
| 4281 | NumAliases = llvm::array_lengthof(GCCRegAliases); |
| 4282 | } |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 4283 | |
| 4284 | // SPARC v8 is the 32-bit mode selected by Triple::sparc. |
| 4285 | class SparcV8TargetInfo : public SparcTargetInfo { |
| 4286 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 4287 | SparcV8TargetInfo(const llvm::Triple &Triple) : SparcTargetInfo(Triple) { |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 4288 | // FIXME: Support Sparc quad-precision long double? |
| 4289 | DescriptionString = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 4290 | "i64:64:64-f32:32:32-f64:64:64-v64:64:64-n32-S64"; |
| 4291 | } |
| 4292 | |
| 4293 | virtual void getTargetDefines(const LangOptions &Opts, |
| 4294 | MacroBuilder &Builder) const { |
| 4295 | SparcTargetInfo::getTargetDefines(Opts, Builder); |
| 4296 | Builder.defineMacro("__sparcv8"); |
| 4297 | } |
| 4298 | }; |
| 4299 | |
| 4300 | // SPARC v9 is the 64-bit mode selected by Triple::sparcv9. |
| 4301 | class SparcV9TargetInfo : public SparcTargetInfo { |
| 4302 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 4303 | SparcV9TargetInfo(const llvm::Triple &Triple) : SparcTargetInfo(Triple) { |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 4304 | // FIXME: Support Sparc quad-precision long double? |
| 4305 | DescriptionString = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 4306 | "i64:64:64-f32:32:32-f64:64:64-v64:64:64-n32:64-S128"; |
Jakob Stoklund Olesen | fcec0c9 | 2013-05-15 03:22:33 +0000 | [diff] [blame] | 4307 | // This is an LP64 platform. |
| 4308 | LongWidth = LongAlign = PointerWidth = PointerAlign = 64; |
Jakob Stoklund Olesen | 5ac8c4f | 2013-05-19 17:53:37 +0000 | [diff] [blame] | 4309 | |
| 4310 | // OpenBSD uses long long for int64_t and intmax_t. |
| 4311 | if (getTriple().getOS() == llvm::Triple::OpenBSD) { |
| 4312 | IntMaxType = SignedLongLong; |
| 4313 | UIntMaxType = UnsignedLongLong; |
| 4314 | } else { |
| 4315 | IntMaxType = SignedLong; |
| 4316 | UIntMaxType = UnsignedLong; |
| 4317 | } |
| 4318 | Int64Type = IntMaxType; |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 4319 | } |
| 4320 | |
| 4321 | virtual void getTargetDefines(const LangOptions &Opts, |
| 4322 | MacroBuilder &Builder) const { |
| 4323 | SparcTargetInfo::getTargetDefines(Opts, Builder); |
| 4324 | Builder.defineMacro("__sparcv9"); |
Jakob Stoklund Olesen | 44f72d3 | 2013-04-24 04:36:38 +0000 | [diff] [blame] | 4325 | Builder.defineMacro("__arch64__"); |
| 4326 | // Solaris and its derivative AuroraUX don't need these variants, but the |
| 4327 | // BSDs do. |
| 4328 | if (getTriple().getOS() != llvm::Triple::Solaris && |
| 4329 | getTriple().getOS() != llvm::Triple::AuroraUX) { |
| 4330 | Builder.defineMacro("__sparc64__"); |
| 4331 | Builder.defineMacro("__sparc_v9__"); |
| 4332 | Builder.defineMacro("__sparcv9__"); |
| 4333 | } |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 4334 | } |
| 4335 | }; |
| 4336 | |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 4337 | } // end anonymous namespace. |
| 4338 | |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 4339 | namespace { |
Edward O'Callaghan | 991f9a7 | 2009-10-18 13:33:59 +0000 | [diff] [blame] | 4340 | class AuroraUXSparcV8TargetInfo : public AuroraUXTargetInfo<SparcV8TargetInfo> { |
| 4341 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 4342 | AuroraUXSparcV8TargetInfo(const llvm::Triple &Triple) |
| 4343 | : AuroraUXTargetInfo<SparcV8TargetInfo>(Triple) { |
Edward O'Callaghan | 991f9a7 | 2009-10-18 13:33:59 +0000 | [diff] [blame] | 4344 | SizeType = UnsignedInt; |
| 4345 | PtrDiffType = SignedInt; |
| 4346 | } |
| 4347 | }; |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 4348 | class SolarisSparcV8TargetInfo : public SolarisTargetInfo<SparcV8TargetInfo> { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 4349 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 4350 | SolarisSparcV8TargetInfo(const llvm::Triple &Triple) |
| 4351 | : SolarisTargetInfo<SparcV8TargetInfo>(Triple) { |
Eli Friedman | f509d73 | 2008-11-02 02:43:55 +0000 | [diff] [blame] | 4352 | SizeType = UnsignedInt; |
| 4353 | PtrDiffType = SignedInt; |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 4354 | } |
| 4355 | }; |
| 4356 | } // end anonymous namespace. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 4357 | |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 4358 | namespace { |
Ulrich Weigand | b840921 | 2013-05-06 16:26:41 +0000 | [diff] [blame] | 4359 | class SystemZTargetInfo : public TargetInfo { |
| 4360 | static const char *const GCCRegNames[]; |
| 4361 | |
| 4362 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 4363 | SystemZTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) { |
Ulrich Weigand | b840921 | 2013-05-06 16:26:41 +0000 | [diff] [blame] | 4364 | TLSSupported = true; |
| 4365 | IntWidth = IntAlign = 32; |
| 4366 | LongWidth = LongLongWidth = LongAlign = LongLongAlign = 64; |
| 4367 | PointerWidth = PointerAlign = 64; |
| 4368 | LongDoubleWidth = 128; |
| 4369 | LongDoubleAlign = 64; |
| 4370 | LongDoubleFormat = &llvm::APFloat::IEEEquad; |
| 4371 | MinGlobalAlign = 16; |
| 4372 | DescriptionString = "E-p:64:64:64-i1:8:16-i8:8:16-i16:16-i32:32-i64:64" |
| 4373 | "-f32:32-f64:64-f128:64-a0:8:16-n32:64"; |
| 4374 | MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; |
| 4375 | } |
| 4376 | virtual void getTargetDefines(const LangOptions &Opts, |
| 4377 | MacroBuilder &Builder) const { |
| 4378 | Builder.defineMacro("__s390__"); |
| 4379 | Builder.defineMacro("__s390x__"); |
| 4380 | Builder.defineMacro("__zarch__"); |
| 4381 | Builder.defineMacro("__LONG_DOUBLE_128__"); |
| 4382 | } |
| 4383 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 4384 | unsigned &NumRecords) const { |
| 4385 | // FIXME: Implement. |
| 4386 | Records = 0; |
| 4387 | NumRecords = 0; |
| 4388 | } |
| 4389 | |
| 4390 | virtual void getGCCRegNames(const char *const *&Names, |
| 4391 | unsigned &NumNames) const; |
| 4392 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 4393 | unsigned &NumAliases) const { |
| 4394 | // No aliases. |
| 4395 | Aliases = 0; |
| 4396 | NumAliases = 0; |
| 4397 | } |
| 4398 | virtual bool validateAsmConstraint(const char *&Name, |
| 4399 | TargetInfo::ConstraintInfo &info) const; |
| 4400 | virtual const char *getClobbers() const { |
| 4401 | // FIXME: Is this really right? |
| 4402 | return ""; |
| 4403 | } |
| 4404 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
| 4405 | return TargetInfo::SystemZBuiltinVaList; |
| 4406 | } |
Richard Sandiford | 5c92b9a | 2013-07-19 16:51:51 +0000 | [diff] [blame] | 4407 | virtual bool setCPU(const std::string &Name) { |
| 4408 | bool CPUKnown = llvm::StringSwitch<bool>(Name) |
| 4409 | .Case("z10", true) |
| 4410 | .Case("z196", true) |
| 4411 | .Case("zEC12", true) |
| 4412 | .Default(false); |
| 4413 | |
| 4414 | // No need to store the CPU yet. There aren't any CPU-specific |
| 4415 | // macros to define. |
| 4416 | return CPUKnown; |
| 4417 | } |
Ulrich Weigand | b840921 | 2013-05-06 16:26:41 +0000 | [diff] [blame] | 4418 | }; |
| 4419 | |
| 4420 | const char *const SystemZTargetInfo::GCCRegNames[] = { |
| 4421 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
| 4422 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", |
| 4423 | "f0", "f2", "f4", "f6", "f1", "f3", "f5", "f7", |
| 4424 | "f8", "f10", "f12", "f14", "f9", "f11", "f13", "f15" |
| 4425 | }; |
| 4426 | |
| 4427 | void SystemZTargetInfo::getGCCRegNames(const char *const *&Names, |
| 4428 | unsigned &NumNames) const { |
| 4429 | Names = GCCRegNames; |
| 4430 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 4431 | } |
| 4432 | |
| 4433 | bool SystemZTargetInfo:: |
| 4434 | validateAsmConstraint(const char *&Name, |
| 4435 | TargetInfo::ConstraintInfo &Info) const { |
| 4436 | switch (*Name) { |
| 4437 | default: |
| 4438 | return false; |
| 4439 | |
| 4440 | case 'a': // Address register |
| 4441 | case 'd': // Data register (equivalent to 'r') |
| 4442 | case 'f': // Floating-point register |
| 4443 | Info.setAllowsRegister(); |
| 4444 | return true; |
| 4445 | |
| 4446 | case 'I': // Unsigned 8-bit constant |
| 4447 | case 'J': // Unsigned 12-bit constant |
| 4448 | case 'K': // Signed 16-bit constant |
| 4449 | case 'L': // Signed 20-bit displacement (on all targets we support) |
| 4450 | case 'M': // 0x7fffffff |
| 4451 | return true; |
| 4452 | |
| 4453 | case 'Q': // Memory with base and unsigned 12-bit displacement |
| 4454 | case 'R': // Likewise, plus an index |
| 4455 | case 'S': // Memory with base and signed 20-bit displacement |
| 4456 | case 'T': // Likewise, plus an index |
| 4457 | Info.setAllowsMemory(); |
| 4458 | return true; |
| 4459 | } |
| 4460 | } |
| 4461 | } |
| 4462 | |
| 4463 | namespace { |
Anton Korobeynikov | 73c64e5 | 2009-05-03 13:43:08 +0000 | [diff] [blame] | 4464 | class MSP430TargetInfo : public TargetInfo { |
| 4465 | static const char * const GCCRegNames[]; |
| 4466 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 4467 | MSP430TargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) { |
Eli Friedman | e6a24e8 | 2011-12-22 03:51:45 +0000 | [diff] [blame] | 4468 | BigEndian = false; |
Anton Korobeynikov | 73c64e5 | 2009-05-03 13:43:08 +0000 | [diff] [blame] | 4469 | TLSSupported = false; |
Anton Korobeynikov | 09f52a6 | 2010-01-30 12:55:11 +0000 | [diff] [blame] | 4470 | IntWidth = 16; IntAlign = 16; |
| 4471 | LongWidth = 32; LongLongWidth = 64; |
| 4472 | LongAlign = LongLongAlign = 16; |
| 4473 | PointerWidth = 16; PointerAlign = 16; |
Nick Lewycky | 7ec59c7 | 2011-12-16 22:34:14 +0000 | [diff] [blame] | 4474 | SuitableAlign = 16; |
Anton Korobeynikov | 73c64e5 | 2009-05-03 13:43:08 +0000 | [diff] [blame] | 4475 | SizeType = UnsignedInt; |
Anton Korobeynikov | 18a295d | 2013-07-01 19:42:40 +0000 | [diff] [blame] | 4476 | IntMaxType = SignedLongLong; |
| 4477 | UIntMaxType = UnsignedLongLong; |
| 4478 | IntPtrType = SignedInt; |
Anton Korobeynikov | 73c64e5 | 2009-05-03 13:43:08 +0000 | [diff] [blame] | 4479 | PtrDiffType = SignedInt; |
Edward O'Callaghan | 9cf910e | 2009-11-21 00:49:54 +0000 | [diff] [blame] | 4480 | SigAtomicType = SignedLong; |
Anton Korobeynikov | 5d7c251 | 2009-12-19 01:32:37 +0000 | [diff] [blame] | 4481 | DescriptionString = "e-p:16:16:16-i8:8:8-i16:16:16-i32:16:32-n8:16"; |
Anton Korobeynikov | 73c64e5 | 2009-05-03 13:43:08 +0000 | [diff] [blame] | 4482 | } |
| 4483 | virtual void getTargetDefines(const LangOptions &Opts, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 4484 | MacroBuilder &Builder) const { |
| 4485 | Builder.defineMacro("MSP430"); |
| 4486 | Builder.defineMacro("__MSP430__"); |
Anton Korobeynikov | 73c64e5 | 2009-05-03 13:43:08 +0000 | [diff] [blame] | 4487 | // FIXME: defines for different 'flavours' of MCU |
| 4488 | } |
| 4489 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 4490 | unsigned &NumRecords) const { |
| 4491 | // FIXME: Implement. |
| 4492 | Records = 0; |
| 4493 | NumRecords = 0; |
| 4494 | } |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 4495 | virtual bool hasFeature(StringRef Feature) const { |
| 4496 | return Feature == "msp430"; |
| 4497 | } |
Anton Korobeynikov | 73c64e5 | 2009-05-03 13:43:08 +0000 | [diff] [blame] | 4498 | virtual void getGCCRegNames(const char * const *&Names, |
| 4499 | unsigned &NumNames) const; |
| 4500 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 4501 | unsigned &NumAliases) const { |
| 4502 | // No aliases. |
| 4503 | Aliases = 0; |
| 4504 | NumAliases = 0; |
| 4505 | } |
| 4506 | virtual bool validateAsmConstraint(const char *&Name, |
| 4507 | TargetInfo::ConstraintInfo &info) const { |
Anton Korobeynikov | 03265b6 | 2009-10-15 23:17:13 +0000 | [diff] [blame] | 4508 | // No target constraints for now. |
| 4509 | return false; |
Anton Korobeynikov | 73c64e5 | 2009-05-03 13:43:08 +0000 | [diff] [blame] | 4510 | } |
| 4511 | virtual const char *getClobbers() const { |
| 4512 | // FIXME: Is this really right? |
| 4513 | return ""; |
| 4514 | } |
Meador Inge | c5613b2 | 2012-06-16 03:34:49 +0000 | [diff] [blame] | 4515 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
Anton Korobeynikov | 73c64e5 | 2009-05-03 13:43:08 +0000 | [diff] [blame] | 4516 | // FIXME: implement |
Meador Inge | c5613b2 | 2012-06-16 03:34:49 +0000 | [diff] [blame] | 4517 | return TargetInfo::CharPtrBuiltinVaList; |
Anton Korobeynikov | 73c64e5 | 2009-05-03 13:43:08 +0000 | [diff] [blame] | 4518 | } |
| 4519 | }; |
| 4520 | |
| 4521 | const char * const MSP430TargetInfo::GCCRegNames[] = { |
| 4522 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
| 4523 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" |
| 4524 | }; |
| 4525 | |
| 4526 | void MSP430TargetInfo::getGCCRegNames(const char * const *&Names, |
| 4527 | unsigned &NumNames) const { |
| 4528 | Names = GCCRegNames; |
| 4529 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 4530 | } |
| 4531 | } |
| 4532 | |
Jakob Stoklund Olesen | 1eb4343 | 2009-08-17 20:08:44 +0000 | [diff] [blame] | 4533 | namespace { |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 4534 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 4535 | // LLVM and Clang cannot be used directly to output native binaries for |
| 4536 | // target, but is used to compile C code to llvm bitcode with correct |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 4537 | // type and alignment information. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 4538 | // |
| 4539 | // TCE uses the llvm bitcode as input and uses it for generating customized |
| 4540 | // target processor and program binary. TCE co-design environment is |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 4541 | // publicly available in http://tce.cs.tut.fi |
| 4542 | |
Eli Friedman | 209f5bb | 2011-10-07 19:51:42 +0000 | [diff] [blame] | 4543 | static const unsigned TCEOpenCLAddrSpaceMap[] = { |
| 4544 | 3, // opencl_global |
| 4545 | 4, // opencl_local |
Peter Collingbourne | 4dc34eb | 2012-05-20 21:08:35 +0000 | [diff] [blame] | 4546 | 5, // opencl_constant |
| 4547 | 0, // cuda_device |
| 4548 | 0, // cuda_constant |
| 4549 | 0 // cuda_shared |
Eli Friedman | 209f5bb | 2011-10-07 19:51:42 +0000 | [diff] [blame] | 4550 | }; |
| 4551 | |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 4552 | class TCETargetInfo : public TargetInfo{ |
| 4553 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 4554 | TCETargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) { |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 4555 | TLSSupported = false; |
| 4556 | IntWidth = 32; |
| 4557 | LongWidth = LongLongWidth = 32; |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 4558 | PointerWidth = 32; |
| 4559 | IntAlign = 32; |
| 4560 | LongAlign = LongLongAlign = 32; |
| 4561 | PointerAlign = 32; |
Nick Lewycky | 7ec59c7 | 2011-12-16 22:34:14 +0000 | [diff] [blame] | 4562 | SuitableAlign = 32; |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 4563 | SizeType = UnsignedInt; |
| 4564 | IntMaxType = SignedLong; |
| 4565 | UIntMaxType = UnsignedLong; |
| 4566 | IntPtrType = SignedInt; |
| 4567 | PtrDiffType = SignedInt; |
| 4568 | FloatWidth = 32; |
| 4569 | FloatAlign = 32; |
| 4570 | DoubleWidth = 32; |
| 4571 | DoubleAlign = 32; |
| 4572 | LongDoubleWidth = 32; |
| 4573 | LongDoubleAlign = 32; |
| 4574 | FloatFormat = &llvm::APFloat::IEEEsingle; |
| 4575 | DoubleFormat = &llvm::APFloat::IEEEsingle; |
| 4576 | LongDoubleFormat = &llvm::APFloat::IEEEsingle; |
Chris Lattner | 3a47c4e | 2010-03-04 21:07:38 +0000 | [diff] [blame] | 4577 | DescriptionString = "E-p:32:32:32-i1:8:8-i8:8:32-" |
| 4578 | "i16:16:32-i32:32:32-i64:32:32-" |
NAKAMURA Takumi | c910929 | 2011-02-18 08:44:38 +0000 | [diff] [blame] | 4579 | "f32:32:32-f64:32:32-v64:32:32-" |
| 4580 | "v128:32:32-a0:0:32-n32"; |
Eli Friedman | 209f5bb | 2011-10-07 19:51:42 +0000 | [diff] [blame] | 4581 | AddrSpaceMap = &TCEOpenCLAddrSpaceMap; |
David Tweed | 1eef852 | 2013-09-13 12:04:22 +0000 | [diff] [blame] | 4582 | UseAddrSpaceMapMangling = true; |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 4583 | } |
| 4584 | |
| 4585 | virtual void getTargetDefines(const LangOptions &Opts, |
Benjamin Kramer | a999277 | 2010-01-09 17:55:51 +0000 | [diff] [blame] | 4586 | MacroBuilder &Builder) const { |
| 4587 | DefineStd(Builder, "tce", Opts); |
| 4588 | Builder.defineMacro("__TCE__"); |
| 4589 | Builder.defineMacro("__TCE_V1__"); |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 4590 | } |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 4591 | virtual bool hasFeature(StringRef Feature) const { |
| 4592 | return Feature == "tce"; |
| 4593 | } |
| 4594 | |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 4595 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 4596 | unsigned &NumRecords) const {} |
Daniel Dunbar | 55cc2ed | 2009-08-24 09:54:37 +0000 | [diff] [blame] | 4597 | virtual const char *getClobbers() const { |
| 4598 | return ""; |
| 4599 | } |
Meador Inge | c5613b2 | 2012-06-16 03:34:49 +0000 | [diff] [blame] | 4600 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
| 4601 | return TargetInfo::VoidPtrBuiltinVaList; |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 4602 | } |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 4603 | virtual void getGCCRegNames(const char * const *&Names, |
| 4604 | unsigned &NumNames) const {} |
| 4605 | virtual bool validateAsmConstraint(const char *&Name, |
| 4606 | TargetInfo::ConstraintInfo &info) const { |
| 4607 | return true; |
| 4608 | } |
| 4609 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 4610 | unsigned &NumAliases) const {} |
| 4611 | }; |
| 4612 | } |
| 4613 | |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 4614 | namespace { |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4615 | class MipsTargetInfoBase : public TargetInfo { |
Simon Atanasyan | fbf7005 | 2012-06-28 18:23:16 +0000 | [diff] [blame] | 4616 | static const Builtin::Info BuiltinInfo[]; |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4617 | std::string CPU; |
Simon Atanasyan | 1176bcd | 2012-07-05 16:06:06 +0000 | [diff] [blame] | 4618 | bool IsMips16; |
Simon Atanasyan | 321ae79 | 2013-04-14 14:07:51 +0000 | [diff] [blame] | 4619 | bool IsMicromips; |
Simon Atanasyan | d96e315 | 2013-04-14 14:07:30 +0000 | [diff] [blame] | 4620 | bool IsSingleFloat; |
Simon Atanasyan | bbd9916 | 2012-07-05 15:32:46 +0000 | [diff] [blame] | 4621 | enum MipsFloatABI { |
Simon Atanasyan | d96e315 | 2013-04-14 14:07:30 +0000 | [diff] [blame] | 4622 | HardFloat, SoftFloat |
Simon Atanasyan | bbd9916 | 2012-07-05 15:32:46 +0000 | [diff] [blame] | 4623 | } FloatABI; |
Simon Atanasyan | a1b6227 | 2012-07-05 20:16:22 +0000 | [diff] [blame] | 4624 | enum DspRevEnum { |
| 4625 | NoDSP, DSP1, DSP2 |
| 4626 | } DspRev; |
Jack Carter | c613b67 | 2013-08-12 17:20:29 +0000 | [diff] [blame] | 4627 | bool HasMSA; |
Akira Hatanaka | ad8d8a3 | 2012-03-23 23:07:09 +0000 | [diff] [blame] | 4628 | |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4629 | protected: |
| 4630 | std::string ABI; |
Akira Hatanaka | ad8d8a3 | 2012-03-23 23:07:09 +0000 | [diff] [blame] | 4631 | |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 4632 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 4633 | MipsTargetInfoBase(const llvm::Triple &Triple, const std::string &ABIStr, |
| 4634 | const std::string &CPUStr) |
| 4635 | : TargetInfo(Triple), CPU(CPUStr), IsMips16(false), IsMicromips(false), |
Jack Carter | c613b67 | 2013-08-12 17:20:29 +0000 | [diff] [blame] | 4636 | IsSingleFloat(false), FloatABI(HardFloat), DspRev(NoDSP), |
| 4637 | HasMSA(false), ABI(ABIStr) {} |
Akira Hatanaka | ad8d8a3 | 2012-03-23 23:07:09 +0000 | [diff] [blame] | 4638 | |
Eric Christopher | ed73473 | 2010-03-02 02:41:08 +0000 | [diff] [blame] | 4639 | virtual const char *getABI() const { return ABI.c_str(); } |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4640 | virtual bool setABI(const std::string &Name) = 0; |
Eric Christopher | ed73473 | 2010-03-02 02:41:08 +0000 | [diff] [blame] | 4641 | virtual bool setCPU(const std::string &Name) { |
| 4642 | CPU = Name; |
| 4643 | return true; |
| 4644 | } |
Chandler Carruth | c3a2e65 | 2011-09-28 05:56:05 +0000 | [diff] [blame] | 4645 | void getDefaultFeatures(llvm::StringMap<bool> &Features) const { |
Eric Christopher | ed73473 | 2010-03-02 02:41:08 +0000 | [diff] [blame] | 4646 | Features[ABI] = true; |
| 4647 | Features[CPU] = true; |
| 4648 | } |
Akira Hatanaka | ad8d8a3 | 2012-03-23 23:07:09 +0000 | [diff] [blame] | 4649 | |
Simon Atanasyan | 1d8ae1d | 2012-08-29 19:59:32 +0000 | [diff] [blame] | 4650 | virtual void getTargetDefines(const LangOptions &Opts, |
| 4651 | MacroBuilder &Builder) const { |
Simon Atanasyan | d4935a0 | 2012-08-29 19:14:58 +0000 | [diff] [blame] | 4652 | DefineStd(Builder, "mips", Opts); |
| 4653 | Builder.defineMacro("_mips"); |
| 4654 | Builder.defineMacro("__REGISTER_PREFIX__", ""); |
| 4655 | |
Simon Atanasyan | bbd9916 | 2012-07-05 15:32:46 +0000 | [diff] [blame] | 4656 | switch (FloatABI) { |
Simon Atanasyan | bbd9916 | 2012-07-05 15:32:46 +0000 | [diff] [blame] | 4657 | case HardFloat: |
Simon Atanasyan | 3dbcc88 | 2012-06-05 13:06:56 +0000 | [diff] [blame] | 4658 | Builder.defineMacro("__mips_hard_float", Twine(1)); |
Simon Atanasyan | bbd9916 | 2012-07-05 15:32:46 +0000 | [diff] [blame] | 4659 | break; |
Simon Atanasyan | bbd9916 | 2012-07-05 15:32:46 +0000 | [diff] [blame] | 4660 | case SoftFloat: |
| 4661 | Builder.defineMacro("__mips_soft_float", Twine(1)); |
| 4662 | break; |
Simon Atanasyan | 3dbcc88 | 2012-06-05 13:06:56 +0000 | [diff] [blame] | 4663 | } |
Simon Atanasyan | 9091389 | 2012-04-05 19:28:31 +0000 | [diff] [blame] | 4664 | |
Simon Atanasyan | d96e315 | 2013-04-14 14:07:30 +0000 | [diff] [blame] | 4665 | if (IsSingleFloat) |
| 4666 | Builder.defineMacro("__mips_single_float", Twine(1)); |
| 4667 | |
Simon Atanasyan | 1176bcd | 2012-07-05 16:06:06 +0000 | [diff] [blame] | 4668 | if (IsMips16) |
| 4669 | Builder.defineMacro("__mips16", Twine(1)); |
| 4670 | |
Simon Atanasyan | 321ae79 | 2013-04-14 14:07:51 +0000 | [diff] [blame] | 4671 | if (IsMicromips) |
| 4672 | Builder.defineMacro("__mips_micromips", Twine(1)); |
| 4673 | |
Simon Atanasyan | a1b6227 | 2012-07-05 20:16:22 +0000 | [diff] [blame] | 4674 | switch (DspRev) { |
| 4675 | default: |
| 4676 | break; |
| 4677 | case DSP1: |
| 4678 | Builder.defineMacro("__mips_dsp_rev", Twine(1)); |
| 4679 | Builder.defineMacro("__mips_dsp", Twine(1)); |
| 4680 | break; |
| 4681 | case DSP2: |
| 4682 | Builder.defineMacro("__mips_dsp_rev", Twine(2)); |
| 4683 | Builder.defineMacro("__mips_dspr2", Twine(1)); |
| 4684 | Builder.defineMacro("__mips_dsp", Twine(1)); |
| 4685 | break; |
| 4686 | } |
| 4687 | |
Jack Carter | c613b67 | 2013-08-12 17:20:29 +0000 | [diff] [blame] | 4688 | if (HasMSA) |
| 4689 | Builder.defineMacro("__mips_msa", Twine(1)); |
| 4690 | |
Simon Atanasyan | 9091389 | 2012-04-05 19:28:31 +0000 | [diff] [blame] | 4691 | Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0))); |
| 4692 | Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth())); |
| 4693 | Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth())); |
Simon Atanasyan | 260e506 | 2012-08-29 15:17:29 +0000 | [diff] [blame] | 4694 | |
| 4695 | Builder.defineMacro("_MIPS_ARCH", "\"" + CPU + "\""); |
| 4696 | Builder.defineMacro("_MIPS_ARCH_" + StringRef(CPU).upper()); |
Akira Hatanaka | ad8d8a3 | 2012-03-23 23:07:09 +0000 | [diff] [blame] | 4697 | } |
| 4698 | |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 4699 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 4700 | unsigned &NumRecords) const { |
Simon Atanasyan | fbf7005 | 2012-06-28 18:23:16 +0000 | [diff] [blame] | 4701 | Records = BuiltinInfo; |
| 4702 | NumRecords = clang::Mips::LastTSBuiltin - Builtin::FirstTSBuiltin; |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 4703 | } |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 4704 | virtual bool hasFeature(StringRef Feature) const { |
| 4705 | return Feature == "mips"; |
| 4706 | } |
Meador Inge | c5613b2 | 2012-06-16 03:34:49 +0000 | [diff] [blame] | 4707 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
| 4708 | return TargetInfo::VoidPtrBuiltinVaList; |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 4709 | } |
| 4710 | virtual void getGCCRegNames(const char * const *&Names, |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4711 | unsigned &NumNames) const { |
| 4712 | static const char * const GCCRegNames[] = { |
Eric Christopher | d1f853d | 2012-03-27 19:56:11 +0000 | [diff] [blame] | 4713 | // CPU register names |
| 4714 | // Must match second column of GCCRegAliases |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4715 | "$0", "$1", "$2", "$3", "$4", "$5", "$6", "$7", |
| 4716 | "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", |
| 4717 | "$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23", |
Eric Christopher | d1f853d | 2012-03-27 19:56:11 +0000 | [diff] [blame] | 4718 | "$24", "$25", "$26", "$27", "$28", "$29", "$30", "$31", |
| 4719 | // Floating point register names |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4720 | "$f0", "$f1", "$f2", "$f3", "$f4", "$f5", "$f6", "$f7", |
| 4721 | "$f8", "$f9", "$f10", "$f11", "$f12", "$f13", "$f14", "$f15", |
| 4722 | "$f16", "$f17", "$f18", "$f19", "$f20", "$f21", "$f22", "$f23", |
| 4723 | "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "$f31", |
Eric Christopher | d1f853d | 2012-03-27 19:56:11 +0000 | [diff] [blame] | 4724 | // Hi/lo and condition register names |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4725 | "hi", "lo", "", "$fcc0","$fcc1","$fcc2","$fcc3","$fcc4", |
| 4726 | "$fcc5","$fcc6","$fcc7" |
| 4727 | }; |
| 4728 | Names = GCCRegNames; |
| 4729 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 4730 | } |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 4731 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4732 | unsigned &NumAliases) const = 0; |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 4733 | virtual bool validateAsmConstraint(const char *&Name, |
| 4734 | TargetInfo::ConstraintInfo &Info) const { |
| 4735 | switch (*Name) { |
| 4736 | default: |
Douglas Gregor | 21a2516 | 2011-11-02 20:52:01 +0000 | [diff] [blame] | 4737 | return false; |
| 4738 | |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 4739 | case 'r': // CPU registers. |
| 4740 | case 'd': // Equivalent to "r" unless generating MIPS16 code. |
| 4741 | case 'y': // Equivalent to "r", backwards compatibility only. |
| 4742 | case 'f': // floating-point registers. |
Eric Christopher | 0ea6164 | 2012-04-03 01:16:32 +0000 | [diff] [blame] | 4743 | case 'c': // $25 for indirect jumps |
| 4744 | case 'l': // lo register |
| 4745 | case 'x': // hilo register pair |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 4746 | Info.setAllowsRegister(); |
| 4747 | return true; |
Jack Carter | 9710230 | 2013-03-05 19:10:54 +0000 | [diff] [blame] | 4748 | case 'R': // An address that can be used in a non-macro load or store |
Jack Carter | d2ab6d3 | 2013-03-04 21:36:11 +0000 | [diff] [blame] | 4749 | Info.setAllowsMemory(); |
| 4750 | return true; |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 4751 | } |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 4752 | } |
| 4753 | |
| 4754 | virtual const char *getClobbers() const { |
| 4755 | // FIXME: Implement! |
| 4756 | return ""; |
| 4757 | } |
Akira Hatanaka | ad8d8a3 | 2012-03-23 23:07:09 +0000 | [diff] [blame] | 4758 | |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 4759 | virtual bool HandleTargetFeatures(std::vector<std::string> &Features, |
| 4760 | DiagnosticsEngine &Diags) { |
Simon Atanasyan | 1176bcd | 2012-07-05 16:06:06 +0000 | [diff] [blame] | 4761 | IsMips16 = false; |
Simon Atanasyan | 321ae79 | 2013-04-14 14:07:51 +0000 | [diff] [blame] | 4762 | IsMicromips = false; |
Simon Atanasyan | d96e315 | 2013-04-14 14:07:30 +0000 | [diff] [blame] | 4763 | IsSingleFloat = false; |
Simon Atanasyan | bbd9916 | 2012-07-05 15:32:46 +0000 | [diff] [blame] | 4764 | FloatABI = HardFloat; |
Simon Atanasyan | a1b6227 | 2012-07-05 20:16:22 +0000 | [diff] [blame] | 4765 | DspRev = NoDSP; |
Akira Hatanaka | ad8d8a3 | 2012-03-23 23:07:09 +0000 | [diff] [blame] | 4766 | |
| 4767 | for (std::vector<std::string>::iterator it = Features.begin(), |
| 4768 | ie = Features.end(); it != ie; ++it) { |
Simon Atanasyan | bbd9916 | 2012-07-05 15:32:46 +0000 | [diff] [blame] | 4769 | if (*it == "+single-float") |
Simon Atanasyan | d96e315 | 2013-04-14 14:07:30 +0000 | [diff] [blame] | 4770 | IsSingleFloat = true; |
Simon Atanasyan | bbd9916 | 2012-07-05 15:32:46 +0000 | [diff] [blame] | 4771 | else if (*it == "+soft-float") |
| 4772 | FloatABI = SoftFloat; |
Simon Atanasyan | 1176bcd | 2012-07-05 16:06:06 +0000 | [diff] [blame] | 4773 | else if (*it == "+mips16") |
| 4774 | IsMips16 = true; |
Simon Atanasyan | 321ae79 | 2013-04-14 14:07:51 +0000 | [diff] [blame] | 4775 | else if (*it == "+micromips") |
| 4776 | IsMicromips = true; |
Simon Atanasyan | a1b6227 | 2012-07-05 20:16:22 +0000 | [diff] [blame] | 4777 | else if (*it == "+dsp") |
| 4778 | DspRev = std::max(DspRev, DSP1); |
| 4779 | else if (*it == "+dspr2") |
| 4780 | DspRev = std::max(DspRev, DSP2); |
Jack Carter | c613b67 | 2013-08-12 17:20:29 +0000 | [diff] [blame] | 4781 | else if (*it == "+msa") |
| 4782 | HasMSA = true; |
Akira Hatanaka | ad8d8a3 | 2012-03-23 23:07:09 +0000 | [diff] [blame] | 4783 | } |
Simon Atanasyan | bbd9916 | 2012-07-05 15:32:46 +0000 | [diff] [blame] | 4784 | |
| 4785 | // Remove front-end specific option. |
| 4786 | std::vector<std::string>::iterator it = |
| 4787 | std::find(Features.begin(), Features.end(), "+soft-float"); |
| 4788 | if (it != Features.end()) |
| 4789 | Features.erase(it); |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 4790 | |
| 4791 | return true; |
Akira Hatanaka | ad8d8a3 | 2012-03-23 23:07:09 +0000 | [diff] [blame] | 4792 | } |
Logan Chien | a8f7a97 | 2013-02-23 04:24:36 +0000 | [diff] [blame] | 4793 | |
| 4794 | virtual int getEHDataRegisterNumber(unsigned RegNo) const { |
| 4795 | if (RegNo == 0) return 4; |
| 4796 | if (RegNo == 1) return 5; |
| 4797 | return -1; |
| 4798 | } |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 4799 | }; |
| 4800 | |
Simon Atanasyan | fbf7005 | 2012-06-28 18:23:16 +0000 | [diff] [blame] | 4801 | const Builtin::Info MipsTargetInfoBase::BuiltinInfo[] = { |
| 4802 | #define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, ALL_LANGUAGES }, |
| 4803 | #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER,\ |
| 4804 | ALL_LANGUAGES }, |
| 4805 | #include "clang/Basic/BuiltinsMips.def" |
| 4806 | }; |
| 4807 | |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4808 | class Mips32TargetInfoBase : public MipsTargetInfoBase { |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 4809 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 4810 | Mips32TargetInfoBase(const llvm::Triple &Triple) |
| 4811 | : MipsTargetInfoBase(Triple, "o32", "mips32") { |
Akira Hatanaka | 148735e | 2011-11-05 01:48:34 +0000 | [diff] [blame] | 4812 | SizeType = UnsignedInt; |
| 4813 | PtrDiffType = SignedInt; |
Akira Hatanaka | dbee949 | 2013-01-18 21:58:11 +0000 | [diff] [blame] | 4814 | MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32; |
Akira Hatanaka | 148735e | 2011-11-05 01:48:34 +0000 | [diff] [blame] | 4815 | } |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4816 | virtual bool setABI(const std::string &Name) { |
| 4817 | if ((Name == "o32") || (Name == "eabi")) { |
| 4818 | ABI = Name; |
| 4819 | return true; |
Simon Atanasyan | e9616a4 | 2013-02-27 14:55:49 +0000 | [diff] [blame] | 4820 | } else if (Name == "32") { |
| 4821 | ABI = "o32"; |
| 4822 | return true; |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4823 | } else |
| 4824 | return false; |
| 4825 | } |
Simon Atanasyan | 1d8ae1d | 2012-08-29 19:59:32 +0000 | [diff] [blame] | 4826 | virtual void getTargetDefines(const LangOptions &Opts, |
| 4827 | MacroBuilder &Builder) const { |
| 4828 | MipsTargetInfoBase::getTargetDefines(Opts, Builder); |
Akira Hatanaka | ad8d8a3 | 2012-03-23 23:07:09 +0000 | [diff] [blame] | 4829 | |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4830 | if (ABI == "o32") { |
| 4831 | Builder.defineMacro("__mips_o32"); |
| 4832 | Builder.defineMacro("_ABIO32", "1"); |
| 4833 | Builder.defineMacro("_MIPS_SIM", "_ABIO32"); |
| 4834 | } |
| 4835 | else if (ABI == "eabi") |
| 4836 | Builder.defineMacro("__mips_eabi"); |
| 4837 | else |
David Blaikie | b219cfc | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 4838 | llvm_unreachable("Invalid ABI for Mips32."); |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4839 | } |
| 4840 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 4841 | unsigned &NumAliases) const { |
| 4842 | static const TargetInfo::GCCRegAlias GCCRegAliases[] = { |
| 4843 | { { "at" }, "$1" }, |
| 4844 | { { "v0" }, "$2" }, |
| 4845 | { { "v1" }, "$3" }, |
| 4846 | { { "a0" }, "$4" }, |
| 4847 | { { "a1" }, "$5" }, |
| 4848 | { { "a2" }, "$6" }, |
| 4849 | { { "a3" }, "$7" }, |
| 4850 | { { "t0" }, "$8" }, |
| 4851 | { { "t1" }, "$9" }, |
| 4852 | { { "t2" }, "$10" }, |
| 4853 | { { "t3" }, "$11" }, |
| 4854 | { { "t4" }, "$12" }, |
| 4855 | { { "t5" }, "$13" }, |
| 4856 | { { "t6" }, "$14" }, |
| 4857 | { { "t7" }, "$15" }, |
| 4858 | { { "s0" }, "$16" }, |
| 4859 | { { "s1" }, "$17" }, |
| 4860 | { { "s2" }, "$18" }, |
| 4861 | { { "s3" }, "$19" }, |
| 4862 | { { "s4" }, "$20" }, |
| 4863 | { { "s5" }, "$21" }, |
| 4864 | { { "s6" }, "$22" }, |
| 4865 | { { "s7" }, "$23" }, |
| 4866 | { { "t8" }, "$24" }, |
| 4867 | { { "t9" }, "$25" }, |
| 4868 | { { "k0" }, "$26" }, |
| 4869 | { { "k1" }, "$27" }, |
| 4870 | { { "gp" }, "$28" }, |
Eric Christopher | d1f853d | 2012-03-27 19:56:11 +0000 | [diff] [blame] | 4871 | { { "sp","$sp" }, "$29" }, |
| 4872 | { { "fp","$fp" }, "$30" }, |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4873 | { { "ra" }, "$31" } |
| 4874 | }; |
| 4875 | Aliases = GCCRegAliases; |
| 4876 | NumAliases = llvm::array_lengthof(GCCRegAliases); |
| 4877 | } |
| 4878 | }; |
| 4879 | |
| 4880 | class Mips32EBTargetInfo : public Mips32TargetInfoBase { |
| 4881 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 4882 | Mips32EBTargetInfo(const llvm::Triple &Triple) |
| 4883 | : Mips32TargetInfoBase(Triple) { |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4884 | DescriptionString = "E-p:32:32:32-i1:8:8-i8:8:32-i16:16:32-i32:32:32-" |
Akira Hatanaka | 390a70f | 2013-01-05 02:04:34 +0000 | [diff] [blame] | 4885 | "i64:64:64-f32:32:32-f64:64:64-v64:64:64-n32-S64"; |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4886 | } |
| 4887 | virtual void getTargetDefines(const LangOptions &Opts, |
| 4888 | MacroBuilder &Builder) const { |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4889 | DefineStd(Builder, "MIPSEB", Opts); |
| 4890 | Builder.defineMacro("_MIPSEB"); |
Simon Atanasyan | 1d8ae1d | 2012-08-29 19:59:32 +0000 | [diff] [blame] | 4891 | Mips32TargetInfoBase::getTargetDefines(Opts, Builder); |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4892 | } |
| 4893 | }; |
| 4894 | |
| 4895 | class Mips32ELTargetInfo : public Mips32TargetInfoBase { |
| 4896 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 4897 | Mips32ELTargetInfo(const llvm::Triple &Triple) |
| 4898 | : Mips32TargetInfoBase(Triple) { |
Eli Friedman | e6a24e8 | 2011-12-22 03:51:45 +0000 | [diff] [blame] | 4899 | BigEndian = false; |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 4900 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:32-i16:16:32-i32:32:32-" |
Akira Hatanaka | 390a70f | 2013-01-05 02:04:34 +0000 | [diff] [blame] | 4901 | "i64:64:64-f32:32:32-f64:64:64-v64:64:64-n32-S64"; |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 4902 | } |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 4903 | virtual void getTargetDefines(const LangOptions &Opts, |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4904 | MacroBuilder &Builder) const { |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4905 | DefineStd(Builder, "MIPSEL", Opts); |
| 4906 | Builder.defineMacro("_MIPSEL"); |
Simon Atanasyan | 1d8ae1d | 2012-08-29 19:59:32 +0000 | [diff] [blame] | 4907 | Mips32TargetInfoBase::getTargetDefines(Opts, Builder); |
Akira Hatanaka | b6a37b3 | 2011-09-20 19:00:23 +0000 | [diff] [blame] | 4908 | } |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 4909 | }; |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 4910 | |
| 4911 | class Mips64TargetInfoBase : public MipsTargetInfoBase { |
| 4912 | virtual void SetDescriptionString(const std::string &Name) = 0; |
| 4913 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 4914 | Mips64TargetInfoBase(const llvm::Triple &Triple) |
| 4915 | : MipsTargetInfoBase(Triple, "n64", "mips64") { |
Akira Hatanaka | c7d0ab1 | 2011-10-22 00:07:27 +0000 | [diff] [blame] | 4916 | LongWidth = LongAlign = 64; |
| 4917 | PointerWidth = PointerAlign = 64; |
| 4918 | LongDoubleWidth = LongDoubleAlign = 128; |
| 4919 | LongDoubleFormat = &llvm::APFloat::IEEEquad; |
David Chisnall | 6e399b4 | 2012-12-08 09:06:08 +0000 | [diff] [blame] | 4920 | if (getTriple().getOS() == llvm::Triple::FreeBSD) { |
| 4921 | LongDoubleWidth = LongDoubleAlign = 64; |
| 4922 | LongDoubleFormat = &llvm::APFloat::IEEEdouble; |
| 4923 | } |
Nick Lewycky | 7ec59c7 | 2011-12-16 22:34:14 +0000 | [diff] [blame] | 4924 | SuitableAlign = 128; |
Akira Hatanaka | dbee949 | 2013-01-18 21:58:11 +0000 | [diff] [blame] | 4925 | MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; |
Akira Hatanaka | c7d0ab1 | 2011-10-22 00:07:27 +0000 | [diff] [blame] | 4926 | } |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 4927 | virtual bool setABI(const std::string &Name) { |
| 4928 | SetDescriptionString(Name); |
Akira Hatanaka | c7d0ab1 | 2011-10-22 00:07:27 +0000 | [diff] [blame] | 4929 | if (Name == "n32") { |
| 4930 | LongWidth = LongAlign = 32; |
| 4931 | PointerWidth = PointerAlign = 32; |
Simon Atanasyan | e9616a4 | 2013-02-27 14:55:49 +0000 | [diff] [blame] | 4932 | ABI = Name; |
| 4933 | return true; |
| 4934 | } else if (Name == "n64") { |
| 4935 | ABI = Name; |
| 4936 | return true; |
| 4937 | } else if (Name == "64") { |
| 4938 | ABI = "n64"; |
| 4939 | return true; |
| 4940 | } else |
| 4941 | return false; |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 4942 | } |
Simon Atanasyan | 1d8ae1d | 2012-08-29 19:59:32 +0000 | [diff] [blame] | 4943 | virtual void getTargetDefines(const LangOptions &Opts, |
| 4944 | MacroBuilder &Builder) const { |
| 4945 | MipsTargetInfoBase::getTargetDefines(Opts, Builder); |
Akira Hatanaka | ad8d8a3 | 2012-03-23 23:07:09 +0000 | [diff] [blame] | 4946 | |
Simon Atanasyan | 600a513 | 2012-08-29 20:50:11 +0000 | [diff] [blame] | 4947 | Builder.defineMacro("__mips64"); |
| 4948 | Builder.defineMacro("__mips64__"); |
| 4949 | |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 4950 | if (ABI == "n32") { |
| 4951 | Builder.defineMacro("__mips_n32"); |
| 4952 | Builder.defineMacro("_ABIN32", "2"); |
| 4953 | Builder.defineMacro("_MIPS_SIM", "_ABIN32"); |
| 4954 | } |
| 4955 | else if (ABI == "n64") { |
| 4956 | Builder.defineMacro("__mips_n64"); |
| 4957 | Builder.defineMacro("_ABI64", "3"); |
| 4958 | Builder.defineMacro("_MIPS_SIM", "_ABI64"); |
| 4959 | } |
| 4960 | else |
David Blaikie | b219cfc | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 4961 | llvm_unreachable("Invalid ABI for Mips64."); |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 4962 | } |
| 4963 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 4964 | unsigned &NumAliases) const { |
| 4965 | static const TargetInfo::GCCRegAlias GCCRegAliases[] = { |
| 4966 | { { "at" }, "$1" }, |
| 4967 | { { "v0" }, "$2" }, |
| 4968 | { { "v1" }, "$3" }, |
| 4969 | { { "a0" }, "$4" }, |
| 4970 | { { "a1" }, "$5" }, |
| 4971 | { { "a2" }, "$6" }, |
| 4972 | { { "a3" }, "$7" }, |
| 4973 | { { "a4" }, "$8" }, |
| 4974 | { { "a5" }, "$9" }, |
| 4975 | { { "a6" }, "$10" }, |
| 4976 | { { "a7" }, "$11" }, |
| 4977 | { { "t0" }, "$12" }, |
| 4978 | { { "t1" }, "$13" }, |
| 4979 | { { "t2" }, "$14" }, |
| 4980 | { { "t3" }, "$15" }, |
| 4981 | { { "s0" }, "$16" }, |
| 4982 | { { "s1" }, "$17" }, |
| 4983 | { { "s2" }, "$18" }, |
| 4984 | { { "s3" }, "$19" }, |
| 4985 | { { "s4" }, "$20" }, |
| 4986 | { { "s5" }, "$21" }, |
| 4987 | { { "s6" }, "$22" }, |
| 4988 | { { "s7" }, "$23" }, |
| 4989 | { { "t8" }, "$24" }, |
| 4990 | { { "t9" }, "$25" }, |
| 4991 | { { "k0" }, "$26" }, |
| 4992 | { { "k1" }, "$27" }, |
| 4993 | { { "gp" }, "$28" }, |
Eric Christopher | d1f853d | 2012-03-27 19:56:11 +0000 | [diff] [blame] | 4994 | { { "sp","$sp" }, "$29" }, |
| 4995 | { { "fp","$fp" }, "$30" }, |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 4996 | { { "ra" }, "$31" } |
| 4997 | }; |
| 4998 | Aliases = GCCRegAliases; |
| 4999 | NumAliases = llvm::array_lengthof(GCCRegAliases); |
| 5000 | } |
| 5001 | }; |
| 5002 | |
| 5003 | class Mips64EBTargetInfo : public Mips64TargetInfoBase { |
| 5004 | virtual void SetDescriptionString(const std::string &Name) { |
| 5005 | // Change DescriptionString only if ABI is n32. |
| 5006 | if (Name == "n32") |
| 5007 | DescriptionString = "E-p:32:32:32-i1:8:8-i8:8:32-i16:16:32-i32:32:32-" |
Akira Hatanaka | c7d0ab1 | 2011-10-22 00:07:27 +0000 | [diff] [blame] | 5008 | "i64:64:64-f32:32:32-f64:64:64-f128:128:128-" |
Akira Hatanaka | 390a70f | 2013-01-05 02:04:34 +0000 | [diff] [blame] | 5009 | "v64:64:64-n32:64-S128"; |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5010 | } |
| 5011 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5012 | Mips64EBTargetInfo(const llvm::Triple &Triple) |
| 5013 | : Mips64TargetInfoBase(Triple) { |
| 5014 | // Default ABI is n64. |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5015 | DescriptionString = "E-p:64:64:64-i1:8:8-i8:8:32-i16:16:32-i32:32:32-" |
Akira Hatanaka | c7d0ab1 | 2011-10-22 00:07:27 +0000 | [diff] [blame] | 5016 | "i64:64:64-f32:32:32-f64:64:64-f128:128:128-" |
Akira Hatanaka | 390a70f | 2013-01-05 02:04:34 +0000 | [diff] [blame] | 5017 | "v64:64:64-n32:64-S128"; |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5018 | } |
| 5019 | virtual void getTargetDefines(const LangOptions &Opts, |
| 5020 | MacroBuilder &Builder) const { |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5021 | DefineStd(Builder, "MIPSEB", Opts); |
| 5022 | Builder.defineMacro("_MIPSEB"); |
Simon Atanasyan | 1d8ae1d | 2012-08-29 19:59:32 +0000 | [diff] [blame] | 5023 | Mips64TargetInfoBase::getTargetDefines(Opts, Builder); |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5024 | } |
| 5025 | }; |
| 5026 | |
| 5027 | class Mips64ELTargetInfo : public Mips64TargetInfoBase { |
| 5028 | virtual void SetDescriptionString(const std::string &Name) { |
| 5029 | // Change DescriptionString only if ABI is n32. |
| 5030 | if (Name == "n32") |
| 5031 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:32-i16:16:32-i32:32:32-" |
Akira Hatanaka | c7d0ab1 | 2011-10-22 00:07:27 +0000 | [diff] [blame] | 5032 | "i64:64:64-f32:32:32-f64:64:64-f128:128:128" |
Akira Hatanaka | 390a70f | 2013-01-05 02:04:34 +0000 | [diff] [blame] | 5033 | "-v64:64:64-n32:64-S128"; |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5034 | } |
| 5035 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5036 | Mips64ELTargetInfo(const llvm::Triple &Triple) |
| 5037 | : Mips64TargetInfoBase(Triple) { |
Eli Friedman | e6a24e8 | 2011-12-22 03:51:45 +0000 | [diff] [blame] | 5038 | // Default ABI is n64. |
| 5039 | BigEndian = false; |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5040 | DescriptionString = "e-p:64:64:64-i1:8:8-i8:8:32-i16:16:32-i32:32:32-" |
Akira Hatanaka | c7d0ab1 | 2011-10-22 00:07:27 +0000 | [diff] [blame] | 5041 | "i64:64:64-f32:32:32-f64:64:64-f128:128:128-" |
Akira Hatanaka | 390a70f | 2013-01-05 02:04:34 +0000 | [diff] [blame] | 5042 | "v64:64:64-n32:64-S128"; |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5043 | } |
| 5044 | virtual void getTargetDefines(const LangOptions &Opts, |
| 5045 | MacroBuilder &Builder) const { |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5046 | DefineStd(Builder, "MIPSEL", Opts); |
| 5047 | Builder.defineMacro("_MIPSEL"); |
Simon Atanasyan | 1d8ae1d | 2012-08-29 19:59:32 +0000 | [diff] [blame] | 5048 | Mips64TargetInfoBase::getTargetDefines(Opts, Builder); |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5049 | } |
| 5050 | }; |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 5051 | } // end anonymous namespace. |
| 5052 | |
Ivan Krasin | ef05abd | 2011-08-24 20:22:22 +0000 | [diff] [blame] | 5053 | namespace { |
| 5054 | class PNaClTargetInfo : public TargetInfo { |
| 5055 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5056 | PNaClTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) { |
Eli Friedman | e6a24e8 | 2011-12-22 03:51:45 +0000 | [diff] [blame] | 5057 | BigEndian = false; |
Ivan Krasin | ef05abd | 2011-08-24 20:22:22 +0000 | [diff] [blame] | 5058 | this->UserLabelPrefix = ""; |
| 5059 | this->LongAlign = 32; |
| 5060 | this->LongWidth = 32; |
| 5061 | this->PointerAlign = 32; |
| 5062 | this->PointerWidth = 32; |
| 5063 | this->IntMaxType = TargetInfo::SignedLongLong; |
| 5064 | this->UIntMaxType = TargetInfo::UnsignedLongLong; |
| 5065 | this->Int64Type = TargetInfo::SignedLongLong; |
Ivan Krasin | f619cdc | 2011-08-29 22:39:12 +0000 | [diff] [blame] | 5066 | this->DoubleAlign = 64; |
Ivan Krasin | 68018db | 2011-09-20 14:56:54 +0000 | [diff] [blame] | 5067 | this->LongDoubleWidth = 64; |
Ivan Krasin | f619cdc | 2011-08-29 22:39:12 +0000 | [diff] [blame] | 5068 | this->LongDoubleAlign = 64; |
Ivan Krasin | 68018db | 2011-09-20 14:56:54 +0000 | [diff] [blame] | 5069 | this->SizeType = TargetInfo::UnsignedInt; |
| 5070 | this->PtrDiffType = TargetInfo::SignedInt; |
| 5071 | this->IntPtrType = TargetInfo::SignedInt; |
Eli Bendersky | c0783dc | 2013-04-08 21:31:01 +0000 | [diff] [blame] | 5072 | this->RegParmMax = 0; // Disallow regparm |
Ivan Krasin | ef05abd | 2011-08-24 20:22:22 +0000 | [diff] [blame] | 5073 | DescriptionString = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-" |
| 5074 | "f32:32:32-f64:64:64-p:32:32:32-v128:32:32"; |
| 5075 | } |
| 5076 | |
Chandler Carruth | c3a2e65 | 2011-09-28 05:56:05 +0000 | [diff] [blame] | 5077 | void getDefaultFeatures(llvm::StringMap<bool> &Features) const { |
Ivan Krasin | ef05abd | 2011-08-24 20:22:22 +0000 | [diff] [blame] | 5078 | } |
| 5079 | virtual void getArchDefines(const LangOptions &Opts, |
| 5080 | MacroBuilder &Builder) const { |
| 5081 | Builder.defineMacro("__le32__"); |
| 5082 | Builder.defineMacro("__pnacl__"); |
| 5083 | } |
| 5084 | virtual void getTargetDefines(const LangOptions &Opts, |
| 5085 | MacroBuilder &Builder) const { |
Jan Wen Voung | dde3bdb | 2012-03-29 00:05:59 +0000 | [diff] [blame] | 5086 | Builder.defineMacro("__LITTLE_ENDIAN__"); |
Ivan Krasin | ef05abd | 2011-08-24 20:22:22 +0000 | [diff] [blame] | 5087 | getArchDefines(Opts, Builder); |
| 5088 | } |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 5089 | virtual bool hasFeature(StringRef Feature) const { |
| 5090 | return Feature == "pnacl"; |
| 5091 | } |
Ivan Krasin | ef05abd | 2011-08-24 20:22:22 +0000 | [diff] [blame] | 5092 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 5093 | unsigned &NumRecords) const { |
| 5094 | } |
Meador Inge | c5613b2 | 2012-06-16 03:34:49 +0000 | [diff] [blame] | 5095 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
| 5096 | return TargetInfo::PNaClABIBuiltinVaList; |
Ivan Krasin | ef05abd | 2011-08-24 20:22:22 +0000 | [diff] [blame] | 5097 | } |
| 5098 | virtual void getGCCRegNames(const char * const *&Names, |
| 5099 | unsigned &NumNames) const; |
| 5100 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 5101 | unsigned &NumAliases) const; |
| 5102 | virtual bool validateAsmConstraint(const char *&Name, |
| 5103 | TargetInfo::ConstraintInfo &Info) const { |
| 5104 | return false; |
| 5105 | } |
| 5106 | |
| 5107 | virtual const char *getClobbers() const { |
| 5108 | return ""; |
| 5109 | } |
| 5110 | }; |
| 5111 | |
| 5112 | void PNaClTargetInfo::getGCCRegNames(const char * const *&Names, |
| 5113 | unsigned &NumNames) const { |
| 5114 | Names = NULL; |
| 5115 | NumNames = 0; |
| 5116 | } |
| 5117 | |
| 5118 | void PNaClTargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 5119 | unsigned &NumAliases) const { |
| 5120 | Aliases = NULL; |
| 5121 | NumAliases = 0; |
| 5122 | } |
| 5123 | } // end anonymous namespace. |
| 5124 | |
Guy Benyei | bd5da3c | 2012-12-11 21:38:14 +0000 | [diff] [blame] | 5125 | namespace { |
| 5126 | static const unsigned SPIRAddrSpaceMap[] = { |
| 5127 | 1, // opencl_global |
| 5128 | 3, // opencl_local |
| 5129 | 2, // opencl_constant |
| 5130 | 0, // cuda_device |
| 5131 | 0, // cuda_constant |
| 5132 | 0 // cuda_shared |
| 5133 | }; |
| 5134 | class SPIRTargetInfo : public TargetInfo { |
Guy Benyei | bd5da3c | 2012-12-11 21:38:14 +0000 | [diff] [blame] | 5135 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5136 | SPIRTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) { |
Guy Benyei | bd5da3c | 2012-12-11 21:38:14 +0000 | [diff] [blame] | 5137 | assert(getTriple().getOS() == llvm::Triple::UnknownOS && |
| 5138 | "SPIR target must use unknown OS"); |
| 5139 | assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment && |
| 5140 | "SPIR target must use unknown environment type"); |
| 5141 | BigEndian = false; |
| 5142 | TLSSupported = false; |
| 5143 | LongWidth = LongAlign = 64; |
| 5144 | AddrSpaceMap = &SPIRAddrSpaceMap; |
David Tweed | 1eef852 | 2013-09-13 12:04:22 +0000 | [diff] [blame] | 5145 | UseAddrSpaceMapMangling = true; |
Guy Benyei | bd5da3c | 2012-12-11 21:38:14 +0000 | [diff] [blame] | 5146 | // Define available target features |
| 5147 | // These must be defined in sorted order! |
| 5148 | NoAsmVariants = true; |
| 5149 | } |
| 5150 | virtual void getTargetDefines(const LangOptions &Opts, |
| 5151 | MacroBuilder &Builder) const { |
| 5152 | DefineStd(Builder, "SPIR", Opts); |
| 5153 | } |
| 5154 | virtual bool hasFeature(StringRef Feature) const { |
| 5155 | return Feature == "spir"; |
| 5156 | } |
| 5157 | |
| 5158 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 5159 | unsigned &NumRecords) const {} |
| 5160 | virtual const char *getClobbers() const { |
| 5161 | return ""; |
| 5162 | } |
| 5163 | virtual void getGCCRegNames(const char * const *&Names, |
| 5164 | unsigned &NumNames) const {} |
| 5165 | virtual bool validateAsmConstraint(const char *&Name, |
| 5166 | TargetInfo::ConstraintInfo &info) const { |
| 5167 | return true; |
| 5168 | } |
| 5169 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 5170 | unsigned &NumAliases) const {} |
| 5171 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
| 5172 | return TargetInfo::VoidPtrBuiltinVaList; |
| 5173 | } |
| 5174 | }; |
| 5175 | |
| 5176 | |
| 5177 | class SPIR32TargetInfo : public SPIRTargetInfo { |
| 5178 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5179 | SPIR32TargetInfo(const llvm::Triple &Triple) : SPIRTargetInfo(Triple) { |
Guy Benyei | bd5da3c | 2012-12-11 21:38:14 +0000 | [diff] [blame] | 5180 | PointerWidth = PointerAlign = 32; |
| 5181 | SizeType = TargetInfo::UnsignedInt; |
| 5182 | PtrDiffType = IntPtrType = TargetInfo::SignedInt; |
| 5183 | DescriptionString |
Guy Benyei | f3ddf63 | 2013-03-07 13:06:10 +0000 | [diff] [blame] | 5184 | = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-" |
Guy Benyei | bd5da3c | 2012-12-11 21:38:14 +0000 | [diff] [blame] | 5185 | "f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-" |
| 5186 | "v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-" |
| 5187 | "v512:512:512-v1024:1024:1024"; |
Guy Benyei | f3ddf63 | 2013-03-07 13:06:10 +0000 | [diff] [blame] | 5188 | } |
| 5189 | virtual void getTargetDefines(const LangOptions &Opts, |
| 5190 | MacroBuilder &Builder) const { |
| 5191 | DefineStd(Builder, "SPIR32", Opts); |
| 5192 | } |
Guy Benyei | bd5da3c | 2012-12-11 21:38:14 +0000 | [diff] [blame] | 5193 | }; |
| 5194 | |
| 5195 | class SPIR64TargetInfo : public SPIRTargetInfo { |
| 5196 | public: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5197 | SPIR64TargetInfo(const llvm::Triple &Triple) : SPIRTargetInfo(Triple) { |
Guy Benyei | bd5da3c | 2012-12-11 21:38:14 +0000 | [diff] [blame] | 5198 | PointerWidth = PointerAlign = 64; |
| 5199 | SizeType = TargetInfo::UnsignedLong; |
| 5200 | PtrDiffType = IntPtrType = TargetInfo::SignedLong; |
| 5201 | DescriptionString |
Guy Benyei | f3ddf63 | 2013-03-07 13:06:10 +0000 | [diff] [blame] | 5202 | = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-" |
Guy Benyei | bd5da3c | 2012-12-11 21:38:14 +0000 | [diff] [blame] | 5203 | "f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-" |
| 5204 | "v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-" |
| 5205 | "v512:512:512-v1024:1024:1024"; |
Guy Benyei | f3ddf63 | 2013-03-07 13:06:10 +0000 | [diff] [blame] | 5206 | } |
| 5207 | virtual void getTargetDefines(const LangOptions &Opts, |
| 5208 | MacroBuilder &Builder) const { |
| 5209 | DefineStd(Builder, "SPIR64", Opts); |
| 5210 | } |
Guy Benyei | bd5da3c | 2012-12-11 21:38:14 +0000 | [diff] [blame] | 5211 | }; |
| 5212 | } |
| 5213 | |
Robert Lytton | 5f15f4d | 2013-08-13 09:43:10 +0000 | [diff] [blame] | 5214 | namespace { |
| 5215 | class XCoreTargetInfo : public TargetInfo { |
| 5216 | static const Builtin::Info BuiltinInfo[]; |
| 5217 | public: |
| 5218 | XCoreTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) { |
| 5219 | BigEndian = false; |
| 5220 | NoAsmVariants = true; |
| 5221 | LongLongAlign = 32; |
| 5222 | SuitableAlign = 32; |
| 5223 | DoubleAlign = LongDoubleAlign = 32; |
| 5224 | UseZeroLengthBitfieldAlignment = true; |
| 5225 | DescriptionString = "e-p:32:32:32-a0:0:32-n32" |
| 5226 | "-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32" |
| 5227 | "-f16:16:32-f32:32:32-f64:32:32"; |
| 5228 | } |
| 5229 | virtual void getTargetDefines(const LangOptions &Opts, |
| 5230 | MacroBuilder &Builder) const { |
| 5231 | Builder.defineMacro("__XS1B__"); |
| 5232 | } |
| 5233 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 5234 | unsigned &NumRecords) const { |
| 5235 | Records = BuiltinInfo; |
| 5236 | NumRecords = clang::XCore::LastTSBuiltin-Builtin::FirstTSBuiltin; |
| 5237 | } |
| 5238 | virtual BuiltinVaListKind getBuiltinVaListKind() const { |
| 5239 | return TargetInfo::VoidPtrBuiltinVaList; |
| 5240 | } |
| 5241 | virtual const char *getClobbers() const { |
| 5242 | return ""; |
| 5243 | } |
| 5244 | virtual void getGCCRegNames(const char * const *&Names, |
| 5245 | unsigned &NumNames) const { |
| 5246 | static const char * const GCCRegNames[] = { |
| 5247 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
| 5248 | "r8", "r9", "r10", "r11", "cp", "dp", "sp", "lr" |
| 5249 | }; |
| 5250 | Names = GCCRegNames; |
| 5251 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 5252 | } |
| 5253 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 5254 | unsigned &NumAliases) const { |
| 5255 | Aliases = NULL; |
| 5256 | NumAliases = 0; |
| 5257 | } |
| 5258 | virtual bool validateAsmConstraint(const char *&Name, |
| 5259 | TargetInfo::ConstraintInfo &Info) const { |
| 5260 | return false; |
| 5261 | } |
| 5262 | }; |
| 5263 | |
| 5264 | const Builtin::Info XCoreTargetInfo::BuiltinInfo[] = { |
| 5265 | #define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, ALL_LANGUAGES }, |
| 5266 | #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER,\ |
| 5267 | ALL_LANGUAGES }, |
| 5268 | #include "clang/Basic/BuiltinsXCore.def" |
| 5269 | }; |
| 5270 | } // end anonymous namespace. |
| 5271 | |
Ivan Krasin | ef05abd | 2011-08-24 20:22:22 +0000 | [diff] [blame] | 5272 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 5273 | //===----------------------------------------------------------------------===// |
| 5274 | // Driver code |
| 5275 | //===----------------------------------------------------------------------===// |
| 5276 | |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5277 | static TargetInfo *AllocateTarget(const llvm::Triple &Triple) { |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5278 | llvm::Triple::OSType os = Triple.getOS(); |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 5279 | |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5280 | switch (Triple.getArch()) { |
| 5281 | default: |
| 5282 | return NULL; |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 5283 | |
Robert Lytton | 5f15f4d | 2013-08-13 09:43:10 +0000 | [diff] [blame] | 5284 | case llvm::Triple::xcore: |
| 5285 | return new XCoreTargetInfo(Triple); |
| 5286 | |
Tony Linthicum | 9631939 | 2011-12-12 21:14:55 +0000 | [diff] [blame] | 5287 | case llvm::Triple::hexagon: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5288 | return new HexagonTargetInfo(Triple); |
Tony Linthicum | 9631939 | 2011-12-12 21:14:55 +0000 | [diff] [blame] | 5289 | |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 5290 | case llvm::Triple::aarch64: |
| 5291 | switch (os) { |
| 5292 | case llvm::Triple::Linux: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5293 | return new LinuxTargetInfo<AArch64TargetInfo>(Triple); |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 5294 | default: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5295 | return new AArch64TargetInfo(Triple); |
Tim Northover | c264e16 | 2013-01-31 12:13:10 +0000 | [diff] [blame] | 5296 | } |
| 5297 | |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5298 | case llvm::Triple::arm: |
Daniel Dunbar | f4aa4f61 | 2009-09-11 01:14:50 +0000 | [diff] [blame] | 5299 | case llvm::Triple::thumb: |
Daniel Dunbar | db57a4c | 2011-04-19 21:43:27 +0000 | [diff] [blame] | 5300 | if (Triple.isOSDarwin()) |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5301 | return new DarwinARMTargetInfo(Triple); |
Daniel Dunbar | db57a4c | 2011-04-19 21:43:27 +0000 | [diff] [blame] | 5302 | |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5303 | switch (os) { |
Rafael Espindola | 022a8a5 | 2010-06-10 00:46:51 +0000 | [diff] [blame] | 5304 | case llvm::Triple::Linux: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5305 | return new LinuxTargetInfo<ARMTargetInfo>(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5306 | case llvm::Triple::FreeBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5307 | return new FreeBSDTargetInfo<ARMTargetInfo>(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5308 | case llvm::Triple::NetBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5309 | return new NetBSDTargetInfo<ARMTargetInfo>(Triple); |
Hans Wennborg | 5e601dc | 2012-08-02 13:45:48 +0000 | [diff] [blame] | 5310 | case llvm::Triple::OpenBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5311 | return new OpenBSDTargetInfo<ARMTargetInfo>(Triple); |
Eli Friedman | 42f74f2 | 2012-08-08 23:57:20 +0000 | [diff] [blame] | 5312 | case llvm::Triple::Bitrig: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5313 | return new BitrigTargetInfo<ARMTargetInfo>(Triple); |
Douglas Gregor | dca5226 | 2011-07-01 22:41:14 +0000 | [diff] [blame] | 5314 | case llvm::Triple::RTEMS: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5315 | return new RTEMSTargetInfo<ARMTargetInfo>(Triple); |
Eli Bendersky | 441d9f7 | 2012-12-04 18:38:10 +0000 | [diff] [blame] | 5316 | case llvm::Triple::NaCl: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5317 | return new NaClTargetInfo<ARMTargetInfo>(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5318 | default: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5319 | return new ARMTargetInfo(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5320 | } |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 5321 | |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5322 | case llvm::Triple::msp430: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5323 | return new MSP430TargetInfo(Triple); |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 5324 | |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 5325 | case llvm::Triple::mips: |
Joerg Sonnenberger | fa9772b | 2011-07-05 18:05:54 +0000 | [diff] [blame] | 5326 | switch (os) { |
Joerg Sonnenberger | fa9772b | 2011-07-05 18:05:54 +0000 | [diff] [blame] | 5327 | case llvm::Triple::Linux: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5328 | return new LinuxTargetInfo<Mips32EBTargetInfo>(Triple); |
Joerg Sonnenberger | fa9772b | 2011-07-05 18:05:54 +0000 | [diff] [blame] | 5329 | case llvm::Triple::RTEMS: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5330 | return new RTEMSTargetInfo<Mips32EBTargetInfo>(Triple); |
Joerg Sonnenberger | fa9772b | 2011-07-05 18:05:54 +0000 | [diff] [blame] | 5331 | case llvm::Triple::FreeBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5332 | return new FreeBSDTargetInfo<Mips32EBTargetInfo>(Triple); |
Joerg Sonnenberger | fa9772b | 2011-07-05 18:05:54 +0000 | [diff] [blame] | 5333 | case llvm::Triple::NetBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5334 | return new NetBSDTargetInfo<Mips32EBTargetInfo>(Triple); |
Joerg Sonnenberger | fa9772b | 2011-07-05 18:05:54 +0000 | [diff] [blame] | 5335 | default: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5336 | return new Mips32EBTargetInfo(Triple); |
Joerg Sonnenberger | fa9772b | 2011-07-05 18:05:54 +0000 | [diff] [blame] | 5337 | } |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 5338 | |
| 5339 | case llvm::Triple::mipsel: |
Joerg Sonnenberger | 94c9ce5 | 2011-07-05 18:24:04 +0000 | [diff] [blame] | 5340 | switch (os) { |
Joerg Sonnenberger | 94c9ce5 | 2011-07-05 18:24:04 +0000 | [diff] [blame] | 5341 | case llvm::Triple::Linux: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5342 | return new LinuxTargetInfo<Mips32ELTargetInfo>(Triple); |
Joerg Sonnenberger | 94c9ce5 | 2011-07-05 18:24:04 +0000 | [diff] [blame] | 5343 | case llvm::Triple::RTEMS: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5344 | return new RTEMSTargetInfo<Mips32ELTargetInfo>(Triple); |
Joerg Sonnenberger | 94c9ce5 | 2011-07-05 18:24:04 +0000 | [diff] [blame] | 5345 | case llvm::Triple::FreeBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5346 | return new FreeBSDTargetInfo<Mips32ELTargetInfo>(Triple); |
Joerg Sonnenberger | 94c9ce5 | 2011-07-05 18:24:04 +0000 | [diff] [blame] | 5347 | case llvm::Triple::NetBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5348 | return new NetBSDTargetInfo<Mips32ELTargetInfo>(Triple); |
Joerg Sonnenberger | 94c9ce5 | 2011-07-05 18:24:04 +0000 | [diff] [blame] | 5349 | default: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5350 | return new Mips32ELTargetInfo(Triple); |
Joerg Sonnenberger | 94c9ce5 | 2011-07-05 18:24:04 +0000 | [diff] [blame] | 5351 | } |
Edward O'Callaghan | 84423a8 | 2009-11-15 10:22:07 +0000 | [diff] [blame] | 5352 | |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5353 | case llvm::Triple::mips64: |
| 5354 | switch (os) { |
| 5355 | case llvm::Triple::Linux: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5356 | return new LinuxTargetInfo<Mips64EBTargetInfo>(Triple); |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5357 | case llvm::Triple::RTEMS: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5358 | return new RTEMSTargetInfo<Mips64EBTargetInfo>(Triple); |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5359 | case llvm::Triple::FreeBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5360 | return new FreeBSDTargetInfo<Mips64EBTargetInfo>(Triple); |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5361 | case llvm::Triple::NetBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5362 | return new NetBSDTargetInfo<Mips64EBTargetInfo>(Triple); |
Hans Wennborg | 5e601dc | 2012-08-02 13:45:48 +0000 | [diff] [blame] | 5363 | case llvm::Triple::OpenBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5364 | return new OpenBSDTargetInfo<Mips64EBTargetInfo>(Triple); |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5365 | default: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5366 | return new Mips64EBTargetInfo(Triple); |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5367 | } |
| 5368 | |
| 5369 | case llvm::Triple::mips64el: |
| 5370 | switch (os) { |
| 5371 | case llvm::Triple::Linux: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5372 | return new LinuxTargetInfo<Mips64ELTargetInfo>(Triple); |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5373 | case llvm::Triple::RTEMS: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5374 | return new RTEMSTargetInfo<Mips64ELTargetInfo>(Triple); |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5375 | case llvm::Triple::FreeBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5376 | return new FreeBSDTargetInfo<Mips64ELTargetInfo>(Triple); |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5377 | case llvm::Triple::NetBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5378 | return new NetBSDTargetInfo<Mips64ELTargetInfo>(Triple); |
Hans Wennborg | 5e601dc | 2012-08-02 13:45:48 +0000 | [diff] [blame] | 5379 | case llvm::Triple::OpenBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5380 | return new OpenBSDTargetInfo<Mips64ELTargetInfo>(Triple); |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5381 | default: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5382 | return new Mips64ELTargetInfo(Triple); |
Akira Hatanaka | bf5851a | 2011-09-20 19:21:49 +0000 | [diff] [blame] | 5383 | } |
| 5384 | |
Ivan Krasin | ef05abd | 2011-08-24 20:22:22 +0000 | [diff] [blame] | 5385 | case llvm::Triple::le32: |
| 5386 | switch (os) { |
Eli Bendersky | 441d9f7 | 2012-12-04 18:38:10 +0000 | [diff] [blame] | 5387 | case llvm::Triple::NaCl: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5388 | return new NaClTargetInfo<PNaClTargetInfo>(Triple); |
Ivan Krasin | ef05abd | 2011-08-24 20:22:22 +0000 | [diff] [blame] | 5389 | default: |
| 5390 | return NULL; |
| 5391 | } |
| 5392 | |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5393 | case llvm::Triple::ppc: |
Daniel Dunbar | db57a4c | 2011-04-19 21:43:27 +0000 | [diff] [blame] | 5394 | if (Triple.isOSDarwin()) |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5395 | return new DarwinPPC32TargetInfo(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5396 | switch (os) { |
Anton Korobeynikov | 7e1812f | 2011-10-12 09:30:58 +0000 | [diff] [blame] | 5397 | case llvm::Triple::Linux: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5398 | return new LinuxTargetInfo<PPC32TargetInfo>(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5399 | case llvm::Triple::FreeBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5400 | return new FreeBSDTargetInfo<PPC32TargetInfo>(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5401 | case llvm::Triple::NetBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5402 | return new NetBSDTargetInfo<PPC32TargetInfo>(Triple); |
Hans Wennborg | 5e601dc | 2012-08-02 13:45:48 +0000 | [diff] [blame] | 5403 | case llvm::Triple::OpenBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5404 | return new OpenBSDTargetInfo<PPC32TargetInfo>(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5405 | case llvm::Triple::RTEMS: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5406 | return new RTEMSTargetInfo<PPC32TargetInfo>(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5407 | default: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5408 | return new PPC32TargetInfo(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5409 | } |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5410 | |
| 5411 | case llvm::Triple::ppc64: |
Daniel Dunbar | db57a4c | 2011-04-19 21:43:27 +0000 | [diff] [blame] | 5412 | if (Triple.isOSDarwin()) |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5413 | return new DarwinPPC64TargetInfo(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5414 | switch (os) { |
Anton Korobeynikov | 7e1812f | 2011-10-12 09:30:58 +0000 | [diff] [blame] | 5415 | case llvm::Triple::Linux: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5416 | return new LinuxTargetInfo<PPC64TargetInfo>(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5417 | case llvm::Triple::Lv2: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5418 | return new PS3PPUTargetInfo<PPC64TargetInfo>(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5419 | case llvm::Triple::FreeBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5420 | return new FreeBSDTargetInfo<PPC64TargetInfo>(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5421 | case llvm::Triple::NetBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5422 | return new NetBSDTargetInfo<PPC64TargetInfo>(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5423 | default: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5424 | return new PPC64TargetInfo(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5425 | } |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5426 | |
Bill Schmidt | ea7fb0c | 2013-07-26 01:36:11 +0000 | [diff] [blame] | 5427 | case llvm::Triple::ppc64le: |
| 5428 | switch (os) { |
| 5429 | case llvm::Triple::Linux: |
| 5430 | return new LinuxTargetInfo<PPC64TargetInfo>(Triple); |
| 5431 | default: |
| 5432 | return new PPC64TargetInfo(Triple); |
| 5433 | } |
| 5434 | |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 5435 | case llvm::Triple::nvptx: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5436 | return new NVPTX32TargetInfo(Triple); |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 5437 | case llvm::Triple::nvptx64: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5438 | return new NVPTX64TargetInfo(Triple); |
Peter Collingbourne | edb66f3 | 2012-05-20 23:28:41 +0000 | [diff] [blame] | 5439 | |
Eli Friedman | 6505a29 | 2012-10-12 23:32:00 +0000 | [diff] [blame] | 5440 | case llvm::Triple::r600: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5441 | return new R600TargetInfo(Triple); |
Eli Friedman | 6505a29 | 2012-10-12 23:32:00 +0000 | [diff] [blame] | 5442 | |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5443 | case llvm::Triple::sparc: |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5444 | switch (os) { |
Anton Korobeynikov | 7e1812f | 2011-10-12 09:30:58 +0000 | [diff] [blame] | 5445 | case llvm::Triple::Linux: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5446 | return new LinuxTargetInfo<SparcV8TargetInfo>(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5447 | case llvm::Triple::AuroraUX: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5448 | return new AuroraUXSparcV8TargetInfo(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5449 | case llvm::Triple::Solaris: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5450 | return new SolarisSparcV8TargetInfo(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5451 | case llvm::Triple::NetBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5452 | return new NetBSDTargetInfo<SparcV8TargetInfo>(Triple); |
Hans Wennborg | 5e601dc | 2012-08-02 13:45:48 +0000 | [diff] [blame] | 5453 | case llvm::Triple::OpenBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5454 | return new OpenBSDTargetInfo<SparcV8TargetInfo>(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5455 | case llvm::Triple::RTEMS: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5456 | return new RTEMSTargetInfo<SparcV8TargetInfo>(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5457 | default: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5458 | return new SparcV8TargetInfo(Triple); |
Joerg Sonnenberger | 9a11b74 | 2011-07-04 21:59:44 +0000 | [diff] [blame] | 5459 | } |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5460 | |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 5461 | case llvm::Triple::sparcv9: |
| 5462 | switch (os) { |
| 5463 | case llvm::Triple::Linux: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5464 | return new LinuxTargetInfo<SparcV9TargetInfo>(Triple); |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 5465 | case llvm::Triple::AuroraUX: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5466 | return new AuroraUXTargetInfo<SparcV9TargetInfo>(Triple); |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 5467 | case llvm::Triple::Solaris: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5468 | return new SolarisTargetInfo<SparcV9TargetInfo>(Triple); |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 5469 | case llvm::Triple::NetBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5470 | return new NetBSDTargetInfo<SparcV9TargetInfo>(Triple); |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 5471 | case llvm::Triple::OpenBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5472 | return new OpenBSDTargetInfo<SparcV9TargetInfo>(Triple); |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 5473 | case llvm::Triple::FreeBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5474 | return new FreeBSDTargetInfo<SparcV9TargetInfo>(Triple); |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 5475 | default: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5476 | return new SparcV9TargetInfo(Triple); |
Jakob Stoklund Olesen | 56e1f1f | 2013-04-16 15:17:49 +0000 | [diff] [blame] | 5477 | } |
| 5478 | |
Ulrich Weigand | b840921 | 2013-05-06 16:26:41 +0000 | [diff] [blame] | 5479 | case llvm::Triple::systemz: |
| 5480 | switch (os) { |
| 5481 | case llvm::Triple::Linux: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5482 | return new LinuxTargetInfo<SystemZTargetInfo>(Triple); |
Ulrich Weigand | b840921 | 2013-05-06 16:26:41 +0000 | [diff] [blame] | 5483 | default: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5484 | return new SystemZTargetInfo(Triple); |
Ulrich Weigand | b840921 | 2013-05-06 16:26:41 +0000 | [diff] [blame] | 5485 | } |
| 5486 | |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 5487 | case llvm::Triple::tce: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5488 | return new TCETargetInfo(Triple); |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 5489 | |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5490 | case llvm::Triple::x86: |
Daniel Dunbar | db57a4c | 2011-04-19 21:43:27 +0000 | [diff] [blame] | 5491 | if (Triple.isOSDarwin()) |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5492 | return new DarwinI386TargetInfo(Triple); |
Daniel Dunbar | db57a4c | 2011-04-19 21:43:27 +0000 | [diff] [blame] | 5493 | |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5494 | switch (os) { |
Edward O'Callaghan | 991f9a7 | 2009-10-18 13:33:59 +0000 | [diff] [blame] | 5495 | case llvm::Triple::AuroraUX: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5496 | return new AuroraUXTargetInfo<X86_32TargetInfo>(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5497 | case llvm::Triple::Linux: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5498 | return new LinuxTargetInfo<X86_32TargetInfo>(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5499 | case llvm::Triple::DragonFly: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5500 | return new DragonFlyBSDTargetInfo<X86_32TargetInfo>(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5501 | case llvm::Triple::NetBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5502 | return new NetBSDI386TargetInfo(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5503 | case llvm::Triple::OpenBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5504 | return new OpenBSDI386TargetInfo(Triple); |
Eli Friedman | 42f74f2 | 2012-08-08 23:57:20 +0000 | [diff] [blame] | 5505 | case llvm::Triple::Bitrig: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5506 | return new BitrigI386TargetInfo(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5507 | case llvm::Triple::FreeBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5508 | return new FreeBSDTargetInfo<X86_32TargetInfo>(Triple); |
Sylvestre Ledru | 3309a78 | 2013-09-05 13:47:07 +0000 | [diff] [blame] | 5509 | case llvm::Triple::KFreeBSD: |
| 5510 | return new KFreeBSDTargetInfo<X86_32TargetInfo>(Triple); |
Chris Lattner | 38e317d | 2010-07-07 16:01:42 +0000 | [diff] [blame] | 5511 | case llvm::Triple::Minix: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5512 | return new MinixTargetInfo<X86_32TargetInfo>(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5513 | case llvm::Triple::Solaris: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5514 | return new SolarisTargetInfo<X86_32TargetInfo>(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5515 | case llvm::Triple::Cygwin: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5516 | return new CygwinX86_32TargetInfo(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5517 | case llvm::Triple::MinGW32: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5518 | return new MinGWX86_32TargetInfo(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5519 | case llvm::Triple::Win32: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5520 | return new VisualStudioWindowsX86_32TargetInfo(Triple); |
Chris Lattner | 86ed3a3 | 2010-04-11 19:29:39 +0000 | [diff] [blame] | 5521 | case llvm::Triple::Haiku: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5522 | return new HaikuX86_32TargetInfo(Triple); |
Douglas Gregor | dca5226 | 2011-07-01 22:41:14 +0000 | [diff] [blame] | 5523 | case llvm::Triple::RTEMS: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5524 | return new RTEMSX86_32TargetInfo(Triple); |
Eli Bendersky | 441d9f7 | 2012-12-04 18:38:10 +0000 | [diff] [blame] | 5525 | case llvm::Triple::NaCl: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5526 | return new NaClTargetInfo<X86_32TargetInfo>(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5527 | default: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5528 | return new X86_32TargetInfo(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5529 | } |
| 5530 | |
| 5531 | case llvm::Triple::x86_64: |
Daniel Dunbar | db57a4c | 2011-04-19 21:43:27 +0000 | [diff] [blame] | 5532 | if (Triple.isOSDarwin() || Triple.getEnvironment() == llvm::Triple::MachO) |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5533 | return new DarwinX86_64TargetInfo(Triple); |
Daniel Dunbar | db57a4c | 2011-04-19 21:43:27 +0000 | [diff] [blame] | 5534 | |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5535 | switch (os) { |
Edward O'Callaghan | 991f9a7 | 2009-10-18 13:33:59 +0000 | [diff] [blame] | 5536 | case llvm::Triple::AuroraUX: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5537 | return new AuroraUXTargetInfo<X86_64TargetInfo>(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5538 | case llvm::Triple::Linux: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5539 | return new LinuxTargetInfo<X86_64TargetInfo>(Triple); |
Chris Lattner | 7a7ca28 | 2010-01-09 05:41:14 +0000 | [diff] [blame] | 5540 | case llvm::Triple::DragonFly: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5541 | return new DragonFlyBSDTargetInfo<X86_64TargetInfo>(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5542 | case llvm::Triple::NetBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5543 | return new NetBSDTargetInfo<X86_64TargetInfo>(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5544 | case llvm::Triple::OpenBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5545 | return new OpenBSDX86_64TargetInfo(Triple); |
Eli Friedman | 42f74f2 | 2012-08-08 23:57:20 +0000 | [diff] [blame] | 5546 | case llvm::Triple::Bitrig: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5547 | return new BitrigX86_64TargetInfo(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5548 | case llvm::Triple::FreeBSD: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5549 | return new FreeBSDTargetInfo<X86_64TargetInfo>(Triple); |
Sylvestre Ledru | 3309a78 | 2013-09-05 13:47:07 +0000 | [diff] [blame] | 5550 | case llvm::Triple::KFreeBSD: |
| 5551 | return new KFreeBSDTargetInfo<X86_64TargetInfo>(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5552 | case llvm::Triple::Solaris: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5553 | return new SolarisTargetInfo<X86_64TargetInfo>(Triple); |
NAKAMURA Takumi | 0aa2057 | 2011-02-17 08:51:38 +0000 | [diff] [blame] | 5554 | case llvm::Triple::MinGW32: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5555 | return new MinGWX86_64TargetInfo(Triple); |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 5556 | case llvm::Triple::Win32: // This is what Triple.h supports now. |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5557 | return new VisualStudioWindowsX86_64TargetInfo(Triple); |
Eli Bendersky | 441d9f7 | 2012-12-04 18:38:10 +0000 | [diff] [blame] | 5558 | case llvm::Triple::NaCl: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5559 | return new NaClTargetInfo<X86_64TargetInfo>(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5560 | default: |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5561 | return new X86_64TargetInfo(Triple); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5562 | } |
Guy Benyei | bd5da3c | 2012-12-11 21:38:14 +0000 | [diff] [blame] | 5563 | |
| 5564 | case llvm::Triple::spir: { |
Guy Benyei | bd5da3c | 2012-12-11 21:38:14 +0000 | [diff] [blame] | 5565 | if (Triple.getOS() != llvm::Triple::UnknownOS || |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5566 | Triple.getEnvironment() != llvm::Triple::UnknownEnvironment) |
Guy Benyei | bd5da3c | 2012-12-11 21:38:14 +0000 | [diff] [blame] | 5567 | return NULL; |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5568 | return new SPIR32TargetInfo(Triple); |
Guy Benyei | bd5da3c | 2012-12-11 21:38:14 +0000 | [diff] [blame] | 5569 | } |
| 5570 | case llvm::Triple::spir64: { |
Guy Benyei | bd5da3c | 2012-12-11 21:38:14 +0000 | [diff] [blame] | 5571 | if (Triple.getOS() != llvm::Triple::UnknownOS || |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5572 | Triple.getEnvironment() != llvm::Triple::UnknownEnvironment) |
Guy Benyei | bd5da3c | 2012-12-11 21:38:14 +0000 | [diff] [blame] | 5573 | return NULL; |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5574 | return new SPIR64TargetInfo(Triple); |
Guy Benyei | bd5da3c | 2012-12-11 21:38:14 +0000 | [diff] [blame] | 5575 | } |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 5576 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 5577 | } |
Daniel Dunbar | d58c03f | 2009-11-15 06:48:46 +0000 | [diff] [blame] | 5578 | |
| 5579 | /// CreateTargetInfo - Return the target info object for the specified target |
| 5580 | /// triple. |
David Blaikie | d6471f7 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 5581 | TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags, |
Douglas Gregor | 49a8754 | 2012-11-16 04:24:59 +0000 | [diff] [blame] | 5582 | TargetOptions *Opts) { |
| 5583 | llvm::Triple Triple(Opts->Triple); |
Daniel Dunbar | d58c03f | 2009-11-15 06:48:46 +0000 | [diff] [blame] | 5584 | |
| 5585 | // Construct the target |
Benjamin Kramer | 9df0823 | 2013-06-29 16:37:14 +0000 | [diff] [blame] | 5586 | OwningPtr<TargetInfo> Target(AllocateTarget(Triple)); |
Daniel Dunbar | d58c03f | 2009-11-15 06:48:46 +0000 | [diff] [blame] | 5587 | if (!Target) { |
| 5588 | Diags.Report(diag::err_target_unknown_triple) << Triple.str(); |
| 5589 | return 0; |
| 5590 | } |
Douglas Gregor | 9a022bb | 2012-10-15 16:45:32 +0000 | [diff] [blame] | 5591 | Target->setTargetOpts(Opts); |
Daniel Dunbar | d58c03f | 2009-11-15 06:48:46 +0000 | [diff] [blame] | 5592 | |
Daniel Dunbar | eac7c53 | 2009-12-18 18:42:37 +0000 | [diff] [blame] | 5593 | // Set the target CPU if specified. |
Douglas Gregor | 49a8754 | 2012-11-16 04:24:59 +0000 | [diff] [blame] | 5594 | if (!Opts->CPU.empty() && !Target->setCPU(Opts->CPU)) { |
| 5595 | Diags.Report(diag::err_target_unknown_cpu) << Opts->CPU; |
Daniel Dunbar | eac7c53 | 2009-12-18 18:42:37 +0000 | [diff] [blame] | 5596 | return 0; |
| 5597 | } |
| 5598 | |
Daniel Dunbar | d58c03f | 2009-11-15 06:48:46 +0000 | [diff] [blame] | 5599 | // Set the target ABI if specified. |
Douglas Gregor | 49a8754 | 2012-11-16 04:24:59 +0000 | [diff] [blame] | 5600 | if (!Opts->ABI.empty() && !Target->setABI(Opts->ABI)) { |
| 5601 | Diags.Report(diag::err_target_unknown_abi) << Opts->ABI; |
Daniel Dunbar | d58c03f | 2009-11-15 06:48:46 +0000 | [diff] [blame] | 5602 | return 0; |
| 5603 | } |
| 5604 | |
Charles Davis | 98b7c5c | 2010-06-11 01:06:47 +0000 | [diff] [blame] | 5605 | // Set the target C++ ABI. |
Douglas Gregor | 49a8754 | 2012-11-16 04:24:59 +0000 | [diff] [blame] | 5606 | if (!Opts->CXXABI.empty() && !Target->setCXXABI(Opts->CXXABI)) { |
| 5607 | Diags.Report(diag::err_target_unknown_cxxabi) << Opts->CXXABI; |
Charles Davis | 98b7c5c | 2010-06-11 01:06:47 +0000 | [diff] [blame] | 5608 | return 0; |
| 5609 | } |
| 5610 | |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 5611 | // Set the fp math unit. |
| 5612 | if (!Opts->FPMath.empty() && !Target->setFPMath(Opts->FPMath)) { |
| 5613 | Diags.Report(diag::err_target_unknown_fpmath) << Opts->FPMath; |
| 5614 | return 0; |
| 5615 | } |
| 5616 | |
Daniel Dunbar | d58c03f | 2009-11-15 06:48:46 +0000 | [diff] [blame] | 5617 | // Compute the default target features, we need the target to handle this |
| 5618 | // because features may have dependencies on one another. |
| 5619 | llvm::StringMap<bool> Features; |
Chandler Carruth | c3a2e65 | 2011-09-28 05:56:05 +0000 | [diff] [blame] | 5620 | Target->getDefaultFeatures(Features); |
Daniel Dunbar | d58c03f | 2009-11-15 06:48:46 +0000 | [diff] [blame] | 5621 | |
Rafael Espindola | c84ed54 | 2013-08-20 18:57:55 +0000 | [diff] [blame] | 5622 | // Apply the user specified deltas. |
| 5623 | for (unsigned I = 0, N = Opts->FeaturesAsWritten.size(); |
| 5624 | I < N; ++I) { |
| 5625 | const char *Name = Opts->FeaturesAsWritten[I].c_str(); |
Rafael Espindola | 53ac3d8 | 2011-11-27 20:00:43 +0000 | [diff] [blame] | 5626 | // Apply the feature via the target. |
Rafael Espindola | c84ed54 | 2013-08-20 18:57:55 +0000 | [diff] [blame] | 5627 | bool Enabled = Name[0] == '+'; |
| 5628 | Target->setFeatureEnabled(Features, Name + 1, Enabled); |
Daniel Dunbar | d58c03f | 2009-11-15 06:48:46 +0000 | [diff] [blame] | 5629 | } |
| 5630 | |
| 5631 | // Add the features to the compile options. |
| 5632 | // |
| 5633 | // FIXME: If we are completely confident that we have the right set, we only |
| 5634 | // need to pass the minuses. |
Douglas Gregor | 49a8754 | 2012-11-16 04:24:59 +0000 | [diff] [blame] | 5635 | Opts->Features.clear(); |
Daniel Dunbar | d58c03f | 2009-11-15 06:48:46 +0000 | [diff] [blame] | 5636 | for (llvm::StringMap<bool>::const_iterator it = Features.begin(), |
| 5637 | ie = Features.end(); it != ie; ++it) |
Douglas Gregor | 49a8754 | 2012-11-16 04:24:59 +0000 | [diff] [blame] | 5638 | Opts->Features.push_back((it->second ? "+" : "-") + it->first().str()); |
Rafael Espindola | 5389b84 | 2013-08-21 21:59:03 +0000 | [diff] [blame] | 5639 | if (!Target->HandleTargetFeatures(Opts->Features, Diags)) |
| 5640 | return 0; |
Daniel Dunbar | d58c03f | 2009-11-15 06:48:46 +0000 | [diff] [blame] | 5641 | |
| 5642 | return Target.take(); |
| 5643 | } |