Jia Liu | 44de83a | 2012-02-19 02:03:36 +0000 | [diff] [blame] | 1 | //===-- X86Subtarget.h - Define Subtarget for the X86 ----------*- C++ -*--===// |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Evan Cheng | 5b1b4489 | 2011-07-01 21:01:15 +0000 | [diff] [blame] | 10 | // This file declares the X86 specific subclass of TargetSubtargetInfo. |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef X86SUBTARGET_H |
| 15 | #define X86SUBTARGET_H |
| 16 | |
Craig Topper | 79aa341 | 2012-03-17 18:46:09 +0000 | [diff] [blame] | 17 | #include "llvm/CallingConv.h" |
Eric Christopher | 62f35a2 | 2010-07-05 19:26:33 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/Triple.h" |
Evan Cheng | 5b1b4489 | 2011-07-01 21:01:15 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetSubtargetInfo.h" |
Jim Laskey | b1e1180 | 2005-09-01 21:38:21 +0000 | [diff] [blame] | 20 | #include <string> |
| 21 | |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 22 | #define GET_SUBTARGETINFO_HEADER |
Evan Cheng | 385e930 | 2011-07-01 22:36:09 +0000 | [diff] [blame] | 23 | #include "X86GenSubtargetInfo.inc" |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 24 | |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 25 | namespace llvm { |
Anton Korobeynikov | 7784ebc | 2006-11-30 22:42:55 +0000 | [diff] [blame] | 26 | class GlobalValue; |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 27 | class StringRef; |
Anton Korobeynikov | 2b2bc68 | 2006-12-22 22:29:05 +0000 | [diff] [blame] | 28 | class TargetMachine; |
Mikhail Glushenkov | 5d96eb8 | 2010-02-28 22:54:30 +0000 | [diff] [blame] | 29 | |
Chris Lattner | e4df756 | 2009-07-09 03:15:51 +0000 | [diff] [blame] | 30 | /// PICStyles - The X86 backend supports a number of different styles of PIC. |
Mikhail Glushenkov | 5d96eb8 | 2010-02-28 22:54:30 +0000 | [diff] [blame] | 31 | /// |
Duncan Sands | f9a67a8 | 2008-11-28 09:29:37 +0000 | [diff] [blame] | 32 | namespace PICStyles { |
Anton Korobeynikov | 7f70559 | 2007-01-12 19:20:47 +0000 | [diff] [blame] | 33 | enum Style { |
Chris Lattner | 8097b65 | 2009-07-10 20:58:47 +0000 | [diff] [blame] | 34 | StubPIC, // Used on i386-darwin in -fPIC mode. |
| 35 | StubDynamicNoPIC, // Used on i386-darwin in -mdynamic-no-pic mode. |
| 36 | GOT, // Used on many 32-bit unices in -fPIC mode. |
| 37 | RIPRel, // Used on X86-64 when not in -static mode. |
| 38 | None // Set when in -static mode (not PIC or DynamicNoPIC mode). |
Anton Korobeynikov | 7f70559 | 2007-01-12 19:20:47 +0000 | [diff] [blame] | 39 | }; |
| 40 | } |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 41 | |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 42 | class X86Subtarget : public X86GenSubtargetInfo { |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 43 | protected: |
Evan Cheng | 559806f | 2006-01-27 08:10:46 +0000 | [diff] [blame] | 44 | enum X86SSEEnum { |
Craig Topper | 16de463 | 2012-01-09 09:02:13 +0000 | [diff] [blame] | 45 | NoMMXSSE, MMX, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42, AVX, AVX2 |
Evan Cheng | 559806f | 2006-01-27 08:10:46 +0000 | [diff] [blame] | 46 | }; |
| 47 | |
Evan Cheng | a26eb5e | 2006-10-06 09:17:41 +0000 | [diff] [blame] | 48 | enum X863DNowEnum { |
| 49 | NoThreeDNow, ThreeDNow, ThreeDNowA |
| 50 | }; |
| 51 | |
Andrew Trick | 922d314 | 2012-02-01 23:20:51 +0000 | [diff] [blame] | 52 | enum X86ProcFamilyEnum { |
| 53 | Others, IntelAtom |
| 54 | }; |
| 55 | |
| 56 | /// X86ProcFamily - X86 processor family: Intel Atom, and others |
| 57 | X86ProcFamilyEnum X86ProcFamily; |
| 58 | |
Anton Korobeynikov | 7f70559 | 2007-01-12 19:20:47 +0000 | [diff] [blame] | 59 | /// PICStyle - Which PIC style to use |
Evan Cheng | f6844ca | 2007-08-01 23:45:51 +0000 | [diff] [blame] | 60 | /// |
Duncan Sands | f9a67a8 | 2008-11-28 09:29:37 +0000 | [diff] [blame] | 61 | PICStyles::Style PICStyle; |
Mikhail Glushenkov | 5d96eb8 | 2010-02-28 22:54:30 +0000 | [diff] [blame] | 62 | |
Evan Cheng | add2517 | 2008-02-12 07:59:55 +0000 | [diff] [blame] | 63 | /// X86SSELevel - MMX, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42, or |
| 64 | /// none supported. |
Evan Cheng | 559806f | 2006-01-27 08:10:46 +0000 | [diff] [blame] | 65 | X86SSEEnum X86SSELevel; |
| 66 | |
Evan Cheng | a26eb5e | 2006-10-06 09:17:41 +0000 | [diff] [blame] | 67 | /// X863DNowLevel - 3DNow or 3DNow Athlon, or none supported. |
Evan Cheng | f6844ca | 2007-08-01 23:45:51 +0000 | [diff] [blame] | 68 | /// |
Evan Cheng | a26eb5e | 2006-10-06 09:17:41 +0000 | [diff] [blame] | 69 | X863DNowEnum X863DNowLevel; |
| 70 | |
Chris Lattner | 7008416 | 2009-09-02 05:53:04 +0000 | [diff] [blame] | 71 | /// HasCMov - True if this processor has conditional move instructions |
| 72 | /// (generally pentium pro+). |
| 73 | bool HasCMov; |
Mikhail Glushenkov | 5d96eb8 | 2010-02-28 22:54:30 +0000 | [diff] [blame] | 74 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 75 | /// HasX86_64 - True if the processor supports X86-64 instructions. |
Evan Cheng | f6844ca | 2007-08-01 23:45:51 +0000 | [diff] [blame] | 76 | /// |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 77 | bool HasX86_64; |
Evan Cheng | ccb6976 | 2009-01-02 05:35:45 +0000 | [diff] [blame] | 78 | |
Benjamin Kramer | 1292c22 | 2010-12-04 20:32:23 +0000 | [diff] [blame] | 79 | /// HasPOPCNT - True if the processor supports POPCNT. |
| 80 | bool HasPOPCNT; |
| 81 | |
Stefanus Du Toit | 8cf5ab1 | 2009-05-26 21:04:35 +0000 | [diff] [blame] | 82 | /// HasSSE4A - True if the processor supports SSE4A instructions. |
| 83 | bool HasSSE4A; |
| 84 | |
Eric Christopher | 6d1cd1c | 2010-04-02 21:54:27 +0000 | [diff] [blame] | 85 | /// HasAES - Target has AES instructions |
| 86 | bool HasAES; |
| 87 | |
Benjamin Kramer | c8e340d | 2012-05-31 14:34:17 +0000 | [diff] [blame] | 88 | /// HasPCLMUL - Target has carry-less multiplication |
| 89 | bool HasPCLMUL; |
Bruno Cardoso Lopes | cdae7e8 | 2010-07-23 01:17:51 +0000 | [diff] [blame] | 90 | |
Craig Topper | a15f9d5 | 2012-06-03 18:58:46 +0000 | [diff] [blame] | 91 | /// HasFMA - Target has 3-operand fused multiply-add |
| 92 | bool HasFMA; |
David Greene | 343dadb | 2009-06-26 22:46:54 +0000 | [diff] [blame] | 93 | |
| 94 | /// HasFMA4 - Target has 4-operand fused multiply-add |
| 95 | bool HasFMA4; |
| 96 | |
Jan Sjödin | ce25d26 | 2011-12-02 15:14:37 +0000 | [diff] [blame] | 97 | /// HasXOP - Target has XOP instructions |
| 98 | bool HasXOP; |
| 99 | |
Craig Topper | da39404 | 2011-10-09 07:31:39 +0000 | [diff] [blame] | 100 | /// HasMOVBE - True if the processor has the MOVBE instruction. |
Craig Topper | 581fe82 | 2011-10-03 17:28:23 +0000 | [diff] [blame] | 101 | bool HasMOVBE; |
| 102 | |
Craig Topper | da39404 | 2011-10-09 07:31:39 +0000 | [diff] [blame] | 103 | /// HasRDRAND - True if the processor has the RDRAND instruction. |
Craig Topper | 581fe82 | 2011-10-03 17:28:23 +0000 | [diff] [blame] | 104 | bool HasRDRAND; |
| 105 | |
Craig Topper | da39404 | 2011-10-09 07:31:39 +0000 | [diff] [blame] | 106 | /// HasF16C - Processor has 16-bit floating point conversion instructions. |
| 107 | bool HasF16C; |
| 108 | |
Craig Topper | e7b0550 | 2011-10-30 19:57:21 +0000 | [diff] [blame] | 109 | /// HasFSGSBase - Processor has FS/GS base insturctions. |
| 110 | bool HasFSGSBase; |
| 111 | |
Craig Topper | 37f2167 | 2011-10-11 06:44:02 +0000 | [diff] [blame] | 112 | /// HasLZCNT - Processor has LZCNT instruction. |
| 113 | bool HasLZCNT; |
| 114 | |
Craig Topper | 909652f | 2011-10-14 03:21:46 +0000 | [diff] [blame] | 115 | /// HasBMI - Processor has BMI1 instructions. |
| 116 | bool HasBMI; |
| 117 | |
Craig Topper | b53fa8b | 2011-10-16 07:55:05 +0000 | [diff] [blame] | 118 | /// HasBMI2 - Processor has BMI2 instructions. |
| 119 | bool HasBMI2; |
| 120 | |
David Greene | 343dadb | 2009-06-26 22:46:54 +0000 | [diff] [blame] | 121 | /// IsBTMemSlow - True if BT (bit test) of memory instructions are slow. |
| 122 | bool IsBTMemSlow; |
Evan Cheng | 400073d | 2009-12-18 07:40:29 +0000 | [diff] [blame] | 123 | |
Evan Cheng | 48c58bb | 2010-04-01 05:58:17 +0000 | [diff] [blame] | 124 | /// IsUAMemFast - True if unaligned memory access is fast. |
| 125 | bool IsUAMemFast; |
| 126 | |
Mikhail Glushenkov | 5d96eb8 | 2010-02-28 22:54:30 +0000 | [diff] [blame] | 127 | /// HasVectorUAMem - True if SIMD operations can have unaligned memory |
Evan Cheng | 5528e7b | 2010-04-21 01:47:12 +0000 | [diff] [blame] | 128 | /// operands. This may require setting a feature bit in the processor. |
David Greene | 95eb2ee | 2010-01-11 16:29:42 +0000 | [diff] [blame] | 129 | bool HasVectorUAMem; |
| 130 | |
Eli Friedman | 43f51ae | 2011-08-26 21:21:21 +0000 | [diff] [blame] | 131 | /// HasCmpxchg16b - True if this processor has the CMPXCHG16B instruction; |
| 132 | /// this is true for most x86-64 chips, but not the first AMD chips. |
| 133 | bool HasCmpxchg16b; |
| 134 | |
Evan Cheng | de1df10 | 2012-02-07 22:50:41 +0000 | [diff] [blame] | 135 | /// UseLeaForSP - True if the LEA instruction should be used for adjusting |
| 136 | /// the stack pointer. This is an optimization for Intel Atom processors. |
| 137 | bool UseLeaForSP; |
| 138 | |
Andrew Trick | 922d314 | 2012-02-01 23:20:51 +0000 | [diff] [blame] | 139 | /// PostRAScheduler - True if using post-register-allocation scheduler. |
| 140 | bool PostRAScheduler; |
| 141 | |
Chris Lattner | b151aca | 2005-07-12 02:36:10 +0000 | [diff] [blame] | 142 | /// stackAlignment - The minimum alignment known to hold of the stack frame on |
| 143 | /// entry to the function and which must be maintained by every function. |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 144 | unsigned stackAlignment; |
Jeff Cohen | 9eb59ec | 2005-07-27 05:53:44 +0000 | [diff] [blame] | 145 | |
Rafael Espindola | fc05f40 | 2007-10-31 11:52:06 +0000 | [diff] [blame] | 146 | /// Max. memset / memcpy size that is turned into rep/movs, rep/stos ops. |
Evan Cheng | f6844ca | 2007-08-01 23:45:51 +0000 | [diff] [blame] | 147 | /// |
Rafael Espindola | fc05f40 | 2007-10-31 11:52:06 +0000 | [diff] [blame] | 148 | unsigned MaxInlineSizeThreshold; |
NAKAMURA Takumi | e310b3a | 2011-02-17 12:23:50 +0000 | [diff] [blame] | 149 | |
Eric Christopher | 62f35a2 | 2010-07-05 19:26:33 +0000 | [diff] [blame] | 150 | /// TargetTriple - What processor and OS we're targeting. |
| 151 | Triple TargetTriple; |
Andrew Trick | 922d314 | 2012-02-01 23:20:51 +0000 | [diff] [blame] | 152 | |
| 153 | /// Instruction itineraries for scheduling |
| 154 | InstrItineraryData InstrItins; |
Evan Cheng | 18a8452 | 2006-02-16 00:21:07 +0000 | [diff] [blame] | 155 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 156 | private: |
Evan Cheng | 18fb1d3 | 2011-07-07 21:06:52 +0000 | [diff] [blame] | 157 | /// In64BitMode - True if compiling for 64-bit, false for 32-bit. |
| 158 | bool In64BitMode; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 159 | |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 160 | public: |
Anton Korobeynikov | 12c49af | 2006-11-21 00:01:06 +0000 | [diff] [blame] | 161 | |
Jeff Cohen | 9eb59ec | 2005-07-27 05:53:44 +0000 | [diff] [blame] | 162 | /// This constructor initializes the data members to match that |
Daniel Dunbar | 3be0340 | 2009-08-02 22:11:08 +0000 | [diff] [blame] | 163 | /// of the specified triple. |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 164 | /// |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 165 | X86Subtarget(const std::string &TT, const std::string &CPU, |
Evan Cheng | 18fb1d3 | 2011-07-07 21:06:52 +0000 | [diff] [blame] | 166 | const std::string &FS, |
Evan Cheng | 4d1a8dd | 2011-07-08 22:30:25 +0000 | [diff] [blame] | 167 | unsigned StackAlignOverride, bool is64Bit); |
Chris Lattner | b151aca | 2005-07-12 02:36:10 +0000 | [diff] [blame] | 168 | |
| 169 | /// getStackAlignment - Returns the minimum alignment known to hold of the |
| 170 | /// stack frame on entry to the function and which must be maintained by every |
| 171 | /// function for this subtarget. |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 172 | unsigned getStackAlignment() const { return stackAlignment; } |
Jeff Cohen | 9eb59ec | 2005-07-27 05:53:44 +0000 | [diff] [blame] | 173 | |
Rafael Espindola | fc05f40 | 2007-10-31 11:52:06 +0000 | [diff] [blame] | 174 | /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size |
| 175 | /// that still makes it profitable to inline the call. |
| 176 | unsigned getMaxInlineSizeThreshold() const { return MaxInlineSizeThreshold; } |
Anton Korobeynikov | 12c49af | 2006-11-21 00:01:06 +0000 | [diff] [blame] | 177 | |
| 178 | /// ParseSubtargetFeatures - Parses features string setting specified |
Evan Cheng | a26eb5e | 2006-10-06 09:17:41 +0000 | [diff] [blame] | 179 | /// subtarget options. Definition of function is auto generated by tblgen. |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 180 | void ParseSubtargetFeatures(StringRef CPU, StringRef FS); |
Evan Cheng | a26eb5e | 2006-10-06 09:17:41 +0000 | [diff] [blame] | 181 | |
| 182 | /// AutoDetectSubtargetFeatures - Auto-detect CPU features using CPUID |
| 183 | /// instruction. |
| 184 | void AutoDetectSubtargetFeatures(); |
Evan Cheng | 97c7fc3 | 2006-01-26 09:53:06 +0000 | [diff] [blame] | 185 | |
Evan Cheng | 18fb1d3 | 2011-07-07 21:06:52 +0000 | [diff] [blame] | 186 | bool is64Bit() const { return In64BitMode; } |
Evan Cheng | 97c7fc3 | 2006-01-26 09:53:06 +0000 | [diff] [blame] | 187 | |
Duncan Sands | f9a67a8 | 2008-11-28 09:29:37 +0000 | [diff] [blame] | 188 | PICStyles::Style getPICStyle() const { return PICStyle; } |
| 189 | void setPICStyle(PICStyles::Style Style) { PICStyle = Style; } |
Anton Korobeynikov | 7f70559 | 2007-01-12 19:20:47 +0000 | [diff] [blame] | 190 | |
Chris Lattner | 314a113 | 2010-03-14 18:31:44 +0000 | [diff] [blame] | 191 | bool hasCMov() const { return HasCMov; } |
Evan Cheng | 559806f | 2006-01-27 08:10:46 +0000 | [diff] [blame] | 192 | bool hasMMX() const { return X86SSELevel >= MMX; } |
Craig Topper | c6d5995 | 2012-01-10 06:30:56 +0000 | [diff] [blame] | 193 | bool hasSSE1() const { return X86SSELevel >= SSE1; } |
| 194 | bool hasSSE2() const { return X86SSELevel >= SSE2; } |
| 195 | bool hasSSE3() const { return X86SSELevel >= SSE3; } |
| 196 | bool hasSSSE3() const { return X86SSELevel >= SSSE3; } |
| 197 | bool hasSSE41() const { return X86SSELevel >= SSE41; } |
| 198 | bool hasSSE42() const { return X86SSELevel >= SSE42; } |
Craig Topper | 1accb7e | 2012-01-10 06:54:16 +0000 | [diff] [blame] | 199 | bool hasAVX() const { return X86SSELevel >= AVX; } |
| 200 | bool hasAVX2() const { return X86SSELevel >= AVX2; } |
Stefanus Du Toit | 8cf5ab1 | 2009-05-26 21:04:35 +0000 | [diff] [blame] | 201 | bool hasSSE4A() const { return HasSSE4A; } |
Evan Cheng | a26eb5e | 2006-10-06 09:17:41 +0000 | [diff] [blame] | 202 | bool has3DNow() const { return X863DNowLevel >= ThreeDNow; } |
| 203 | bool has3DNowA() const { return X863DNowLevel >= ThreeDNowA; } |
Benjamin Kramer | 1292c22 | 2010-12-04 20:32:23 +0000 | [diff] [blame] | 204 | bool hasPOPCNT() const { return HasPOPCNT; } |
Eric Christopher | 6d1cd1c | 2010-04-02 21:54:27 +0000 | [diff] [blame] | 205 | bool hasAES() const { return HasAES; } |
Benjamin Kramer | c8e340d | 2012-05-31 14:34:17 +0000 | [diff] [blame] | 206 | bool hasPCLMUL() const { return HasPCLMUL; } |
Craig Topper | a15f9d5 | 2012-06-03 18:58:46 +0000 | [diff] [blame] | 207 | bool hasFMA() const { return HasFMA; } |
David Greene | 343dadb | 2009-06-26 22:46:54 +0000 | [diff] [blame] | 208 | bool hasFMA4() const { return HasFMA4; } |
Jan Sjödin | ce25d26 | 2011-12-02 15:14:37 +0000 | [diff] [blame] | 209 | bool hasXOP() const { return HasXOP; } |
Craig Topper | 581fe82 | 2011-10-03 17:28:23 +0000 | [diff] [blame] | 210 | bool hasMOVBE() const { return HasMOVBE; } |
| 211 | bool hasRDRAND() const { return HasRDRAND; } |
Craig Topper | da39404 | 2011-10-09 07:31:39 +0000 | [diff] [blame] | 212 | bool hasF16C() const { return HasF16C; } |
Craig Topper | e7b0550 | 2011-10-30 19:57:21 +0000 | [diff] [blame] | 213 | bool hasFSGSBase() const { return HasFSGSBase; } |
Craig Topper | 37f2167 | 2011-10-11 06:44:02 +0000 | [diff] [blame] | 214 | bool hasLZCNT() const { return HasLZCNT; } |
Craig Topper | 909652f | 2011-10-14 03:21:46 +0000 | [diff] [blame] | 215 | bool hasBMI() const { return HasBMI; } |
Craig Topper | b53fa8b | 2011-10-16 07:55:05 +0000 | [diff] [blame] | 216 | bool hasBMI2() const { return HasBMI2; } |
Evan Cheng | ccb6976 | 2009-01-02 05:35:45 +0000 | [diff] [blame] | 217 | bool isBTMemSlow() const { return IsBTMemSlow; } |
Evan Cheng | 48c58bb | 2010-04-01 05:58:17 +0000 | [diff] [blame] | 218 | bool isUnalignedMemAccessFast() const { return IsUAMemFast; } |
David Greene | 95eb2ee | 2010-01-11 16:29:42 +0000 | [diff] [blame] | 219 | bool hasVectorUAMem() const { return HasVectorUAMem; } |
Eli Friedman | 43f51ae | 2011-08-26 21:21:21 +0000 | [diff] [blame] | 220 | bool hasCmpxchg16b() const { return HasCmpxchg16b; } |
Evan Cheng | de1df10 | 2012-02-07 22:50:41 +0000 | [diff] [blame] | 221 | bool useLeaForSP() const { return UseLeaForSP; } |
Evan Cheng | ccb6976 | 2009-01-02 05:35:45 +0000 | [diff] [blame] | 222 | |
Andrew Trick | 922d314 | 2012-02-01 23:20:51 +0000 | [diff] [blame] | 223 | bool isAtom() const { return X86ProcFamily == IntelAtom; } |
| 224 | |
Daniel Dunbar | 24cfd06 | 2011-04-19 21:01:47 +0000 | [diff] [blame] | 225 | const Triple &getTargetTriple() const { return TargetTriple; } |
| 226 | |
Daniel Dunbar | 912225e | 2011-04-19 21:14:45 +0000 | [diff] [blame] | 227 | bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); } |
| 228 | bool isTargetFreeBSD() const { |
| 229 | return TargetTriple.getOS() == Triple::FreeBSD; |
| 230 | } |
| 231 | bool isTargetSolaris() const { |
| 232 | return TargetTriple.getOS() == Triple::Solaris; |
| 233 | } |
NAKAMURA Takumi | e310b3a | 2011-02-17 12:23:50 +0000 | [diff] [blame] | 234 | |
Eric Christopher | 62f35a2 | 2010-07-05 19:26:33 +0000 | [diff] [blame] | 235 | // ELF is a reasonably sane default and the only other X86 targets we |
| 236 | // support are Darwin and Windows. Just use "not those". |
Chandler Carruth | 69f4469 | 2012-02-05 08:26:40 +0000 | [diff] [blame] | 237 | bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); } |
Eric Christopher | 62f35a2 | 2010-07-05 19:26:33 +0000 | [diff] [blame] | 238 | bool isTargetLinux() const { return TargetTriple.getOS() == Triple::Linux; } |
Nick Lewycky | 1fac6b5 | 2011-09-05 21:51:43 +0000 | [diff] [blame] | 239 | bool isTargetNaCl() const { |
| 240 | return TargetTriple.getOS() == Triple::NativeClient; |
| 241 | } |
| 242 | bool isTargetNaCl32() const { return isTargetNaCl() && !is64Bit(); } |
| 243 | bool isTargetNaCl64() const { return isTargetNaCl() && is64Bit(); } |
Eric Christopher | 62f35a2 | 2010-07-05 19:26:33 +0000 | [diff] [blame] | 244 | bool isTargetWindows() const { return TargetTriple.getOS() == Triple::Win32; } |
NAKAMURA Takumi | 6904f05 | 2011-02-17 12:24:17 +0000 | [diff] [blame] | 245 | bool isTargetMingw() const { return TargetTriple.getOS() == Triple::MinGW32; } |
Eric Christopher | 62f35a2 | 2010-07-05 19:26:33 +0000 | [diff] [blame] | 246 | bool isTargetCygwin() const { return TargetTriple.getOS() == Triple::Cygwin; } |
Chandler Carruth | 69f4469 | 2012-02-05 08:26:40 +0000 | [diff] [blame] | 247 | bool isTargetCygMing() const { return TargetTriple.isOSCygMing(); } |
| 248 | bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); } |
| 249 | bool isTargetEnvMacho() const { return TargetTriple.isEnvironmentMachO(); } |
Mikhail Glushenkov | 5d96eb8 | 2010-02-28 22:54:30 +0000 | [diff] [blame] | 250 | |
Anton Korobeynikov | 1a979d9 | 2008-03-22 20:57:27 +0000 | [diff] [blame] | 251 | bool isTargetWin64() const { |
NAKAMURA Takumi | e3345c4 | 2011-07-20 04:02:20 +0000 | [diff] [blame] | 252 | // FIXME: x86_64-cygwin has not been released yet. |
Chandler Carruth | 69f4469 | 2012-02-05 08:26:40 +0000 | [diff] [blame] | 253 | return In64BitMode && TargetTriple.isOSWindows(); |
Evan Cheng | 2bffee2 | 2011-02-01 01:14:13 +0000 | [diff] [blame] | 254 | } |
| 255 | |
Anton Korobeynikov | ace53f2 | 2010-09-02 23:03:46 +0000 | [diff] [blame] | 256 | bool isTargetWin32() const { |
Chandler Carruth | 69f4469 | 2012-02-05 08:26:40 +0000 | [diff] [blame] | 257 | // FIXME: Cygwin is included for isTargetWin64 -- should it be included |
| 258 | // here too? |
Evan Cheng | 18fb1d3 | 2011-07-07 21:06:52 +0000 | [diff] [blame] | 259 | return !In64BitMode && (isTargetMingw() || isTargetWindows()); |
Anton Korobeynikov | ace53f2 | 2010-09-02 23:03:46 +0000 | [diff] [blame] | 260 | } |
| 261 | |
Duncan Sands | f9a67a8 | 2008-11-28 09:29:37 +0000 | [diff] [blame] | 262 | bool isPICStyleSet() const { return PICStyle != PICStyles::None; } |
| 263 | bool isPICStyleGOT() const { return PICStyle == PICStyles::GOT; } |
Duncan Sands | f9a67a8 | 2008-11-28 09:29:37 +0000 | [diff] [blame] | 264 | bool isPICStyleRIPRel() const { return PICStyle == PICStyles::RIPRel; } |
Chris Lattner | 3b67e9b | 2009-07-10 20:47:30 +0000 | [diff] [blame] | 265 | |
Chris Lattner | e2c9208 | 2009-07-10 21:00:45 +0000 | [diff] [blame] | 266 | bool isPICStyleStubPIC() const { |
Chris Lattner | 8097b65 | 2009-07-10 20:58:47 +0000 | [diff] [blame] | 267 | return PICStyle == PICStyles::StubPIC; |
| 268 | } |
| 269 | |
Chris Lattner | e2c9208 | 2009-07-10 21:00:45 +0000 | [diff] [blame] | 270 | bool isPICStyleStubNoDynamic() const { |
Chris Lattner | 8097b65 | 2009-07-10 20:58:47 +0000 | [diff] [blame] | 271 | return PICStyle == PICStyles::StubDynamicNoPIC; |
| 272 | } |
| 273 | bool isPICStyleStubAny() const { |
| 274 | return PICStyle == PICStyles::StubDynamicNoPIC || |
| 275 | PICStyle == PICStyles::StubPIC; } |
Mikhail Glushenkov | 5d96eb8 | 2010-02-28 22:54:30 +0000 | [diff] [blame] | 276 | |
Chris Lattner | d392bd9 | 2009-07-10 07:20:05 +0000 | [diff] [blame] | 277 | /// ClassifyGlobalReference - Classify a global variable reference for the |
| 278 | /// current subtarget according to how we should reference it in a non-pcrel |
| 279 | /// context. |
| 280 | unsigned char ClassifyGlobalReference(const GlobalValue *GV, |
| 281 | const TargetMachine &TM)const; |
Anton Korobeynikov | 15fccf1 | 2006-12-20 01:03:20 +0000 | [diff] [blame] | 282 | |
Dan Gohman | 29cbade | 2009-11-20 23:18:13 +0000 | [diff] [blame] | 283 | /// ClassifyBlockAddressReference - Classify a blockaddress reference for the |
| 284 | /// current subtarget according to how we should reference it in a non-pcrel |
| 285 | /// context. |
| 286 | unsigned char ClassifyBlockAddressReference() const; |
| 287 | |
Evan Cheng | d7f666a | 2009-05-20 04:53:57 +0000 | [diff] [blame] | 288 | /// IsLegalToCallImmediateAddr - Return true if the subtarget allows calls |
| 289 | /// to immediate address. |
| 290 | bool IsLegalToCallImmediateAddr(const TargetMachine &TM) const; |
| 291 | |
Dan Gohman | 68d599d | 2008-04-01 20:38:36 +0000 | [diff] [blame] | 292 | /// This function returns the name of a function which has an interface |
| 293 | /// like the non-standard bzero function, if such a function exists on |
| 294 | /// the current subtarget and it is considered prefereable over |
| 295 | /// memset with zero passed as the second argument. Otherwise it |
| 296 | /// returns null. |
Bill Wendling | 6e08738 | 2008-09-30 22:05:33 +0000 | [diff] [blame] | 297 | const char *getBZeroEntry() const; |
Dan Gohman | 8749b61 | 2008-12-16 03:35:01 +0000 | [diff] [blame] | 298 | |
| 299 | /// getSpecialAddressLatency - For targets where it is beneficial to |
| 300 | /// backschedule instructions that compute addresses, return a value |
| 301 | /// indicating the number of scheduling cycles of backscheduling that |
| 302 | /// should be attempted. |
| 303 | unsigned getSpecialAddressLatency() const; |
Andrew Trick | 922d314 | 2012-02-01 23:20:51 +0000 | [diff] [blame] | 304 | |
| 305 | /// enablePostRAScheduler - run for Atom optimization. |
| 306 | bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, |
| 307 | TargetSubtargetInfo::AntiDepBreakMode& Mode, |
| 308 | RegClassVector& CriticalPathRCs) const; |
| 309 | |
Preston Gurd | 6a8c7bf | 2012-04-23 21:39:35 +0000 | [diff] [blame] | 310 | bool postRAScheduler() const { return PostRAScheduler; } |
| 311 | |
Andrew Trick | 922d314 | 2012-02-01 23:20:51 +0000 | [diff] [blame] | 312 | /// getInstrItins = Return the instruction itineraries based on the |
| 313 | /// subtarget selection. |
| 314 | const InstrItineraryData &getInstrItineraryData() const { return InstrItins; } |
Evan Cheng | d0da6ff | 2009-09-03 04:37:05 +0000 | [diff] [blame] | 315 | }; |
Evan Cheng | 751c0e1 | 2006-10-16 21:00:37 +0000 | [diff] [blame] | 316 | |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 317 | } // End llvm namespace |
| 318 | |
| 319 | #endif |