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 | // |
Ted Kremenek | bbced58 | 2007-12-12 18:05:32 +0000 | [diff] [blame] | 10 | // This file implements construction of a TargetInfo object from a |
| 11 | // target triple. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Douglas Gregor | b1152d8 | 2009-02-16 21:58:21 +0000 | [diff] [blame] | 15 | // FIXME: Layering violation |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 16 | #include "clang/AST/Builtins.h" |
Anders Carlsson | 564f1de | 2007-12-09 23:17:02 +0000 | [diff] [blame] | 17 | #include "clang/AST/TargetBuiltins.h" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 18 | #include "clang/Basic/TargetInfo.h" |
Chris Lattner | 8fc4dfb | 2008-12-04 22:54:33 +0000 | [diff] [blame] | 19 | #include "clang/Basic/LangOptions.h" |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/STLExtras.h" |
Eli Friedman | 2553126 | 2008-05-20 14:27:34 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/APFloat.h" |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 22 | #include "llvm/ADT/SmallString.h" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 23 | using namespace clang; |
| 24 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 25 | //===----------------------------------------------------------------------===// |
| 26 | // Common code shared among targets. |
| 27 | //===----------------------------------------------------------------------===// |
| 28 | |
Chris Lattner | d15fa82 | 2007-10-06 06:57:34 +0000 | [diff] [blame] | 29 | static void Define(std::vector<char> &Buf, const char *Macro, |
| 30 | const char *Val = "1") { |
| 31 | const char *Def = "#define "; |
| 32 | Buf.insert(Buf.end(), Def, Def+strlen(Def)); |
| 33 | Buf.insert(Buf.end(), Macro, Macro+strlen(Macro)); |
| 34 | Buf.push_back(' '); |
| 35 | Buf.insert(Buf.end(), Val, Val+strlen(Val)); |
| 36 | Buf.push_back('\n'); |
| 37 | } |
| 38 | |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 39 | /// DefineStd - Define a macro name and standard variants. For example if |
| 40 | /// MacroName is "unix", then this will define "__unix", "__unix__", and "unix" |
| 41 | /// when in GNU mode. |
| 42 | static void DefineStd(std::vector<char> &Buf, const char *MacroName, |
| 43 | const LangOptions &Opts) { |
| 44 | assert(MacroName[0] != '_' && "Identifier should be in the user's namespace"); |
| 45 | |
| 46 | // If in GNU mode (e.g. -std=gnu99 but not -std=c99) define the raw identifier |
| 47 | // in the user's namespace. |
| 48 | if (Opts.GNUMode) |
| 49 | Define(Buf, MacroName); |
| 50 | |
| 51 | // Define __unix. |
| 52 | llvm::SmallString<20> TmpStr; |
| 53 | TmpStr = "__"; |
| 54 | TmpStr += MacroName; |
| 55 | Define(Buf, TmpStr.c_str()); |
| 56 | |
| 57 | // Define __unix__. |
| 58 | TmpStr += "__"; |
| 59 | Define(Buf, TmpStr.c_str()); |
| 60 | } |
| 61 | |
Chris Lattner | d29b630 | 2008-10-05 21:50:58 +0000 | [diff] [blame] | 62 | //===----------------------------------------------------------------------===// |
| 63 | // Defines specific to certain operating systems. |
| 64 | //===----------------------------------------------------------------------===// |
| 65 | |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 66 | static void getSolarisDefines(std::vector<char> &Defs) { |
| 67 | Define(Defs, "__SUN__"); |
| 68 | Define(Defs, "__SOLARIS__"); |
| 69 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 70 | |
Chris Lattner | 318ca71 | 2009-03-20 15:55:34 +0000 | [diff] [blame] | 71 | static void getFreeBSDDefines(const LangOptions &Opts, bool is64Bit, |
| 72 | const char *Triple, std::vector<char> &Defs) { |
Chris Lattner | fd0269d | 2008-10-16 17:04:31 +0000 | [diff] [blame] | 73 | // FreeBSD defines; list based off of gcc output |
| 74 | |
| 75 | const char *FreeBSD = strstr(Triple, "-freebsd"); |
| 76 | FreeBSD += strlen("-freebsd"); |
| 77 | char release[] = "X"; |
| 78 | release[0] = FreeBSD[0]; |
| 79 | char version[] = "X00001"; |
| 80 | version[0] = FreeBSD[0]; |
| 81 | |
| 82 | Define(Defs, "__FreeBSD__", release); |
| 83 | Define(Defs, "__FreeBSD_cc_version", version); |
| 84 | Define(Defs, "__KPRINTF_ATTRIBUTE__"); |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 85 | DefineStd(Defs, "unix", Opts); |
Anton Korobeynikov | 2793bda | 2009-02-14 16:42:50 +0000 | [diff] [blame] | 86 | Define(Defs, "__ELF__", "1"); |
Chris Lattner | fd0269d | 2008-10-16 17:04:31 +0000 | [diff] [blame] | 87 | if (is64Bit) { |
| 88 | Define(Defs, "__LP64__"); |
| 89 | } |
| 90 | } |
| 91 | |
Chris Lattner | 318ca71 | 2009-03-20 15:55:34 +0000 | [diff] [blame] | 92 | static void getDragonFlyDefines(const LangOptions &Opts, |
| 93 | std::vector<char> &Defs) { |
Chris Lattner | d29b630 | 2008-10-05 21:50:58 +0000 | [diff] [blame] | 94 | // DragonFly defines; list based off of gcc output |
| 95 | Define(Defs, "__DragonFly__"); |
| 96 | Define(Defs, "__DragonFly_cc_version", "100001"); |
| 97 | Define(Defs, "__ELF__"); |
| 98 | Define(Defs, "__KPRINTF_ATTRIBUTE__"); |
| 99 | Define(Defs, "__tune_i386__"); |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 100 | DefineStd(Defs, "unix", Opts); |
Chris Lattner | d29b630 | 2008-10-05 21:50:58 +0000 | [diff] [blame] | 101 | } |
| 102 | |
Chris Lattner | 318ca71 | 2009-03-20 15:55:34 +0000 | [diff] [blame] | 103 | static void getLinuxDefines(const LangOptions &Opts, std::vector<char> &Defs) { |
Chris Lattner | d29b630 | 2008-10-05 21:50:58 +0000 | [diff] [blame] | 104 | // Linux defines; list based off of gcc output |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 105 | DefineStd(Defs, "unix", Opts); |
| 106 | DefineStd(Defs, "linux", Opts); |
Chris Lattner | d29b630 | 2008-10-05 21:50:58 +0000 | [diff] [blame] | 107 | Define(Defs, "__gnu_linux__"); |
Argyrios Kyrtzidis | 487cdee | 2009-02-14 15:02:45 +0000 | [diff] [blame] | 108 | Define(Defs, "__ELF__", "1"); |
Chris Lattner | d29b630 | 2008-10-05 21:50:58 +0000 | [diff] [blame] | 109 | } |
| 110 | |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 111 | /// getDarwinNumber - Parse the 'darwin number' out of the specific targe |
| 112 | /// triple. For example, if we have darwin8.5 return 8,5,4. If any entry is |
| 113 | /// not defined, return 0's. Return true if we have -darwin in the string or |
| 114 | /// false otherwise. |
| 115 | static bool getDarwinNumber(const char *Triple, unsigned &Maj, unsigned &Min) { |
| 116 | Maj = Min = 0; |
| 117 | const char *Darwin = strstr(Triple, "-darwin"); |
| 118 | if (Darwin == 0) return false; |
| 119 | |
| 120 | Darwin += strlen("-darwin"); |
| 121 | if (Darwin[0] < '0' || Darwin[0] > '9') |
| 122 | return true; |
| 123 | |
| 124 | Maj = Darwin[0]-'0'; |
| 125 | ++Darwin; |
| 126 | |
| 127 | // Handle "darwin11". |
| 128 | if (Maj == 1 && Darwin[0] >= '0' && Darwin[0] <= '9') { |
| 129 | Maj = 10+Darwin[0]-'0'; |
| 130 | ++Darwin; |
| 131 | } |
| 132 | |
| 133 | // Handle minor version: 10.4.9 -> darwin8.9 -> "1049" |
| 134 | if (Darwin[0] == '.' && Darwin[1] >= '0' && Darwin[1] <= '9' && |
| 135 | Darwin[2] == '\0') |
| 136 | Min = Darwin[1]-'0'; |
| 137 | |
| 138 | return true; |
| 139 | } |
| 140 | |
Chris Lattner | 3a5cbd3 | 2009-04-07 04:48:21 +0000 | [diff] [blame] | 141 | static void getDarwinDefines(std::vector<char> &Defs, const LangOptions &Opts, |
| 142 | const char *Triple) { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 143 | Define(Defs, "__APPLE__"); |
| 144 | Define(Defs, "__MACH__"); |
Chris Lattner | d427ad4 | 2009-02-05 07:19:24 +0000 | [diff] [blame] | 145 | Define(Defs, "OBJC_NEW_PROPERTIES"); |
| 146 | |
Chris Lattner | 10d2427 | 2009-04-07 16:50:40 +0000 | [diff] [blame^] | 147 | // __weak is always defined, for use in blocks and with objc pointers. |
| 148 | Define(Defs, "__weak", "__attribute__((objc_gc(weak)))"); |
| 149 | |
| 150 | // Darwin defines __strong even in C mode (just to nothing). |
| 151 | if (!Opts.ObjC1 || Opts.getGCMode() == LangOptions::NonGC) |
Chris Lattner | 3a5cbd3 | 2009-04-07 04:48:21 +0000 | [diff] [blame] | 152 | Define(Defs, "__strong", ""); |
Chris Lattner | 10d2427 | 2009-04-07 16:50:40 +0000 | [diff] [blame^] | 153 | else |
Chris Lattner | 3a5cbd3 | 2009-04-07 04:48:21 +0000 | [diff] [blame] | 154 | Define(Defs, "__strong", "__attribute__((objc_gc(strong)))"); |
Chris Lattner | 3a5cbd3 | 2009-04-07 04:48:21 +0000 | [diff] [blame] | 155 | |
Chris Lattner | d427ad4 | 2009-02-05 07:19:24 +0000 | [diff] [blame] | 156 | // FIXME: OBJC_ZEROCOST_EXCEPTIONS when using zero cost eh. |
Chris Lattner | 8b30c41 | 2008-09-30 01:00:25 +0000 | [diff] [blame] | 157 | |
| 158 | // Figure out which "darwin number" the target triple is. "darwin9" -> 10.5. |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 159 | unsigned Maj, Min; |
| 160 | if (getDarwinNumber(Triple, Maj, Min)) { |
Chris Lattner | 079f2c46 | 2008-09-30 20:30:12 +0000 | [diff] [blame] | 161 | char DarwinStr[] = "1000"; |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 162 | if (Maj >= 4 && Maj <= 13) { // 10.0-10.9 |
| 163 | // darwin7 -> 1030, darwin8 -> 1040, darwin9 -> 1050, etc. |
| 164 | DarwinStr[2] = '0' + Maj-4; |
Chris Lattner | 8b30c41 | 2008-09-30 01:00:25 +0000 | [diff] [blame] | 165 | } |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 166 | |
| 167 | // Handle minor version: 10.4.9 -> darwin8.9 -> "1049" |
| 168 | DarwinStr[3] = Min+'0'; |
Chris Lattner | 079f2c46 | 2008-09-30 20:30:12 +0000 | [diff] [blame] | 169 | Define(Defs, "__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__", DarwinStr); |
Chris Lattner | 8b30c41 | 2008-09-30 01:00:25 +0000 | [diff] [blame] | 170 | } |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 171 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 172 | |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 173 | /// GetDarwinLanguageOptions - Set the default language options for darwin. |
| 174 | static void GetDarwinLanguageOptions(LangOptions &Opts, |
| 175 | const char *Triple) { |
| 176 | Opts.NeXTRuntime = true; |
| 177 | |
| 178 | unsigned Maj, Min; |
| 179 | if (!getDarwinNumber(Triple, Maj, Min)) |
| 180 | return; |
| 181 | |
| 182 | // Blocks default to on for 10.6 (darwin10) and beyond. |
Fariborz Jahanian | a30b17b | 2009-02-12 17:54:33 +0000 | [diff] [blame] | 183 | // As does nonfragile-abi for 64bit mode |
Fariborz Jahanian | 66a5c2c | 2009-02-24 23:34:44 +0000 | [diff] [blame] | 184 | if (Maj > 9) |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 185 | Opts.Blocks = 1; |
Fariborz Jahanian | 66a5c2c | 2009-02-24 23:34:44 +0000 | [diff] [blame] | 186 | |
Fariborz Jahanian | 84d0133 | 2009-02-24 23:38:42 +0000 | [diff] [blame] | 187 | if (Maj >= 9 && Opts.ObjC1 && !strncmp(Triple, "x86_64", 6)) |
| 188 | Opts.ObjCNonFragileABI = 1; |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | |
Chris Lattner | d29b630 | 2008-10-05 21:50:58 +0000 | [diff] [blame] | 192 | //===----------------------------------------------------------------------===// |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 193 | // Specific target implementations. |
| 194 | //===----------------------------------------------------------------------===// |
Anders Carlsson | fb5e5ba | 2007-10-13 00:45:48 +0000 | [diff] [blame] | 195 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 196 | namespace { |
| 197 | // PPC abstract base class |
| 198 | class PPCTargetInfo : public TargetInfo { |
| 199 | static const Builtin::Info BuiltinInfo[]; |
| 200 | static const char * const GCCRegNames[]; |
| 201 | static const TargetInfo::GCCRegAlias GCCRegAliases[]; |
| 202 | |
| 203 | public: |
| 204 | PPCTargetInfo(const std::string& triple) : TargetInfo(triple) { |
| 205 | CharIsSigned = false; |
| 206 | } |
| 207 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 208 | unsigned &NumRecords) const { |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 209 | Records = BuiltinInfo; |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 210 | NumRecords = clang::PPC::LastTSBuiltin-Builtin::FirstTSBuiltin; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 211 | } |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 212 | |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 213 | virtual void getTargetDefines(const LangOptions &Opts, |
| 214 | std::vector<char> &Defines) const; |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 215 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 216 | virtual const char *getVAListDeclaration() const { |
Chris Lattner | d599850 | 2008-10-27 01:11:29 +0000 | [diff] [blame] | 217 | return "typedef char* __builtin_va_list;"; |
| 218 | // This is the right definition for ABI/V4: System V.4/eabi. |
| 219 | /*return "typedef struct __va_list_tag {" |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 220 | " unsigned char gpr;" |
| 221 | " unsigned char fpr;" |
| 222 | " unsigned short reserved;" |
| 223 | " void* overflow_arg_area;" |
| 224 | " void* reg_save_area;" |
Chris Lattner | d599850 | 2008-10-27 01:11:29 +0000 | [diff] [blame] | 225 | "} __builtin_va_list[1];";*/ |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 226 | } |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 227 | virtual const char *getTargetPrefix() const { |
| 228 | return "ppc"; |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 229 | } |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 230 | virtual void getGCCRegNames(const char * const *&Names, |
| 231 | unsigned &NumNames) const; |
| 232 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 233 | unsigned &NumAliases) const; |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 234 | virtual bool validateAsmConstraint(const char *&Name, |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 235 | TargetInfo::ConstraintInfo &info) const { |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 236 | switch (*Name) { |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 237 | default: return false; |
| 238 | case 'O': // Zero |
| 239 | return true; |
| 240 | case 'b': // Base register |
| 241 | case 'f': // Floating point register |
| 242 | info = (TargetInfo::ConstraintInfo)(info|TargetInfo::CI_AllowsRegister); |
| 243 | return true; |
| 244 | } |
| 245 | } |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 246 | virtual const char *getClobbers() const { |
| 247 | return ""; |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 248 | } |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 249 | }; |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 250 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 251 | const Builtin::Info PPCTargetInfo::BuiltinInfo[] = { |
Douglas Gregor | b1152d8 | 2009-02-16 21:58:21 +0000 | [diff] [blame] | 252 | #define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, false }, |
| 253 | #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER, false }, |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 254 | #include "clang/AST/PPCBuiltins.def" |
| 255 | }; |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 256 | |
| 257 | |
| 258 | /// PPCTargetInfo::getTargetDefines - Return a set of the PowerPC-specific |
| 259 | /// #defines that are not tied to a specific subtarget. |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 260 | void PPCTargetInfo::getTargetDefines(const LangOptions &Opts, |
| 261 | std::vector<char> &Defs) const { |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 262 | // Target identification. |
| 263 | Define(Defs, "__ppc__"); |
| 264 | Define(Defs, "_ARCH_PPC"); |
| 265 | Define(Defs, "__POWERPC__"); |
| 266 | if (PointerWidth == 64) { |
| 267 | Define(Defs, "_ARCH_PPC64"); |
| 268 | Define(Defs, "_LP64"); |
| 269 | Define(Defs, "__LP64__"); |
| 270 | Define(Defs, "__ppc64__"); |
| 271 | } else { |
| 272 | Define(Defs, "__ppc__"); |
| 273 | } |
| 274 | |
| 275 | // Target properties. |
| 276 | Define(Defs, "_BIG_ENDIAN"); |
| 277 | Define(Defs, "__BIG_ENDIAN__"); |
| 278 | |
| 279 | // Subtarget options. |
| 280 | Define(Defs, "__NATURAL_ALIGNMENT__"); |
| 281 | Define(Defs, "__REGISTER_PREFIX__", ""); |
| 282 | |
| 283 | // FIXME: Should be controlled by command line option. |
| 284 | Define(Defs, "__LONG_DOUBLE_128__"); |
| 285 | } |
| 286 | |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 287 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 288 | const char * const PPCTargetInfo::GCCRegNames[] = { |
| 289 | "0", "1", "2", "3", "4", "5", "6", "7", |
| 290 | "8", "9", "10", "11", "12", "13", "14", "15", |
| 291 | "16", "17", "18", "19", "20", "21", "22", "23", |
| 292 | "24", "25", "26", "27", "28", "29", "30", "31", |
| 293 | "0", "1", "2", "3", "4", "5", "6", "7", |
| 294 | "8", "9", "10", "11", "12", "13", "14", "15", |
| 295 | "16", "17", "18", "19", "20", "21", "22", "23", |
| 296 | "24", "25", "26", "27", "28", "29", "30", "31", |
| 297 | "mq", "lr", "ctr", "ap", |
| 298 | "0", "1", "2", "3", "4", "5", "6", "7", |
| 299 | "xer", |
| 300 | "0", "1", "2", "3", "4", "5", "6", "7", |
| 301 | "8", "9", "10", "11", "12", "13", "14", "15", |
| 302 | "16", "17", "18", "19", "20", "21", "22", "23", |
| 303 | "24", "25", "26", "27", "28", "29", "30", "31", |
| 304 | "vrsave", "vscr", |
| 305 | "spe_acc", "spefscr", |
| 306 | "sfp" |
| 307 | }; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 308 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 309 | void PPCTargetInfo::getGCCRegNames(const char * const *&Names, |
| 310 | unsigned &NumNames) const { |
| 311 | Names = GCCRegNames; |
| 312 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 313 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 314 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 315 | const TargetInfo::GCCRegAlias PPCTargetInfo::GCCRegAliases[] = { |
| 316 | // While some of these aliases do map to different registers |
| 317 | // they still share the same register name. |
| 318 | { { "cc", "cr0", "fr0", "r0", "v0"}, "0" }, |
| 319 | { { "cr1", "fr1", "r1", "sp", "v1"}, "1" }, |
| 320 | { { "cr2", "fr2", "r2", "toc", "v2"}, "2" }, |
| 321 | { { "cr3", "fr3", "r3", "v3"}, "3" }, |
| 322 | { { "cr4", "fr4", "r4", "v4"}, "4" }, |
| 323 | { { "cr5", "fr5", "r5", "v5"}, "5" }, |
| 324 | { { "cr6", "fr6", "r6", "v6"}, "6" }, |
| 325 | { { "cr7", "fr7", "r7", "v7"}, "7" }, |
| 326 | { { "fr8", "r8", "v8"}, "8" }, |
| 327 | { { "fr9", "r9", "v9"}, "9" }, |
| 328 | { { "fr10", "r10", "v10"}, "10" }, |
| 329 | { { "fr11", "r11", "v11"}, "11" }, |
| 330 | { { "fr12", "r12", "v12"}, "12" }, |
| 331 | { { "fr13", "r13", "v13"}, "13" }, |
| 332 | { { "fr14", "r14", "v14"}, "14" }, |
| 333 | { { "fr15", "r15", "v15"}, "15" }, |
| 334 | { { "fr16", "r16", "v16"}, "16" }, |
| 335 | { { "fr17", "r17", "v17"}, "17" }, |
| 336 | { { "fr18", "r18", "v18"}, "18" }, |
| 337 | { { "fr19", "r19", "v19"}, "19" }, |
| 338 | { { "fr20", "r20", "v20"}, "20" }, |
| 339 | { { "fr21", "r21", "v21"}, "21" }, |
| 340 | { { "fr22", "r22", "v22"}, "22" }, |
| 341 | { { "fr23", "r23", "v23"}, "23" }, |
| 342 | { { "fr24", "r24", "v24"}, "24" }, |
| 343 | { { "fr25", "r25", "v25"}, "25" }, |
| 344 | { { "fr26", "r26", "v26"}, "26" }, |
| 345 | { { "fr27", "r27", "v27"}, "27" }, |
| 346 | { { "fr28", "r28", "v28"}, "28" }, |
| 347 | { { "fr29", "r29", "v29"}, "29" }, |
| 348 | { { "fr30", "r30", "v30"}, "30" }, |
| 349 | { { "fr31", "r31", "v31"}, "31" }, |
| 350 | }; |
| 351 | |
| 352 | void PPCTargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 353 | unsigned &NumAliases) const { |
| 354 | Aliases = GCCRegAliases; |
| 355 | NumAliases = llvm::array_lengthof(GCCRegAliases); |
| 356 | } |
| 357 | } // end anonymous namespace. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 358 | |
| 359 | namespace { |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 360 | class PPC32TargetInfo : public PPCTargetInfo { |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 361 | public: |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 362 | PPC32TargetInfo(const std::string& triple) : PPCTargetInfo(triple) { |
| 363 | DescriptionString = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 364 | "i64:64:64-f32:32:32-f64:64:64-v128:128:128"; |
| 365 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 366 | }; |
| 367 | } // end anonymous namespace. |
| 368 | |
| 369 | namespace { |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 370 | class PPC64TargetInfo : public PPCTargetInfo { |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 371 | public: |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 372 | PPC64TargetInfo(const std::string& triple) : PPCTargetInfo(triple) { |
Chris Lattner | f291b10 | 2008-05-09 06:17:04 +0000 | [diff] [blame] | 373 | LongWidth = LongAlign = PointerWidth = PointerAlign = 64; |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 374 | DescriptionString = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 375 | "i64:64:64-f32:32:32-f64:64:64-v128:128:128"; |
Chris Lattner | f291b10 | 2008-05-09 06:17:04 +0000 | [diff] [blame] | 376 | } |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 377 | }; |
| 378 | } // end anonymous namespace. |
| 379 | |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 380 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 381 | namespace { |
| 382 | class DarwinPPCTargetInfo : public PPC32TargetInfo { |
| 383 | public: |
| 384 | DarwinPPCTargetInfo(const std::string& triple) : PPC32TargetInfo(triple) {} |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 385 | virtual void getTargetDefines(const LangOptions &Opts, |
| 386 | std::vector<char> &Defines) const { |
| 387 | PPC32TargetInfo::getTargetDefines(Opts, Defines); |
Chris Lattner | 3a5cbd3 | 2009-04-07 04:48:21 +0000 | [diff] [blame] | 388 | getDarwinDefines(Defines, Opts, getTargetTriple()); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 389 | } |
Daniel Dunbar | dcb4a1a | 2008-08-23 08:43:39 +0000 | [diff] [blame] | 390 | |
Chris Lattner | 8fc4dfb | 2008-12-04 22:54:33 +0000 | [diff] [blame] | 391 | /// getDefaultLangOptions - Allow the target to specify default settings for |
| 392 | /// various language options. These may be overridden by command line |
| 393 | /// options. |
| 394 | virtual void getDefaultLangOptions(LangOptions &Opts) { |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 395 | GetDarwinLanguageOptions(Opts, getTargetTriple()); |
Chris Lattner | 8fc4dfb | 2008-12-04 22:54:33 +0000 | [diff] [blame] | 396 | } |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 397 | }; |
| 398 | } // end anonymous namespace. |
| 399 | |
| 400 | namespace { |
| 401 | class DarwinPPC64TargetInfo : public PPC64TargetInfo { |
| 402 | public: |
| 403 | DarwinPPC64TargetInfo(const std::string& triple) : PPC64TargetInfo(triple) {} |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 404 | virtual void getTargetDefines(const LangOptions &Opts, |
| 405 | std::vector<char> &Defines) const { |
| 406 | PPC64TargetInfo::getTargetDefines(Opts, Defines); |
Chris Lattner | 3a5cbd3 | 2009-04-07 04:48:21 +0000 | [diff] [blame] | 407 | getDarwinDefines(Defines, Opts, getTargetTriple()); |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 408 | } |
Daniel Dunbar | dcb4a1a | 2008-08-23 08:43:39 +0000 | [diff] [blame] | 409 | |
Chris Lattner | 8fc4dfb | 2008-12-04 22:54:33 +0000 | [diff] [blame] | 410 | /// getDefaultLangOptions - Allow the target to specify default settings for |
| 411 | /// various language options. These may be overridden by command line |
| 412 | /// options. |
| 413 | virtual void getDefaultLangOptions(LangOptions &Opts) { |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 414 | GetDarwinLanguageOptions(Opts, getTargetTriple()); |
Chris Lattner | 8fc4dfb | 2008-12-04 22:54:33 +0000 | [diff] [blame] | 415 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 416 | }; |
| 417 | } // end anonymous namespace. |
| 418 | |
| 419 | namespace { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 420 | // Namespace for x86 abstract base class |
| 421 | const Builtin::Info BuiltinInfo[] = { |
Douglas Gregor | b1152d8 | 2009-02-16 21:58:21 +0000 | [diff] [blame] | 422 | #define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, false }, |
| 423 | #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER, false }, |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 424 | #include "clang/AST/X86Builtins.def" |
| 425 | }; |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 426 | |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 427 | const char *GCCRegNames[] = { |
| 428 | "ax", "dx", "cx", "bx", "si", "di", "bp", "sp", |
| 429 | "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)", |
| 430 | "argp", "flags", "fspr", "dirflag", "frame", |
| 431 | "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", |
| 432 | "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7", |
| 433 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", |
| 434 | "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15" |
| 435 | }; |
| 436 | |
| 437 | const TargetInfo::GCCRegAlias GCCRegAliases[] = { |
| 438 | { { "al", "ah", "eax", "rax" }, "ax" }, |
| 439 | { { "bl", "bh", "ebx", "rbx" }, "bx" }, |
| 440 | { { "cl", "ch", "ecx", "rcx" }, "cx" }, |
| 441 | { { "dl", "dh", "edx", "rdx" }, "dx" }, |
| 442 | { { "esi", "rsi" }, "si" }, |
| 443 | { { "edi", "rdi" }, "di" }, |
| 444 | { { "esp", "rsp" }, "sp" }, |
| 445 | { { "ebp", "rbp" }, "bp" }, |
| 446 | }; |
| 447 | |
| 448 | // X86 target abstract base class; x86-32 and x86-64 are very close, so |
| 449 | // most of the implementation can be shared. |
| 450 | class X86TargetInfo : public TargetInfo { |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 451 | enum X86SSEEnum { |
| 452 | NoMMXSSE, MMX, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42 |
| 453 | } SSELevel; |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 454 | public: |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 455 | X86TargetInfo(const std::string& triple) |
Chris Lattner | 6328cc3 | 2009-03-03 19:56:18 +0000 | [diff] [blame] | 456 | : TargetInfo(triple), |
| 457 | // FIXME: hard coding to SSE2 for now. This should change to NoMMXSSE so |
| 458 | // that the driver controls this. |
| 459 | SSELevel(SSE2) { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 460 | LongDoubleFormat = &llvm::APFloat::x87DoubleExtended; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 461 | } |
| 462 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 463 | unsigned &NumRecords) const { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 464 | Records = BuiltinInfo; |
| 465 | NumRecords = clang::X86::LastTSBuiltin-Builtin::FirstTSBuiltin; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 466 | } |
Anders Carlsson | 44fe49c | 2007-12-08 19:32:57 +0000 | [diff] [blame] | 467 | virtual const char *getTargetPrefix() const { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 468 | return "x86"; |
Anders Carlsson | 44fe49c | 2007-12-08 19:32:57 +0000 | [diff] [blame] | 469 | } |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 470 | virtual void getGCCRegNames(const char * const *&Names, |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 471 | unsigned &NumNames) const { |
| 472 | Names = GCCRegNames; |
| 473 | NumNames = llvm::array_lengthof(GCCRegNames); |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 474 | } |
| 475 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 476 | unsigned &NumAliases) const { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 477 | Aliases = GCCRegAliases; |
| 478 | NumAliases = llvm::array_lengthof(GCCRegAliases); |
Anders Carlsson | fb5e5ba | 2007-10-13 00:45:48 +0000 | [diff] [blame] | 479 | } |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 480 | virtual bool validateAsmConstraint(const char *&Name, |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 481 | TargetInfo::ConstraintInfo &info) const; |
| 482 | virtual std::string convertConstraint(const char Constraint) const; |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 483 | virtual const char *getClobbers() const { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 484 | return "~{dirflag},~{fpsr},~{flags}"; |
| 485 | } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 486 | virtual void getTargetDefines(const LangOptions &Opts, |
| 487 | std::vector<char> &Defines) const; |
Chris Lattner | 3daed52 | 2009-03-02 22:20:04 +0000 | [diff] [blame] | 488 | |
Chris Lattner | 6328cc3 | 2009-03-03 19:56:18 +0000 | [diff] [blame] | 489 | virtual int HandleTargetFeatures(std::string *StrArray, unsigned NumStrs, |
| 490 | std::string &ErrorReason); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 491 | }; |
Chris Lattner | 3daed52 | 2009-03-02 22:20:04 +0000 | [diff] [blame] | 492 | |
| 493 | /// HandleTargetOptions - Handle target-specific options like -msse2 and |
| 494 | /// friends. An array of arguments is passed in: if they are all valid, this |
| 495 | /// should handle them and return -1. If there is an error, the index of the |
| 496 | /// invalid argument should be returned along with an optional error string. |
Chris Lattner | 6328cc3 | 2009-03-03 19:56:18 +0000 | [diff] [blame] | 497 | int X86TargetInfo::HandleTargetFeatures(std::string *StrArray, unsigned NumStrs, |
| 498 | std::string &ErrorReason) { |
| 499 | for (unsigned i = 0; i != NumStrs; ++i) { |
| 500 | const std::string &Feature = StrArray[i]; |
| 501 | if (Feature.size() < 2) return i; |
| 502 | // Ignore explicitly disabled features. |
| 503 | if (Feature[0] == '-') continue; |
| 504 | |
| 505 | // Feature strings are of the form "+feature". |
| 506 | if (Feature[0] != '+') return i; |
| 507 | |
| 508 | // The set of supported subtarget features is defined in |
| 509 | // lib/Target/X86/X86.td. Here we recognize and map onto our internal |
| 510 | // state. |
| 511 | if (Feature == "+mmx") |
| 512 | SSELevel = std::max(SSELevel, MMX); |
| 513 | else if (Feature == "+sse") |
| 514 | SSELevel = std::max(SSELevel, SSE1); |
| 515 | else if (Feature == "+sse2") |
| 516 | SSELevel = std::max(SSELevel, SSE2); |
| 517 | else if (Feature == "+sse3") |
| 518 | SSELevel = std::max(SSELevel, SSE3); |
| 519 | else if (Feature == "+ssse3") |
| 520 | SSELevel = std::max(SSELevel, SSSE3); |
| 521 | else if (Feature == "+sse41") |
| 522 | SSELevel = std::max(SSELevel, SSE41); |
| 523 | else if (Feature == "+sse42") |
| 524 | SSELevel = std::max(SSELevel, SSE42); |
| 525 | else if (Feature == "+64bit" || Feature == "+slow-bt-mem") |
| 526 | // Ignore these features. |
| 527 | continue; |
| 528 | else |
| 529 | return i; |
| 530 | } |
| 531 | return -1; |
Chris Lattner | 3daed52 | 2009-03-02 22:20:04 +0000 | [diff] [blame] | 532 | } |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 533 | |
| 534 | /// X86TargetInfo::getTargetDefines - Return a set of the X86-specific #defines |
| 535 | /// that are not tied to a specific subtarget. |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 536 | void X86TargetInfo::getTargetDefines(const LangOptions &Opts, |
| 537 | std::vector<char> &Defs) const { |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 538 | // Target identification. |
| 539 | if (PointerWidth == 64) { |
| 540 | Define(Defs, "_LP64"); |
| 541 | Define(Defs, "__LP64__"); |
| 542 | Define(Defs, "__amd64__"); |
| 543 | Define(Defs, "__amd64"); |
| 544 | Define(Defs, "__x86_64"); |
| 545 | Define(Defs, "__x86_64__"); |
| 546 | Define(Defs, "__SSE3__"); |
| 547 | } else { |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 548 | DefineStd(Defs, "i386", Opts); |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | // Target properties. |
| 552 | Define(Defs, "__LITTLE_ENDIAN__"); |
| 553 | |
| 554 | // Subtarget options. |
| 555 | Define(Defs, "__nocona"); |
| 556 | Define(Defs, "__nocona__"); |
| 557 | Define(Defs, "__tune_nocona__"); |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 558 | Define(Defs, "__REGISTER_PREFIX__", ""); |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 559 | |
| 560 | // Each case falls through to the previous one here. |
| 561 | switch (SSELevel) { |
| 562 | case SSE42: |
| 563 | Define(Defs, "__SSE4_2__"); |
| 564 | case SSE41: |
| 565 | Define(Defs, "__SSE4_1__"); |
| 566 | case SSSE3: |
| 567 | Define(Defs, "__SSSE3__"); |
| 568 | case SSE3: |
| 569 | Define(Defs, "__SSE3__"); |
| 570 | case SSE2: |
| 571 | Define(Defs, "__SSE2__"); |
| 572 | Define(Defs, "__SSE2_MATH__"); // -mfp-math=sse always implied. |
| 573 | case SSE1: |
| 574 | Define(Defs, "__SSE__"); |
| 575 | Define(Defs, "__SSE_MATH__"); // -mfp-math=sse always implied. |
| 576 | case MMX: |
| 577 | Define(Defs, "__MMX__"); |
| 578 | case NoMMXSSE: |
| 579 | break; |
| 580 | } |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 581 | } |
| 582 | |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 583 | |
| 584 | bool |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 585 | X86TargetInfo::validateAsmConstraint(const char *&Name, |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 586 | TargetInfo::ConstraintInfo &info) const { |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 587 | switch (*Name) { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 588 | default: return false; |
| 589 | case 'a': // eax. |
| 590 | case 'b': // ebx. |
| 591 | case 'c': // ecx. |
| 592 | case 'd': // edx. |
| 593 | case 'S': // esi. |
| 594 | case 'D': // edi. |
| 595 | case 'A': // edx:eax. |
| 596 | case 't': // top of floating point stack. |
| 597 | case 'u': // second from top of floating point stack. |
| 598 | 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] | 599 | case 'y': // Any MMX register. |
Anders Carlsson | a7406d4 | 2008-10-06 19:17:39 +0000 | [diff] [blame] | 600 | case 'x': // Any SSE register. |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 601 | case 'Q': // Any register accessible as [r]h: a, b, c, and d. |
Anders Carlsson | 79bc64c | 2009-01-24 18:03:09 +0000 | [diff] [blame] | 602 | case 'e': // 32-bit signed integer constant for use with zero-extending |
| 603 | // x86_64 instructions. |
| 604 | case 'Z': // 32-bit unsigned integer constant for use with zero-extending |
| 605 | // x86_64 instructions. |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 606 | case 'N': // unsigned 8-bit integer constant for use with in and out |
| 607 | // instructions. |
| 608 | info = (TargetInfo::ConstraintInfo)(info|TargetInfo::CI_AllowsRegister); |
| 609 | return true; |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | std::string |
| 614 | X86TargetInfo::convertConstraint(const char Constraint) const { |
| 615 | switch (Constraint) { |
| 616 | case 'a': return std::string("{ax}"); |
| 617 | case 'b': return std::string("{bx}"); |
| 618 | case 'c': return std::string("{cx}"); |
| 619 | case 'd': return std::string("{dx}"); |
| 620 | case 'S': return std::string("{si}"); |
| 621 | case 'D': return std::string("{di}"); |
| 622 | case 't': // top of floating point stack. |
| 623 | return std::string("{st}"); |
| 624 | case 'u': // second from top of floating point stack. |
| 625 | return std::string("{st(1)}"); // second from top of floating point stack. |
| 626 | default: |
| 627 | return std::string(1, Constraint); |
| 628 | } |
| 629 | } |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 630 | } // end anonymous namespace |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 631 | |
| 632 | namespace { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 633 | // X86-32 generic target |
| 634 | class X86_32TargetInfo : public X86TargetInfo { |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 635 | public: |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 636 | X86_32TargetInfo(const std::string& triple) : X86TargetInfo(triple) { |
| 637 | DoubleAlign = LongLongAlign = 32; |
| 638 | LongDoubleWidth = 96; |
| 639 | LongDoubleAlign = 32; |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 640 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 641 | "i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-" |
| 642 | "a0:0:64-f80:32:32"; |
Eli Friedman | 1afabd9 | 2009-03-29 20:31:09 +0000 | [diff] [blame] | 643 | SizeType = UnsignedInt; |
| 644 | PtrDiffType = SignedInt; |
| 645 | IntPtrType = SignedInt; |
Anton Korobeynikov | 264a76c | 2009-04-03 23:38:25 +0000 | [diff] [blame] | 646 | RegParmMax = 3; |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 647 | } |
| 648 | virtual const char *getVAListDeclaration() const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 649 | return "typedef char* __builtin_va_list;"; |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 650 | } |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 651 | }; |
| 652 | } // end anonymous namespace |
| 653 | |
| 654 | namespace { |
| 655 | // x86-32 Darwin (OS X) target |
| 656 | class DarwinI386TargetInfo : public X86_32TargetInfo { |
| 657 | public: |
| 658 | DarwinI386TargetInfo(const std::string& triple) : X86_32TargetInfo(triple) { |
| 659 | LongDoubleWidth = 128; |
| 660 | LongDoubleAlign = 128; |
Eli Friedman | 1afabd9 | 2009-03-29 20:31:09 +0000 | [diff] [blame] | 661 | SizeType = UnsignedLong; |
| 662 | IntPtrType = SignedLong; |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 663 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 664 | "i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-" |
| 665 | "a0:0:64-f80:128:128"; |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 666 | } |
Daniel Dunbar | 8e5c2b8 | 2009-03-31 23:42:16 +0000 | [diff] [blame] | 667 | |
| 668 | virtual const char *getStringSymbolPrefix(bool IsConstant) const { |
| 669 | return IsConstant ? "\01LC" : "\01lC"; |
| 670 | } |
| 671 | |
Daniel Dunbar | a9668e0 | 2009-04-03 00:57:44 +0000 | [diff] [blame] | 672 | virtual const char *getUnicodeStringSymbolPrefix() const { |
| 673 | return "__utf16_string_"; |
| 674 | } |
| 675 | |
| 676 | virtual const char *getUnicodeStringSection() const { |
| 677 | return "__TEXT,__ustring"; |
| 678 | } |
| 679 | |
Daniel Dunbar | 8e5c2b8 | 2009-03-31 23:42:16 +0000 | [diff] [blame] | 680 | virtual const char *getCFStringSymbolPrefix() const { |
| 681 | return "\01LC"; |
| 682 | } |
| 683 | |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 684 | virtual void getTargetDefines(const LangOptions &Opts, |
| 685 | std::vector<char> &Defines) const { |
| 686 | X86_32TargetInfo::getTargetDefines(Opts, Defines); |
Chris Lattner | 3a5cbd3 | 2009-04-07 04:48:21 +0000 | [diff] [blame] | 687 | getDarwinDefines(Defines, Opts, getTargetTriple()); |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 688 | } |
Daniel Dunbar | 8e5c2b8 | 2009-03-31 23:42:16 +0000 | [diff] [blame] | 689 | |
Chris Lattner | 8fc4dfb | 2008-12-04 22:54:33 +0000 | [diff] [blame] | 690 | /// getDefaultLangOptions - Allow the target to specify default settings for |
| 691 | /// various language options. These may be overridden by command line |
| 692 | /// options. |
| 693 | virtual void getDefaultLangOptions(LangOptions &Opts) { |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 694 | GetDarwinLanguageOptions(Opts, getTargetTriple()); |
Chris Lattner | 8fc4dfb | 2008-12-04 22:54:33 +0000 | [diff] [blame] | 695 | } |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 696 | }; |
| 697 | } // end anonymous namespace |
| 698 | |
| 699 | namespace { |
Chris Lattner | fd0269d | 2008-10-16 17:04:31 +0000 | [diff] [blame] | 700 | // x86-32 FreeBSD target |
| 701 | class FreeBSDX86_32TargetInfo : public X86_32TargetInfo { |
| 702 | public: |
Eli Friedman | f509d73 | 2008-11-02 02:43:55 +0000 | [diff] [blame] | 703 | FreeBSDX86_32TargetInfo(const std::string& triple) : |
Eli Friedman | 1afabd9 | 2009-03-29 20:31:09 +0000 | [diff] [blame] | 704 | X86_32TargetInfo(triple) { } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 705 | virtual void getTargetDefines(const LangOptions &Opts, |
| 706 | std::vector<char> &Defines) const { |
| 707 | X86_32TargetInfo::getTargetDefines(Opts, Defines); |
Chris Lattner | 318ca71 | 2009-03-20 15:55:34 +0000 | [diff] [blame] | 708 | getFreeBSDDefines(Opts, 0, getTargetTriple(), Defines); |
Chris Lattner | fd0269d | 2008-10-16 17:04:31 +0000 | [diff] [blame] | 709 | } |
| 710 | }; |
| 711 | } // end anonymous namespace |
| 712 | |
| 713 | namespace { |
Chris Lattner | eac7aee | 2008-08-23 18:23:14 +0000 | [diff] [blame] | 714 | // x86-32 DragonFly target |
| 715 | class DragonFlyX86_32TargetInfo : public X86_32TargetInfo { |
| 716 | public: |
Eli Friedman | f509d73 | 2008-11-02 02:43:55 +0000 | [diff] [blame] | 717 | DragonFlyX86_32TargetInfo(const std::string& triple) : |
Eli Friedman | 1afabd9 | 2009-03-29 20:31:09 +0000 | [diff] [blame] | 718 | X86_32TargetInfo(triple) { } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 719 | virtual void getTargetDefines(const LangOptions &Opts, |
| 720 | std::vector<char> &Defines) const { |
| 721 | X86_32TargetInfo::getTargetDefines(Opts, Defines); |
Chris Lattner | 318ca71 | 2009-03-20 15:55:34 +0000 | [diff] [blame] | 722 | getDragonFlyDefines(Opts, Defines); |
Chris Lattner | eac7aee | 2008-08-23 18:23:14 +0000 | [diff] [blame] | 723 | } |
| 724 | }; |
| 725 | } // end anonymous namespace |
| 726 | |
| 727 | namespace { |
Eli Friedman | 0d4047b | 2008-08-21 00:24:02 +0000 | [diff] [blame] | 728 | // x86-32 Linux target |
| 729 | class LinuxX86_32TargetInfo : public X86_32TargetInfo { |
| 730 | public: |
| 731 | LinuxX86_32TargetInfo(const std::string& triple) : X86_32TargetInfo(triple) { |
Chris Lattner | 9b53316 | 2008-10-05 19:44:25 +0000 | [diff] [blame] | 732 | UserLabelPrefix = ""; |
Eli Friedman | 0d4047b | 2008-08-21 00:24:02 +0000 | [diff] [blame] | 733 | } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 734 | virtual void getTargetDefines(const LangOptions &Opts, |
| 735 | std::vector<char> &Defines) const { |
| 736 | X86_32TargetInfo::getTargetDefines(Opts, Defines); |
Chris Lattner | 318ca71 | 2009-03-20 15:55:34 +0000 | [diff] [blame] | 737 | getLinuxDefines(Opts, Defines); |
Eli Friedman | 0d4047b | 2008-08-21 00:24:02 +0000 | [diff] [blame] | 738 | } |
| 739 | }; |
| 740 | } // end anonymous namespace |
| 741 | |
| 742 | namespace { |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 743 | // x86-32 Windows target |
| 744 | class WindowsX86_32TargetInfo : public X86_32TargetInfo { |
| 745 | public: |
| 746 | WindowsX86_32TargetInfo(const std::string& triple) |
| 747 | : X86_32TargetInfo(triple) { |
| 748 | // FIXME: Fix wchar_t. |
| 749 | // FIXME: We should probably enable -fms-extensions by default for |
| 750 | // this target. |
| 751 | } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 752 | virtual void getTargetDefines(const LangOptions &Opts, |
| 753 | std::vector<char> &Defines) const { |
| 754 | X86_32TargetInfo::getTargetDefines(Opts, Defines); |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 755 | // 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] | 756 | Define(Defines, "_WIN32"); |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 757 | DefineStd(Defines, "WIN32", Opts); |
| 758 | DefineStd(Defines, "WINNT", Opts); |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 759 | Define(Defines, "_X86_"); |
| 760 | Define(Defines, "__MSVCRT__"); |
| 761 | } |
| 762 | }; |
| 763 | } // end anonymous namespace |
| 764 | |
| 765 | namespace { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 766 | // x86-64 generic target |
| 767 | class X86_64TargetInfo : public X86TargetInfo { |
| 768 | public: |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 769 | X86_64TargetInfo(const std::string &triple) : X86TargetInfo(triple) { |
Chris Lattner | f291b10 | 2008-05-09 06:17:04 +0000 | [diff] [blame] | 770 | LongWidth = LongAlign = PointerWidth = PointerAlign = 64; |
Chris Lattner | 778601f | 2009-01-28 06:58:19 +0000 | [diff] [blame] | 771 | DoubleAlign = LongLongAlign = 64; |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 772 | LongDoubleWidth = 128; |
| 773 | LongDoubleAlign = 128; |
Chris Lattner | 06ebe86 | 2009-02-05 07:32:46 +0000 | [diff] [blame] | 774 | IntMaxType = SignedLong; |
| 775 | UIntMaxType = UnsignedLong; |
Anton Korobeynikov | 264a76c | 2009-04-03 23:38:25 +0000 | [diff] [blame] | 776 | RegParmMax = 6; |
Chris Lattner | 06ebe86 | 2009-02-05 07:32:46 +0000 | [diff] [blame] | 777 | |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 778 | DescriptionString = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 779 | "i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-" |
| 780 | "a0:0:64-f80:128:128"; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 781 | } |
Anders Carlsson | fb5e5ba | 2007-10-13 00:45:48 +0000 | [diff] [blame] | 782 | virtual const char *getVAListDeclaration() const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 783 | return "typedef struct __va_list_tag {" |
| 784 | " unsigned gp_offset;" |
| 785 | " unsigned fp_offset;" |
| 786 | " void* overflow_arg_area;" |
| 787 | " void* reg_save_area;" |
| 788 | "} __builtin_va_list[1];"; |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 789 | } |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 790 | }; |
| 791 | } // end anonymous namespace |
| 792 | |
| 793 | namespace { |
Chris Lattner | fd0269d | 2008-10-16 17:04:31 +0000 | [diff] [blame] | 794 | // x86-64 FreeBSD target |
| 795 | class FreeBSDX86_64TargetInfo : public X86_64TargetInfo { |
| 796 | public: |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 797 | FreeBSDX86_64TargetInfo(const std::string &triple) |
| 798 | : X86_64TargetInfo(triple) {} |
| 799 | virtual void getTargetDefines(const LangOptions &Opts, |
| 800 | std::vector<char> &Defines) const { |
| 801 | X86_64TargetInfo::getTargetDefines(Opts, Defines); |
Chris Lattner | 318ca71 | 2009-03-20 15:55:34 +0000 | [diff] [blame] | 802 | getFreeBSDDefines(Opts, 1, getTargetTriple(), Defines); |
Chris Lattner | fd0269d | 2008-10-16 17:04:31 +0000 | [diff] [blame] | 803 | } |
| 804 | }; |
| 805 | } // end anonymous namespace |
| 806 | |
| 807 | namespace { |
Daniel Dunbar | b55a42b | 2008-09-23 17:37:57 +0000 | [diff] [blame] | 808 | // x86-64 Linux target |
| 809 | class LinuxX86_64TargetInfo : public X86_64TargetInfo { |
| 810 | public: |
| 811 | LinuxX86_64TargetInfo(const std::string& triple) : X86_64TargetInfo(triple) { |
Chris Lattner | 9b53316 | 2008-10-05 19:44:25 +0000 | [diff] [blame] | 812 | UserLabelPrefix = ""; |
Daniel Dunbar | b55a42b | 2008-09-23 17:37:57 +0000 | [diff] [blame] | 813 | } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 814 | virtual void getTargetDefines(const LangOptions &Opts, |
| 815 | std::vector<char> &Defines) const { |
| 816 | X86_64TargetInfo::getTargetDefines(Opts, Defines); |
Chris Lattner | 318ca71 | 2009-03-20 15:55:34 +0000 | [diff] [blame] | 817 | getLinuxDefines(Opts, Defines); |
Daniel Dunbar | b55a42b | 2008-09-23 17:37:57 +0000 | [diff] [blame] | 818 | } |
| 819 | }; |
| 820 | } // end anonymous namespace |
| 821 | |
| 822 | namespace { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 823 | // x86-64 Darwin (OS X) target |
| 824 | class DarwinX86_64TargetInfo : public X86_64TargetInfo { |
| 825 | public: |
| 826 | DarwinX86_64TargetInfo(const std::string& triple) : |
| 827 | X86_64TargetInfo(triple) {} |
| 828 | |
Daniel Dunbar | 8e5c2b8 | 2009-03-31 23:42:16 +0000 | [diff] [blame] | 829 | virtual const char *getStringSymbolPrefix(bool IsConstant) const { |
| 830 | return IsConstant ? "\01LC" : "\01lC"; |
| 831 | } |
| 832 | |
Daniel Dunbar | a9668e0 | 2009-04-03 00:57:44 +0000 | [diff] [blame] | 833 | virtual const char *getUnicodeStringSymbolPrefix() const { |
| 834 | return "__utf16_string_"; |
| 835 | } |
| 836 | |
| 837 | virtual const char *getUnicodeStringSection() const { |
| 838 | return "__TEXT,__ustring"; |
| 839 | } |
| 840 | |
Daniel Dunbar | 8e5c2b8 | 2009-03-31 23:42:16 +0000 | [diff] [blame] | 841 | virtual const char *getCFStringSymbolPrefix() const { |
| 842 | return "\01L_unnamed_cfstring_"; |
| 843 | } |
| 844 | |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 845 | virtual void getTargetDefines(const LangOptions &Opts, |
| 846 | std::vector<char> &Defines) const { |
| 847 | X86_64TargetInfo::getTargetDefines(Opts, Defines); |
Chris Lattner | 3a5cbd3 | 2009-04-07 04:48:21 +0000 | [diff] [blame] | 848 | getDarwinDefines(Defines, Opts, getTargetTriple()); |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 849 | } |
Daniel Dunbar | dcb4a1a | 2008-08-23 08:43:39 +0000 | [diff] [blame] | 850 | |
Chris Lattner | 8fc4dfb | 2008-12-04 22:54:33 +0000 | [diff] [blame] | 851 | /// getDefaultLangOptions - Allow the target to specify default settings for |
| 852 | /// various language options. These may be overridden by command line |
| 853 | /// options. |
| 854 | virtual void getDefaultLangOptions(LangOptions &Opts) { |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 855 | GetDarwinLanguageOptions(Opts, getTargetTriple()); |
Chris Lattner | 8fc4dfb | 2008-12-04 22:54:33 +0000 | [diff] [blame] | 856 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 857 | }; |
| 858 | } // end anonymous namespace. |
| 859 | |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 860 | namespace { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 861 | class ARMTargetInfo : public TargetInfo { |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 862 | public: |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 863 | ARMTargetInfo(const std::string& triple) : TargetInfo(triple) { |
| 864 | // FIXME: Are the defaults correct for ARM? |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 865 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 866 | "i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:64"; |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 867 | } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 868 | virtual void getTargetDefines(const LangOptions &Opts, |
| 869 | std::vector<char> &Defs) const { |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 870 | // Target identification. |
| 871 | Define(Defs, "__arm"); |
| 872 | Define(Defs, "__arm__"); |
| 873 | |
| 874 | // Target properties. |
| 875 | Define(Defs, "__LITTLE_ENDIAN__"); |
| 876 | |
| 877 | // Subtarget options. [hard coded to v6 for now] |
| 878 | Define(Defs, "__ARM_ARCH_6K__"); |
| 879 | Define(Defs, "__ARMEL__"); |
| 880 | Define(Defs, "__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__", "20000"); |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 881 | } |
| 882 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 883 | unsigned &NumRecords) const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 884 | // FIXME: Implement. |
| 885 | Records = 0; |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 886 | NumRecords = 0; |
| 887 | } |
| 888 | virtual const char *getVAListDeclaration() const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 889 | return "typedef char* __builtin_va_list;"; |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 890 | } |
| 891 | virtual const char *getTargetPrefix() const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 892 | return "arm"; |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 893 | } |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 894 | virtual void getGCCRegNames(const char * const *&Names, |
| 895 | unsigned &NumNames) const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 896 | // FIXME: Implement. |
| 897 | Names = 0; |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 898 | NumNames = 0; |
| 899 | } |
| 900 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 901 | unsigned &NumAliases) const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 902 | // FIXME: Implement. |
| 903 | Aliases = 0; |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 904 | NumAliases = 0; |
| 905 | } |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 906 | virtual bool validateAsmConstraint(const char *&Name, |
Nate Begeman | ad487f4 | 2008-04-22 05:03:19 +0000 | [diff] [blame] | 907 | TargetInfo::ConstraintInfo &info) const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 908 | // FIXME: Check if this is complete |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 909 | switch (*Name) { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 910 | default: |
Nate Begeman | ad487f4 | 2008-04-22 05:03:19 +0000 | [diff] [blame] | 911 | case 'l': // r0-r7 |
| 912 | case 'h': // r8-r15 |
| 913 | case 'w': // VFP Floating point register single precision |
| 914 | case 'P': // VFP Floating point register double precision |
| 915 | info = (TargetInfo::ConstraintInfo)(info|TargetInfo::CI_AllowsRegister); |
| 916 | return true; |
| 917 | } |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 918 | return false; |
| 919 | } |
| 920 | virtual const char *getClobbers() const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 921 | // FIXME: Is this really right? |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 922 | return ""; |
| 923 | } |
| 924 | }; |
| 925 | } // end anonymous namespace. |
| 926 | |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 927 | |
| 928 | namespace { |
| 929 | class DarwinARMTargetInfo : public ARMTargetInfo { |
| 930 | public: |
| 931 | DarwinARMTargetInfo(const std::string& triple) : ARMTargetInfo(triple) {} |
| 932 | |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 933 | virtual void getTargetDefines(const LangOptions &Opts, |
| 934 | std::vector<char> &Defines) const { |
| 935 | ARMTargetInfo::getTargetDefines(Opts, Defines); |
Chris Lattner | 3a5cbd3 | 2009-04-07 04:48:21 +0000 | [diff] [blame] | 936 | getDarwinDefines(Defines, Opts, getTargetTriple()); |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 937 | } |
| 938 | }; |
| 939 | } // end anonymous namespace. |
| 940 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 941 | namespace { |
Daniel Dunbar | 1e0107a | 2009-03-23 16:09:04 +0000 | [diff] [blame] | 942 | // arm FreeBSD target |
| 943 | class FreeBSDARMTargetInfo : public ARMTargetInfo { |
| 944 | public: |
| 945 | FreeBSDARMTargetInfo(const std::string& triple) : ARMTargetInfo(triple) {} |
| 946 | virtual void getTargetDefines(const LangOptions &Opts, |
| 947 | std::vector<char> &Defines) const { |
| 948 | ARMTargetInfo::getTargetDefines(Opts, Defines); |
| 949 | getFreeBSDDefines(Opts, 0, getTargetTriple(), Defines); |
| 950 | } |
| 951 | }; |
| 952 | } // end anonymous namespace |
| 953 | |
| 954 | namespace { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 955 | class SparcV8TargetInfo : public TargetInfo { |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 956 | static const TargetInfo::GCCRegAlias GCCRegAliases[]; |
| 957 | static const char * const GCCRegNames[]; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 958 | public: |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 959 | SparcV8TargetInfo(const std::string& triple) : TargetInfo(triple) { |
| 960 | // FIXME: Support Sparc quad-precision long double? |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 961 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 962 | "i64:64:64-f32:32:32-f64:64:64-v64:64:64"; |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 963 | } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 964 | virtual void getTargetDefines(const LangOptions &Opts, |
| 965 | std::vector<char> &Defines) const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 966 | // FIXME: This is missing a lot of important defines; some of the |
| 967 | // missing stuff is likely to break system headers. |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 968 | Define(Defines, "__sparc"); |
Eli Friedman | bf0c9bd | 2008-05-25 05:26:09 +0000 | [diff] [blame] | 969 | Define(Defines, "__sparc__"); |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 970 | Define(Defines, "__sparcv8"); |
| 971 | } |
| 972 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 973 | unsigned &NumRecords) const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 974 | // FIXME: Implement! |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 975 | } |
| 976 | virtual const char *getVAListDeclaration() const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 977 | return "typedef void* __builtin_va_list;"; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 978 | } |
| 979 | virtual const char *getTargetPrefix() const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 980 | return "sparc"; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 981 | } |
| 982 | virtual void getGCCRegNames(const char * const *&Names, |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 983 | unsigned &NumNames) const; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 984 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 985 | unsigned &NumAliases) const; |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 986 | virtual bool validateAsmConstraint(const char *&Name, |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 987 | TargetInfo::ConstraintInfo &info) const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 988 | // FIXME: Implement! |
| 989 | return false; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 990 | } |
| 991 | virtual const char *getClobbers() const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 992 | // FIXME: Implement! |
| 993 | return ""; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 994 | } |
| 995 | }; |
| 996 | |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 997 | const char * const SparcV8TargetInfo::GCCRegNames[] = { |
| 998 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
| 999 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", |
| 1000 | "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", |
| 1001 | "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31" |
| 1002 | }; |
| 1003 | |
| 1004 | void SparcV8TargetInfo::getGCCRegNames(const char * const *&Names, |
| 1005 | unsigned &NumNames) const { |
| 1006 | Names = GCCRegNames; |
| 1007 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 1008 | } |
| 1009 | |
| 1010 | const TargetInfo::GCCRegAlias SparcV8TargetInfo::GCCRegAliases[] = { |
| 1011 | { { "g0" }, "r0" }, |
| 1012 | { { "g1" }, "r1" }, |
| 1013 | { { "g2" }, "r2" }, |
| 1014 | { { "g3" }, "r3" }, |
| 1015 | { { "g4" }, "r4" }, |
| 1016 | { { "g5" }, "r5" }, |
| 1017 | { { "g6" }, "r6" }, |
| 1018 | { { "g7" }, "r7" }, |
| 1019 | { { "o0" }, "r8" }, |
| 1020 | { { "o1" }, "r9" }, |
| 1021 | { { "o2" }, "r10" }, |
| 1022 | { { "o3" }, "r11" }, |
| 1023 | { { "o4" }, "r12" }, |
| 1024 | { { "o5" }, "r13" }, |
| 1025 | { { "o6", "sp" }, "r14" }, |
| 1026 | { { "o7" }, "r15" }, |
| 1027 | { { "l0" }, "r16" }, |
| 1028 | { { "l1" }, "r17" }, |
| 1029 | { { "l2" }, "r18" }, |
| 1030 | { { "l3" }, "r19" }, |
| 1031 | { { "l4" }, "r20" }, |
| 1032 | { { "l5" }, "r21" }, |
| 1033 | { { "l6" }, "r22" }, |
| 1034 | { { "l7" }, "r23" }, |
| 1035 | { { "i0" }, "r24" }, |
| 1036 | { { "i1" }, "r25" }, |
| 1037 | { { "i2" }, "r26" }, |
| 1038 | { { "i3" }, "r27" }, |
| 1039 | { { "i4" }, "r28" }, |
| 1040 | { { "i5" }, "r29" }, |
| 1041 | { { "i6", "fp" }, "r30" }, |
| 1042 | { { "i7" }, "r31" }, |
| 1043 | }; |
| 1044 | |
| 1045 | void SparcV8TargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 1046 | unsigned &NumAliases) const { |
| 1047 | Aliases = GCCRegAliases; |
| 1048 | NumAliases = llvm::array_lengthof(GCCRegAliases); |
| 1049 | } |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1050 | } // end anonymous namespace. |
| 1051 | |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1052 | namespace { |
| 1053 | class SolarisSparcV8TargetInfo : public SparcV8TargetInfo { |
| 1054 | public: |
| 1055 | SolarisSparcV8TargetInfo(const std::string& triple) : |
Eli Friedman | f509d73 | 2008-11-02 02:43:55 +0000 | [diff] [blame] | 1056 | SparcV8TargetInfo(triple) { |
| 1057 | SizeType = UnsignedInt; |
| 1058 | PtrDiffType = SignedInt; |
| 1059 | } |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1060 | |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 1061 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1062 | std::vector<char> &Defines) const { |
| 1063 | SparcV8TargetInfo::getTargetDefines(Opts, Defines); |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1064 | getSolarisDefines(Defines); |
| 1065 | } |
| 1066 | }; |
| 1067 | } // end anonymous namespace. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1068 | |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 1069 | namespace { |
| 1070 | class PIC16TargetInfo : public TargetInfo{ |
| 1071 | public: |
| 1072 | PIC16TargetInfo(const std::string& triple) : TargetInfo(triple) { |
Sanjiv Gupta | 31fc07d | 2008-10-31 09:52:39 +0000 | [diff] [blame] | 1073 | IntWidth = 16; |
| 1074 | LongWidth = LongLongWidth = 32; |
| 1075 | PointerWidth = 16; |
| 1076 | IntAlign = 8; |
| 1077 | LongAlign = LongLongAlign = 8; |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1078 | PointerAlign = 8; |
Sanjiv Gupta | 31fc07d | 2008-10-31 09:52:39 +0000 | [diff] [blame] | 1079 | SizeType = UnsignedInt; |
| 1080 | IntMaxType = SignedLong; |
| 1081 | UIntMaxType = UnsignedLong; |
Chris Lattner | 6ad474f | 2009-02-13 22:28:55 +0000 | [diff] [blame] | 1082 | IntPtrType = SignedShort; |
Eli Friedman | f509d73 | 2008-11-02 02:43:55 +0000 | [diff] [blame] | 1083 | PtrDiffType = SignedInt; |
Sanjiv Gupta | 364af81 | 2008-08-18 10:05:22 +0000 | [diff] [blame] | 1084 | DescriptionString = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"; |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 1085 | } |
Chris Lattner | 927686f | 2008-05-09 06:08:39 +0000 | [diff] [blame] | 1086 | virtual uint64_t getPointerWidthV(unsigned AddrSpace) const { return 16; } |
| 1087 | virtual uint64_t getPointerAlignV(unsigned AddrSpace) const { return 8; } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 1088 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1089 | std::vector<char> &Defines) const { |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 1090 | Define(Defines, "__pic16"); |
| 1091 | } |
| 1092 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 1093 | unsigned &NumRecords) const {} |
| 1094 | virtual const char *getVAListDeclaration() const { return "";} |
| 1095 | virtual const char *getClobbers() const {return "";} |
| 1096 | virtual const char *getTargetPrefix() const {return "";} |
| 1097 | virtual void getGCCRegNames(const char * const *&Names, |
| 1098 | unsigned &NumNames) const {} |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 1099 | virtual bool validateAsmConstraint(const char *&Name, |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 1100 | TargetInfo::ConstraintInfo &info) const { |
| 1101 | return true; |
| 1102 | } |
| 1103 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 1104 | unsigned &NumAliases) const {} |
| 1105 | virtual bool useGlobalsForAutomaticVariables() const {return true;} |
| 1106 | }; |
| 1107 | } |
| 1108 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1109 | //===----------------------------------------------------------------------===// |
| 1110 | // Driver code |
| 1111 | //===----------------------------------------------------------------------===// |
| 1112 | |
Ted Kremenek | 8448d38 | 2007-12-04 17:07:35 +0000 | [diff] [blame] | 1113 | static inline bool IsX86(const std::string& TT) { |
Ted Kremenek | ae36076 | 2007-12-03 22:06:55 +0000 | [diff] [blame] | 1114 | return (TT.size() >= 5 && TT[0] == 'i' && TT[2] == '8' && TT[3] == '6' && |
| 1115 | TT[4] == '-' && TT[1] - '3' < 6); |
| 1116 | } |
| 1117 | |
Chris Lattner | 42e6737 | 2008-03-05 01:18:20 +0000 | [diff] [blame] | 1118 | /// CreateTargetInfo - Return the target info object for the specified target |
| 1119 | /// triple. |
| 1120 | TargetInfo* TargetInfo::CreateTargetInfo(const std::string &T) { |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1121 | // OS detection; this isn't really anywhere near complete. |
| 1122 | // Additions and corrections are welcome. |
| 1123 | bool isDarwin = T.find("-darwin") != std::string::npos; |
Chris Lattner | eac7aee | 2008-08-23 18:23:14 +0000 | [diff] [blame] | 1124 | bool isDragonFly = T.find("-dragonfly") != std::string::npos; |
Chris Lattner | fd0269d | 2008-10-16 17:04:31 +0000 | [diff] [blame] | 1125 | bool isFreeBSD = T.find("-freebsd") != std::string::npos; |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1126 | bool isSolaris = T.find("-solaris") != std::string::npos; |
| 1127 | bool isLinux = T.find("-linux") != std::string::npos; |
| 1128 | bool isWindows = T.find("-windows") != std::string::npos || |
| 1129 | T.find("-win32") != std::string::npos || |
| 1130 | T.find("-mingw") != std::string::npos; |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1131 | |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1132 | if (T.find("ppc-") == 0 || T.find("powerpc-") == 0) { |
| 1133 | if (isDarwin) |
| 1134 | return new DarwinPPCTargetInfo(T); |
| 1135 | return new PPC32TargetInfo(T); |
| 1136 | } |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1137 | |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1138 | if (T.find("ppc64-") == 0 || T.find("powerpc64-") == 0) { |
| 1139 | if (isDarwin) |
| 1140 | return new DarwinPPC64TargetInfo(T); |
| 1141 | return new PPC64TargetInfo(T); |
| 1142 | } |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1143 | |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1144 | if (T.find("armv6-") == 0 || T.find("arm-") == 0) { |
| 1145 | if (isDarwin) |
| 1146 | return new DarwinARMTargetInfo(T); |
Daniel Dunbar | 1e0107a | 2009-03-23 16:09:04 +0000 | [diff] [blame] | 1147 | if (isFreeBSD) |
| 1148 | return new FreeBSDARMTargetInfo(T); |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1149 | return new ARMTargetInfo(T); |
| 1150 | } |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1151 | |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1152 | if (T.find("sparc-") == 0) { |
| 1153 | if (isSolaris) |
| 1154 | return new SolarisSparcV8TargetInfo(T); |
| 1155 | return new SparcV8TargetInfo(T); |
| 1156 | } |
| 1157 | |
Chris Lattner | 54fefbe | 2009-02-20 17:04:14 +0000 | [diff] [blame] | 1158 | if (T.find("x86_64-") == 0 || T.find("amd64-") == 0) { |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1159 | if (isDarwin) |
| 1160 | return new DarwinX86_64TargetInfo(T); |
Daniel Dunbar | b55a42b | 2008-09-23 17:37:57 +0000 | [diff] [blame] | 1161 | if (isLinux) |
| 1162 | return new LinuxX86_64TargetInfo(T); |
Chris Lattner | fd0269d | 2008-10-16 17:04:31 +0000 | [diff] [blame] | 1163 | if (isFreeBSD) |
| 1164 | return new FreeBSDX86_64TargetInfo(T); |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1165 | return new X86_64TargetInfo(T); |
| 1166 | } |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1167 | |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 1168 | if (T.find("pic16-") == 0) |
| 1169 | return new PIC16TargetInfo(T); |
| 1170 | |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1171 | if (IsX86(T)) { |
| 1172 | if (isDarwin) |
| 1173 | return new DarwinI386TargetInfo(T); |
Eli Friedman | 0d4047b | 2008-08-21 00:24:02 +0000 | [diff] [blame] | 1174 | if (isLinux) |
| 1175 | return new LinuxX86_32TargetInfo(T); |
Chris Lattner | eac7aee | 2008-08-23 18:23:14 +0000 | [diff] [blame] | 1176 | if (isDragonFly) |
| 1177 | return new DragonFlyX86_32TargetInfo(T); |
Chris Lattner | fd0269d | 2008-10-16 17:04:31 +0000 | [diff] [blame] | 1178 | if (isFreeBSD) |
| 1179 | return new FreeBSDX86_32TargetInfo(T); |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 1180 | if (isWindows) |
| 1181 | return new WindowsX86_32TargetInfo(T); |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1182 | return new X86_32TargetInfo(T); |
| 1183 | } |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1184 | |
Chris Lattner | 42e6737 | 2008-03-05 01:18:20 +0000 | [diff] [blame] | 1185 | return NULL; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1186 | } |
Ted Kremenek | fb79f7c | 2008-03-04 17:47:18 +0000 | [diff] [blame] | 1187 | |