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 | |
Chris Lattner | 6b15cdc | 2009-06-14 01:05:48 +0000 | [diff] [blame] | 15 | #include "clang/Basic/Builtins.h" |
| 16 | #include "clang/Basic/TargetBuiltins.h" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 17 | #include "clang/Basic/TargetInfo.h" |
Chris Lattner | 8fc4dfb | 2008-12-04 22:54:33 +0000 | [diff] [blame] | 18 | #include "clang/Basic/LangOptions.h" |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/STLExtras.h" |
Eli Friedman | 2553126 | 2008-05-20 14:27:34 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/APFloat.h" |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/SmallString.h" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 22 | using namespace clang; |
| 23 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 24 | //===----------------------------------------------------------------------===// |
| 25 | // Common code shared among targets. |
| 26 | //===----------------------------------------------------------------------===// |
| 27 | |
Chris Lattner | d15fa82 | 2007-10-06 06:57:34 +0000 | [diff] [blame] | 28 | static void Define(std::vector<char> &Buf, const char *Macro, |
| 29 | const char *Val = "1") { |
| 30 | const char *Def = "#define "; |
| 31 | Buf.insert(Buf.end(), Def, Def+strlen(Def)); |
| 32 | Buf.insert(Buf.end(), Macro, Macro+strlen(Macro)); |
| 33 | Buf.push_back(' '); |
| 34 | Buf.insert(Buf.end(), Val, Val+strlen(Val)); |
| 35 | Buf.push_back('\n'); |
| 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. |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 41 | static void DefineStd(std::vector<char> &Buf, const char *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) |
| 48 | Define(Buf, 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. |
| 51 | llvm::SmallString<20> TmpStr; |
| 52 | TmpStr = "__"; |
| 53 | TmpStr += MacroName; |
| 54 | Define(Buf, TmpStr.c_str()); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 55 | |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 56 | // Define __unix__. |
| 57 | TmpStr += "__"; |
| 58 | Define(Buf, TmpStr.c_str()); |
| 59 | } |
| 60 | |
Chris Lattner | d29b630 | 2008-10-05 21:50:58 +0000 | [diff] [blame] | 61 | //===----------------------------------------------------------------------===// |
| 62 | // Defines specific to certain operating systems. |
| 63 | //===----------------------------------------------------------------------===// |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 64 | namespace { |
Douglas Gregor | a384492 | 2009-07-01 15:12:53 +0000 | [diff] [blame] | 65 | template<typename TgtInfo> |
| 66 | class OSTargetInfo : public TgtInfo { |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 67 | protected: |
| 68 | virtual void getOSDefines(const LangOptions &Opts, const char *Triple, |
| 69 | std::vector<char> &Defines) const=0; |
| 70 | public: |
Douglas Gregor | a384492 | 2009-07-01 15:12:53 +0000 | [diff] [blame] | 71 | OSTargetInfo(const std::string& triple) : TgtInfo(triple) {} |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 72 | virtual void getTargetDefines(const LangOptions &Opts, |
| 73 | std::vector<char> &Defines) const { |
Douglas Gregor | a384492 | 2009-07-01 15:12:53 +0000 | [diff] [blame] | 74 | TgtInfo::getTargetDefines(Opts, Defines); |
| 75 | getOSDefines(Opts, TgtInfo::getTargetTriple(), Defines); |
Torok Edwin | b0a5b24 | 2009-06-30 17:00:25 +0000 | [diff] [blame] | 76 | } |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 77 | |
| 78 | }; |
Torok Edwin | b0a5b24 | 2009-06-30 17:00:25 +0000 | [diff] [blame] | 79 | } |
| 80 | |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 81 | namespace { |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 82 | /// getDarwinNumber - Parse the 'darwin number' out of the specific targe |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 83 | /// triple. For example, if we have darwin8.5 return 8,5,0. If any entry is |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 84 | /// not defined, return 0's. Return true if we have -darwin in the string or |
| 85 | /// false otherwise. |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 86 | static bool getDarwinNumber(const char *Triple, unsigned &Maj, unsigned &Min, unsigned &Revision) { |
| 87 | Maj = Min = Revision = 0; |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 88 | const char *Darwin = strstr(Triple, "-darwin"); |
| 89 | if (Darwin == 0) return false; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 90 | |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 91 | Darwin += strlen("-darwin"); |
| 92 | if (Darwin[0] < '0' || Darwin[0] > '9') |
| 93 | return true; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 94 | |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 95 | Maj = Darwin[0]-'0'; |
| 96 | ++Darwin; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 97 | |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 98 | // Handle "darwin11". |
| 99 | if (Maj == 1 && Darwin[0] >= '0' && Darwin[0] <= '9') { |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 100 | Maj = Maj*10 + (Darwin[0] - '0'); |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 101 | ++Darwin; |
| 102 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 103 | |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 104 | // Handle minor version: 10.4.9 -> darwin8.9 -> "1049" |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 105 | if (Darwin[0] != '.') |
| 106 | return true; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 107 | |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 108 | ++Darwin; |
| 109 | if (Darwin[0] < '0' || Darwin[0] > '9') |
| 110 | return true; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 111 | |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 112 | Min = Darwin[0]-'0'; |
| 113 | ++Darwin; |
| 114 | |
| 115 | // Handle 10.4.11 -> darwin8.11 |
| 116 | if (Min == 1 && Darwin[0] >= '0' && Darwin[0] <= '9') { |
| 117 | Min = Min*10 + (Darwin[0] - '0'); |
| 118 | ++Darwin; |
| 119 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 120 | |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 121 | // Handle revision darwin8.9.1 |
| 122 | if (Darwin[0] != '.') |
| 123 | return true; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 124 | |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 125 | ++Darwin; |
| 126 | if (Darwin[0] < '0' || Darwin[0] > '9') |
| 127 | return true; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 128 | |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 129 | Revision = Darwin[0]-'0'; |
| 130 | ++Darwin; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 131 | |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 132 | if (Revision == 1 && Darwin[0] >= '0' && Darwin[0] <= '9') { |
| 133 | Revision = Revision*10 + (Darwin[0] - '0'); |
| 134 | ++Darwin; |
| 135 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 136 | |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 137 | return true; |
| 138 | } |
| 139 | |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 140 | static void getDarwinDefines(std::vector<char> &Defs, const LangOptions &Opts) { |
Chris Lattner | 7478bbf | 2009-06-23 00:43:21 +0000 | [diff] [blame] | 141 | Define(Defs, "__APPLE_CC__", "5621"); |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 142 | Define(Defs, "__APPLE__"); |
| 143 | Define(Defs, "__MACH__"); |
Chris Lattner | d427ad4 | 2009-02-05 07:19:24 +0000 | [diff] [blame] | 144 | Define(Defs, "OBJC_NEW_PROPERTIES"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 145 | |
Chris Lattner | 10d2427 | 2009-04-07 16:50:40 +0000 | [diff] [blame] | 146 | // __weak is always defined, for use in blocks and with objc pointers. |
| 147 | Define(Defs, "__weak", "__attribute__((objc_gc(weak)))"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 148 | |
Chris Lattner | 10d2427 | 2009-04-07 16:50:40 +0000 | [diff] [blame] | 149 | // Darwin defines __strong even in C mode (just to nothing). |
| 150 | if (!Opts.ObjC1 || Opts.getGCMode() == LangOptions::NonGC) |
Chris Lattner | 3a5cbd3 | 2009-04-07 04:48:21 +0000 | [diff] [blame] | 151 | Define(Defs, "__strong", ""); |
Chris Lattner | 10d2427 | 2009-04-07 16:50:40 +0000 | [diff] [blame] | 152 | else |
Chris Lattner | 3a5cbd3 | 2009-04-07 04:48:21 +0000 | [diff] [blame] | 153 | Define(Defs, "__strong", "__attribute__((objc_gc(strong)))"); |
Eli Friedman | 2de4fee | 2009-06-04 23:00:29 +0000 | [diff] [blame] | 154 | |
| 155 | if (Opts.Static) |
| 156 | Define(Defs, "__STATIC__"); |
| 157 | else |
| 158 | Define(Defs, "__DYNAMIC__"); |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | static void getDarwinOSXDefines(std::vector<char> &Defs, const char *Triple) { |
Chris Lattner | 8b30c41 | 2008-09-30 01:00:25 +0000 | [diff] [blame] | 162 | // Figure out which "darwin number" the target triple is. "darwin9" -> 10.5. |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 163 | unsigned Maj, Min, Rev; |
| 164 | if (getDarwinNumber(Triple, Maj, Min, Rev)) { |
| 165 | char MacOSXStr[] = "1000"; |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 166 | if (Maj >= 4 && Maj <= 13) { // 10.0-10.9 |
| 167 | // darwin7 -> 1030, darwin8 -> 1040, darwin9 -> 1050, etc. |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 168 | MacOSXStr[2] = '0' + Maj-4; |
| 169 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 170 | |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 171 | // Handle minor version: 10.4.9 -> darwin8.9 -> "1049" |
| 172 | // Cap 10.4.11 -> darwin8.11 -> "1049" |
| 173 | MacOSXStr[3] = std::min(Min, 9U)+'0'; |
| 174 | Define(Defs, "__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__", MacOSXStr); |
| 175 | } |
| 176 | } |
| 177 | |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 178 | static void getDarwinIPhoneOSDefines(std::vector<char> &Defs, |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 179 | const char *Triple) { |
| 180 | // Figure out which "darwin number" the target triple is. "darwin9" -> 10.5. |
| 181 | unsigned Maj, Min, Rev; |
| 182 | if (getDarwinNumber(Triple, Maj, Min, Rev)) { |
| 183 | // When targetting iPhone OS, interpret the minor version and |
| 184 | // revision as the iPhone OS version |
| 185 | char iPhoneOSStr[] = "10000"; |
| 186 | if (Min >= 2 && Min <= 9) { // iPhone OS 2.0-9.0 |
| 187 | // darwin9.2.0 -> 20000, darwin9.3.0 -> 30000, etc. |
| 188 | iPhoneOSStr[0] = '0' + Min; |
Chris Lattner | 8b30c41 | 2008-09-30 01:00:25 +0000 | [diff] [blame] | 189 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 190 | |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 191 | // Handle minor version: 2.2 -> darwin9.2.2 -> 20200 |
| 192 | iPhoneOSStr[2] = std::min(Rev, 9U)+'0'; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 193 | Define(Defs, "__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__", |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 194 | iPhoneOSStr); |
Chris Lattner | 8b30c41 | 2008-09-30 01:00:25 +0000 | [diff] [blame] | 195 | } |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 196 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 197 | |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 198 | /// GetDarwinLanguageOptions - Set the default language options for darwin. |
| 199 | static void GetDarwinLanguageOptions(LangOptions &Opts, |
| 200 | const char *Triple) { |
| 201 | Opts.NeXTRuntime = true; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 202 | |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 203 | unsigned Maj, Min, Rev; |
| 204 | if (!getDarwinNumber(Triple, Maj, Min, Rev)) |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 205 | return; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 206 | |
Bill Wendling | 45483f7 | 2009-06-28 07:36:13 +0000 | [diff] [blame] | 207 | // Blocks and stack protectors default to on for 10.6 (darwin10) and beyond. |
| 208 | if (Maj > 9) { |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 209 | Opts.Blocks = 1; |
Bill Wendling | 4ebe3e4 | 2009-06-28 23:01:01 +0000 | [diff] [blame] | 210 | Opts.setStackProtectorMode(LangOptions::SSPOn); |
Bill Wendling | 45483f7 | 2009-06-28 07:36:13 +0000 | [diff] [blame] | 211 | } |
Fariborz Jahanian | 66a5c2c | 2009-02-24 23:34:44 +0000 | [diff] [blame] | 212 | |
Bill Wendling | 45483f7 | 2009-06-28 07:36:13 +0000 | [diff] [blame] | 213 | // Non-fragile ABI (in 64-bit mode) default to on for 10.5 (darwin9) and |
| 214 | // beyond. |
Fariborz Jahanian | 84d0133 | 2009-02-24 23:38:42 +0000 | [diff] [blame] | 215 | if (Maj >= 9 && Opts.ObjC1 && !strncmp(Triple, "x86_64", 6)) |
| 216 | Opts.ObjCNonFragileABI = 1; |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 217 | } |
| 218 | |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 219 | template<typename Target> |
| 220 | class DarwinTargetInfo : public OSTargetInfo<Target> { |
| 221 | protected: |
| 222 | virtual void getOSDefines(const LangOptions &Opts, const char *Triple, |
| 223 | std::vector<char> &Defines) const { |
| 224 | getDarwinDefines(Defines, Opts); |
| 225 | getDarwinOSXDefines(Defines, Triple); |
| 226 | } |
| 227 | |
| 228 | /// getDefaultLangOptions - Allow the target to specify default settings for |
| 229 | /// various language options. These may be overridden by command line |
| 230 | /// options. |
| 231 | virtual void getDefaultLangOptions(LangOptions &Opts) { |
| 232 | TargetInfo::getDefaultLangOptions(Opts); |
| 233 | GetDarwinLanguageOptions(Opts, TargetInfo::getTargetTriple()); |
| 234 | } |
| 235 | public: |
| 236 | DarwinTargetInfo(const std::string& triple) : |
| 237 | OSTargetInfo<Target>(triple) { |
| 238 | this->TLSSupported = false; |
| 239 | } |
| 240 | |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 241 | virtual const char *getUnicodeStringSymbolPrefix() const { |
| 242 | return "__utf16_string_"; |
| 243 | } |
| 244 | |
| 245 | virtual const char *getUnicodeStringSection() const { |
| 246 | return "__TEXT,__ustring"; |
| 247 | } |
| 248 | }; |
| 249 | |
| 250 | // DragonFlyBSD Target |
| 251 | template<typename Target> |
| 252 | class DragonFlyBSDTargetInfo : public OSTargetInfo<Target> { |
| 253 | protected: |
| 254 | virtual void getOSDefines(const LangOptions &Opts, const char *Triple, |
| 255 | std::vector<char> &Defs) const { |
| 256 | // DragonFly defines; list based off of gcc output |
| 257 | Define(Defs, "__DragonFly__"); |
| 258 | Define(Defs, "__DragonFly_cc_version", "100001"); |
| 259 | Define(Defs, "__ELF__"); |
| 260 | Define(Defs, "__KPRINTF_ATTRIBUTE__"); |
| 261 | Define(Defs, "__tune_i386__"); |
| 262 | DefineStd(Defs, "unix", Opts); |
| 263 | } |
| 264 | public: |
| 265 | DragonFlyBSDTargetInfo(const std::string &triple) |
| 266 | : OSTargetInfo<Target>(triple) {} |
| 267 | }; |
| 268 | |
| 269 | // FreeBSD Target |
| 270 | template<typename Target> |
| 271 | class FreeBSDTargetInfo : public OSTargetInfo<Target> { |
| 272 | protected: |
| 273 | virtual void getOSDefines(const LangOptions &Opts, const char *Triple, |
| 274 | std::vector<char> &Defs) const { |
| 275 | // FreeBSD defines; list based off of gcc output |
| 276 | |
| 277 | const char *FreeBSD = strstr(Triple, "-freebsd"); |
| 278 | FreeBSD += strlen("-freebsd"); |
| 279 | char release[] = "X"; |
| 280 | release[0] = FreeBSD[0]; |
| 281 | char version[] = "X00001"; |
| 282 | version[0] = FreeBSD[0]; |
| 283 | |
| 284 | Define(Defs, "__FreeBSD__", release); |
| 285 | Define(Defs, "__FreeBSD_cc_version", version); |
| 286 | Define(Defs, "__KPRINTF_ATTRIBUTE__"); |
| 287 | DefineStd(Defs, "unix", Opts); |
| 288 | Define(Defs, "__ELF__", "1"); |
| 289 | } |
| 290 | public: |
| 291 | FreeBSDTargetInfo(const std::string &triple) |
Duncan Sands | 1e90faf | 2009-07-08 13:55:08 +0000 | [diff] [blame] | 292 | : OSTargetInfo<Target>(triple) { |
| 293 | this->UserLabelPrefix = ""; |
| 294 | } |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 295 | }; |
| 296 | |
| 297 | // Linux target |
| 298 | template<typename Target> |
| 299 | class LinuxTargetInfo : public OSTargetInfo<Target> { |
| 300 | protected: |
| 301 | virtual void getOSDefines(const LangOptions &Opts, const char *Triple, |
| 302 | std::vector<char> &Defs) const { |
| 303 | // Linux defines; list based off of gcc output |
| 304 | DefineStd(Defs, "unix", Opts); |
| 305 | DefineStd(Defs, "linux", Opts); |
| 306 | Define(Defs, "__gnu_linux__"); |
| 307 | Define(Defs, "__ELF__", "1"); |
| 308 | } |
| 309 | public: |
| 310 | LinuxTargetInfo(const std::string& triple) |
| 311 | : OSTargetInfo<Target>(triple) { |
| 312 | this->UserLabelPrefix = ""; |
| 313 | } |
| 314 | }; |
| 315 | |
Chris Lattner | b62bb28 | 2009-07-13 20:29:08 +0000 | [diff] [blame] | 316 | // NetBSD Target |
| 317 | template<typename Target> |
| 318 | class NetBSDTargetInfo : public OSTargetInfo<Target> { |
| 319 | protected: |
| 320 | virtual void getOSDefines(const LangOptions &Opts, const char *Triple, |
| 321 | std::vector<char> &Defs) const { |
| 322 | // NetBSD defines; list based off of gcc output |
| 323 | Define(Defs, "__NetBSD__", "1"); |
| 324 | Define(Defs, "__unix__", "1"); |
| 325 | Define(Defs, "__ELF__", "1"); |
| 326 | } |
| 327 | public: |
| 328 | NetBSDTargetInfo(const std::string &triple) |
| 329 | : OSTargetInfo<Target>(triple) { |
| 330 | this->UserLabelPrefix = ""; |
| 331 | } |
| 332 | }; |
| 333 | |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 334 | // OpenBSD Target |
| 335 | template<typename Target> |
| 336 | class OpenBSDTargetInfo : public OSTargetInfo<Target> { |
| 337 | protected: |
| 338 | virtual void getOSDefines(const LangOptions &Opts, const char *Triple, |
| 339 | std::vector<char> &Defs) const { |
| 340 | // OpenBSD defines; list based off of gcc output |
| 341 | |
| 342 | Define(Defs, "__OpenBSD__", "1"); |
| 343 | DefineStd(Defs, "unix", Opts); |
| 344 | Define(Defs, "__ELF__", "1"); |
| 345 | } |
| 346 | public: |
| 347 | OpenBSDTargetInfo(const std::string &triple) |
| 348 | : OSTargetInfo<Target>(triple) {} |
| 349 | }; |
| 350 | |
| 351 | // Solaris target |
| 352 | template<typename Target> |
| 353 | class SolarisTargetInfo : public OSTargetInfo<Target> { |
| 354 | protected: |
| 355 | virtual void getOSDefines(const LangOptions &Opts, const char *Triple, |
| 356 | std::vector<char> &Defs) const { |
| 357 | DefineStd(Defs, "sun", Opts); |
| 358 | DefineStd(Defs, "unix", Opts); |
| 359 | Define(Defs, "__ELF__"); |
| 360 | Define(Defs, "__svr4__"); |
| 361 | Define(Defs, "__SVR4"); |
| 362 | } |
| 363 | public: |
| 364 | SolarisTargetInfo(const std::string& triple) |
| 365 | : OSTargetInfo<Target>(triple) { |
| 366 | this->UserLabelPrefix = ""; |
| 367 | this->WCharType = this->SignedLong; |
| 368 | // FIXME: WIntType should be SignedLong |
| 369 | } |
| 370 | }; |
| 371 | } // end anonymous namespace. |
| 372 | |
Eli Friedman | abc4e32 | 2009-06-08 06:11:14 +0000 | [diff] [blame] | 373 | /// GetWindowsLanguageOptions - Set the default language options for Windows. |
| 374 | static void GetWindowsLanguageOptions(LangOptions &Opts, |
| 375 | const char *Triple) { |
| 376 | Opts.Microsoft = true; |
| 377 | } |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 378 | |
Chris Lattner | d29b630 | 2008-10-05 21:50:58 +0000 | [diff] [blame] | 379 | //===----------------------------------------------------------------------===// |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 380 | // Specific target implementations. |
| 381 | //===----------------------------------------------------------------------===// |
Anders Carlsson | fb5e5ba | 2007-10-13 00:45:48 +0000 | [diff] [blame] | 382 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 383 | namespace { |
| 384 | // PPC abstract base class |
| 385 | class PPCTargetInfo : public TargetInfo { |
| 386 | static const Builtin::Info BuiltinInfo[]; |
| 387 | static const char * const GCCRegNames[]; |
| 388 | static const TargetInfo::GCCRegAlias GCCRegAliases[]; |
| 389 | |
| 390 | public: |
Eli Friedman | 15b9176 | 2009-06-05 07:05:05 +0000 | [diff] [blame] | 391 | PPCTargetInfo(const std::string& triple) : TargetInfo(triple) {} |
| 392 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 393 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 394 | unsigned &NumRecords) const { |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 395 | Records = BuiltinInfo; |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 396 | NumRecords = clang::PPC::LastTSBuiltin-Builtin::FirstTSBuiltin; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 397 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 398 | |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 399 | virtual void getTargetDefines(const LangOptions &Opts, |
| 400 | std::vector<char> &Defines) const; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 401 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 402 | virtual const char *getVAListDeclaration() const { |
Chris Lattner | d599850 | 2008-10-27 01:11:29 +0000 | [diff] [blame] | 403 | return "typedef char* __builtin_va_list;"; |
| 404 | // This is the right definition for ABI/V4: System V.4/eabi. |
| 405 | /*return "typedef struct __va_list_tag {" |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 406 | " unsigned char gpr;" |
| 407 | " unsigned char fpr;" |
| 408 | " unsigned short reserved;" |
| 409 | " void* overflow_arg_area;" |
| 410 | " void* reg_save_area;" |
Chris Lattner | d599850 | 2008-10-27 01:11:29 +0000 | [diff] [blame] | 411 | "} __builtin_va_list[1];";*/ |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 412 | } |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 413 | virtual const char *getTargetPrefix() const { |
| 414 | return "ppc"; |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 415 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 416 | virtual void getGCCRegNames(const char * const *&Names, |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 417 | unsigned &NumNames) const; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 418 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 419 | unsigned &NumAliases) const; |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 420 | virtual bool validateAsmConstraint(const char *&Name, |
Chris Lattner | 44def07 | 2009-04-26 07:16:29 +0000 | [diff] [blame] | 421 | TargetInfo::ConstraintInfo &Info) const { |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 422 | switch (*Name) { |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 423 | default: return false; |
| 424 | case 'O': // Zero |
| 425 | return true; |
| 426 | case 'b': // Base register |
| 427 | case 'f': // Floating point register |
Chris Lattner | 44def07 | 2009-04-26 07:16:29 +0000 | [diff] [blame] | 428 | Info.setAllowsRegister(); |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 429 | return true; |
| 430 | } |
| 431 | } |
Eli Friedman | 15b9176 | 2009-06-05 07:05:05 +0000 | [diff] [blame] | 432 | virtual void getDefaultLangOptions(LangOptions &Opts) { |
| 433 | TargetInfo::getDefaultLangOptions(Opts); |
| 434 | Opts.CharIsSigned = false; |
| 435 | } |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 436 | virtual const char *getClobbers() const { |
| 437 | return ""; |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 438 | } |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 439 | }; |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 440 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 441 | const Builtin::Info PPCTargetInfo::BuiltinInfo[] = { |
Douglas Gregor | b1152d8 | 2009-02-16 21:58:21 +0000 | [diff] [blame] | 442 | #define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, false }, |
| 443 | #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER, false }, |
Chris Lattner | 6b15cdc | 2009-06-14 01:05:48 +0000 | [diff] [blame] | 444 | #include "clang/Basic/BuiltinsPPC.def" |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 445 | }; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 446 | |
| 447 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 448 | /// PPCTargetInfo::getTargetDefines - Return a set of the PowerPC-specific |
| 449 | /// #defines that are not tied to a specific subtarget. |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 450 | void PPCTargetInfo::getTargetDefines(const LangOptions &Opts, |
| 451 | std::vector<char> &Defs) const { |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 452 | // Target identification. |
| 453 | Define(Defs, "__ppc__"); |
| 454 | Define(Defs, "_ARCH_PPC"); |
| 455 | Define(Defs, "__POWERPC__"); |
| 456 | if (PointerWidth == 64) { |
| 457 | Define(Defs, "_ARCH_PPC64"); |
| 458 | Define(Defs, "_LP64"); |
| 459 | Define(Defs, "__LP64__"); |
| 460 | Define(Defs, "__ppc64__"); |
| 461 | } else { |
| 462 | Define(Defs, "__ppc__"); |
| 463 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 464 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 465 | // Target properties. |
| 466 | Define(Defs, "_BIG_ENDIAN"); |
| 467 | Define(Defs, "__BIG_ENDIAN__"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 468 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 469 | // Subtarget options. |
| 470 | Define(Defs, "__NATURAL_ALIGNMENT__"); |
| 471 | Define(Defs, "__REGISTER_PREFIX__", ""); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 472 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 473 | // FIXME: Should be controlled by command line option. |
| 474 | Define(Defs, "__LONG_DOUBLE_128__"); |
| 475 | } |
| 476 | |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 477 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 478 | const char * const PPCTargetInfo::GCCRegNames[] = { |
| 479 | "0", "1", "2", "3", "4", "5", "6", "7", |
| 480 | "8", "9", "10", "11", "12", "13", "14", "15", |
| 481 | "16", "17", "18", "19", "20", "21", "22", "23", |
| 482 | "24", "25", "26", "27", "28", "29", "30", "31", |
| 483 | "0", "1", "2", "3", "4", "5", "6", "7", |
| 484 | "8", "9", "10", "11", "12", "13", "14", "15", |
| 485 | "16", "17", "18", "19", "20", "21", "22", "23", |
| 486 | "24", "25", "26", "27", "28", "29", "30", "31", |
| 487 | "mq", "lr", "ctr", "ap", |
| 488 | "0", "1", "2", "3", "4", "5", "6", "7", |
| 489 | "xer", |
| 490 | "0", "1", "2", "3", "4", "5", "6", "7", |
| 491 | "8", "9", "10", "11", "12", "13", "14", "15", |
| 492 | "16", "17", "18", "19", "20", "21", "22", "23", |
| 493 | "24", "25", "26", "27", "28", "29", "30", "31", |
| 494 | "vrsave", "vscr", |
| 495 | "spe_acc", "spefscr", |
| 496 | "sfp" |
| 497 | }; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 498 | |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 499 | void PPCTargetInfo::getGCCRegNames(const char * const *&Names, |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 500 | unsigned &NumNames) const { |
| 501 | Names = GCCRegNames; |
| 502 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 503 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 504 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 505 | const TargetInfo::GCCRegAlias PPCTargetInfo::GCCRegAliases[] = { |
| 506 | // While some of these aliases do map to different registers |
| 507 | // they still share the same register name. |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 508 | { { "cc", "cr0", "fr0", "r0", "v0"}, "0" }, |
| 509 | { { "cr1", "fr1", "r1", "sp", "v1"}, "1" }, |
| 510 | { { "cr2", "fr2", "r2", "toc", "v2"}, "2" }, |
| 511 | { { "cr3", "fr3", "r3", "v3"}, "3" }, |
| 512 | { { "cr4", "fr4", "r4", "v4"}, "4" }, |
| 513 | { { "cr5", "fr5", "r5", "v5"}, "5" }, |
| 514 | { { "cr6", "fr6", "r6", "v6"}, "6" }, |
| 515 | { { "cr7", "fr7", "r7", "v7"}, "7" }, |
| 516 | { { "fr8", "r8", "v8"}, "8" }, |
| 517 | { { "fr9", "r9", "v9"}, "9" }, |
| 518 | { { "fr10", "r10", "v10"}, "10" }, |
| 519 | { { "fr11", "r11", "v11"}, "11" }, |
| 520 | { { "fr12", "r12", "v12"}, "12" }, |
| 521 | { { "fr13", "r13", "v13"}, "13" }, |
| 522 | { { "fr14", "r14", "v14"}, "14" }, |
| 523 | { { "fr15", "r15", "v15"}, "15" }, |
| 524 | { { "fr16", "r16", "v16"}, "16" }, |
| 525 | { { "fr17", "r17", "v17"}, "17" }, |
| 526 | { { "fr18", "r18", "v18"}, "18" }, |
| 527 | { { "fr19", "r19", "v19"}, "19" }, |
| 528 | { { "fr20", "r20", "v20"}, "20" }, |
| 529 | { { "fr21", "r21", "v21"}, "21" }, |
| 530 | { { "fr22", "r22", "v22"}, "22" }, |
| 531 | { { "fr23", "r23", "v23"}, "23" }, |
| 532 | { { "fr24", "r24", "v24"}, "24" }, |
| 533 | { { "fr25", "r25", "v25"}, "25" }, |
| 534 | { { "fr26", "r26", "v26"}, "26" }, |
| 535 | { { "fr27", "r27", "v27"}, "27" }, |
| 536 | { { "fr28", "r28", "v28"}, "28" }, |
| 537 | { { "fr29", "r29", "v29"}, "29" }, |
| 538 | { { "fr30", "r30", "v30"}, "30" }, |
| 539 | { { "fr31", "r31", "v31"}, "31" }, |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 540 | }; |
| 541 | |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 542 | void PPCTargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases, |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 543 | unsigned &NumAliases) const { |
| 544 | Aliases = GCCRegAliases; |
| 545 | NumAliases = llvm::array_lengthof(GCCRegAliases); |
| 546 | } |
| 547 | } // end anonymous namespace. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 548 | |
| 549 | namespace { |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 550 | class PPC32TargetInfo : public PPCTargetInfo { |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 551 | public: |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 552 | PPC32TargetInfo(const std::string& triple) : PPCTargetInfo(triple) { |
| 553 | DescriptionString = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 554 | "i64:64:64-f32:32:32-f64:64:64-v128:128:128"; |
| 555 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 556 | }; |
| 557 | } // end anonymous namespace. |
| 558 | |
| 559 | namespace { |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 560 | class PPC64TargetInfo : public PPCTargetInfo { |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 561 | public: |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 562 | PPC64TargetInfo(const std::string& triple) : PPCTargetInfo(triple) { |
Chris Lattner | f291b10 | 2008-05-09 06:17:04 +0000 | [diff] [blame] | 563 | LongWidth = LongAlign = PointerWidth = PointerAlign = 64; |
Eli Friedman | 3c7b6e4 | 2009-07-01 03:36:11 +0000 | [diff] [blame] | 564 | IntMaxType = SignedLong; |
| 565 | UIntMaxType = UnsignedLong; |
| 566 | Int64Type = SignedLong; |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 567 | DescriptionString = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 568 | "i64:64:64-f32:32:32-f64:64:64-v128:128:128"; |
Chris Lattner | f291b10 | 2008-05-09 06:17:04 +0000 | [diff] [blame] | 569 | } |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 570 | }; |
| 571 | } // end anonymous namespace. |
| 572 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 573 | namespace { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 574 | // Namespace for x86 abstract base class |
| 575 | const Builtin::Info BuiltinInfo[] = { |
Douglas Gregor | b1152d8 | 2009-02-16 21:58:21 +0000 | [diff] [blame] | 576 | #define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, false }, |
| 577 | #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER, false }, |
Chris Lattner | 6b15cdc | 2009-06-14 01:05:48 +0000 | [diff] [blame] | 578 | #include "clang/Basic/BuiltinsX86.def" |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 579 | }; |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 580 | |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 581 | const char *GCCRegNames[] = { |
| 582 | "ax", "dx", "cx", "bx", "si", "di", "bp", "sp", |
| 583 | "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)", |
| 584 | "argp", "flags", "fspr", "dirflag", "frame", |
| 585 | "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", |
| 586 | "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7", |
| 587 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", |
| 588 | "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15" |
| 589 | }; |
| 590 | |
| 591 | const TargetInfo::GCCRegAlias GCCRegAliases[] = { |
| 592 | { { "al", "ah", "eax", "rax" }, "ax" }, |
| 593 | { { "bl", "bh", "ebx", "rbx" }, "bx" }, |
| 594 | { { "cl", "ch", "ecx", "rcx" }, "cx" }, |
| 595 | { { "dl", "dh", "edx", "rdx" }, "dx" }, |
| 596 | { { "esi", "rsi" }, "si" }, |
| 597 | { { "edi", "rdi" }, "di" }, |
| 598 | { { "esp", "rsp" }, "sp" }, |
| 599 | { { "ebp", "rbp" }, "bp" }, |
| 600 | }; |
| 601 | |
| 602 | // X86 target abstract base class; x86-32 and x86-64 are very close, so |
| 603 | // most of the implementation can be shared. |
| 604 | class X86TargetInfo : public TargetInfo { |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 605 | enum X86SSEEnum { |
| 606 | NoMMXSSE, MMX, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42 |
| 607 | } SSELevel; |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 608 | public: |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 609 | X86TargetInfo(const std::string& triple) |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 610 | : TargetInfo(triple), SSELevel(NoMMXSSE) { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 611 | LongDoubleFormat = &llvm::APFloat::x87DoubleExtended; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 612 | } |
| 613 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 614 | unsigned &NumRecords) const { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 615 | Records = BuiltinInfo; |
| 616 | NumRecords = clang::X86::LastTSBuiltin-Builtin::FirstTSBuiltin; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 617 | } |
Anders Carlsson | 44fe49c | 2007-12-08 19:32:57 +0000 | [diff] [blame] | 618 | virtual const char *getTargetPrefix() const { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 619 | return "x86"; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 620 | } |
| 621 | virtual void getGCCRegNames(const char * const *&Names, |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 622 | unsigned &NumNames) const { |
| 623 | Names = GCCRegNames; |
| 624 | NumNames = llvm::array_lengthof(GCCRegNames); |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 625 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 626 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 627 | unsigned &NumAliases) const { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 628 | Aliases = GCCRegAliases; |
| 629 | NumAliases = llvm::array_lengthof(GCCRegAliases); |
Anders Carlsson | fb5e5ba | 2007-10-13 00:45:48 +0000 | [diff] [blame] | 630 | } |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 631 | virtual bool validateAsmConstraint(const char *&Name, |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 632 | TargetInfo::ConstraintInfo &info) const; |
| 633 | virtual std::string convertConstraint(const char Constraint) const; |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 634 | virtual const char *getClobbers() const { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 635 | return "~{dirflag},~{fpsr},~{flags}"; |
| 636 | } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 637 | virtual void getTargetDefines(const LangOptions &Opts, |
| 638 | std::vector<char> &Defines) const; |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 639 | virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features, |
| 640 | const std::string &Name, |
| 641 | bool Enabled) const; |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 642 | virtual void getDefaultFeatures(const std::string &CPU, |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 643 | llvm::StringMap<bool> &Features) const; |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 644 | virtual void HandleTargetFeatures(const llvm::StringMap<bool> &Features); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 645 | }; |
Chris Lattner | 3daed52 | 2009-03-02 22:20:04 +0000 | [diff] [blame] | 646 | |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 647 | void X86TargetInfo::getDefaultFeatures(const std::string &CPU, |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 648 | llvm::StringMap<bool> &Features) const { |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 649 | // FIXME: This should not be here. |
| 650 | Features["3dnow"] = false; |
| 651 | Features["3dnowa"] = false; |
| 652 | Features["mmx"] = false; |
| 653 | Features["sse"] = false; |
| 654 | Features["sse2"] = false; |
| 655 | Features["sse3"] = false; |
| 656 | Features["ssse3"] = false; |
| 657 | Features["sse41"] = false; |
| 658 | Features["sse42"] = false; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 659 | |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 660 | // LLVM does not currently recognize this. |
| 661 | // Features["sse4a"] = false; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 662 | |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 663 | // FIXME: This *really* should not be here. |
| 664 | |
| 665 | // X86_64 always has SSE2. |
| 666 | if (PointerWidth == 64) |
| 667 | Features["sse2"] = Features["sse"] = Features["mmx"] = true; |
| 668 | |
Daniel Dunbar | 3ac7904 | 2009-05-06 21:56:32 +0000 | [diff] [blame] | 669 | if (CPU == "generic" || CPU == "i386" || CPU == "i486" || CPU == "i586" || |
| 670 | CPU == "pentium" || CPU == "i686" || CPU == "pentiumpro") |
| 671 | ; |
| 672 | else if (CPU == "pentium-mmx" || CPU == "pentium2") |
| 673 | setFeatureEnabled(Features, "mmx", true); |
| 674 | else if (CPU == "pentium3") |
| 675 | setFeatureEnabled(Features, "sse", true); |
| 676 | else if (CPU == "pentium-m" || CPU == "pentium4" || CPU == "x86-64") |
| 677 | setFeatureEnabled(Features, "sse2", true); |
| 678 | else if (CPU == "yonah" || CPU == "prescott" || CPU == "nocona") |
| 679 | setFeatureEnabled(Features, "sse3", true); |
| 680 | else if (CPU == "core2") |
| 681 | setFeatureEnabled(Features, "ssse3", true); |
| 682 | else if (CPU == "penryn") { |
| 683 | setFeatureEnabled(Features, "sse4", true); |
| 684 | Features["sse42"] = false; |
| 685 | } else if (CPU == "atom") |
| 686 | setFeatureEnabled(Features, "sse3", true); |
| 687 | else if (CPU == "corei7") |
| 688 | setFeatureEnabled(Features, "sse4", true); |
| 689 | else if (CPU == "k6" || CPU == "winchip-c6") |
| 690 | setFeatureEnabled(Features, "mmx", true); |
| 691 | else if (CPU == "k6-2" || CPU == "k6-3" || CPU == "athlon" || |
| 692 | CPU == "athlon-tbird" || CPU == "winchip2" || CPU == "c3") { |
| 693 | setFeatureEnabled(Features, "mmx", true); |
| 694 | setFeatureEnabled(Features, "3dnow", true); |
| 695 | } else if (CPU == "athlon-4" || CPU == "athlon-xp" || CPU == "athlon-mp") { |
| 696 | setFeatureEnabled(Features, "sse", true); |
| 697 | setFeatureEnabled(Features, "3dnowa", true); |
| 698 | } else if (CPU == "k8" || CPU == "opteron" || CPU == "athlon64" || |
| 699 | CPU == "athlon-fx") { |
| 700 | setFeatureEnabled(Features, "sse2", true); |
| 701 | setFeatureEnabled(Features, "3dnowa", true); |
| 702 | } else if (CPU == "c3-2") |
| 703 | setFeatureEnabled(Features, "sse", true); |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 704 | } |
| 705 | |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 706 | bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features, |
| 707 | const std::string &Name, |
| 708 | bool Enabled) const { |
| 709 | // FIXME: This *really* should not be here. |
| 710 | if (!Features.count(Name) && Name != "sse4") |
| 711 | return false; |
| 712 | |
| 713 | if (Enabled) { |
| 714 | if (Name == "mmx") |
| 715 | Features["mmx"] = true; |
| 716 | else if (Name == "sse") |
| 717 | Features["mmx"] = Features["sse"] = true; |
| 718 | else if (Name == "sse2") |
| 719 | Features["mmx"] = Features["sse"] = Features["sse2"] = true; |
| 720 | else if (Name == "sse3") |
| 721 | Features["mmx"] = Features["sse"] = Features["sse2"] = |
| 722 | Features["sse3"] = true; |
| 723 | else if (Name == "ssse3") |
| 724 | Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] = |
| 725 | Features["ssse3"] = true; |
| 726 | else if (Name == "sse4") |
| 727 | Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] = |
| 728 | Features["ssse3"] = Features["sse41"] = Features["sse42"] = true; |
| 729 | else if (Name == "3dnow") |
| 730 | Features["3dnowa"] = true; |
| 731 | else if (Name == "3dnowa") |
| 732 | Features["3dnow"] = Features["3dnowa"] = true; |
| 733 | } else { |
| 734 | if (Name == "mmx") |
| 735 | Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] = |
| 736 | Features["ssse3"] = Features["sse41"] = Features["sse42"] = false; |
| 737 | else if (Name == "sse") |
| 738 | Features["sse"] = Features["sse2"] = Features["sse3"] = |
| 739 | Features["ssse3"] = Features["sse41"] = Features["sse42"] = false; |
| 740 | else if (Name == "sse2") |
| 741 | Features["sse2"] = Features["sse3"] = Features["ssse3"] = |
| 742 | Features["sse41"] = Features["sse42"] = false; |
| 743 | else if (Name == "sse3") |
| 744 | Features["sse3"] = Features["ssse3"] = Features["sse41"] = |
| 745 | Features["sse42"] = false; |
| 746 | else if (Name == "ssse3") |
| 747 | Features["ssse3"] = Features["sse41"] = Features["sse42"] = false; |
| 748 | else if (Name == "sse4") |
| 749 | Features["sse41"] = Features["sse42"] = false; |
| 750 | else if (Name == "3dnow") |
| 751 | Features["3dnow"] = Features["3dnowa"] = false; |
| 752 | else if (Name == "3dnowa") |
| 753 | Features["3dnowa"] = false; |
| 754 | } |
| 755 | |
| 756 | return true; |
| 757 | } |
| 758 | |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 759 | /// HandleTargetOptions - Perform initialization based on the user |
| 760 | /// configured set of features. |
| 761 | void X86TargetInfo::HandleTargetFeatures(const llvm::StringMap<bool>&Features) { |
| 762 | if (Features.lookup("sse42")) |
| 763 | SSELevel = SSE42; |
| 764 | else if (Features.lookup("sse41")) |
| 765 | SSELevel = SSE41; |
| 766 | else if (Features.lookup("ssse3")) |
| 767 | SSELevel = SSSE3; |
| 768 | else if (Features.lookup("sse3")) |
| 769 | SSELevel = SSE3; |
| 770 | else if (Features.lookup("sse2")) |
| 771 | SSELevel = SSE2; |
| 772 | else if (Features.lookup("sse")) |
| 773 | SSELevel = SSE1; |
| 774 | else if (Features.lookup("mmx")) |
| 775 | SSELevel = MMX; |
Chris Lattner | 3daed52 | 2009-03-02 22:20:04 +0000 | [diff] [blame] | 776 | } |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 777 | |
| 778 | /// X86TargetInfo::getTargetDefines - Return a set of the X86-specific #defines |
| 779 | /// that are not tied to a specific subtarget. |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 780 | void X86TargetInfo::getTargetDefines(const LangOptions &Opts, |
| 781 | std::vector<char> &Defs) const { |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 782 | // Target identification. |
| 783 | if (PointerWidth == 64) { |
| 784 | Define(Defs, "_LP64"); |
| 785 | Define(Defs, "__LP64__"); |
| 786 | Define(Defs, "__amd64__"); |
| 787 | Define(Defs, "__amd64"); |
| 788 | Define(Defs, "__x86_64"); |
| 789 | Define(Defs, "__x86_64__"); |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 790 | } else { |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 791 | DefineStd(Defs, "i386", Opts); |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 792 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 793 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 794 | // Target properties. |
| 795 | Define(Defs, "__LITTLE_ENDIAN__"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 796 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 797 | // Subtarget options. |
| 798 | Define(Defs, "__nocona"); |
| 799 | Define(Defs, "__nocona__"); |
| 800 | Define(Defs, "__tune_nocona__"); |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 801 | Define(Defs, "__REGISTER_PREFIX__", ""); |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 802 | |
Chris Lattner | 5417544 | 2009-04-19 17:32:33 +0000 | [diff] [blame] | 803 | // Define __NO_MATH_INLINES on linux/x86 so that we don't get inline |
| 804 | // functions in glibc header files that use FP Stack inline asm which the |
| 805 | // backend can't deal with (PR879). |
| 806 | Define(Defs, "__NO_MATH_INLINES"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 807 | |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 808 | // Each case falls through to the previous one here. |
| 809 | switch (SSELevel) { |
| 810 | case SSE42: |
| 811 | Define(Defs, "__SSE4_2__"); |
| 812 | case SSE41: |
| 813 | Define(Defs, "__SSE4_1__"); |
| 814 | case SSSE3: |
| 815 | Define(Defs, "__SSSE3__"); |
| 816 | case SSE3: |
| 817 | Define(Defs, "__SSE3__"); |
| 818 | case SSE2: |
| 819 | Define(Defs, "__SSE2__"); |
| 820 | Define(Defs, "__SSE2_MATH__"); // -mfp-math=sse always implied. |
| 821 | case SSE1: |
| 822 | Define(Defs, "__SSE__"); |
| 823 | Define(Defs, "__SSE_MATH__"); // -mfp-math=sse always implied. |
| 824 | case MMX: |
| 825 | Define(Defs, "__MMX__"); |
| 826 | case NoMMXSSE: |
| 827 | break; |
| 828 | } |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 829 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 830 | |
| 831 | |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 832 | bool |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 833 | X86TargetInfo::validateAsmConstraint(const char *&Name, |
Chris Lattner | 44def07 | 2009-04-26 07:16:29 +0000 | [diff] [blame] | 834 | TargetInfo::ConstraintInfo &Info) const { |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 835 | switch (*Name) { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 836 | default: return false; |
| 837 | case 'a': // eax. |
| 838 | case 'b': // ebx. |
| 839 | case 'c': // ecx. |
| 840 | case 'd': // edx. |
| 841 | case 'S': // esi. |
| 842 | case 'D': // edi. |
| 843 | case 'A': // edx:eax. |
| 844 | case 't': // top of floating point stack. |
| 845 | case 'u': // second from top of floating point stack. |
| 846 | 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] | 847 | case 'y': // Any MMX register. |
Anders Carlsson | a7406d4 | 2008-10-06 19:17:39 +0000 | [diff] [blame] | 848 | case 'x': // Any SSE register. |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 849 | case 'Q': // Any register accessible as [r]h: a, b, c, and d. |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 850 | case 'e': // 32-bit signed integer constant for use with zero-extending |
Anders Carlsson | 79bc64c | 2009-01-24 18:03:09 +0000 | [diff] [blame] | 851 | // x86_64 instructions. |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 852 | case 'Z': // 32-bit unsigned integer constant for use with zero-extending |
Anders Carlsson | 79bc64c | 2009-01-24 18:03:09 +0000 | [diff] [blame] | 853 | // x86_64 instructions. |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 854 | case 'N': // unsigned 8-bit integer constant for use with in and out |
| 855 | // instructions. |
Eli Friedman | 12b2da0 | 2009-06-08 20:45:44 +0000 | [diff] [blame] | 856 | case 'R': // "legacy" registers: ax, bx, cx, dx, di, si, sp, bp. |
Chris Lattner | 44def07 | 2009-04-26 07:16:29 +0000 | [diff] [blame] | 857 | Info.setAllowsRegister(); |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 858 | return true; |
| 859 | } |
| 860 | } |
| 861 | |
| 862 | std::string |
| 863 | X86TargetInfo::convertConstraint(const char Constraint) const { |
| 864 | switch (Constraint) { |
| 865 | case 'a': return std::string("{ax}"); |
| 866 | case 'b': return std::string("{bx}"); |
| 867 | case 'c': return std::string("{cx}"); |
| 868 | case 'd': return std::string("{dx}"); |
| 869 | case 'S': return std::string("{si}"); |
| 870 | case 'D': return std::string("{di}"); |
| 871 | case 't': // top of floating point stack. |
| 872 | return std::string("{st}"); |
| 873 | case 'u': // second from top of floating point stack. |
| 874 | return std::string("{st(1)}"); // second from top of floating point stack. |
| 875 | default: |
| 876 | return std::string(1, Constraint); |
| 877 | } |
| 878 | } |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 879 | } // end anonymous namespace |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 880 | |
| 881 | namespace { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 882 | // X86-32 generic target |
| 883 | class X86_32TargetInfo : public X86TargetInfo { |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 884 | public: |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 885 | X86_32TargetInfo(const std::string& triple) : X86TargetInfo(triple) { |
| 886 | DoubleAlign = LongLongAlign = 32; |
| 887 | LongDoubleWidth = 96; |
| 888 | LongDoubleAlign = 32; |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 889 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 890 | "i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-" |
| 891 | "a0:0:64-f80:32:32"; |
Eli Friedman | 1afabd9 | 2009-03-29 20:31:09 +0000 | [diff] [blame] | 892 | SizeType = UnsignedInt; |
| 893 | PtrDiffType = SignedInt; |
| 894 | IntPtrType = SignedInt; |
Anton Korobeynikov | 264a76c | 2009-04-03 23:38:25 +0000 | [diff] [blame] | 895 | RegParmMax = 3; |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 896 | } |
| 897 | virtual const char *getVAListDeclaration() const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 898 | return "typedef char* __builtin_va_list;"; |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 899 | } |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 900 | }; |
| 901 | } // end anonymous namespace |
| 902 | |
| 903 | namespace { |
Eli Friedman | 624c146 | 2009-07-05 18:47:56 +0000 | [diff] [blame] | 904 | class OpenBSDI386TargetInfo : public OpenBSDTargetInfo<X86_32TargetInfo> { |
| 905 | public: |
| 906 | OpenBSDI386TargetInfo(const std::string& triple) : |
| 907 | OpenBSDTargetInfo<X86_32TargetInfo>(triple) { |
| 908 | SizeType = UnsignedLong; |
| 909 | IntPtrType = SignedLong; |
Eli Friedman | 6036ebe | 2009-07-05 22:31:18 +0000 | [diff] [blame] | 910 | PtrDiffType = SignedLong; |
Eli Friedman | 624c146 | 2009-07-05 18:47:56 +0000 | [diff] [blame] | 911 | } |
| 912 | }; |
| 913 | } // end anonymous namespace |
| 914 | |
| 915 | namespace { |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 916 | class DarwinI386TargetInfo : public DarwinTargetInfo<X86_32TargetInfo> { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 917 | public: |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 918 | DarwinI386TargetInfo(const std::string& triple) : |
| 919 | DarwinTargetInfo<X86_32TargetInfo>(triple) { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 920 | LongDoubleWidth = 128; |
| 921 | LongDoubleAlign = 128; |
Eli Friedman | 1afabd9 | 2009-03-29 20:31:09 +0000 | [diff] [blame] | 922 | SizeType = UnsignedLong; |
| 923 | IntPtrType = SignedLong; |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 924 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 925 | "i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-" |
| 926 | "a0:0:64-f80:128:128"; |
Torok Edwin | b0a5b24 | 2009-06-30 17:00:25 +0000 | [diff] [blame] | 927 | } |
| 928 | |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 929 | }; |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 930 | } // end anonymous namespace |
| 931 | |
| 932 | namespace { |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 933 | // x86-32 Windows target |
| 934 | class WindowsX86_32TargetInfo : public X86_32TargetInfo { |
| 935 | public: |
| 936 | WindowsX86_32TargetInfo(const std::string& triple) |
| 937 | : X86_32TargetInfo(triple) { |
Eli Friedman | b030f02 | 2009-04-19 21:38:35 +0000 | [diff] [blame] | 938 | TLSSupported = false; |
Chris Lattner | 85de9e7 | 2009-06-24 17:12:15 +0000 | [diff] [blame] | 939 | WCharType = UnsignedShort; |
Eli Friedman | abc4e32 | 2009-06-08 06:11:14 +0000 | [diff] [blame] | 940 | WCharWidth = WCharAlign = 16; |
Eli Friedman | 9c2f84e | 2009-06-08 21:16:17 +0000 | [diff] [blame] | 941 | DoubleAlign = LongLongAlign = 64; |
| 942 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 943 | "i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-" |
| 944 | "a0:0:64-f80:32:32"; |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 945 | } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 946 | virtual void getTargetDefines(const LangOptions &Opts, |
| 947 | std::vector<char> &Defines) const { |
| 948 | X86_32TargetInfo::getTargetDefines(Opts, Defines); |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 949 | // This list is based off of the the list of things MingW defines |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 950 | Define(Defines, "_WIN32"); |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 951 | DefineStd(Defines, "WIN32", Opts); |
| 952 | DefineStd(Defines, "WINNT", Opts); |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 953 | Define(Defines, "_X86_"); |
| 954 | Define(Defines, "__MSVCRT__"); |
| 955 | } |
Eli Friedman | abc4e32 | 2009-06-08 06:11:14 +0000 | [diff] [blame] | 956 | |
| 957 | virtual void getDefaultLangOptions(LangOptions &Opts) { |
| 958 | X86_32TargetInfo::getDefaultLangOptions(Opts); |
| 959 | GetWindowsLanguageOptions(Opts, getTargetTriple()); |
| 960 | } |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 961 | }; |
| 962 | } // end anonymous namespace |
| 963 | |
| 964 | namespace { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 965 | // x86-64 generic target |
| 966 | class X86_64TargetInfo : public X86TargetInfo { |
| 967 | public: |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 968 | X86_64TargetInfo(const std::string &triple) : X86TargetInfo(triple) { |
Chris Lattner | f291b10 | 2008-05-09 06:17:04 +0000 | [diff] [blame] | 969 | LongWidth = LongAlign = PointerWidth = PointerAlign = 64; |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 970 | LongDoubleWidth = 128; |
| 971 | LongDoubleAlign = 128; |
Chris Lattner | 06ebe86 | 2009-02-05 07:32:46 +0000 | [diff] [blame] | 972 | IntMaxType = SignedLong; |
| 973 | UIntMaxType = UnsignedLong; |
Eli Friedman | 3c7b6e4 | 2009-07-01 03:36:11 +0000 | [diff] [blame] | 974 | Int64Type = SignedLong; |
Anton Korobeynikov | 264a76c | 2009-04-03 23:38:25 +0000 | [diff] [blame] | 975 | RegParmMax = 6; |
Chris Lattner | 06ebe86 | 2009-02-05 07:32:46 +0000 | [diff] [blame] | 976 | |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 977 | DescriptionString = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 978 | "i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-" |
Daniel Dunbar | 9e7d596 | 2009-06-08 22:39:13 +0000 | [diff] [blame] | 979 | "a0:0:64-s0:64:64-f80:128:128"; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 980 | } |
Anders Carlsson | fb5e5ba | 2007-10-13 00:45:48 +0000 | [diff] [blame] | 981 | virtual const char *getVAListDeclaration() const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 982 | return "typedef struct __va_list_tag {" |
| 983 | " unsigned gp_offset;" |
| 984 | " unsigned fp_offset;" |
| 985 | " void* overflow_arg_area;" |
| 986 | " void* reg_save_area;" |
Eli Friedman | dc04316 | 2009-07-03 00:45:06 +0000 | [diff] [blame] | 987 | "} __va_list_tag;" |
| 988 | "typedef __va_list_tag __builtin_va_list[1];"; |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 989 | } |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 990 | }; |
| 991 | } // end anonymous namespace |
| 992 | |
| 993 | namespace { |
Eli Friedman | 3c7b6e4 | 2009-07-01 03:36:11 +0000 | [diff] [blame] | 994 | class DarwinX86_64TargetInfo : public DarwinTargetInfo<X86_64TargetInfo> { |
| 995 | public: |
| 996 | DarwinX86_64TargetInfo(const std::string& triple) |
| 997 | : DarwinTargetInfo<X86_64TargetInfo>(triple) { |
| 998 | Int64Type = SignedLongLong; |
| 999 | } |
| 1000 | }; |
| 1001 | } // end anonymous namespace |
| 1002 | |
| 1003 | namespace { |
Eli Friedman | 6036ebe | 2009-07-05 22:31:18 +0000 | [diff] [blame] | 1004 | class OpenBSDX86_64TargetInfo : public OpenBSDTargetInfo<X86_64TargetInfo> { |
| 1005 | public: |
| 1006 | OpenBSDX86_64TargetInfo(const std::string& triple) |
| 1007 | : OpenBSDTargetInfo<X86_64TargetInfo>(triple) { |
| 1008 | IntMaxType = SignedLongLong; |
| 1009 | UIntMaxType = UnsignedLongLong; |
| 1010 | Int64Type = SignedLongLong; |
| 1011 | } |
| 1012 | }; |
| 1013 | } // end anonymous namespace |
| 1014 | |
| 1015 | namespace { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1016 | class ARMTargetInfo : public TargetInfo { |
Mike Stump | 437bb4b | 2009-04-08 02:07:04 +0000 | [diff] [blame] | 1017 | enum { |
| 1018 | Armv4t, |
| 1019 | Armv5, |
| 1020 | Armv6, |
| 1021 | XScale |
| 1022 | } ArmArch; |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1023 | public: |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1024 | ARMTargetInfo(const std::string& triple) : TargetInfo(triple) { |
| 1025 | // FIXME: Are the defaults correct for ARM? |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1026 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 1027 | "i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:64"; |
Chris Lattner | 5b37dc0 | 2009-04-23 04:22:04 +0000 | [diff] [blame] | 1028 | if (triple.find("arm-") == 0 || triple.find("armv6-") == 0) |
Mike Stump | 437bb4b | 2009-04-08 02:07:04 +0000 | [diff] [blame] | 1029 | ArmArch = Armv6; |
Chris Lattner | 5b37dc0 | 2009-04-23 04:22:04 +0000 | [diff] [blame] | 1030 | else if (triple.find("armv5-") == 0) |
Mike Stump | 437bb4b | 2009-04-08 02:07:04 +0000 | [diff] [blame] | 1031 | ArmArch = Armv5; |
Chris Lattner | 5b37dc0 | 2009-04-23 04:22:04 +0000 | [diff] [blame] | 1032 | else if (triple.find("armv4t-") == 0) |
Mike Stump | 437bb4b | 2009-04-08 02:07:04 +0000 | [diff] [blame] | 1033 | ArmArch = Armv4t; |
Chris Lattner | 5b37dc0 | 2009-04-23 04:22:04 +0000 | [diff] [blame] | 1034 | else if (triple.find("xscale-") == 0) |
Mike Stump | 437bb4b | 2009-04-08 02:07:04 +0000 | [diff] [blame] | 1035 | ArmArch = XScale; |
Chris Lattner | 5b37dc0 | 2009-04-23 04:22:04 +0000 | [diff] [blame] | 1036 | else if (triple.find("armv") == 0) { |
| 1037 | // FIXME: fuzzy match for other random weird arm triples. This is useful |
| 1038 | // for the static analyzer and other clients, but probably should be |
| 1039 | // re-evaluated when codegen is brought up. |
| 1040 | ArmArch = Armv6; |
| 1041 | } |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1042 | } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 1043 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1044 | std::vector<char> &Defs) const { |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 1045 | // Target identification. |
| 1046 | Define(Defs, "__arm"); |
| 1047 | Define(Defs, "__arm__"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1048 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 1049 | // Target properties. |
| 1050 | Define(Defs, "__LITTLE_ENDIAN__"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1051 | |
Mike Stump | 437bb4b | 2009-04-08 02:07:04 +0000 | [diff] [blame] | 1052 | // Subtarget options. |
| 1053 | if (ArmArch == Armv6) { |
| 1054 | Define(Defs, "__ARM_ARCH_6K__"); |
| 1055 | Define(Defs, "__THUMB_INTERWORK__"); |
| 1056 | } else if (ArmArch == Armv5) { |
| 1057 | Define(Defs, "__ARM_ARCH_5TEJ__"); |
| 1058 | Define(Defs, "__THUMB_INTERWORK__"); |
| 1059 | Define(Defs, "__SOFTFP__"); |
| 1060 | } else if (ArmArch == Armv4t) { |
| 1061 | Define(Defs, "__ARM_ARCH_4T__"); |
| 1062 | Define(Defs, "__SOFTFP__"); |
| 1063 | } else if (ArmArch == XScale) { |
| 1064 | Define(Defs, "__ARM_ARCH_5TE__"); |
| 1065 | Define(Defs, "__XSCALE__"); |
| 1066 | Define(Defs, "__SOFTFP__"); |
| 1067 | } |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 1068 | Define(Defs, "__ARMEL__"); |
Eli Friedman | 1926242 | 2009-05-29 19:00:15 +0000 | [diff] [blame] | 1069 | Define(Defs, "__APCS_32__"); |
| 1070 | Define(Defs, "__VFP_FP__"); |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1071 | } |
| 1072 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 1073 | unsigned &NumRecords) const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1074 | // FIXME: Implement. |
| 1075 | Records = 0; |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1076 | NumRecords = 0; |
| 1077 | } |
| 1078 | virtual const char *getVAListDeclaration() const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1079 | return "typedef char* __builtin_va_list;"; |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1080 | } |
| 1081 | virtual const char *getTargetPrefix() const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1082 | return "arm"; |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1083 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1084 | virtual void getGCCRegNames(const char * const *&Names, |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1085 | unsigned &NumNames) const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1086 | // FIXME: Implement. |
| 1087 | Names = 0; |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1088 | NumNames = 0; |
| 1089 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1090 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1091 | unsigned &NumAliases) const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1092 | // FIXME: Implement. |
| 1093 | Aliases = 0; |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1094 | NumAliases = 0; |
| 1095 | } |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 1096 | virtual bool validateAsmConstraint(const char *&Name, |
Chris Lattner | 44def07 | 2009-04-26 07:16:29 +0000 | [diff] [blame] | 1097 | TargetInfo::ConstraintInfo &Info) const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1098 | // FIXME: Check if this is complete |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 1099 | switch (*Name) { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1100 | default: |
Nate Begeman | ad487f4 | 2008-04-22 05:03:19 +0000 | [diff] [blame] | 1101 | case 'l': // r0-r7 |
| 1102 | case 'h': // r8-r15 |
| 1103 | case 'w': // VFP Floating point register single precision |
| 1104 | case 'P': // VFP Floating point register double precision |
Chris Lattner | 44def07 | 2009-04-26 07:16:29 +0000 | [diff] [blame] | 1105 | Info.setAllowsRegister(); |
Nate Begeman | ad487f4 | 2008-04-22 05:03:19 +0000 | [diff] [blame] | 1106 | return true; |
| 1107 | } |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1108 | return false; |
| 1109 | } |
| 1110 | virtual const char *getClobbers() const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1111 | // FIXME: Is this really right? |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1112 | return ""; |
| 1113 | } |
| 1114 | }; |
| 1115 | } // end anonymous namespace. |
| 1116 | |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1117 | |
| 1118 | namespace { |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1119 | class DarwinARMTargetInfo : |
| 1120 | public DarwinTargetInfo<ARMTargetInfo> { |
| 1121 | protected: |
| 1122 | virtual void getOSDefines(const LangOptions &Opts, const char *Triple, |
| 1123 | std::vector<char> &Defines) const { |
| 1124 | getDarwinDefines(Defines, Opts); |
| 1125 | getDarwinIPhoneOSDefines(Defines, Triple); |
Eli Friedman | b030f02 | 2009-04-19 21:38:35 +0000 | [diff] [blame] | 1126 | } |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1127 | |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1128 | public: |
| 1129 | DarwinARMTargetInfo(const std::string& triple) |
| 1130 | : DarwinTargetInfo<ARMTargetInfo>(triple) {} |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1131 | }; |
| 1132 | } // end anonymous namespace. |
| 1133 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1134 | namespace { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1135 | class SparcV8TargetInfo : public TargetInfo { |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 1136 | static const TargetInfo::GCCRegAlias GCCRegAliases[]; |
| 1137 | static const char * const GCCRegNames[]; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1138 | public: |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1139 | SparcV8TargetInfo(const std::string& triple) : TargetInfo(triple) { |
| 1140 | // FIXME: Support Sparc quad-precision long double? |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1141 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 1142 | "i64:64:64-f32:32:32-f64:64:64-v64:64:64"; |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1143 | } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 1144 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1145 | std::vector<char> &Defines) const { |
Eli Friedman | 09c3a6d | 2009-05-22 01:12:57 +0000 | [diff] [blame] | 1146 | DefineStd(Defines, "sparc", Opts); |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1147 | Define(Defines, "__sparcv8"); |
Eli Friedman | 09c3a6d | 2009-05-22 01:12:57 +0000 | [diff] [blame] | 1148 | Define(Defines, "__REGISTER_PREFIX__", ""); |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1149 | } |
| 1150 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 1151 | unsigned &NumRecords) const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1152 | // FIXME: Implement! |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1153 | } |
| 1154 | virtual const char *getVAListDeclaration() const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1155 | return "typedef void* __builtin_va_list;"; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1156 | } |
| 1157 | virtual const char *getTargetPrefix() const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1158 | return "sparc"; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1159 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1160 | virtual void getGCCRegNames(const char * const *&Names, |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 1161 | unsigned &NumNames) const; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1162 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 1163 | unsigned &NumAliases) const; |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 1164 | virtual bool validateAsmConstraint(const char *&Name, |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1165 | TargetInfo::ConstraintInfo &info) const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1166 | // FIXME: Implement! |
| 1167 | return false; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1168 | } |
| 1169 | virtual const char *getClobbers() const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1170 | // FIXME: Implement! |
| 1171 | return ""; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1172 | } |
| 1173 | }; |
| 1174 | |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 1175 | const char * const SparcV8TargetInfo::GCCRegNames[] = { |
| 1176 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
| 1177 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", |
| 1178 | "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", |
| 1179 | "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31" |
| 1180 | }; |
| 1181 | |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1182 | void SparcV8TargetInfo::getGCCRegNames(const char * const *&Names, |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 1183 | unsigned &NumNames) const { |
| 1184 | Names = GCCRegNames; |
| 1185 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 1186 | } |
| 1187 | |
| 1188 | const TargetInfo::GCCRegAlias SparcV8TargetInfo::GCCRegAliases[] = { |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1189 | { { "g0" }, "r0" }, |
| 1190 | { { "g1" }, "r1" }, |
| 1191 | { { "g2" }, "r2" }, |
| 1192 | { { "g3" }, "r3" }, |
| 1193 | { { "g4" }, "r4" }, |
| 1194 | { { "g5" }, "r5" }, |
| 1195 | { { "g6" }, "r6" }, |
| 1196 | { { "g7" }, "r7" }, |
| 1197 | { { "o0" }, "r8" }, |
| 1198 | { { "o1" }, "r9" }, |
| 1199 | { { "o2" }, "r10" }, |
| 1200 | { { "o3" }, "r11" }, |
| 1201 | { { "o4" }, "r12" }, |
| 1202 | { { "o5" }, "r13" }, |
| 1203 | { { "o6", "sp" }, "r14" }, |
| 1204 | { { "o7" }, "r15" }, |
| 1205 | { { "l0" }, "r16" }, |
| 1206 | { { "l1" }, "r17" }, |
| 1207 | { { "l2" }, "r18" }, |
| 1208 | { { "l3" }, "r19" }, |
| 1209 | { { "l4" }, "r20" }, |
| 1210 | { { "l5" }, "r21" }, |
| 1211 | { { "l6" }, "r22" }, |
| 1212 | { { "l7" }, "r23" }, |
| 1213 | { { "i0" }, "r24" }, |
| 1214 | { { "i1" }, "r25" }, |
| 1215 | { { "i2" }, "r26" }, |
| 1216 | { { "i3" }, "r27" }, |
| 1217 | { { "i4" }, "r28" }, |
| 1218 | { { "i5" }, "r29" }, |
| 1219 | { { "i6", "fp" }, "r30" }, |
| 1220 | { { "i7" }, "r31" }, |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 1221 | }; |
| 1222 | |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1223 | void SparcV8TargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases, |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 1224 | unsigned &NumAliases) const { |
| 1225 | Aliases = GCCRegAliases; |
| 1226 | NumAliases = llvm::array_lengthof(GCCRegAliases); |
| 1227 | } |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1228 | } // end anonymous namespace. |
| 1229 | |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1230 | namespace { |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1231 | class SolarisSparcV8TargetInfo : public SolarisTargetInfo<SparcV8TargetInfo> { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1232 | public: |
| 1233 | SolarisSparcV8TargetInfo(const std::string& triple) : |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1234 | SolarisTargetInfo<SparcV8TargetInfo>(triple) { |
Eli Friedman | f509d73 | 2008-11-02 02:43:55 +0000 | [diff] [blame] | 1235 | SizeType = UnsignedInt; |
| 1236 | PtrDiffType = SignedInt; |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1237 | } |
| 1238 | }; |
| 1239 | } // end anonymous namespace. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1240 | |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 1241 | namespace { |
| 1242 | class PIC16TargetInfo : public TargetInfo{ |
| 1243 | public: |
| 1244 | PIC16TargetInfo(const std::string& triple) : TargetInfo(triple) { |
Eli Friedman | b030f02 | 2009-04-19 21:38:35 +0000 | [diff] [blame] | 1245 | TLSSupported = false; |
Sanjiv Gupta | 31fc07d | 2008-10-31 09:52:39 +0000 | [diff] [blame] | 1246 | IntWidth = 16; |
| 1247 | LongWidth = LongLongWidth = 32; |
Eli Friedman | 3f7a531 | 2009-05-16 23:30:57 +0000 | [diff] [blame] | 1248 | IntMaxTWidth = 32; |
Sanjiv Gupta | 31fc07d | 2008-10-31 09:52:39 +0000 | [diff] [blame] | 1249 | PointerWidth = 16; |
| 1250 | IntAlign = 8; |
| 1251 | LongAlign = LongLongAlign = 8; |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1252 | PointerAlign = 8; |
Sanjiv Gupta | 31fc07d | 2008-10-31 09:52:39 +0000 | [diff] [blame] | 1253 | SizeType = UnsignedInt; |
| 1254 | IntMaxType = SignedLong; |
| 1255 | UIntMaxType = UnsignedLong; |
Chris Lattner | 6ad474f | 2009-02-13 22:28:55 +0000 | [diff] [blame] | 1256 | IntPtrType = SignedShort; |
Eli Friedman | f509d73 | 2008-11-02 02:43:55 +0000 | [diff] [blame] | 1257 | PtrDiffType = SignedInt; |
Sanjiv Gupta | 9eb4cef | 2009-06-02 04:43:46 +0000 | [diff] [blame] | 1258 | FloatWidth = 32; |
| 1259 | FloatAlign = 32; |
| 1260 | DoubleWidth = 32; |
| 1261 | DoubleAlign = 32; |
| 1262 | LongDoubleWidth = 32; |
| 1263 | LongDoubleAlign = 32; |
| 1264 | FloatFormat = &llvm::APFloat::IEEEsingle; |
| 1265 | DoubleFormat = &llvm::APFloat::IEEEsingle; |
| 1266 | LongDoubleFormat = &llvm::APFloat::IEEEsingle; |
| 1267 | DescriptionString = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8-f32:32:32"; |
| 1268 | |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 1269 | } |
Chris Lattner | 927686f | 2008-05-09 06:08:39 +0000 | [diff] [blame] | 1270 | virtual uint64_t getPointerWidthV(unsigned AddrSpace) const { return 16; } |
| 1271 | virtual uint64_t getPointerAlignV(unsigned AddrSpace) const { return 8; } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 1272 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1273 | std::vector<char> &Defines) const { |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 1274 | Define(Defines, "__pic16"); |
Sanjiv Gupta | 7f579b1 | 2009-07-07 04:42:23 +0000 | [diff] [blame] | 1275 | Define(Defines, "rom", "__attribute__((address_space(1)))"); |
| 1276 | Define(Defines, "ram", "__attribute__((address_space(0)))"); |
| 1277 | Define(Defines, "_section(SectName)", "__attribute__((section(SectName)))"); |
| 1278 | Define(Defines, "_address(Addr)","__attribute__((section(\"Address=\"#Addr)))"); |
| 1279 | Define(Defines, "_CONFIG(conf)", "asm(\"CONFIG \"#conf)"); |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 1280 | } |
| 1281 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 1282 | unsigned &NumRecords) const {} |
| 1283 | virtual const char *getVAListDeclaration() const { return "";} |
| 1284 | virtual const char *getClobbers() const {return "";} |
Sanjiv Gupta | 70aa5f9 | 2009-04-21 06:01:16 +0000 | [diff] [blame] | 1285 | virtual const char *getTargetPrefix() const {return "pic16";} |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1286 | virtual void getGCCRegNames(const char * const *&Names, |
| 1287 | unsigned &NumNames) const {} |
| 1288 | virtual bool validateAsmConstraint(const char *&Name, |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 1289 | TargetInfo::ConstraintInfo &info) const { |
| 1290 | return true; |
| 1291 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1292 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 1293 | unsigned &NumAliases) const {} |
| 1294 | virtual bool useGlobalsForAutomaticVariables() const {return true;} |
| 1295 | }; |
| 1296 | } |
| 1297 | |
Anton Korobeynikov | 73c64e5 | 2009-05-03 13:43:08 +0000 | [diff] [blame] | 1298 | namespace { |
| 1299 | class MSP430TargetInfo : public TargetInfo { |
| 1300 | static const char * const GCCRegNames[]; |
| 1301 | public: |
| 1302 | MSP430TargetInfo(const std::string& triple) : TargetInfo(triple) { |
| 1303 | TLSSupported = false; |
| 1304 | IntWidth = 16; |
| 1305 | LongWidth = LongLongWidth = 32; |
Eli Friedman | 3f7a531 | 2009-05-16 23:30:57 +0000 | [diff] [blame] | 1306 | IntMaxTWidth = 32; |
Anton Korobeynikov | 73c64e5 | 2009-05-03 13:43:08 +0000 | [diff] [blame] | 1307 | PointerWidth = 16; |
| 1308 | IntAlign = 8; |
| 1309 | LongAlign = LongLongAlign = 8; |
| 1310 | PointerAlign = 8; |
| 1311 | SizeType = UnsignedInt; |
| 1312 | IntMaxType = SignedLong; |
| 1313 | UIntMaxType = UnsignedLong; |
| 1314 | IntPtrType = SignedShort; |
| 1315 | PtrDiffType = SignedInt; |
| 1316 | DescriptionString = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"; |
| 1317 | } |
| 1318 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1319 | std::vector<char> &Defines) const { |
| 1320 | Define(Defines, "MSP430"); |
| 1321 | Define(Defines, "__MSP430__"); |
| 1322 | // FIXME: defines for different 'flavours' of MCU |
| 1323 | } |
| 1324 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 1325 | unsigned &NumRecords) const { |
| 1326 | // FIXME: Implement. |
| 1327 | Records = 0; |
| 1328 | NumRecords = 0; |
| 1329 | } |
| 1330 | virtual const char *getTargetPrefix() const { |
| 1331 | return "msp430"; |
| 1332 | } |
| 1333 | virtual void getGCCRegNames(const char * const *&Names, |
| 1334 | unsigned &NumNames) const; |
| 1335 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 1336 | unsigned &NumAliases) const { |
| 1337 | // No aliases. |
| 1338 | Aliases = 0; |
| 1339 | NumAliases = 0; |
| 1340 | } |
| 1341 | virtual bool validateAsmConstraint(const char *&Name, |
| 1342 | TargetInfo::ConstraintInfo &info) const { |
| 1343 | // FIXME: implement |
| 1344 | return true; |
| 1345 | } |
| 1346 | virtual const char *getClobbers() const { |
| 1347 | // FIXME: Is this really right? |
| 1348 | return ""; |
| 1349 | } |
| 1350 | virtual const char *getVAListDeclaration() const { |
| 1351 | // FIXME: implement |
Anton Korobeynikov | eb71685 | 2009-05-08 18:24:57 +0000 | [diff] [blame] | 1352 | return "typedef char* __builtin_va_list;"; |
Anton Korobeynikov | 73c64e5 | 2009-05-03 13:43:08 +0000 | [diff] [blame] | 1353 | } |
| 1354 | }; |
| 1355 | |
| 1356 | const char * const MSP430TargetInfo::GCCRegNames[] = { |
| 1357 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
| 1358 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" |
| 1359 | }; |
| 1360 | |
| 1361 | void MSP430TargetInfo::getGCCRegNames(const char * const *&Names, |
| 1362 | unsigned &NumNames) const { |
| 1363 | Names = GCCRegNames; |
| 1364 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 1365 | } |
| 1366 | } |
| 1367 | |
| 1368 | |
Anton Korobeynikov | 89e887f | 2009-07-16 20:09:57 +0000 | [diff] [blame^] | 1369 | namespace { |
| 1370 | class SystemZTargetInfo : public TargetInfo { |
| 1371 | static const char * const GCCRegNames[]; |
| 1372 | public: |
| 1373 | SystemZTargetInfo(const std::string& triple) : TargetInfo(triple) { |
| 1374 | TLSSupported = false; |
| 1375 | IntWidth = IntAlign = 32; |
| 1376 | LongWidth = LongLongWidth = LongAlign = LongLongAlign = 64; |
| 1377 | PointerWidth = PointerAlign = 64; |
| 1378 | DescriptionString = "E-p:64:64:64-i8:8:16-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-a0:16:16"; |
| 1379 | } |
| 1380 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1381 | std::vector<char> &Defines) const { |
| 1382 | Define(Defines, "__s390__"); |
| 1383 | Define(Defines, "__s390x__"); |
| 1384 | } |
| 1385 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 1386 | unsigned &NumRecords) const { |
| 1387 | // FIXME: Implement. |
| 1388 | Records = 0; |
| 1389 | NumRecords = 0; |
| 1390 | } |
| 1391 | virtual const char *getTargetPrefix() const { |
| 1392 | return "s390x"; |
| 1393 | } |
| 1394 | |
| 1395 | virtual void getDefaultLangOptions(LangOptions &Opts) { |
| 1396 | TargetInfo::getDefaultLangOptions(Opts); |
| 1397 | Opts.CharIsSigned = false; |
| 1398 | } |
| 1399 | |
| 1400 | virtual void getGCCRegNames(const char * const *&Names, |
| 1401 | unsigned &NumNames) const; |
| 1402 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 1403 | unsigned &NumAliases) const { |
| 1404 | // No aliases. |
| 1405 | Aliases = 0; |
| 1406 | NumAliases = 0; |
| 1407 | } |
| 1408 | virtual bool validateAsmConstraint(const char *&Name, |
| 1409 | TargetInfo::ConstraintInfo &info) const { |
| 1410 | // FIXME: implement |
| 1411 | return true; |
| 1412 | } |
| 1413 | virtual const char *getClobbers() const { |
| 1414 | // FIXME: Is this really right? |
| 1415 | return ""; |
| 1416 | } |
| 1417 | virtual const char *getVAListDeclaration() const { |
| 1418 | // FIXME: implement |
| 1419 | return "typedef char* __builtin_va_list;"; |
| 1420 | } |
| 1421 | }; |
| 1422 | |
| 1423 | const char * const SystemZTargetInfo::GCCRegNames[] = { |
| 1424 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
| 1425 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" |
| 1426 | }; |
| 1427 | |
| 1428 | void SystemZTargetInfo::getGCCRegNames(const char * const *&Names, |
| 1429 | unsigned &NumNames) const { |
| 1430 | Names = GCCRegNames; |
| 1431 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 1432 | } |
| 1433 | } |
| 1434 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1435 | //===----------------------------------------------------------------------===// |
| 1436 | // Driver code |
| 1437 | //===----------------------------------------------------------------------===// |
| 1438 | |
Ted Kremenek | 8448d38 | 2007-12-04 17:07:35 +0000 | [diff] [blame] | 1439 | static inline bool IsX86(const std::string& TT) { |
Ted Kremenek | ae36076 | 2007-12-03 22:06:55 +0000 | [diff] [blame] | 1440 | return (TT.size() >= 5 && TT[0] == 'i' && TT[2] == '8' && TT[3] == '6' && |
| 1441 | TT[4] == '-' && TT[1] - '3' < 6); |
| 1442 | } |
| 1443 | |
Chris Lattner | 42e6737 | 2008-03-05 01:18:20 +0000 | [diff] [blame] | 1444 | /// CreateTargetInfo - Return the target info object for the specified target |
| 1445 | /// triple. |
| 1446 | TargetInfo* TargetInfo::CreateTargetInfo(const std::string &T) { |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1447 | // OS detection; this isn't really anywhere near complete. |
| 1448 | // Additions and corrections are welcome. |
| 1449 | bool isDarwin = T.find("-darwin") != std::string::npos; |
Chris Lattner | eac7aee | 2008-08-23 18:23:14 +0000 | [diff] [blame] | 1450 | bool isDragonFly = T.find("-dragonfly") != std::string::npos; |
Chris Lattner | b62bb28 | 2009-07-13 20:29:08 +0000 | [diff] [blame] | 1451 | bool isNetBSD = T.find("-netbsd") != std::string::npos; |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 1452 | bool isOpenBSD = T.find("-openbsd") != std::string::npos; |
Chris Lattner | fd0269d | 2008-10-16 17:04:31 +0000 | [diff] [blame] | 1453 | bool isFreeBSD = T.find("-freebsd") != std::string::npos; |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1454 | bool isSolaris = T.find("-solaris") != std::string::npos; |
| 1455 | bool isLinux = T.find("-linux") != std::string::npos; |
| 1456 | bool isWindows = T.find("-windows") != std::string::npos || |
| 1457 | T.find("-win32") != std::string::npos || |
| 1458 | T.find("-mingw") != std::string::npos; |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1459 | |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1460 | if (T.find("ppc-") == 0 || T.find("powerpc-") == 0) { |
| 1461 | if (isDarwin) |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1462 | return new DarwinTargetInfo<PPCTargetInfo>(T); |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1463 | return new PPC32TargetInfo(T); |
| 1464 | } |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1465 | |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1466 | if (T.find("ppc64-") == 0 || T.find("powerpc64-") == 0) { |
| 1467 | if (isDarwin) |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1468 | return new DarwinTargetInfo<PPC64TargetInfo>(T); |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1469 | return new PPC64TargetInfo(T); |
| 1470 | } |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1471 | |
Chris Lattner | 5b37dc0 | 2009-04-23 04:22:04 +0000 | [diff] [blame] | 1472 | if (T.find("armv") == 0 || T.find("arm-") == 0 || T.find("xscale") == 0) { |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1473 | if (isDarwin) |
| 1474 | return new DarwinARMTargetInfo(T); |
Daniel Dunbar | 1e0107a | 2009-03-23 16:09:04 +0000 | [diff] [blame] | 1475 | if (isFreeBSD) |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1476 | return new FreeBSDTargetInfo<ARMTargetInfo>(T); |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1477 | return new ARMTargetInfo(T); |
| 1478 | } |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1479 | |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1480 | if (T.find("sparc-") == 0) { |
| 1481 | if (isSolaris) |
| 1482 | return new SolarisSparcV8TargetInfo(T); |
| 1483 | return new SparcV8TargetInfo(T); |
| 1484 | } |
| 1485 | |
Chris Lattner | 54fefbe | 2009-02-20 17:04:14 +0000 | [diff] [blame] | 1486 | if (T.find("x86_64-") == 0 || T.find("amd64-") == 0) { |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1487 | if (isDarwin) |
Eli Friedman | 3c7b6e4 | 2009-07-01 03:36:11 +0000 | [diff] [blame] | 1488 | return new DarwinX86_64TargetInfo(T); |
Daniel Dunbar | b55a42b | 2008-09-23 17:37:57 +0000 | [diff] [blame] | 1489 | if (isLinux) |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1490 | return new LinuxTargetInfo<X86_64TargetInfo>(T); |
Chris Lattner | b62bb28 | 2009-07-13 20:29:08 +0000 | [diff] [blame] | 1491 | if (isNetBSD) |
| 1492 | return new NetBSDTargetInfo<X86_64TargetInfo>(T); |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 1493 | if (isOpenBSD) |
Eli Friedman | 6036ebe | 2009-07-05 22:31:18 +0000 | [diff] [blame] | 1494 | return new OpenBSDX86_64TargetInfo(T); |
Chris Lattner | fd0269d | 2008-10-16 17:04:31 +0000 | [diff] [blame] | 1495 | if (isFreeBSD) |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1496 | return new FreeBSDTargetInfo<X86_64TargetInfo>(T); |
Douglas Gregor | 163a7c7 | 2009-05-21 23:51:30 +0000 | [diff] [blame] | 1497 | if (isSolaris) |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1498 | return new SolarisTargetInfo<X86_64TargetInfo>(T); |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1499 | return new X86_64TargetInfo(T); |
| 1500 | } |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1501 | |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 1502 | if (T.find("pic16-") == 0) |
| 1503 | return new PIC16TargetInfo(T); |
| 1504 | |
Anton Korobeynikov | 73c64e5 | 2009-05-03 13:43:08 +0000 | [diff] [blame] | 1505 | if (T.find("msp430-") == 0) |
| 1506 | return new MSP430TargetInfo(T); |
| 1507 | |
Anton Korobeynikov | 89e887f | 2009-07-16 20:09:57 +0000 | [diff] [blame^] | 1508 | if (T.find("s390x-") == 0) |
| 1509 | return new SystemZTargetInfo(T); |
| 1510 | |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1511 | if (IsX86(T)) { |
| 1512 | if (isDarwin) |
| 1513 | return new DarwinI386TargetInfo(T); |
Eli Friedman | 0d4047b | 2008-08-21 00:24:02 +0000 | [diff] [blame] | 1514 | if (isLinux) |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1515 | return new LinuxTargetInfo<X86_32TargetInfo>(T); |
Chris Lattner | eac7aee | 2008-08-23 18:23:14 +0000 | [diff] [blame] | 1516 | if (isDragonFly) |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1517 | return new DragonFlyBSDTargetInfo<X86_32TargetInfo>(T); |
Chris Lattner | b62bb28 | 2009-07-13 20:29:08 +0000 | [diff] [blame] | 1518 | if (isNetBSD) |
| 1519 | return new NetBSDTargetInfo<X86_32TargetInfo>(T); |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 1520 | if (isOpenBSD) |
Eli Friedman | 624c146 | 2009-07-05 18:47:56 +0000 | [diff] [blame] | 1521 | return new OpenBSDI386TargetInfo(T); |
Chris Lattner | fd0269d | 2008-10-16 17:04:31 +0000 | [diff] [blame] | 1522 | if (isFreeBSD) |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1523 | return new FreeBSDTargetInfo<X86_32TargetInfo>(T); |
Douglas Gregor | 163a7c7 | 2009-05-21 23:51:30 +0000 | [diff] [blame] | 1524 | if (isSolaris) |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1525 | return new SolarisTargetInfo<X86_32TargetInfo>(T); |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 1526 | if (isWindows) |
| 1527 | return new WindowsX86_32TargetInfo(T); |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1528 | return new X86_32TargetInfo(T); |
| 1529 | } |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1530 | |
Chris Lattner | 42e6737 | 2008-03-05 01:18:20 +0000 | [diff] [blame] | 1531 | return NULL; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1532 | } |