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" |
Eli Friedman | 2553126 | 2008-05-20 14:27:34 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/APFloat.h" |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/SmallString.h" |
Daniel Dunbar | 7765934 | 2009-08-19 20:04:03 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/StringRef.h" |
Chris Lattner | 4c28b1c | 2009-08-12 06:24:27 +0000 | [diff] [blame] | 22 | #include "llvm/ADT/STLExtras.h" |
| 23 | #include "llvm/ADT/Triple.h" |
Chris Lattner | 797c3c4 | 2009-08-10 19:03:04 +0000 | [diff] [blame] | 24 | #include "llvm/MC/MCSectionMachO.h" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 25 | using namespace clang; |
| 26 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 27 | //===----------------------------------------------------------------------===// |
| 28 | // Common code shared among targets. |
| 29 | //===----------------------------------------------------------------------===// |
| 30 | |
Daniel Dunbar | 7765934 | 2009-08-19 20:04:03 +0000 | [diff] [blame] | 31 | static void Define(std::vector<char> &Buf, const llvm::StringRef &Macro, |
| 32 | const llvm::StringRef &Val = "1") { |
Chris Lattner | d15fa82 | 2007-10-06 06:57:34 +0000 | [diff] [blame] | 33 | const char *Def = "#define "; |
| 34 | Buf.insert(Buf.end(), Def, Def+strlen(Def)); |
Daniel Dunbar | 7765934 | 2009-08-19 20:04:03 +0000 | [diff] [blame] | 35 | Buf.insert(Buf.end(), Macro.begin(), Macro.end()); |
Chris Lattner | d15fa82 | 2007-10-06 06:57:34 +0000 | [diff] [blame] | 36 | Buf.push_back(' '); |
Daniel Dunbar | 7765934 | 2009-08-19 20:04:03 +0000 | [diff] [blame] | 37 | Buf.insert(Buf.end(), Val.begin(), Val.end()); |
Chris Lattner | d15fa82 | 2007-10-06 06:57:34 +0000 | [diff] [blame] | 38 | Buf.push_back('\n'); |
| 39 | } |
| 40 | |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 41 | /// DefineStd - Define a macro name and standard variants. For example if |
| 42 | /// MacroName is "unix", then this will define "__unix", "__unix__", and "unix" |
| 43 | /// when in GNU mode. |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 44 | static void DefineStd(std::vector<char> &Buf, const char *MacroName, |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 45 | const LangOptions &Opts) { |
| 46 | assert(MacroName[0] != '_' && "Identifier should be in the user's namespace"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 47 | |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 48 | // If in GNU mode (e.g. -std=gnu99 but not -std=c99) define the raw identifier |
| 49 | // in the user's namespace. |
| 50 | if (Opts.GNUMode) |
| 51 | Define(Buf, MacroName); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 52 | |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 53 | // Define __unix. |
| 54 | llvm::SmallString<20> TmpStr; |
| 55 | TmpStr = "__"; |
| 56 | TmpStr += MacroName; |
Daniel Dunbar | 7765934 | 2009-08-19 20:04:03 +0000 | [diff] [blame] | 57 | Define(Buf, TmpStr.str()); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 58 | |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 59 | // Define __unix__. |
| 60 | TmpStr += "__"; |
Daniel Dunbar | 7765934 | 2009-08-19 20:04:03 +0000 | [diff] [blame] | 61 | Define(Buf, TmpStr.str()); |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 62 | } |
| 63 | |
Chris Lattner | d29b630 | 2008-10-05 21:50:58 +0000 | [diff] [blame] | 64 | //===----------------------------------------------------------------------===// |
| 65 | // Defines specific to certain operating systems. |
| 66 | //===----------------------------------------------------------------------===// |
Chris Lattner | 797c3c4 | 2009-08-10 19:03:04 +0000 | [diff] [blame] | 67 | |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 68 | namespace { |
Douglas Gregor | a384492 | 2009-07-01 15:12:53 +0000 | [diff] [blame] | 69 | template<typename TgtInfo> |
| 70 | class OSTargetInfo : public TgtInfo { |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 71 | protected: |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 72 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 73 | std::vector<char> &Defines) const=0; |
| 74 | public: |
Douglas Gregor | a384492 | 2009-07-01 15:12:53 +0000 | [diff] [blame] | 75 | OSTargetInfo(const std::string& triple) : TgtInfo(triple) {} |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 76 | virtual void getTargetDefines(const LangOptions &Opts, |
| 77 | std::vector<char> &Defines) const { |
Douglas Gregor | a384492 | 2009-07-01 15:12:53 +0000 | [diff] [blame] | 78 | TgtInfo::getTargetDefines(Opts, Defines); |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 79 | getOSDefines(Opts, TgtInfo::getTriple(), Defines); |
Torok Edwin | b0a5b24 | 2009-06-30 17:00:25 +0000 | [diff] [blame] | 80 | } |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 81 | |
| 82 | }; |
Chris Lattner | 4c28b1c | 2009-08-12 06:24:27 +0000 | [diff] [blame] | 83 | } // end anonymous namespace |
Torok Edwin | b0a5b24 | 2009-06-30 17:00:25 +0000 | [diff] [blame] | 84 | |
Chris Lattner | 797c3c4 | 2009-08-10 19:03:04 +0000 | [diff] [blame] | 85 | |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 86 | static void getDarwinDefines(std::vector<char> &Defs, const LangOptions &Opts) { |
Chris Lattner | 7478bbf | 2009-06-23 00:43:21 +0000 | [diff] [blame] | 87 | Define(Defs, "__APPLE_CC__", "5621"); |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 88 | Define(Defs, "__APPLE__"); |
| 89 | Define(Defs, "__MACH__"); |
Chris Lattner | d427ad4 | 2009-02-05 07:19:24 +0000 | [diff] [blame] | 90 | Define(Defs, "OBJC_NEW_PROPERTIES"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 91 | |
Chris Lattner | 10d2427 | 2009-04-07 16:50:40 +0000 | [diff] [blame] | 92 | // __weak is always defined, for use in blocks and with objc pointers. |
| 93 | Define(Defs, "__weak", "__attribute__((objc_gc(weak)))"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 94 | |
Chris Lattner | 10d2427 | 2009-04-07 16:50:40 +0000 | [diff] [blame] | 95 | // Darwin defines __strong even in C mode (just to nothing). |
| 96 | if (!Opts.ObjC1 || Opts.getGCMode() == LangOptions::NonGC) |
Chris Lattner | 3a5cbd3 | 2009-04-07 04:48:21 +0000 | [diff] [blame] | 97 | Define(Defs, "__strong", ""); |
Chris Lattner | 10d2427 | 2009-04-07 16:50:40 +0000 | [diff] [blame] | 98 | else |
Chris Lattner | 3a5cbd3 | 2009-04-07 04:48:21 +0000 | [diff] [blame] | 99 | Define(Defs, "__strong", "__attribute__((objc_gc(strong)))"); |
Eli Friedman | 2de4fee | 2009-06-04 23:00:29 +0000 | [diff] [blame] | 100 | |
| 101 | if (Opts.Static) |
| 102 | Define(Defs, "__STATIC__"); |
| 103 | else |
| 104 | Define(Defs, "__DYNAMIC__"); |
Daniel Dunbar | 5345c39 | 2009-09-03 04:54:28 +0000 | [diff] [blame] | 105 | |
| 106 | if (Opts.POSIXThreads) |
| 107 | Define(Defs, "_REENTRANT", "1"); |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 108 | } |
| 109 | |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 110 | static void getDarwinOSXDefines(std::vector<char> &Defs, |
| 111 | const llvm::Triple &Triple) { |
| 112 | if (Triple.getOS() != llvm::Triple::Darwin) |
Chris Lattner | 4c28b1c | 2009-08-12 06:24:27 +0000 | [diff] [blame] | 113 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 114 | |
Chris Lattner | 8b30c41 | 2008-09-30 01:00:25 +0000 | [diff] [blame] | 115 | // Figure out which "darwin number" the target triple is. "darwin9" -> 10.5. |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 116 | unsigned Maj, Min, Rev; |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 117 | Triple.getDarwinNumber(Maj, Min, Rev); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 118 | |
Chris Lattner | 4c28b1c | 2009-08-12 06:24:27 +0000 | [diff] [blame] | 119 | char MacOSXStr[] = "1000"; |
| 120 | if (Maj >= 4 && Maj <= 13) { // 10.0-10.9 |
| 121 | // darwin7 -> 1030, darwin8 -> 1040, darwin9 -> 1050, etc. |
| 122 | MacOSXStr[2] = '0' + Maj-4; |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 123 | } |
Chris Lattner | 4c28b1c | 2009-08-12 06:24:27 +0000 | [diff] [blame] | 124 | |
| 125 | // Handle minor version: 10.4.9 -> darwin8.9 -> "1049" |
| 126 | // Cap 10.4.11 -> darwin8.11 -> "1049" |
| 127 | MacOSXStr[3] = std::min(Min, 9U)+'0'; |
| 128 | Define(Defs, "__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__", MacOSXStr); |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 129 | } |
| 130 | |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 131 | static void getDarwinIPhoneOSDefines(std::vector<char> &Defs, |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 132 | const llvm::Triple &Triple) { |
| 133 | if (Triple.getOS() != llvm::Triple::Darwin) |
Chris Lattner | 4c28b1c | 2009-08-12 06:24:27 +0000 | [diff] [blame] | 134 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 135 | |
Daniel Dunbar | 8d33cd7 | 2009-04-10 19:52:24 +0000 | [diff] [blame] | 136 | // Figure out which "darwin number" the target triple is. "darwin9" -> 10.5. |
| 137 | unsigned Maj, Min, Rev; |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 138 | Triple.getDarwinNumber(Maj, Min, Rev); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 139 | |
Chris Lattner | 4c28b1c | 2009-08-12 06:24:27 +0000 | [diff] [blame] | 140 | // When targetting iPhone OS, interpret the minor version and |
| 141 | // revision as the iPhone OS version |
| 142 | char iPhoneOSStr[] = "10000"; |
| 143 | if (Min >= 2 && Min <= 9) { // iPhone OS 2.0-9.0 |
| 144 | // darwin9.2.0 -> 20000, darwin9.3.0 -> 30000, etc. |
| 145 | iPhoneOSStr[0] = '0' + Min; |
Chris Lattner | 8b30c41 | 2008-09-30 01:00:25 +0000 | [diff] [blame] | 146 | } |
Chris Lattner | 4c28b1c | 2009-08-12 06:24:27 +0000 | [diff] [blame] | 147 | |
| 148 | // Handle minor version: 2.2 -> darwin9.2.2 -> 20200 |
| 149 | iPhoneOSStr[2] = std::min(Rev, 9U)+'0'; |
| 150 | Define(Defs, "__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__", |
| 151 | iPhoneOSStr); |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 152 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 153 | |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 154 | /// GetDarwinLanguageOptions - Set the default language options for darwin. |
| 155 | static void GetDarwinLanguageOptions(LangOptions &Opts, |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 156 | const llvm::Triple &Triple) { |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 157 | Opts.NeXTRuntime = true; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 158 | |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 159 | if (Triple.getOS() != llvm::Triple::Darwin) |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 160 | return; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 161 | |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 162 | unsigned MajorVersion = Triple.getDarwinMajorNumber(); |
Chris Lattner | 4c28b1c | 2009-08-12 06:24:27 +0000 | [diff] [blame] | 163 | |
Bill Wendling | 45483f7 | 2009-06-28 07:36:13 +0000 | [diff] [blame] | 164 | // Blocks and stack protectors default to on for 10.6 (darwin10) and beyond. |
Chris Lattner | 4c28b1c | 2009-08-12 06:24:27 +0000 | [diff] [blame] | 165 | if (MajorVersion > 9) { |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 166 | Opts.Blocks = 1; |
Bill Wendling | 4ebe3e4 | 2009-06-28 23:01:01 +0000 | [diff] [blame] | 167 | Opts.setStackProtectorMode(LangOptions::SSPOn); |
Bill Wendling | 45483f7 | 2009-06-28 07:36:13 +0000 | [diff] [blame] | 168 | } |
Fariborz Jahanian | 66a5c2c | 2009-02-24 23:34:44 +0000 | [diff] [blame] | 169 | |
Bill Wendling | 45483f7 | 2009-06-28 07:36:13 +0000 | [diff] [blame] | 170 | // Non-fragile ABI (in 64-bit mode) default to on for 10.5 (darwin9) and |
| 171 | // beyond. |
Chris Lattner | 4c28b1c | 2009-08-12 06:24:27 +0000 | [diff] [blame] | 172 | if (MajorVersion >= 9 && Opts.ObjC1 && |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 173 | Triple.getArch() == llvm::Triple::x86_64) |
Fariborz Jahanian | 84d0133 | 2009-02-24 23:38:42 +0000 | [diff] [blame] | 174 | Opts.ObjCNonFragileABI = 1; |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 175 | } |
| 176 | |
Chris Lattner | 797c3c4 | 2009-08-10 19:03:04 +0000 | [diff] [blame] | 177 | namespace { |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 178 | template<typename Target> |
| 179 | class DarwinTargetInfo : public OSTargetInfo<Target> { |
| 180 | protected: |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 181 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 182 | std::vector<char> &Defines) const { |
| 183 | getDarwinDefines(Defines, Opts); |
| 184 | getDarwinOSXDefines(Defines, Triple); |
| 185 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 186 | |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 187 | /// getDefaultLangOptions - Allow the target to specify default settings for |
| 188 | /// various language options. These may be overridden by command line |
| 189 | /// options. |
| 190 | virtual void getDefaultLangOptions(LangOptions &Opts) { |
| 191 | TargetInfo::getDefaultLangOptions(Opts); |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 192 | GetDarwinLanguageOptions(Opts, TargetInfo::getTriple()); |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 193 | } |
| 194 | public: |
| 195 | DarwinTargetInfo(const std::string& triple) : |
| 196 | OSTargetInfo<Target>(triple) { |
| 197 | this->TLSSupported = false; |
| 198 | } |
| 199 | |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 200 | virtual const char *getUnicodeStringSymbolPrefix() const { |
| 201 | return "__utf16_string_"; |
| 202 | } |
| 203 | |
| 204 | virtual const char *getUnicodeStringSection() const { |
| 205 | return "__TEXT,__ustring"; |
| 206 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 207 | |
Chris Lattner | 797c3c4 | 2009-08-10 19:03:04 +0000 | [diff] [blame] | 208 | virtual std::string isValidSectionSpecifier(const llvm::StringRef &SR) const { |
| 209 | // Let MCSectionMachO validate this. |
| 210 | llvm::StringRef Segment, Section; |
| 211 | unsigned TAA, StubSize; |
| 212 | return llvm::MCSectionMachO::ParseSectionSpecifier(SR, Segment, Section, |
| 213 | TAA, StubSize); |
| 214 | } |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 215 | }; |
| 216 | |
Chris Lattner | 797c3c4 | 2009-08-10 19:03:04 +0000 | [diff] [blame] | 217 | |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 218 | // DragonFlyBSD Target |
| 219 | template<typename Target> |
| 220 | class DragonFlyBSDTargetInfo : public OSTargetInfo<Target> { |
| 221 | protected: |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 222 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 223 | std::vector<char> &Defs) const { |
| 224 | // DragonFly defines; list based off of gcc output |
| 225 | Define(Defs, "__DragonFly__"); |
| 226 | Define(Defs, "__DragonFly_cc_version", "100001"); |
| 227 | Define(Defs, "__ELF__"); |
| 228 | Define(Defs, "__KPRINTF_ATTRIBUTE__"); |
| 229 | Define(Defs, "__tune_i386__"); |
| 230 | DefineStd(Defs, "unix", Opts); |
| 231 | } |
| 232 | public: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 233 | DragonFlyBSDTargetInfo(const std::string &triple) |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 234 | : OSTargetInfo<Target>(triple) {} |
| 235 | }; |
| 236 | |
| 237 | // FreeBSD Target |
| 238 | template<typename Target> |
| 239 | class FreeBSDTargetInfo : public OSTargetInfo<Target> { |
| 240 | protected: |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 241 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 242 | std::vector<char> &Defs) const { |
| 243 | // FreeBSD defines; list based off of gcc output |
| 244 | |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 245 | // FIXME: Move version number handling to llvm::Triple. |
| 246 | const char *FreeBSD = strstr(Triple.getTriple().c_str(), |
| 247 | "-freebsd"); |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 248 | FreeBSD += strlen("-freebsd"); |
| 249 | char release[] = "X"; |
| 250 | release[0] = FreeBSD[0]; |
| 251 | char version[] = "X00001"; |
| 252 | version[0] = FreeBSD[0]; |
| 253 | |
| 254 | Define(Defs, "__FreeBSD__", release); |
| 255 | Define(Defs, "__FreeBSD_cc_version", version); |
| 256 | Define(Defs, "__KPRINTF_ATTRIBUTE__"); |
| 257 | DefineStd(Defs, "unix", Opts); |
| 258 | Define(Defs, "__ELF__", "1"); |
| 259 | } |
| 260 | public: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 261 | FreeBSDTargetInfo(const std::string &triple) |
Duncan Sands | 1e90faf | 2009-07-08 13:55:08 +0000 | [diff] [blame] | 262 | : OSTargetInfo<Target>(triple) { |
| 263 | this->UserLabelPrefix = ""; |
| 264 | } |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 265 | }; |
| 266 | |
| 267 | // Linux target |
| 268 | template<typename Target> |
| 269 | class LinuxTargetInfo : public OSTargetInfo<Target> { |
| 270 | protected: |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 271 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 272 | std::vector<char> &Defs) const { |
| 273 | // Linux defines; list based off of gcc output |
| 274 | DefineStd(Defs, "unix", Opts); |
| 275 | DefineStd(Defs, "linux", Opts); |
| 276 | Define(Defs, "__gnu_linux__"); |
| 277 | Define(Defs, "__ELF__", "1"); |
Daniel Dunbar | 5345c39 | 2009-09-03 04:54:28 +0000 | [diff] [blame] | 278 | if (Opts.POSIXThreads) |
| 279 | Define(Defs, "_REENTRANT", "1"); |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 280 | } |
| 281 | public: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 282 | LinuxTargetInfo(const std::string& triple) |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 283 | : OSTargetInfo<Target>(triple) { |
| 284 | this->UserLabelPrefix = ""; |
| 285 | } |
| 286 | }; |
| 287 | |
Chris Lattner | b62bb28 | 2009-07-13 20:29:08 +0000 | [diff] [blame] | 288 | // NetBSD Target |
| 289 | template<typename Target> |
| 290 | class NetBSDTargetInfo : public OSTargetInfo<Target> { |
| 291 | protected: |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 292 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Chris Lattner | b62bb28 | 2009-07-13 20:29:08 +0000 | [diff] [blame] | 293 | std::vector<char> &Defs) const { |
| 294 | // NetBSD defines; list based off of gcc output |
| 295 | Define(Defs, "__NetBSD__", "1"); |
| 296 | Define(Defs, "__unix__", "1"); |
| 297 | Define(Defs, "__ELF__", "1"); |
Daniel Dunbar | 5345c39 | 2009-09-03 04:54:28 +0000 | [diff] [blame] | 298 | if (Opts.POSIXThreads) |
| 299 | Define(Defs, "_POSIX_THREADS", "1"); |
Chris Lattner | b62bb28 | 2009-07-13 20:29:08 +0000 | [diff] [blame] | 300 | } |
| 301 | public: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 302 | NetBSDTargetInfo(const std::string &triple) |
Chris Lattner | b62bb28 | 2009-07-13 20:29:08 +0000 | [diff] [blame] | 303 | : OSTargetInfo<Target>(triple) { |
| 304 | this->UserLabelPrefix = ""; |
| 305 | } |
| 306 | }; |
| 307 | |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 308 | // OpenBSD Target |
| 309 | template<typename Target> |
| 310 | class OpenBSDTargetInfo : public OSTargetInfo<Target> { |
| 311 | protected: |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 312 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 313 | std::vector<char> &Defs) const { |
| 314 | // OpenBSD defines; list based off of gcc output |
| 315 | |
| 316 | Define(Defs, "__OpenBSD__", "1"); |
| 317 | DefineStd(Defs, "unix", Opts); |
| 318 | Define(Defs, "__ELF__", "1"); |
Daniel Dunbar | 5345c39 | 2009-09-03 04:54:28 +0000 | [diff] [blame] | 319 | if (Opts.POSIXThreads) |
| 320 | Define(Defs, "_POSIX_THREADS", "1"); |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 321 | } |
| 322 | public: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 323 | OpenBSDTargetInfo(const std::string &triple) |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 324 | : OSTargetInfo<Target>(triple) {} |
| 325 | }; |
| 326 | |
| 327 | // Solaris target |
| 328 | template<typename Target> |
| 329 | class SolarisTargetInfo : public OSTargetInfo<Target> { |
| 330 | protected: |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 331 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 332 | std::vector<char> &Defs) const { |
| 333 | DefineStd(Defs, "sun", Opts); |
| 334 | DefineStd(Defs, "unix", Opts); |
| 335 | Define(Defs, "__ELF__"); |
| 336 | Define(Defs, "__svr4__"); |
| 337 | Define(Defs, "__SVR4"); |
| 338 | } |
| 339 | public: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 340 | SolarisTargetInfo(const std::string& triple) |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 341 | : OSTargetInfo<Target>(triple) { |
| 342 | this->UserLabelPrefix = ""; |
| 343 | this->WCharType = this->SignedLong; |
| 344 | // FIXME: WIntType should be SignedLong |
| 345 | } |
| 346 | }; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 347 | } // end anonymous namespace. |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 348 | |
Chris Lattner | d29b630 | 2008-10-05 21:50:58 +0000 | [diff] [blame] | 349 | //===----------------------------------------------------------------------===// |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 350 | // Specific target implementations. |
| 351 | //===----------------------------------------------------------------------===// |
Anders Carlsson | fb5e5ba | 2007-10-13 00:45:48 +0000 | [diff] [blame] | 352 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 353 | namespace { |
| 354 | // PPC abstract base class |
| 355 | class PPCTargetInfo : public TargetInfo { |
| 356 | static const Builtin::Info BuiltinInfo[]; |
| 357 | static const char * const GCCRegNames[]; |
| 358 | static const TargetInfo::GCCRegAlias GCCRegAliases[]; |
| 359 | |
| 360 | public: |
Eli Friedman | 15b9176 | 2009-06-05 07:05:05 +0000 | [diff] [blame] | 361 | PPCTargetInfo(const std::string& triple) : TargetInfo(triple) {} |
| 362 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 363 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 364 | unsigned &NumRecords) const { |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 365 | Records = BuiltinInfo; |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 366 | NumRecords = clang::PPC::LastTSBuiltin-Builtin::FirstTSBuiltin; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 367 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 368 | |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 369 | virtual void getTargetDefines(const LangOptions &Opts, |
| 370 | std::vector<char> &Defines) const; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 371 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 372 | virtual const char *getVAListDeclaration() const { |
Chris Lattner | d599850 | 2008-10-27 01:11:29 +0000 | [diff] [blame] | 373 | return "typedef char* __builtin_va_list;"; |
| 374 | // This is the right definition for ABI/V4: System V.4/eabi. |
| 375 | /*return "typedef struct __va_list_tag {" |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 376 | " unsigned char gpr;" |
| 377 | " unsigned char fpr;" |
| 378 | " unsigned short reserved;" |
| 379 | " void* overflow_arg_area;" |
| 380 | " void* reg_save_area;" |
Chris Lattner | d599850 | 2008-10-27 01:11:29 +0000 | [diff] [blame] | 381 | "} __builtin_va_list[1];";*/ |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 382 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 383 | virtual void getGCCRegNames(const char * const *&Names, |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 384 | unsigned &NumNames) const; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 385 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 386 | unsigned &NumAliases) const; |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 387 | virtual bool validateAsmConstraint(const char *&Name, |
Chris Lattner | 44def07 | 2009-04-26 07:16:29 +0000 | [diff] [blame] | 388 | TargetInfo::ConstraintInfo &Info) const { |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 389 | switch (*Name) { |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 390 | default: return false; |
| 391 | case 'O': // Zero |
| 392 | return true; |
| 393 | case 'b': // Base register |
| 394 | case 'f': // Floating point register |
Chris Lattner | 44def07 | 2009-04-26 07:16:29 +0000 | [diff] [blame] | 395 | Info.setAllowsRegister(); |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 396 | return true; |
| 397 | } |
| 398 | } |
Eli Friedman | 15b9176 | 2009-06-05 07:05:05 +0000 | [diff] [blame] | 399 | virtual void getDefaultLangOptions(LangOptions &Opts) { |
| 400 | TargetInfo::getDefaultLangOptions(Opts); |
| 401 | Opts.CharIsSigned = false; |
| 402 | } |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 403 | virtual const char *getClobbers() const { |
| 404 | return ""; |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 405 | } |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 406 | }; |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 407 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 408 | const Builtin::Info PPCTargetInfo::BuiltinInfo[] = { |
Douglas Gregor | b1152d8 | 2009-02-16 21:58:21 +0000 | [diff] [blame] | 409 | #define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, false }, |
| 410 | #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER, false }, |
Chris Lattner | 6b15cdc | 2009-06-14 01:05:48 +0000 | [diff] [blame] | 411 | #include "clang/Basic/BuiltinsPPC.def" |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 412 | }; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 413 | |
| 414 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 415 | /// PPCTargetInfo::getTargetDefines - Return a set of the PowerPC-specific |
| 416 | /// #defines that are not tied to a specific subtarget. |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 417 | void PPCTargetInfo::getTargetDefines(const LangOptions &Opts, |
| 418 | std::vector<char> &Defs) const { |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 419 | // Target identification. |
| 420 | Define(Defs, "__ppc__"); |
| 421 | Define(Defs, "_ARCH_PPC"); |
| 422 | Define(Defs, "__POWERPC__"); |
| 423 | if (PointerWidth == 64) { |
| 424 | Define(Defs, "_ARCH_PPC64"); |
| 425 | Define(Defs, "_LP64"); |
| 426 | Define(Defs, "__LP64__"); |
| 427 | Define(Defs, "__ppc64__"); |
| 428 | } else { |
| 429 | Define(Defs, "__ppc__"); |
| 430 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 431 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 432 | // Target properties. |
| 433 | Define(Defs, "_BIG_ENDIAN"); |
| 434 | Define(Defs, "__BIG_ENDIAN__"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 435 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 436 | // Subtarget options. |
| 437 | Define(Defs, "__NATURAL_ALIGNMENT__"); |
| 438 | Define(Defs, "__REGISTER_PREFIX__", ""); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 439 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 440 | // FIXME: Should be controlled by command line option. |
| 441 | Define(Defs, "__LONG_DOUBLE_128__"); |
| 442 | } |
| 443 | |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 444 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 445 | const char * const PPCTargetInfo::GCCRegNames[] = { |
Chris Lattner | e94e0d4 | 2009-09-16 05:05:27 +0000 | [diff] [blame] | 446 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
| 447 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", |
| 448 | "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", |
| 449 | "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", |
| 450 | "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", |
| 451 | "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", |
| 452 | "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", |
| 453 | "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 454 | "mq", "lr", "ctr", "ap", |
Chris Lattner | e94e0d4 | 2009-09-16 05:05:27 +0000 | [diff] [blame] | 455 | "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 456 | "xer", |
Chris Lattner | e94e0d4 | 2009-09-16 05:05:27 +0000 | [diff] [blame] | 457 | "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", |
| 458 | "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", |
| 459 | "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", |
| 460 | "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31", |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 461 | "vrsave", "vscr", |
| 462 | "spe_acc", "spefscr", |
| 463 | "sfp" |
| 464 | }; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 465 | |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 466 | void PPCTargetInfo::getGCCRegNames(const char * const *&Names, |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 467 | unsigned &NumNames) const { |
| 468 | Names = GCCRegNames; |
| 469 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 470 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 471 | |
Eli Friedman | e427798 | 2008-08-20 23:11:40 +0000 | [diff] [blame] | 472 | const TargetInfo::GCCRegAlias PPCTargetInfo::GCCRegAliases[] = { |
| 473 | // While some of these aliases do map to different registers |
| 474 | // they still share the same register name. |
Daniel Dunbar | c1f2cdd | 2009-09-17 07:03:19 +0000 | [diff] [blame] | 475 | { { "0" }, "r0" }, |
| 476 | { { "1"}, "r1" }, |
| 477 | { { "2" }, "r2" }, |
| 478 | { { "3" }, "r3" }, |
| 479 | { { "4" }, "r4" }, |
| 480 | { { "5" }, "r5" }, |
| 481 | { { "6" }, "r6" }, |
| 482 | { { "7" }, "r7" }, |
| 483 | { { "8" }, "r8" }, |
| 484 | { { "9" }, "r9" }, |
| 485 | { { "10" }, "r10" }, |
| 486 | { { "11" }, "r11" }, |
| 487 | { { "12" }, "r12" }, |
| 488 | { { "13" }, "r13" }, |
| 489 | { { "14" }, "r14" }, |
| 490 | { { "15" }, "r15" }, |
| 491 | { { "16" }, "r16" }, |
| 492 | { { "17" }, "r17" }, |
| 493 | { { "18" }, "r18" }, |
| 494 | { { "19" }, "r19" }, |
| 495 | { { "20" }, "r20" }, |
| 496 | { { "21" }, "r21" }, |
| 497 | { { "22" }, "r22" }, |
| 498 | { { "23" }, "r23" }, |
| 499 | { { "24" }, "r24" }, |
| 500 | { { "25" }, "r25" }, |
| 501 | { { "26" }, "r26" }, |
| 502 | { { "27" }, "r27" }, |
| 503 | { { "28" }, "r28" }, |
| 504 | { { "29" }, "r29" }, |
| 505 | { { "30" }, "r30" }, |
| 506 | { { "31" }, "r31" }, |
| 507 | { { "fr0" }, "f0" }, |
| 508 | { { "fr1" }, "f1" }, |
| 509 | { { "fr2" }, "f2" }, |
| 510 | { { "fr3" }, "f3" }, |
| 511 | { { "fr4" }, "f4" }, |
| 512 | { { "fr5" }, "f5" }, |
| 513 | { { "fr6" }, "f6" }, |
| 514 | { { "fr7" }, "f7" }, |
| 515 | { { "fr8" }, "f8" }, |
| 516 | { { "fr9" }, "f9" }, |
Mike Stump | 1088039 | 2009-09-17 21:15:00 +0000 | [diff] [blame] | 517 | { { "fr10" }, "f10" }, |
Daniel Dunbar | c1f2cdd | 2009-09-17 07:03:19 +0000 | [diff] [blame] | 518 | { { "fr11" }, "f11" }, |
| 519 | { { "fr12" }, "f12" }, |
| 520 | { { "fr13" }, "f13" }, |
| 521 | { { "fr14" }, "f14" }, |
| 522 | { { "fr15" }, "f15" }, |
| 523 | { { "fr16" }, "f16" }, |
| 524 | { { "fr17" }, "f17" }, |
| 525 | { { "fr18" }, "f18" }, |
| 526 | { { "fr19" }, "f19" }, |
| 527 | { { "fr20" }, "f20" }, |
| 528 | { { "fr21" }, "f21" }, |
| 529 | { { "fr22" }, "f22" }, |
| 530 | { { "fr23" }, "f23" }, |
| 531 | { { "fr24" }, "f24" }, |
| 532 | { { "fr25" }, "f25" }, |
| 533 | { { "fr26" }, "f26" }, |
| 534 | { { "fr27" }, "f27" }, |
| 535 | { { "fr28" }, "f28" }, |
| 536 | { { "fr29" }, "f29" }, |
| 537 | { { "fr30" }, "f30" }, |
| 538 | { { "fr31" }, "f31" }, |
| 539 | { { "cc" }, "cr0" }, |
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 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 618 | virtual void getGCCRegNames(const char * const *&Names, |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 619 | unsigned &NumNames) const { |
| 620 | Names = GCCRegNames; |
| 621 | NumNames = llvm::array_lengthof(GCCRegNames); |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 622 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 623 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 624 | unsigned &NumAliases) const { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 625 | Aliases = GCCRegAliases; |
| 626 | NumAliases = llvm::array_lengthof(GCCRegAliases); |
Anders Carlsson | fb5e5ba | 2007-10-13 00:45:48 +0000 | [diff] [blame] | 627 | } |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 628 | virtual bool validateAsmConstraint(const char *&Name, |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 629 | TargetInfo::ConstraintInfo &info) const; |
| 630 | virtual std::string convertConstraint(const char Constraint) const; |
Anders Carlsson | d04c6e2 | 2007-11-27 04:11:28 +0000 | [diff] [blame] | 631 | virtual const char *getClobbers() const { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 632 | return "~{dirflag},~{fpsr},~{flags}"; |
| 633 | } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 634 | virtual void getTargetDefines(const LangOptions &Opts, |
| 635 | std::vector<char> &Defines) const; |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 636 | virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features, |
| 637 | const std::string &Name, |
| 638 | bool Enabled) const; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 639 | virtual void getDefaultFeatures(const std::string &CPU, |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 640 | llvm::StringMap<bool> &Features) const; |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 641 | virtual void HandleTargetFeatures(const llvm::StringMap<bool> &Features); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 642 | }; |
Chris Lattner | 3daed52 | 2009-03-02 22:20:04 +0000 | [diff] [blame] | 643 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 644 | void X86TargetInfo::getDefaultFeatures(const std::string &CPU, |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 645 | llvm::StringMap<bool> &Features) const { |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 646 | // FIXME: This should not be here. |
| 647 | Features["3dnow"] = false; |
| 648 | Features["3dnowa"] = false; |
| 649 | Features["mmx"] = false; |
| 650 | Features["sse"] = false; |
| 651 | Features["sse2"] = false; |
| 652 | Features["sse3"] = false; |
| 653 | Features["ssse3"] = false; |
| 654 | Features["sse41"] = false; |
| 655 | Features["sse42"] = false; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 656 | |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 657 | // LLVM does not currently recognize this. |
| 658 | // Features["sse4a"] = 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 | // FIXME: This *really* should not be here. |
| 661 | |
| 662 | // X86_64 always has SSE2. |
| 663 | if (PointerWidth == 64) |
| 664 | Features["sse2"] = Features["sse"] = Features["mmx"] = true; |
| 665 | |
Daniel Dunbar | 3ac7904 | 2009-05-06 21:56:32 +0000 | [diff] [blame] | 666 | if (CPU == "generic" || CPU == "i386" || CPU == "i486" || CPU == "i586" || |
| 667 | CPU == "pentium" || CPU == "i686" || CPU == "pentiumpro") |
| 668 | ; |
| 669 | else if (CPU == "pentium-mmx" || CPU == "pentium2") |
| 670 | setFeatureEnabled(Features, "mmx", true); |
| 671 | else if (CPU == "pentium3") |
| 672 | setFeatureEnabled(Features, "sse", true); |
| 673 | else if (CPU == "pentium-m" || CPU == "pentium4" || CPU == "x86-64") |
| 674 | setFeatureEnabled(Features, "sse2", true); |
| 675 | else if (CPU == "yonah" || CPU == "prescott" || CPU == "nocona") |
| 676 | setFeatureEnabled(Features, "sse3", true); |
| 677 | else if (CPU == "core2") |
| 678 | setFeatureEnabled(Features, "ssse3", true); |
| 679 | else if (CPU == "penryn") { |
| 680 | setFeatureEnabled(Features, "sse4", true); |
| 681 | Features["sse42"] = false; |
| 682 | } else if (CPU == "atom") |
| 683 | setFeatureEnabled(Features, "sse3", true); |
| 684 | else if (CPU == "corei7") |
| 685 | setFeatureEnabled(Features, "sse4", true); |
| 686 | else if (CPU == "k6" || CPU == "winchip-c6") |
| 687 | setFeatureEnabled(Features, "mmx", true); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 688 | else if (CPU == "k6-2" || CPU == "k6-3" || CPU == "athlon" || |
Daniel Dunbar | 3ac7904 | 2009-05-06 21:56:32 +0000 | [diff] [blame] | 689 | CPU == "athlon-tbird" || CPU == "winchip2" || CPU == "c3") { |
| 690 | setFeatureEnabled(Features, "mmx", true); |
| 691 | setFeatureEnabled(Features, "3dnow", true); |
| 692 | } else if (CPU == "athlon-4" || CPU == "athlon-xp" || CPU == "athlon-mp") { |
| 693 | setFeatureEnabled(Features, "sse", true); |
| 694 | setFeatureEnabled(Features, "3dnowa", true); |
| 695 | } else if (CPU == "k8" || CPU == "opteron" || CPU == "athlon64" || |
| 696 | CPU == "athlon-fx") { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 697 | setFeatureEnabled(Features, "sse2", true); |
Daniel Dunbar | 3ac7904 | 2009-05-06 21:56:32 +0000 | [diff] [blame] | 698 | setFeatureEnabled(Features, "3dnowa", true); |
| 699 | } else if (CPU == "c3-2") |
| 700 | setFeatureEnabled(Features, "sse", true); |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 701 | } |
| 702 | |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 703 | bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 704 | const std::string &Name, |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 705 | bool Enabled) const { |
| 706 | // FIXME: This *really* should not be here. |
| 707 | if (!Features.count(Name) && Name != "sse4") |
| 708 | return false; |
| 709 | |
| 710 | if (Enabled) { |
| 711 | if (Name == "mmx") |
| 712 | Features["mmx"] = true; |
| 713 | else if (Name == "sse") |
| 714 | Features["mmx"] = Features["sse"] = true; |
| 715 | else if (Name == "sse2") |
| 716 | Features["mmx"] = Features["sse"] = Features["sse2"] = true; |
| 717 | else if (Name == "sse3") |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 718 | Features["mmx"] = Features["sse"] = Features["sse2"] = |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 719 | Features["sse3"] = true; |
| 720 | else if (Name == "ssse3") |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 721 | Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] = |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 722 | Features["ssse3"] = true; |
| 723 | else if (Name == "sse4") |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 724 | Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] = |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 725 | Features["ssse3"] = Features["sse41"] = Features["sse42"] = true; |
| 726 | else if (Name == "3dnow") |
| 727 | Features["3dnowa"] = true; |
| 728 | else if (Name == "3dnowa") |
| 729 | Features["3dnow"] = Features["3dnowa"] = true; |
| 730 | } else { |
| 731 | if (Name == "mmx") |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 732 | Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] = |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 733 | Features["ssse3"] = Features["sse41"] = Features["sse42"] = false; |
| 734 | else if (Name == "sse") |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 735 | Features["sse"] = Features["sse2"] = Features["sse3"] = |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 736 | Features["ssse3"] = Features["sse41"] = Features["sse42"] = false; |
| 737 | else if (Name == "sse2") |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 738 | Features["sse2"] = Features["sse3"] = Features["ssse3"] = |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 739 | Features["sse41"] = Features["sse42"] = false; |
| 740 | else if (Name == "sse3") |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 741 | Features["sse3"] = Features["ssse3"] = Features["sse41"] = |
Daniel Dunbar | 17ca363 | 2009-05-06 21:07:50 +0000 | [diff] [blame] | 742 | Features["sse42"] = false; |
| 743 | else if (Name == "ssse3") |
| 744 | Features["ssse3"] = Features["sse41"] = Features["sse42"] = false; |
| 745 | else if (Name == "sse4") |
| 746 | Features["sse41"] = Features["sse42"] = false; |
| 747 | else if (Name == "3dnow") |
| 748 | Features["3dnow"] = Features["3dnowa"] = false; |
| 749 | else if (Name == "3dnowa") |
| 750 | Features["3dnowa"] = false; |
| 751 | } |
| 752 | |
| 753 | return true; |
| 754 | } |
| 755 | |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 756 | /// HandleTargetOptions - Perform initialization based on the user |
| 757 | /// configured set of features. |
| 758 | void X86TargetInfo::HandleTargetFeatures(const llvm::StringMap<bool>&Features) { |
| 759 | if (Features.lookup("sse42")) |
| 760 | SSELevel = SSE42; |
| 761 | else if (Features.lookup("sse41")) |
| 762 | SSELevel = SSE41; |
| 763 | else if (Features.lookup("ssse3")) |
| 764 | SSELevel = SSSE3; |
| 765 | else if (Features.lookup("sse3")) |
| 766 | SSELevel = SSE3; |
| 767 | else if (Features.lookup("sse2")) |
| 768 | SSELevel = SSE2; |
| 769 | else if (Features.lookup("sse")) |
| 770 | SSELevel = SSE1; |
| 771 | else if (Features.lookup("mmx")) |
| 772 | SSELevel = MMX; |
Chris Lattner | 3daed52 | 2009-03-02 22:20:04 +0000 | [diff] [blame] | 773 | } |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 774 | |
| 775 | /// X86TargetInfo::getTargetDefines - Return a set of the X86-specific #defines |
| 776 | /// that are not tied to a specific subtarget. |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 777 | void X86TargetInfo::getTargetDefines(const LangOptions &Opts, |
| 778 | std::vector<char> &Defs) const { |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 779 | // Target identification. |
| 780 | if (PointerWidth == 64) { |
| 781 | Define(Defs, "_LP64"); |
| 782 | Define(Defs, "__LP64__"); |
| 783 | Define(Defs, "__amd64__"); |
| 784 | Define(Defs, "__amd64"); |
| 785 | Define(Defs, "__x86_64"); |
| 786 | Define(Defs, "__x86_64__"); |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 787 | } else { |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 788 | DefineStd(Defs, "i386", Opts); |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 789 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 790 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 791 | // Target properties. |
| 792 | Define(Defs, "__LITTLE_ENDIAN__"); |
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 | // Subtarget options. |
| 795 | Define(Defs, "__nocona"); |
| 796 | Define(Defs, "__nocona__"); |
| 797 | Define(Defs, "__tune_nocona__"); |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 798 | Define(Defs, "__REGISTER_PREFIX__", ""); |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 799 | |
Chris Lattner | 5417544 | 2009-04-19 17:32:33 +0000 | [diff] [blame] | 800 | // Define __NO_MATH_INLINES on linux/x86 so that we don't get inline |
| 801 | // functions in glibc header files that use FP Stack inline asm which the |
| 802 | // backend can't deal with (PR879). |
| 803 | Define(Defs, "__NO_MATH_INLINES"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 804 | |
Chris Lattner | 84f0ea8 | 2009-03-02 22:40:39 +0000 | [diff] [blame] | 805 | // Each case falls through to the previous one here. |
| 806 | switch (SSELevel) { |
| 807 | case SSE42: |
| 808 | Define(Defs, "__SSE4_2__"); |
| 809 | case SSE41: |
| 810 | Define(Defs, "__SSE4_1__"); |
| 811 | case SSSE3: |
| 812 | Define(Defs, "__SSSE3__"); |
| 813 | case SSE3: |
| 814 | Define(Defs, "__SSE3__"); |
| 815 | case SSE2: |
| 816 | Define(Defs, "__SSE2__"); |
| 817 | Define(Defs, "__SSE2_MATH__"); // -mfp-math=sse always implied. |
| 818 | case SSE1: |
| 819 | Define(Defs, "__SSE__"); |
| 820 | Define(Defs, "__SSE_MATH__"); // -mfp-math=sse always implied. |
| 821 | case MMX: |
| 822 | Define(Defs, "__MMX__"); |
| 823 | case NoMMXSSE: |
| 824 | break; |
| 825 | } |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 826 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 827 | |
| 828 | |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 829 | bool |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 830 | X86TargetInfo::validateAsmConstraint(const char *&Name, |
Chris Lattner | 44def07 | 2009-04-26 07:16:29 +0000 | [diff] [blame] | 831 | TargetInfo::ConstraintInfo &Info) const { |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 832 | switch (*Name) { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 833 | default: return false; |
| 834 | case 'a': // eax. |
| 835 | case 'b': // ebx. |
| 836 | case 'c': // ecx. |
| 837 | case 'd': // edx. |
| 838 | case 'S': // esi. |
| 839 | case 'D': // edi. |
| 840 | case 'A': // edx:eax. |
| 841 | case 't': // top of floating point stack. |
| 842 | case 'u': // second from top of floating point stack. |
| 843 | 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] | 844 | case 'y': // Any MMX register. |
Anders Carlsson | a7406d4 | 2008-10-06 19:17:39 +0000 | [diff] [blame] | 845 | case 'x': // Any SSE register. |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 846 | 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] | 847 | case 'e': // 32-bit signed integer constant for use with zero-extending |
Anders Carlsson | 79bc64c | 2009-01-24 18:03:09 +0000 | [diff] [blame] | 848 | // x86_64 instructions. |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 849 | case 'Z': // 32-bit unsigned integer constant for use with zero-extending |
Anders Carlsson | 79bc64c | 2009-01-24 18:03:09 +0000 | [diff] [blame] | 850 | // x86_64 instructions. |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 851 | case 'N': // unsigned 8-bit integer constant for use with in and out |
| 852 | // instructions. |
Eli Friedman | 12b2da0 | 2009-06-08 20:45:44 +0000 | [diff] [blame] | 853 | case 'R': // "legacy" registers: ax, bx, cx, dx, di, si, sp, bp. |
Chris Lattner | 44def07 | 2009-04-26 07:16:29 +0000 | [diff] [blame] | 854 | Info.setAllowsRegister(); |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 855 | return true; |
| 856 | } |
| 857 | } |
| 858 | |
| 859 | std::string |
| 860 | X86TargetInfo::convertConstraint(const char Constraint) const { |
| 861 | switch (Constraint) { |
| 862 | case 'a': return std::string("{ax}"); |
| 863 | case 'b': return std::string("{bx}"); |
| 864 | case 'c': return std::string("{cx}"); |
| 865 | case 'd': return std::string("{dx}"); |
| 866 | case 'S': return std::string("{si}"); |
| 867 | case 'D': return std::string("{di}"); |
| 868 | case 't': // top of floating point stack. |
| 869 | return std::string("{st}"); |
| 870 | case 'u': // second from top of floating point stack. |
| 871 | return std::string("{st(1)}"); // second from top of floating point stack. |
| 872 | default: |
| 873 | return std::string(1, Constraint); |
| 874 | } |
| 875 | } |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 876 | } // end anonymous namespace |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 877 | |
| 878 | namespace { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 879 | // X86-32 generic target |
| 880 | class X86_32TargetInfo : public X86TargetInfo { |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 881 | public: |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 882 | X86_32TargetInfo(const std::string& triple) : X86TargetInfo(triple) { |
| 883 | DoubleAlign = LongLongAlign = 32; |
| 884 | LongDoubleWidth = 96; |
| 885 | LongDoubleAlign = 32; |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 886 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 887 | "i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-" |
| 888 | "a0:0:64-f80:32:32"; |
Eli Friedman | 1afabd9 | 2009-03-29 20:31:09 +0000 | [diff] [blame] | 889 | SizeType = UnsignedInt; |
| 890 | PtrDiffType = SignedInt; |
| 891 | IntPtrType = SignedInt; |
Anton Korobeynikov | 264a76c | 2009-04-03 23:38:25 +0000 | [diff] [blame] | 892 | RegParmMax = 3; |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 893 | } |
| 894 | virtual const char *getVAListDeclaration() const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 895 | return "typedef char* __builtin_va_list;"; |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 896 | } |
Chris Lattner | 21fb98e | 2009-09-23 06:06:36 +0000 | [diff] [blame] | 897 | |
| 898 | int getEHDataRegisterNumber(unsigned RegNo) const { |
| 899 | if (RegNo == 0) return 0; |
| 900 | if (RegNo == 1) return 2; |
| 901 | return -1; |
| 902 | } |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 903 | }; |
| 904 | } // end anonymous namespace |
| 905 | |
| 906 | namespace { |
Eli Friedman | 624c146 | 2009-07-05 18:47:56 +0000 | [diff] [blame] | 907 | class OpenBSDI386TargetInfo : public OpenBSDTargetInfo<X86_32TargetInfo> { |
| 908 | public: |
| 909 | OpenBSDI386TargetInfo(const std::string& triple) : |
| 910 | OpenBSDTargetInfo<X86_32TargetInfo>(triple) { |
| 911 | SizeType = UnsignedLong; |
| 912 | IntPtrType = SignedLong; |
Eli Friedman | 6036ebe | 2009-07-05 22:31:18 +0000 | [diff] [blame] | 913 | PtrDiffType = SignedLong; |
Eli Friedman | 624c146 | 2009-07-05 18:47:56 +0000 | [diff] [blame] | 914 | } |
| 915 | }; |
| 916 | } // end anonymous namespace |
| 917 | |
| 918 | namespace { |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 919 | class DarwinI386TargetInfo : public DarwinTargetInfo<X86_32TargetInfo> { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 920 | public: |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 921 | DarwinI386TargetInfo(const std::string& triple) : |
| 922 | DarwinTargetInfo<X86_32TargetInfo>(triple) { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 923 | LongDoubleWidth = 128; |
| 924 | LongDoubleAlign = 128; |
Eli Friedman | 1afabd9 | 2009-03-29 20:31:09 +0000 | [diff] [blame] | 925 | SizeType = UnsignedLong; |
| 926 | IntPtrType = SignedLong; |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 927 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 928 | "i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-" |
| 929 | "a0:0:64-f80:128:128"; |
Torok Edwin | b0a5b24 | 2009-06-30 17:00:25 +0000 | [diff] [blame] | 930 | } |
| 931 | |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 932 | }; |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 933 | } // end anonymous namespace |
| 934 | |
| 935 | namespace { |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 936 | // x86-32 Windows target |
| 937 | class WindowsX86_32TargetInfo : public X86_32TargetInfo { |
| 938 | public: |
| 939 | WindowsX86_32TargetInfo(const std::string& triple) |
| 940 | : X86_32TargetInfo(triple) { |
Eli Friedman | b030f02 | 2009-04-19 21:38:35 +0000 | [diff] [blame] | 941 | TLSSupported = false; |
Chris Lattner | 85de9e7 | 2009-06-24 17:12:15 +0000 | [diff] [blame] | 942 | WCharType = UnsignedShort; |
Eli Friedman | abc4e32 | 2009-06-08 06:11:14 +0000 | [diff] [blame] | 943 | WCharWidth = WCharAlign = 16; |
Eli Friedman | 9c2f84e | 2009-06-08 21:16:17 +0000 | [diff] [blame] | 944 | DoubleAlign = LongLongAlign = 64; |
| 945 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 946 | "i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-" |
| 947 | "a0:0:64-f80:32:32"; |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 948 | } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 949 | virtual void getTargetDefines(const LangOptions &Opts, |
| 950 | std::vector<char> &Defines) const { |
| 951 | X86_32TargetInfo::getTargetDefines(Opts, Defines); |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 952 | // 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] | 953 | Define(Defines, "_WIN32"); |
Chris Lattner | ca45cff | 2009-03-20 16:06:38 +0000 | [diff] [blame] | 954 | DefineStd(Defines, "WIN32", Opts); |
| 955 | DefineStd(Defines, "WINNT", Opts); |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 956 | Define(Defines, "_X86_"); |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 957 | } |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 958 | }; |
| 959 | } // end anonymous namespace |
Eli Friedman | abc4e32 | 2009-06-08 06:11:14 +0000 | [diff] [blame] | 960 | |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 961 | namespace { |
| 962 | |
| 963 | /// GetWindowsVisualStudioLanguageOptions - Set the default language options for Windows. |
| 964 | static void GetWindowsVisualStudioLanguageOptions(LangOptions &Opts) { |
| 965 | Opts.Microsoft = true; |
| 966 | } |
| 967 | |
| 968 | // x86-32 Windows Visual Studio target |
| 969 | class VisualStudioWindowsX86_32TargetInfo : public WindowsX86_32TargetInfo { |
| 970 | public: |
| 971 | VisualStudioWindowsX86_32TargetInfo(const std::string& triple) |
| 972 | : WindowsX86_32TargetInfo(triple) { |
| 973 | } |
| 974 | virtual void getTargetDefines(const LangOptions &Opts, |
| 975 | std::vector<char> &Defines) const { |
| 976 | WindowsX86_32TargetInfo::getTargetDefines(Opts, Defines); |
| 977 | // The value of the following reflects processor type. |
| 978 | // 300=386, 400=486, 500=Pentium, 600=Blend (default) |
| 979 | // We lost the original triple, so we use the default. |
| 980 | Define(Defines, "_M_IX86", "600"); |
| 981 | } |
Eli Friedman | abc4e32 | 2009-06-08 06:11:14 +0000 | [diff] [blame] | 982 | virtual void getDefaultLangOptions(LangOptions &Opts) { |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 983 | WindowsX86_32TargetInfo::getDefaultLangOptions(Opts); |
| 984 | GetWindowsVisualStudioLanguageOptions(Opts); |
| 985 | } |
| 986 | }; |
| 987 | } // end anonymous namespace |
| 988 | |
| 989 | namespace { |
| 990 | // x86-32 MinGW target |
| 991 | class MinGWX86_32TargetInfo : public WindowsX86_32TargetInfo { |
| 992 | public: |
| 993 | MinGWX86_32TargetInfo(const std::string& triple) |
| 994 | : WindowsX86_32TargetInfo(triple) { |
| 995 | } |
| 996 | virtual void getTargetDefines(const LangOptions &Opts, |
| 997 | std::vector<char> &Defines) const { |
| 998 | WindowsX86_32TargetInfo::getTargetDefines(Opts, Defines); |
| 999 | Define(Defines, "__MSVCRT__"); |
| 1000 | Define(Defines, "__MINGW32__"); |
Cedric Venet | 9a7b085 | 2009-09-27 10:09:11 +0000 | [diff] [blame^] | 1001 | Define(Defines, "__declspec", "__declspec"); |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 1002 | } |
| 1003 | }; |
| 1004 | } // end anonymous namespace |
| 1005 | |
| 1006 | namespace { |
| 1007 | // x86-32 Cygwin target |
| 1008 | class CygwinX86_32TargetInfo : public X86_32TargetInfo { |
| 1009 | public: |
| 1010 | CygwinX86_32TargetInfo(const std::string& triple) |
| 1011 | : X86_32TargetInfo(triple) { |
| 1012 | TLSSupported = false; |
| 1013 | WCharType = UnsignedShort; |
| 1014 | WCharWidth = WCharAlign = 16; |
| 1015 | DoubleAlign = LongLongAlign = 64; |
| 1016 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 1017 | "i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-" |
| 1018 | "a0:0:64-f80:32:32"; |
| 1019 | } |
| 1020 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1021 | std::vector<char> &Defines) const { |
| 1022 | X86_32TargetInfo::getTargetDefines(Opts, Defines); |
| 1023 | Define(Defines, "__CYGWIN__"); |
| 1024 | Define(Defines, "__CYGWIN32__"); |
| 1025 | DefineStd(Defines, "unix", Opts); |
Eli Friedman | abc4e32 | 2009-06-08 06:11:14 +0000 | [diff] [blame] | 1026 | } |
Eli Friedman | 29a3050 | 2008-08-21 01:40:19 +0000 | [diff] [blame] | 1027 | }; |
| 1028 | } // end anonymous namespace |
| 1029 | |
| 1030 | namespace { |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 1031 | // x86-64 generic target |
| 1032 | class X86_64TargetInfo : public X86TargetInfo { |
| 1033 | public: |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 1034 | X86_64TargetInfo(const std::string &triple) : X86TargetInfo(triple) { |
Chris Lattner | f291b10 | 2008-05-09 06:17:04 +0000 | [diff] [blame] | 1035 | LongWidth = LongAlign = PointerWidth = PointerAlign = 64; |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1036 | LongDoubleWidth = 128; |
| 1037 | LongDoubleAlign = 128; |
Chris Lattner | 06ebe86 | 2009-02-05 07:32:46 +0000 | [diff] [blame] | 1038 | IntMaxType = SignedLong; |
| 1039 | UIntMaxType = UnsignedLong; |
Eli Friedman | 3c7b6e4 | 2009-07-01 03:36:11 +0000 | [diff] [blame] | 1040 | Int64Type = SignedLong; |
Anton Korobeynikov | 264a76c | 2009-04-03 23:38:25 +0000 | [diff] [blame] | 1041 | RegParmMax = 6; |
Chris Lattner | 06ebe86 | 2009-02-05 07:32:46 +0000 | [diff] [blame] | 1042 | |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1043 | DescriptionString = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 1044 | "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] | 1045 | "a0:0:64-s0:64:64-f80:128:128"; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1046 | } |
Anders Carlsson | fb5e5ba | 2007-10-13 00:45:48 +0000 | [diff] [blame] | 1047 | virtual const char *getVAListDeclaration() const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1048 | return "typedef struct __va_list_tag {" |
| 1049 | " unsigned gp_offset;" |
| 1050 | " unsigned fp_offset;" |
| 1051 | " void* overflow_arg_area;" |
| 1052 | " void* reg_save_area;" |
Eli Friedman | dc04316 | 2009-07-03 00:45:06 +0000 | [diff] [blame] | 1053 | "} __va_list_tag;" |
| 1054 | "typedef __va_list_tag __builtin_va_list[1];"; |
Anders Carlsson | 3346ae6 | 2007-11-24 23:38:12 +0000 | [diff] [blame] | 1055 | } |
Chris Lattner | 21fb98e | 2009-09-23 06:06:36 +0000 | [diff] [blame] | 1056 | |
| 1057 | int getEHDataRegisterNumber(unsigned RegNo) const { |
| 1058 | if (RegNo == 0) return 0; |
| 1059 | if (RegNo == 1) return 1; |
| 1060 | return -1; |
| 1061 | } |
Eli Friedman | 618234a | 2008-08-20 02:34:37 +0000 | [diff] [blame] | 1062 | }; |
| 1063 | } // end anonymous namespace |
| 1064 | |
| 1065 | namespace { |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 1066 | // x86-64 Windows target |
| 1067 | class WindowsX86_64TargetInfo : public X86_64TargetInfo { |
| 1068 | public: |
| 1069 | WindowsX86_64TargetInfo(const std::string& triple) |
| 1070 | : X86_64TargetInfo(triple) { |
| 1071 | TLSSupported = false; |
| 1072 | WCharType = UnsignedShort; |
| 1073 | WCharWidth = WCharAlign = 16; |
| 1074 | DoubleAlign = LongLongAlign = 64; |
| 1075 | } |
| 1076 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1077 | std::vector<char> &Defines) const { |
| 1078 | X86_64TargetInfo::getTargetDefines(Opts, Defines); |
| 1079 | Define(Defines, "_WIN64"); |
| 1080 | DefineStd(Defines, "WIN64", Opts); |
| 1081 | } |
| 1082 | }; |
| 1083 | } // end anonymous namespace |
| 1084 | |
| 1085 | namespace { |
| 1086 | // x86-64 Windows Visual Studio target |
| 1087 | class VisualStudioWindowsX86_64TargetInfo : public WindowsX86_64TargetInfo { |
| 1088 | public: |
| 1089 | VisualStudioWindowsX86_64TargetInfo(const std::string& triple) |
| 1090 | : WindowsX86_64TargetInfo(triple) { |
| 1091 | } |
| 1092 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1093 | std::vector<char> &Defines) const { |
| 1094 | WindowsX86_64TargetInfo::getTargetDefines(Opts, Defines); |
| 1095 | Define(Defines, "_M_X64"); |
| 1096 | } |
| 1097 | virtual const char *getVAListDeclaration() const { |
| 1098 | return "typedef char* va_list;"; |
| 1099 | } |
| 1100 | }; |
| 1101 | } // end anonymous namespace |
| 1102 | |
| 1103 | namespace { |
| 1104 | // x86-64 MinGW target |
| 1105 | class MinGWX86_64TargetInfo : public WindowsX86_64TargetInfo { |
| 1106 | public: |
| 1107 | MinGWX86_64TargetInfo(const std::string& triple) |
| 1108 | : WindowsX86_64TargetInfo(triple) { |
| 1109 | } |
| 1110 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1111 | std::vector<char> &Defines) const { |
| 1112 | WindowsX86_64TargetInfo::getTargetDefines(Opts, Defines); |
| 1113 | Define(Defines, "__MSVCRT__"); |
| 1114 | Define(Defines, "__MINGW64__"); |
| 1115 | Define(Defines, "__declspec"); |
| 1116 | } |
| 1117 | }; |
| 1118 | } // end anonymous namespace |
| 1119 | |
| 1120 | namespace { |
Eli Friedman | 3c7b6e4 | 2009-07-01 03:36:11 +0000 | [diff] [blame] | 1121 | class DarwinX86_64TargetInfo : public DarwinTargetInfo<X86_64TargetInfo> { |
| 1122 | public: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1123 | DarwinX86_64TargetInfo(const std::string& triple) |
Eli Friedman | 3c7b6e4 | 2009-07-01 03:36:11 +0000 | [diff] [blame] | 1124 | : DarwinTargetInfo<X86_64TargetInfo>(triple) { |
| 1125 | Int64Type = SignedLongLong; |
| 1126 | } |
| 1127 | }; |
| 1128 | } // end anonymous namespace |
| 1129 | |
| 1130 | namespace { |
Eli Friedman | 6036ebe | 2009-07-05 22:31:18 +0000 | [diff] [blame] | 1131 | class OpenBSDX86_64TargetInfo : public OpenBSDTargetInfo<X86_64TargetInfo> { |
| 1132 | public: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1133 | OpenBSDX86_64TargetInfo(const std::string& triple) |
Eli Friedman | 6036ebe | 2009-07-05 22:31:18 +0000 | [diff] [blame] | 1134 | : OpenBSDTargetInfo<X86_64TargetInfo>(triple) { |
| 1135 | IntMaxType = SignedLongLong; |
| 1136 | UIntMaxType = UnsignedLongLong; |
| 1137 | Int64Type = SignedLongLong; |
| 1138 | } |
| 1139 | }; |
| 1140 | } // end anonymous namespace |
| 1141 | |
| 1142 | namespace { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1143 | class ARMTargetInfo : public TargetInfo { |
Mike Stump | 437bb4b | 2009-04-08 02:07:04 +0000 | [diff] [blame] | 1144 | enum { |
| 1145 | Armv4t, |
| 1146 | Armv5, |
| 1147 | Armv6, |
Mike Stump | 59e6572 | 2009-08-04 19:48:52 +0000 | [diff] [blame] | 1148 | Armv7a, |
Mike Stump | 437bb4b | 2009-04-08 02:07:04 +0000 | [diff] [blame] | 1149 | XScale |
| 1150 | } ArmArch; |
Daniel Dunbar | 018ba5a | 2009-09-14 00:35:03 +0000 | [diff] [blame] | 1151 | |
Daniel Dunbar | c1f2cdd | 2009-09-17 07:03:19 +0000 | [diff] [blame] | 1152 | static const TargetInfo::GCCRegAlias GCCRegAliases[]; |
| 1153 | static const char * const GCCRegNames[]; |
| 1154 | |
Daniel Dunbar | 018ba5a | 2009-09-14 00:35:03 +0000 | [diff] [blame] | 1155 | std::string ABI; |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 1156 | bool IsThumb; |
Daniel Dunbar | 018ba5a | 2009-09-14 00:35:03 +0000 | [diff] [blame] | 1157 | |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1158 | public: |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 1159 | ARMTargetInfo(const std::string &TripleStr) |
| 1160 | : TargetInfo(TripleStr), ABI("aapcs-linux"), IsThumb(false) |
Daniel Dunbar | 018ba5a | 2009-09-14 00:35:03 +0000 | [diff] [blame] | 1161 | { |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 1162 | llvm::Triple Triple(TripleStr); |
| 1163 | |
Daniel Dunbar | a2a4161 | 2009-09-14 00:02:24 +0000 | [diff] [blame] | 1164 | SizeType = UnsignedInt; |
| 1165 | PtrDiffType = SignedInt; |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 1166 | |
| 1167 | // FIXME: This shouldn't be done this way, we should use features to |
| 1168 | // indicate the arch. See lib/Driver/Tools.cpp. |
| 1169 | llvm::StringRef Version(""), Arch = Triple.getArchName(); |
| 1170 | if (Arch.startswith("arm")) |
| 1171 | Version = Arch.substr(3); |
| 1172 | else if (Arch.startswith("thumb")) |
| 1173 | Version = Arch.substr(5); |
| 1174 | if (Version == "v7") |
Mike Stump | 59e6572 | 2009-08-04 19:48:52 +0000 | [diff] [blame] | 1175 | ArmArch = Armv7a; |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 1176 | else if (Version.empty() || Version == "v6" || Version == "v6t2") |
Mike Stump | 437bb4b | 2009-04-08 02:07:04 +0000 | [diff] [blame] | 1177 | ArmArch = Armv6; |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 1178 | else if (Version == "v5") |
Mike Stump | 437bb4b | 2009-04-08 02:07:04 +0000 | [diff] [blame] | 1179 | ArmArch = Armv5; |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 1180 | else if (Version == "v4t") |
Mike Stump | 437bb4b | 2009-04-08 02:07:04 +0000 | [diff] [blame] | 1181 | ArmArch = Armv4t; |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 1182 | else if (Arch == "xscale" || Arch == "thumbv5e") |
Mike Stump | 437bb4b | 2009-04-08 02:07:04 +0000 | [diff] [blame] | 1183 | ArmArch = XScale; |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 1184 | else |
Chris Lattner | 5b37dc0 | 2009-04-23 04:22:04 +0000 | [diff] [blame] | 1185 | ArmArch = Armv6; |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 1186 | |
| 1187 | if (Arch.startswith("thumb")) |
| 1188 | IsThumb = true; |
Daniel Dunbar | dff10dc | 2009-09-22 21:44:58 +0000 | [diff] [blame] | 1189 | |
| 1190 | if (IsThumb) { |
| 1191 | DescriptionString = ("e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-" |
| 1192 | "i64:64:64-f32:32:32-f64:64:64-" |
| 1193 | "v64:64:64-v128:128:128-a0:0:32"); |
| 1194 | } else { |
| 1195 | DescriptionString = ("e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 1196 | "i64:64:64-f32:32:32-f64:64:64-" |
| 1197 | "v64:64:64-v128:128:128-a0:0:64"); |
| 1198 | } |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1199 | } |
Daniel Dunbar | 018ba5a | 2009-09-14 00:35:03 +0000 | [diff] [blame] | 1200 | virtual const char *getABI() const { return ABI.c_str(); } |
Daniel Dunbar | a2a4161 | 2009-09-14 00:02:24 +0000 | [diff] [blame] | 1201 | virtual bool setABI(const std::string &Name) { |
Daniel Dunbar | 018ba5a | 2009-09-14 00:35:03 +0000 | [diff] [blame] | 1202 | ABI = Name; |
| 1203 | |
Daniel Dunbar | a2a4161 | 2009-09-14 00:02:24 +0000 | [diff] [blame] | 1204 | // The defaults (above) are for AAPCS, check if we need to change them. |
| 1205 | // |
| 1206 | // FIXME: We need support for -meabi... we could just mangle it into the |
| 1207 | // name. |
| 1208 | if (Name == "apcs-gnu") { |
| 1209 | DoubleAlign = LongLongAlign = 32; |
| 1210 | SizeType = UnsignedLong; |
| 1211 | |
Daniel Dunbar | dff10dc | 2009-09-22 21:44:58 +0000 | [diff] [blame] | 1212 | if (IsThumb) { |
| 1213 | DescriptionString = ("e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-" |
| 1214 | "i64:32:32-f32:32:32-f64:32:32-" |
| 1215 | "v64:64:64-v128:128:128-a0:0:32"); |
| 1216 | } else { |
| 1217 | DescriptionString = ("e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 1218 | "i64:32:32-f32:32:32-f64:32:32-" |
| 1219 | "v64:64:64-v128:128:128-a0:0:64"); |
| 1220 | } |
| 1221 | |
Daniel Dunbar | a2a4161 | 2009-09-14 00:02:24 +0000 | [diff] [blame] | 1222 | // FIXME: Override "preferred align" for double and long long. |
| 1223 | } else if (Name == "aapcs") { |
| 1224 | // FIXME: Enumerated types are variable width in straight AAPCS. |
| 1225 | } else if (Name == "aapcs-linux") { |
| 1226 | ; |
| 1227 | } else |
| 1228 | return false; |
| 1229 | |
| 1230 | return true; |
| 1231 | } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 1232 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1233 | std::vector<char> &Defs) const { |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 1234 | // Target identification. |
| 1235 | Define(Defs, "__arm"); |
| 1236 | Define(Defs, "__arm__"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1237 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 1238 | // Target properties. |
| 1239 | Define(Defs, "__LITTLE_ENDIAN__"); |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1240 | |
Mike Stump | 437bb4b | 2009-04-08 02:07:04 +0000 | [diff] [blame] | 1241 | // Subtarget options. |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 1242 | // |
| 1243 | // FIXME: Neither THUMB_INTERWORK nor SOFTFP is not being set correctly |
| 1244 | // here. |
Mike Stump | 59e6572 | 2009-08-04 19:48:52 +0000 | [diff] [blame] | 1245 | if (ArmArch == Armv7a) { |
| 1246 | Define(Defs, "__ARM_ARCH_7A__"); |
| 1247 | Define(Defs, "__THUMB_INTERWORK__"); |
| 1248 | } else if (ArmArch == Armv6) { |
Mike Stump | 437bb4b | 2009-04-08 02:07:04 +0000 | [diff] [blame] | 1249 | Define(Defs, "__ARM_ARCH_6K__"); |
| 1250 | Define(Defs, "__THUMB_INTERWORK__"); |
| 1251 | } else if (ArmArch == Armv5) { |
| 1252 | Define(Defs, "__ARM_ARCH_5TEJ__"); |
| 1253 | Define(Defs, "__THUMB_INTERWORK__"); |
| 1254 | Define(Defs, "__SOFTFP__"); |
| 1255 | } else if (ArmArch == Armv4t) { |
| 1256 | Define(Defs, "__ARM_ARCH_4T__"); |
| 1257 | Define(Defs, "__SOFTFP__"); |
| 1258 | } else if (ArmArch == XScale) { |
| 1259 | Define(Defs, "__ARM_ARCH_5TE__"); |
| 1260 | Define(Defs, "__XSCALE__"); |
| 1261 | Define(Defs, "__SOFTFP__"); |
| 1262 | } |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 1263 | |
Chris Lattner | c0f5921 | 2009-03-02 22:27:17 +0000 | [diff] [blame] | 1264 | Define(Defs, "__ARMEL__"); |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 1265 | |
| 1266 | if (IsThumb) { |
| 1267 | Define(Defs, "__THUMBEL__"); |
| 1268 | Define(Defs, "__thumb__"); |
| 1269 | if (ArmArch == Armv7a) |
| 1270 | Define(Defs, "__thumb2__"); |
| 1271 | } |
| 1272 | |
| 1273 | // Note, this is always on in gcc, even though it doesn't make sense. |
Eli Friedman | 1926242 | 2009-05-29 19:00:15 +0000 | [diff] [blame] | 1274 | Define(Defs, "__APCS_32__"); |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 1275 | // FIXME: This should be conditional on VFP instruction support. |
Eli Friedman | 1926242 | 2009-05-29 19:00:15 +0000 | [diff] [blame] | 1276 | Define(Defs, "__VFP_FP__"); |
Daniel Dunbar | e1f63b3 | 2009-09-17 16:21:10 +0000 | [diff] [blame] | 1277 | |
| 1278 | Define(Defs, "__USING_SJLJ_EXCEPTIONS__"); |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1279 | } |
| 1280 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 1281 | unsigned &NumRecords) const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1282 | // FIXME: Implement. |
| 1283 | Records = 0; |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1284 | NumRecords = 0; |
| 1285 | } |
| 1286 | virtual const char *getVAListDeclaration() const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1287 | return "typedef char* __builtin_va_list;"; |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1288 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1289 | virtual void getGCCRegNames(const char * const *&Names, |
Daniel Dunbar | c1f2cdd | 2009-09-17 07:03:19 +0000 | [diff] [blame] | 1290 | unsigned &NumNames) const; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1291 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
Daniel Dunbar | c1f2cdd | 2009-09-17 07:03:19 +0000 | [diff] [blame] | 1292 | unsigned &NumAliases) const; |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 1293 | virtual bool validateAsmConstraint(const char *&Name, |
Chris Lattner | 44def07 | 2009-04-26 07:16:29 +0000 | [diff] [blame] | 1294 | TargetInfo::ConstraintInfo &Info) const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1295 | // FIXME: Check if this is complete |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 1296 | switch (*Name) { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1297 | default: |
Nate Begeman | ad487f4 | 2008-04-22 05:03:19 +0000 | [diff] [blame] | 1298 | case 'l': // r0-r7 |
| 1299 | case 'h': // r8-r15 |
| 1300 | case 'w': // VFP Floating point register single precision |
| 1301 | case 'P': // VFP Floating point register double precision |
Chris Lattner | 44def07 | 2009-04-26 07:16:29 +0000 | [diff] [blame] | 1302 | Info.setAllowsRegister(); |
Nate Begeman | ad487f4 | 2008-04-22 05:03:19 +0000 | [diff] [blame] | 1303 | return true; |
| 1304 | } |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1305 | return false; |
| 1306 | } |
| 1307 | virtual const char *getClobbers() const { |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1308 | // FIXME: Is this really right? |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1309 | return ""; |
| 1310 | } |
| 1311 | }; |
Daniel Dunbar | c1f2cdd | 2009-09-17 07:03:19 +0000 | [diff] [blame] | 1312 | |
| 1313 | const char * const ARMTargetInfo::GCCRegNames[] = { |
| 1314 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
| 1315 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" |
| 1316 | }; |
| 1317 | |
| 1318 | void ARMTargetInfo::getGCCRegNames(const char * const *&Names, |
| 1319 | unsigned &NumNames) const { |
| 1320 | Names = GCCRegNames; |
| 1321 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 1322 | } |
| 1323 | |
| 1324 | const TargetInfo::GCCRegAlias ARMTargetInfo::GCCRegAliases[] = { |
| 1325 | |
| 1326 | { { "a1" }, "r0" }, |
| 1327 | { { "a2" }, "r1" }, |
| 1328 | { { "a3" }, "r2" }, |
| 1329 | { { "a4" }, "r3" }, |
| 1330 | { { "v1" }, "r4" }, |
| 1331 | { { "v2" }, "r5" }, |
| 1332 | { { "v3" }, "r6" }, |
| 1333 | { { "v4" }, "r7" }, |
| 1334 | { { "v5" }, "r8" }, |
| 1335 | { { "v6", "rfp" }, "r9" }, |
| 1336 | { { "sl" }, "r10" }, |
| 1337 | { { "fp" }, "r11" }, |
| 1338 | { { "ip" }, "r12" }, |
| 1339 | { { "sp" }, "r13" }, |
| 1340 | { { "lr" }, "r14" }, |
| 1341 | { { "pc" }, "r15" }, |
| 1342 | }; |
| 1343 | |
| 1344 | void ARMTargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 1345 | unsigned &NumAliases) const { |
| 1346 | Aliases = GCCRegAliases; |
| 1347 | NumAliases = llvm::array_lengthof(GCCRegAliases); |
| 1348 | } |
Chris Lattner | 393ff04 | 2008-04-21 18:56:49 +0000 | [diff] [blame] | 1349 | } // end anonymous namespace. |
| 1350 | |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1351 | |
| 1352 | namespace { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1353 | class DarwinARMTargetInfo : |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1354 | public DarwinTargetInfo<ARMTargetInfo> { |
| 1355 | protected: |
Daniel Dunbar | 1752ee4 | 2009-08-24 09:10:05 +0000 | [diff] [blame] | 1356 | virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1357 | std::vector<char> &Defines) const { |
| 1358 | getDarwinDefines(Defines, Opts); |
| 1359 | getDarwinIPhoneOSDefines(Defines, Triple); |
Eli Friedman | b030f02 | 2009-04-19 21:38:35 +0000 | [diff] [blame] | 1360 | } |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1361 | |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1362 | public: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1363 | DarwinARMTargetInfo(const std::string& triple) |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1364 | : DarwinTargetInfo<ARMTargetInfo>(triple) {} |
Eli Friedman | a9f5496 | 2008-08-20 07:44:10 +0000 | [diff] [blame] | 1365 | }; |
| 1366 | } // end anonymous namespace. |
| 1367 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1368 | namespace { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1369 | class SparcV8TargetInfo : public TargetInfo { |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 1370 | static const TargetInfo::GCCRegAlias GCCRegAliases[]; |
| 1371 | static const char * const GCCRegNames[]; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1372 | public: |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1373 | SparcV8TargetInfo(const std::string& triple) : TargetInfo(triple) { |
| 1374 | // FIXME: Support Sparc quad-precision long double? |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1375 | DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
| 1376 | "i64:64:64-f32:32:32-f64:64:64-v64:64:64"; |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1377 | } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 1378 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1379 | std::vector<char> &Defines) const { |
Eli Friedman | 09c3a6d | 2009-05-22 01:12:57 +0000 | [diff] [blame] | 1380 | DefineStd(Defines, "sparc", Opts); |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1381 | Define(Defines, "__sparcv8"); |
Eli Friedman | 09c3a6d | 2009-05-22 01:12:57 +0000 | [diff] [blame] | 1382 | Define(Defines, "__REGISTER_PREFIX__", ""); |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1383 | } |
| 1384 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 1385 | unsigned &NumRecords) const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1386 | // FIXME: Implement! |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1387 | } |
| 1388 | virtual const char *getVAListDeclaration() const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1389 | return "typedef void* __builtin_va_list;"; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1390 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1391 | virtual void getGCCRegNames(const char * const *&Names, |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 1392 | unsigned &NumNames) const; |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1393 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 1394 | unsigned &NumAliases) const; |
Anders Carlsson | 066d2ea | 2009-02-28 17:11:49 +0000 | [diff] [blame] | 1395 | virtual bool validateAsmConstraint(const char *&Name, |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1396 | TargetInfo::ConstraintInfo &info) const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1397 | // FIXME: Implement! |
| 1398 | return false; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1399 | } |
| 1400 | virtual const char *getClobbers() const { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1401 | // FIXME: Implement! |
| 1402 | return ""; |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1403 | } |
| 1404 | }; |
| 1405 | |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 1406 | const char * const SparcV8TargetInfo::GCCRegNames[] = { |
| 1407 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
| 1408 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", |
| 1409 | "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", |
| 1410 | "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31" |
| 1411 | }; |
| 1412 | |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1413 | void SparcV8TargetInfo::getGCCRegNames(const char * const *&Names, |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 1414 | unsigned &NumNames) const { |
| 1415 | Names = GCCRegNames; |
| 1416 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 1417 | } |
| 1418 | |
| 1419 | const TargetInfo::GCCRegAlias SparcV8TargetInfo::GCCRegAliases[] = { |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1420 | { { "g0" }, "r0" }, |
| 1421 | { { "g1" }, "r1" }, |
| 1422 | { { "g2" }, "r2" }, |
| 1423 | { { "g3" }, "r3" }, |
| 1424 | { { "g4" }, "r4" }, |
| 1425 | { { "g5" }, "r5" }, |
| 1426 | { { "g6" }, "r6" }, |
| 1427 | { { "g7" }, "r7" }, |
| 1428 | { { "o0" }, "r8" }, |
| 1429 | { { "o1" }, "r9" }, |
| 1430 | { { "o2" }, "r10" }, |
| 1431 | { { "o3" }, "r11" }, |
| 1432 | { { "o4" }, "r12" }, |
| 1433 | { { "o5" }, "r13" }, |
| 1434 | { { "o6", "sp" }, "r14" }, |
| 1435 | { { "o7" }, "r15" }, |
| 1436 | { { "l0" }, "r16" }, |
| 1437 | { { "l1" }, "r17" }, |
| 1438 | { { "l2" }, "r18" }, |
| 1439 | { { "l3" }, "r19" }, |
| 1440 | { { "l4" }, "r20" }, |
| 1441 | { { "l5" }, "r21" }, |
| 1442 | { { "l6" }, "r22" }, |
| 1443 | { { "l7" }, "r23" }, |
| 1444 | { { "i0" }, "r24" }, |
| 1445 | { { "i1" }, "r25" }, |
| 1446 | { { "i2" }, "r26" }, |
| 1447 | { { "i3" }, "r27" }, |
| 1448 | { { "i4" }, "r28" }, |
| 1449 | { { "i5" }, "r29" }, |
| 1450 | { { "i6", "fp" }, "r30" }, |
| 1451 | { { "i7" }, "r31" }, |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 1452 | }; |
| 1453 | |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1454 | void SparcV8TargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases, |
Chris Lattner | e957f53 | 2009-01-27 01:58:38 +0000 | [diff] [blame] | 1455 | unsigned &NumAliases) const { |
| 1456 | Aliases = GCCRegAliases; |
| 1457 | NumAliases = llvm::array_lengthof(GCCRegAliases); |
| 1458 | } |
Gabor Greif | 2665867 | 2008-02-21 16:29:08 +0000 | [diff] [blame] | 1459 | } // end anonymous namespace. |
| 1460 | |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1461 | namespace { |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1462 | class SolarisSparcV8TargetInfo : public SolarisTargetInfo<SparcV8TargetInfo> { |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1463 | public: |
| 1464 | SolarisSparcV8TargetInfo(const std::string& triple) : |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1465 | SolarisTargetInfo<SparcV8TargetInfo>(triple) { |
Eli Friedman | f509d73 | 2008-11-02 02:43:55 +0000 | [diff] [blame] | 1466 | SizeType = UnsignedInt; |
| 1467 | PtrDiffType = SignedInt; |
Eli Friedman | 01b8668 | 2008-08-20 07:28:14 +0000 | [diff] [blame] | 1468 | } |
| 1469 | }; |
| 1470 | } // end anonymous namespace. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1471 | |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 1472 | namespace { |
| 1473 | class PIC16TargetInfo : public TargetInfo{ |
| 1474 | public: |
| 1475 | PIC16TargetInfo(const std::string& triple) : TargetInfo(triple) { |
Eli Friedman | b030f02 | 2009-04-19 21:38:35 +0000 | [diff] [blame] | 1476 | TLSSupported = false; |
Sanjiv Gupta | 31fc07d | 2008-10-31 09:52:39 +0000 | [diff] [blame] | 1477 | IntWidth = 16; |
| 1478 | LongWidth = LongLongWidth = 32; |
Eli Friedman | 3f7a531 | 2009-05-16 23:30:57 +0000 | [diff] [blame] | 1479 | IntMaxTWidth = 32; |
Sanjiv Gupta | 31fc07d | 2008-10-31 09:52:39 +0000 | [diff] [blame] | 1480 | PointerWidth = 16; |
| 1481 | IntAlign = 8; |
| 1482 | LongAlign = LongLongAlign = 8; |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1483 | PointerAlign = 8; |
Sanjiv Gupta | 31fc07d | 2008-10-31 09:52:39 +0000 | [diff] [blame] | 1484 | SizeType = UnsignedInt; |
| 1485 | IntMaxType = SignedLong; |
| 1486 | UIntMaxType = UnsignedLong; |
Chris Lattner | 6ad474f | 2009-02-13 22:28:55 +0000 | [diff] [blame] | 1487 | IntPtrType = SignedShort; |
Eli Friedman | f509d73 | 2008-11-02 02:43:55 +0000 | [diff] [blame] | 1488 | PtrDiffType = SignedInt; |
Sanjiv Gupta | 9eb4cef | 2009-06-02 04:43:46 +0000 | [diff] [blame] | 1489 | FloatWidth = 32; |
| 1490 | FloatAlign = 32; |
| 1491 | DoubleWidth = 32; |
| 1492 | DoubleAlign = 32; |
| 1493 | LongDoubleWidth = 32; |
| 1494 | LongDoubleAlign = 32; |
| 1495 | FloatFormat = &llvm::APFloat::IEEEsingle; |
| 1496 | DoubleFormat = &llvm::APFloat::IEEEsingle; |
| 1497 | LongDoubleFormat = &llvm::APFloat::IEEEsingle; |
| 1498 | DescriptionString = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8-f32:32:32"; |
| 1499 | |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 1500 | } |
Chris Lattner | 927686f | 2008-05-09 06:08:39 +0000 | [diff] [blame] | 1501 | virtual uint64_t getPointerWidthV(unsigned AddrSpace) const { return 16; } |
| 1502 | virtual uint64_t getPointerAlignV(unsigned AddrSpace) const { return 8; } |
Chris Lattner | 3332864 | 2009-03-20 15:52:06 +0000 | [diff] [blame] | 1503 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1504 | std::vector<char> &Defines) const { |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 1505 | Define(Defines, "__pic16"); |
Sanjiv Gupta | 7f579b1 | 2009-07-07 04:42:23 +0000 | [diff] [blame] | 1506 | Define(Defines, "rom", "__attribute__((address_space(1)))"); |
| 1507 | Define(Defines, "ram", "__attribute__((address_space(0)))"); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1508 | Define(Defines, "_section(SectName)", |
Sanjiv Gupta | da3e03e | 2009-08-20 17:48:52 +0000 | [diff] [blame] | 1509 | "__attribute__((section(SectName)))"); |
| 1510 | Define(Defines, "_address(Addr)", |
| 1511 | "__attribute__((section(\"Address=\"#Addr)))"); |
Sanjiv Gupta | 7f579b1 | 2009-07-07 04:42:23 +0000 | [diff] [blame] | 1512 | Define(Defines, "_CONFIG(conf)", "asm(\"CONFIG \"#conf)"); |
Sanjiv Gupta | da3e03e | 2009-08-20 17:48:52 +0000 | [diff] [blame] | 1513 | Define(Defines, "_interrupt", |
| 1514 | "__attribute__((section(\"interrupt=0x4\"))) \ |
| 1515 | __attribute__((used))"); |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 1516 | } |
| 1517 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 1518 | unsigned &NumRecords) const {} |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1519 | virtual const char *getVAListDeclaration() const { |
Daniel Dunbar | 55cc2ed | 2009-08-24 09:54:37 +0000 | [diff] [blame] | 1520 | return ""; |
| 1521 | } |
| 1522 | virtual const char *getClobbers() const { |
| 1523 | return ""; |
| 1524 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1525 | virtual void getGCCRegNames(const char * const *&Names, |
| 1526 | unsigned &NumNames) const {} |
| 1527 | virtual bool validateAsmConstraint(const char *&Name, |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 1528 | TargetInfo::ConstraintInfo &info) const { |
| 1529 | return true; |
| 1530 | } |
Anton Korobeynikov | a7c4717 | 2009-05-03 13:42:53 +0000 | [diff] [blame] | 1531 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
Chris Lattner | 2621fd1 | 2008-05-08 05:58:21 +0000 | [diff] [blame] | 1532 | unsigned &NumAliases) const {} |
| 1533 | virtual bool useGlobalsForAutomaticVariables() const {return true;} |
| 1534 | }; |
| 1535 | } |
| 1536 | |
Anton Korobeynikov | 73c64e5 | 2009-05-03 13:43:08 +0000 | [diff] [blame] | 1537 | namespace { |
| 1538 | class MSP430TargetInfo : public TargetInfo { |
| 1539 | static const char * const GCCRegNames[]; |
| 1540 | public: |
| 1541 | MSP430TargetInfo(const std::string& triple) : TargetInfo(triple) { |
| 1542 | TLSSupported = false; |
| 1543 | IntWidth = 16; |
| 1544 | LongWidth = LongLongWidth = 32; |
Eli Friedman | 3f7a531 | 2009-05-16 23:30:57 +0000 | [diff] [blame] | 1545 | IntMaxTWidth = 32; |
Anton Korobeynikov | 73c64e5 | 2009-05-03 13:43:08 +0000 | [diff] [blame] | 1546 | PointerWidth = 16; |
| 1547 | IntAlign = 8; |
| 1548 | LongAlign = LongLongAlign = 8; |
| 1549 | PointerAlign = 8; |
| 1550 | SizeType = UnsignedInt; |
| 1551 | IntMaxType = SignedLong; |
| 1552 | UIntMaxType = UnsignedLong; |
| 1553 | IntPtrType = SignedShort; |
| 1554 | PtrDiffType = SignedInt; |
| 1555 | DescriptionString = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"; |
| 1556 | } |
| 1557 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1558 | std::vector<char> &Defines) const { |
| 1559 | Define(Defines, "MSP430"); |
| 1560 | Define(Defines, "__MSP430__"); |
| 1561 | // FIXME: defines for different 'flavours' of MCU |
| 1562 | } |
| 1563 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 1564 | unsigned &NumRecords) const { |
| 1565 | // FIXME: Implement. |
| 1566 | Records = 0; |
| 1567 | NumRecords = 0; |
| 1568 | } |
Anton Korobeynikov | 73c64e5 | 2009-05-03 13:43:08 +0000 | [diff] [blame] | 1569 | virtual void getGCCRegNames(const char * const *&Names, |
| 1570 | unsigned &NumNames) const; |
| 1571 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 1572 | unsigned &NumAliases) const { |
| 1573 | // No aliases. |
| 1574 | Aliases = 0; |
| 1575 | NumAliases = 0; |
| 1576 | } |
| 1577 | virtual bool validateAsmConstraint(const char *&Name, |
| 1578 | TargetInfo::ConstraintInfo &info) const { |
| 1579 | // FIXME: implement |
| 1580 | return true; |
| 1581 | } |
| 1582 | virtual const char *getClobbers() const { |
| 1583 | // FIXME: Is this really right? |
| 1584 | return ""; |
| 1585 | } |
| 1586 | virtual const char *getVAListDeclaration() const { |
| 1587 | // FIXME: implement |
Anton Korobeynikov | eb71685 | 2009-05-08 18:24:57 +0000 | [diff] [blame] | 1588 | return "typedef char* __builtin_va_list;"; |
Anton Korobeynikov | 73c64e5 | 2009-05-03 13:43:08 +0000 | [diff] [blame] | 1589 | } |
| 1590 | }; |
| 1591 | |
| 1592 | const char * const MSP430TargetInfo::GCCRegNames[] = { |
| 1593 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
| 1594 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" |
| 1595 | }; |
| 1596 | |
| 1597 | void MSP430TargetInfo::getGCCRegNames(const char * const *&Names, |
| 1598 | unsigned &NumNames) const { |
| 1599 | Names = GCCRegNames; |
| 1600 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 1601 | } |
| 1602 | } |
| 1603 | |
| 1604 | |
Anton Korobeynikov | 89e887f | 2009-07-16 20:09:57 +0000 | [diff] [blame] | 1605 | namespace { |
| 1606 | class SystemZTargetInfo : public TargetInfo { |
| 1607 | static const char * const GCCRegNames[]; |
| 1608 | public: |
| 1609 | SystemZTargetInfo(const std::string& triple) : TargetInfo(triple) { |
| 1610 | TLSSupported = false; |
| 1611 | IntWidth = IntAlign = 32; |
| 1612 | LongWidth = LongLongWidth = LongAlign = LongLongAlign = 64; |
| 1613 | PointerWidth = PointerAlign = 64; |
| 1614 | 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"; |
| 1615 | } |
| 1616 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1617 | std::vector<char> &Defines) const { |
| 1618 | Define(Defines, "__s390__"); |
| 1619 | Define(Defines, "__s390x__"); |
| 1620 | } |
| 1621 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 1622 | unsigned &NumRecords) const { |
| 1623 | // FIXME: Implement. |
| 1624 | Records = 0; |
| 1625 | NumRecords = 0; |
| 1626 | } |
Anton Korobeynikov | 89e887f | 2009-07-16 20:09:57 +0000 | [diff] [blame] | 1627 | |
| 1628 | virtual void getDefaultLangOptions(LangOptions &Opts) { |
| 1629 | TargetInfo::getDefaultLangOptions(Opts); |
| 1630 | Opts.CharIsSigned = false; |
| 1631 | } |
| 1632 | |
| 1633 | virtual void getGCCRegNames(const char * const *&Names, |
| 1634 | unsigned &NumNames) const; |
| 1635 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 1636 | unsigned &NumAliases) const { |
| 1637 | // No aliases. |
| 1638 | Aliases = 0; |
| 1639 | NumAliases = 0; |
| 1640 | } |
| 1641 | virtual bool validateAsmConstraint(const char *&Name, |
| 1642 | TargetInfo::ConstraintInfo &info) const { |
| 1643 | // FIXME: implement |
| 1644 | return true; |
| 1645 | } |
| 1646 | virtual const char *getClobbers() const { |
| 1647 | // FIXME: Is this really right? |
| 1648 | return ""; |
| 1649 | } |
| 1650 | virtual const char *getVAListDeclaration() const { |
| 1651 | // FIXME: implement |
| 1652 | return "typedef char* __builtin_va_list;"; |
| 1653 | } |
| 1654 | }; |
| 1655 | |
| 1656 | const char * const SystemZTargetInfo::GCCRegNames[] = { |
| 1657 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
| 1658 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" |
| 1659 | }; |
| 1660 | |
| 1661 | void SystemZTargetInfo::getGCCRegNames(const char * const *&Names, |
| 1662 | unsigned &NumNames) const { |
| 1663 | Names = GCCRegNames; |
| 1664 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 1665 | } |
| 1666 | } |
| 1667 | |
Jakob Stoklund Olesen | 1eb4343 | 2009-08-17 20:08:44 +0000 | [diff] [blame] | 1668 | namespace { |
| 1669 | class BlackfinTargetInfo : public TargetInfo { |
| 1670 | static const char * const GCCRegNames[]; |
| 1671 | public: |
| 1672 | BlackfinTargetInfo(const std::string& triple) : TargetInfo(triple) { |
| 1673 | TLSSupported = false; |
| 1674 | DoubleAlign = 32; |
| 1675 | LongLongAlign = 32; |
| 1676 | LongDoubleAlign = 32; |
| 1677 | DescriptionString = "e-p:32:32-i64:32-f64:32"; |
| 1678 | } |
| 1679 | |
| 1680 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1681 | std::vector<char> &Defines) const { |
| 1682 | DefineStd(Defines, "bfin", Opts); |
| 1683 | DefineStd(Defines, "BFIN", Opts); |
| 1684 | Define(Defines, "__ADSPBLACKFIN__"); |
| 1685 | // FIXME: This one is really dependent on -mcpu |
| 1686 | Define(Defines, "__ADSPLPBLACKFIN__"); |
| 1687 | // FIXME: Add cpu-dependent defines and __SILICON_REVISION__ |
| 1688 | } |
| 1689 | |
| 1690 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 1691 | unsigned &NumRecords) const { |
| 1692 | // FIXME: Implement. |
| 1693 | Records = 0; |
| 1694 | NumRecords = 0; |
| 1695 | } |
| 1696 | |
Jakob Stoklund Olesen | 1eb4343 | 2009-08-17 20:08:44 +0000 | [diff] [blame] | 1697 | virtual void getGCCRegNames(const char * const *&Names, |
| 1698 | unsigned &NumNames) const; |
| 1699 | |
| 1700 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 1701 | unsigned &NumAliases) const { |
| 1702 | // No aliases. |
| 1703 | Aliases = 0; |
| 1704 | NumAliases = 0; |
| 1705 | } |
| 1706 | |
| 1707 | virtual bool validateAsmConstraint(const char *&Name, |
| 1708 | TargetInfo::ConstraintInfo &Info) const { |
| 1709 | if (strchr("adzDWeABbvfcCtukxywZY", Name[0])) { |
| 1710 | Info.setAllowsRegister(); |
| 1711 | return true; |
| 1712 | } |
| 1713 | return false; |
| 1714 | } |
| 1715 | |
| 1716 | virtual const char *getClobbers() const { |
| 1717 | return ""; |
| 1718 | } |
| 1719 | |
| 1720 | virtual const char *getVAListDeclaration() const { |
| 1721 | return "typedef char* __builtin_va_list;"; |
| 1722 | } |
| 1723 | }; |
| 1724 | |
| 1725 | const char * const BlackfinTargetInfo::GCCRegNames[] = { |
| 1726 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
| 1727 | "p0", "p1", "p2", "p3", "p4", "p5", "sp", "fp", |
| 1728 | "i0", "i1", "i2", "i3", "b0", "b1", "b2", "b3", |
| 1729 | "l0", "l1", "l2", "l3", "m0", "m1", "m2", "m3", |
| 1730 | "a0", "a1", "cc", |
| 1731 | "rets", "reti", "retx", "retn", "rete", "astat", "seqstat", "usp", |
| 1732 | "argp", "lt0", "lt1", "lc0", "lc1", "lb0", "lb1" |
| 1733 | }; |
| 1734 | |
| 1735 | void BlackfinTargetInfo::getGCCRegNames(const char * const *&Names, |
| 1736 | unsigned &NumNames) const { |
| 1737 | Names = GCCRegNames; |
| 1738 | NumNames = llvm::array_lengthof(GCCRegNames); |
| 1739 | } |
| 1740 | } |
| 1741 | |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 1742 | namespace { |
| 1743 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1744 | // LLVM and Clang cannot be used directly to output native binaries for |
| 1745 | // target, but is used to compile C code to llvm bitcode with correct |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 1746 | // type and alignment information. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1747 | // |
| 1748 | // TCE uses the llvm bitcode as input and uses it for generating customized |
| 1749 | // target processor and program binary. TCE co-design environment is |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 1750 | // publicly available in http://tce.cs.tut.fi |
| 1751 | |
| 1752 | class TCETargetInfo : public TargetInfo{ |
| 1753 | public: |
| 1754 | TCETargetInfo(const std::string& triple) : TargetInfo(triple) { |
| 1755 | TLSSupported = false; |
| 1756 | IntWidth = 32; |
| 1757 | LongWidth = LongLongWidth = 32; |
| 1758 | IntMaxTWidth = 32; |
| 1759 | PointerWidth = 32; |
| 1760 | IntAlign = 32; |
| 1761 | LongAlign = LongLongAlign = 32; |
| 1762 | PointerAlign = 32; |
| 1763 | SizeType = UnsignedInt; |
| 1764 | IntMaxType = SignedLong; |
| 1765 | UIntMaxType = UnsignedLong; |
| 1766 | IntPtrType = SignedInt; |
| 1767 | PtrDiffType = SignedInt; |
| 1768 | FloatWidth = 32; |
| 1769 | FloatAlign = 32; |
| 1770 | DoubleWidth = 32; |
| 1771 | DoubleAlign = 32; |
| 1772 | LongDoubleWidth = 32; |
| 1773 | LongDoubleAlign = 32; |
| 1774 | FloatFormat = &llvm::APFloat::IEEEsingle; |
| 1775 | DoubleFormat = &llvm::APFloat::IEEEsingle; |
| 1776 | LongDoubleFormat = &llvm::APFloat::IEEEsingle; |
| 1777 | DescriptionString = "E-p:32:32:32-a0:32:32" |
| 1778 | "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64" |
| 1779 | "-f32:32:32-f64:32:64"; |
| 1780 | } |
| 1781 | |
| 1782 | virtual void getTargetDefines(const LangOptions &Opts, |
| 1783 | std::vector<char> &Defines) const { |
| 1784 | DefineStd(Defines, "tce", Opts); |
| 1785 | Define(Defines, "__TCE__"); |
| 1786 | Define(Defines, "__TCE_V1__"); |
| 1787 | } |
| 1788 | virtual void getTargetBuiltins(const Builtin::Info *&Records, |
| 1789 | unsigned &NumRecords) const {} |
Daniel Dunbar | 55cc2ed | 2009-08-24 09:54:37 +0000 | [diff] [blame] | 1790 | virtual const char *getClobbers() const { |
| 1791 | return ""; |
| 1792 | } |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 1793 | virtual const char *getVAListDeclaration() const { |
| 1794 | return "typedef void* __builtin_va_list;"; |
| 1795 | } |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 1796 | virtual void getGCCRegNames(const char * const *&Names, |
| 1797 | unsigned &NumNames) const {} |
| 1798 | virtual bool validateAsmConstraint(const char *&Name, |
| 1799 | TargetInfo::ConstraintInfo &info) const { |
| 1800 | return true; |
| 1801 | } |
| 1802 | virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, |
| 1803 | unsigned &NumAliases) const {} |
| 1804 | }; |
| 1805 | } |
| 1806 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1807 | //===----------------------------------------------------------------------===// |
| 1808 | // Driver code |
| 1809 | //===----------------------------------------------------------------------===// |
| 1810 | |
Chris Lattner | 42e6737 | 2008-03-05 01:18:20 +0000 | [diff] [blame] | 1811 | /// CreateTargetInfo - Return the target info object for the specified target |
| 1812 | /// triple. |
| 1813 | TargetInfo* TargetInfo::CreateTargetInfo(const std::string &T) { |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 1814 | llvm::Triple Triple(T); |
| 1815 | llvm::Triple::OSType os = Triple.getOS(); |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1816 | |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 1817 | switch (Triple.getArch()) { |
| 1818 | default: |
| 1819 | return NULL; |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1820 | |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 1821 | case llvm::Triple::arm: |
Daniel Dunbar | f4aa4f61 | 2009-09-11 01:14:50 +0000 | [diff] [blame] | 1822 | case llvm::Triple::thumb: |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 1823 | switch (os) { |
| 1824 | case llvm::Triple::Darwin: |
Eli Friedman | ed855cb | 2008-08-21 00:13:15 +0000 | [diff] [blame] | 1825 | return new DarwinARMTargetInfo(T); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 1826 | case llvm::Triple::FreeBSD: |
Torok Edwin | 5f6c194 | 2009-06-30 17:10:35 +0000 | [diff] [blame] | 1827 | return new FreeBSDTargetInfo<ARMTargetInfo>(T); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 1828 | default: |
| 1829 | return new ARMTargetInfo(T); |
| 1830 | } |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1831 | |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 1832 | case llvm::Triple::bfin: |
Jakob Stoklund Olesen | 1eb4343 | 2009-08-17 20:08:44 +0000 | [diff] [blame] | 1833 | return new BlackfinTargetInfo(T); |
| 1834 | |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 1835 | case llvm::Triple::msp430: |
| 1836 | return new MSP430TargetInfo(T); |
Eli Friedman | 61538a7 | 2008-05-20 14:21:01 +0000 | [diff] [blame] | 1837 | |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 1838 | case llvm::Triple::pic16: |
| 1839 | return new PIC16TargetInfo(T); |
| 1840 | |
| 1841 | case llvm::Triple::ppc: |
| 1842 | if (os == llvm::Triple::Darwin) |
| 1843 | return new DarwinTargetInfo<PPCTargetInfo>(T); |
| 1844 | return new PPC32TargetInfo(T); |
| 1845 | |
| 1846 | case llvm::Triple::ppc64: |
| 1847 | if (os == llvm::Triple::Darwin) |
| 1848 | return new DarwinTargetInfo<PPC64TargetInfo>(T); |
| 1849 | return new PPC64TargetInfo(T); |
| 1850 | |
| 1851 | case llvm::Triple::sparc: |
| 1852 | if (os == llvm::Triple::Solaris) |
| 1853 | return new SolarisSparcV8TargetInfo(T); |
| 1854 | return new SparcV8TargetInfo(T); |
| 1855 | |
| 1856 | case llvm::Triple::systemz: |
| 1857 | return new SystemZTargetInfo(T); |
| 1858 | |
Eli Friedman | b63decf | 2009-08-19 20:47:07 +0000 | [diff] [blame] | 1859 | case llvm::Triple::tce: |
| 1860 | return new TCETargetInfo(T); |
| 1861 | |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 1862 | case llvm::Triple::x86: |
| 1863 | switch (os) { |
| 1864 | case llvm::Triple::Darwin: |
| 1865 | return new DarwinI386TargetInfo(T); |
| 1866 | case llvm::Triple::Linux: |
| 1867 | return new LinuxTargetInfo<X86_32TargetInfo>(T); |
| 1868 | case llvm::Triple::DragonFly: |
| 1869 | return new DragonFlyBSDTargetInfo<X86_32TargetInfo>(T); |
| 1870 | case llvm::Triple::NetBSD: |
| 1871 | return new NetBSDTargetInfo<X86_32TargetInfo>(T); |
| 1872 | case llvm::Triple::OpenBSD: |
| 1873 | return new OpenBSDI386TargetInfo(T); |
| 1874 | case llvm::Triple::FreeBSD: |
| 1875 | return new FreeBSDTargetInfo<X86_32TargetInfo>(T); |
| 1876 | case llvm::Triple::Solaris: |
| 1877 | return new SolarisTargetInfo<X86_32TargetInfo>(T); |
| 1878 | case llvm::Triple::Cygwin: |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 1879 | return new CygwinX86_32TargetInfo(T); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 1880 | case llvm::Triple::MinGW32: |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 1881 | return new MinGWX86_32TargetInfo(T); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 1882 | case llvm::Triple::Win32: |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 1883 | return new VisualStudioWindowsX86_32TargetInfo(T); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 1884 | default: |
| 1885 | return new X86_32TargetInfo(T); |
| 1886 | } |
| 1887 | |
| 1888 | case llvm::Triple::x86_64: |
| 1889 | switch (os) { |
| 1890 | case llvm::Triple::Darwin: |
| 1891 | return new DarwinX86_64TargetInfo(T); |
| 1892 | case llvm::Triple::Linux: |
| 1893 | return new LinuxTargetInfo<X86_64TargetInfo>(T); |
| 1894 | case llvm::Triple::NetBSD: |
| 1895 | return new NetBSDTargetInfo<X86_64TargetInfo>(T); |
| 1896 | case llvm::Triple::OpenBSD: |
| 1897 | return new OpenBSDX86_64TargetInfo(T); |
| 1898 | case llvm::Triple::FreeBSD: |
| 1899 | return new FreeBSDTargetInfo<X86_64TargetInfo>(T); |
| 1900 | case llvm::Triple::Solaris: |
| 1901 | return new SolarisTargetInfo<X86_64TargetInfo>(T); |
Daniel Dunbar | 9fe4a5d | 2009-09-23 07:31:35 +0000 | [diff] [blame] | 1902 | case llvm::Triple::MinGW64: |
| 1903 | return new MinGWX86_64TargetInfo(T); |
| 1904 | case llvm::Triple::Win32: // This is what Triple.h supports now. |
| 1905 | return new VisualStudioWindowsX86_64TargetInfo(T); |
Daniel Dunbar | 9d6fa61 | 2009-08-18 05:47:58 +0000 | [diff] [blame] | 1906 | default: |
| 1907 | return new X86_64TargetInfo(T); |
| 1908 | } |
| 1909 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1910 | } |