Bill Wendling | 2bce78e | 2010-12-04 23:57:24 +0000 | [diff] [blame] | 1 | //===-- X86Subtarget.cpp - X86 Subtarget Information ----------------------===// |
Nate Begeman | f26625e | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | f3ebc3f | 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 | f26625e | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Evan Cheng | 0d639a2 | 2011-07-01 21:01:15 +0000 | [diff] [blame] | 10 | // This file implements the X86 specific subclass of TargetSubtargetInfo. |
Nate Begeman | f26625e | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "X86Subtarget.h" |
Chris Lattner | dc842c0 | 2009-07-10 07:20:05 +0000 | [diff] [blame] | 15 | #include "X86InstrInfo.h" |
Eric Christopher | 4629ed7 | 2014-08-09 01:07:25 +0000 | [diff] [blame] | 16 | #include "X86TargetMachine.h" |
Bill Wendling | aef9c37 | 2013-02-15 22:31:27 +0000 | [diff] [blame] | 17 | #include "llvm/IR/Attributes.h" |
| 18 | #include "llvm/IR/Function.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 19 | #include "llvm/IR/GlobalValue.h" |
Eric Christopher | 3470bbb | 2014-05-21 23:51:57 +0000 | [diff] [blame] | 20 | #include "llvm/Support/CommandLine.h" |
Evan Cheng | 9a3ec1b | 2009-01-03 04:04:46 +0000 | [diff] [blame] | 21 | #include "llvm/Support/Debug.h" |
Rafael Espindola | 6559656 | 2011-09-07 16:10:57 +0000 | [diff] [blame] | 22 | #include "llvm/Support/ErrorHandling.h" |
Michael J. Spencer | 447762d | 2010-11-29 18:16:10 +0000 | [diff] [blame] | 23 | #include "llvm/Support/Host.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 24 | #include "llvm/Support/raw_ostream.h" |
Anton Korobeynikov | 430e68a1 | 2006-12-22 22:29:05 +0000 | [diff] [blame] | 25 | #include "llvm/Target/TargetMachine.h" |
Rafael Espindola | 6559656 | 2011-09-07 16:10:57 +0000 | [diff] [blame] | 26 | #include "llvm/Target/TargetOptions.h" |
Evan Cheng | 54b68e3 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 27 | |
Chris Lattner | 3ad60b1 | 2009-04-25 18:27:23 +0000 | [diff] [blame] | 28 | #if defined(_MSC_VER) |
Bill Wendling | 6eecd56 | 2009-08-03 00:11:34 +0000 | [diff] [blame] | 29 | #include <intrin.h> |
Chris Lattner | 3ad60b1 | 2009-04-25 18:27:23 +0000 | [diff] [blame] | 30 | #endif |
| 31 | |
Chandler Carruth | 84e68b2 | 2014-04-22 02:41:26 +0000 | [diff] [blame] | 32 | using namespace llvm; |
| 33 | |
| 34 | #define DEBUG_TYPE "subtarget" |
| 35 | |
Chandler Carruth | d174b72 | 2014-04-22 02:03:14 +0000 | [diff] [blame] | 36 | #define GET_SUBTARGETINFO_TARGET_DESC |
| 37 | #define GET_SUBTARGETINFO_CTOR |
| 38 | #include "X86GenSubtargetInfo.inc" |
| 39 | |
Eric Christopher | 6b0fcfe | 2014-05-21 23:40:26 +0000 | [diff] [blame] | 40 | // Temporary option to control early if-conversion for x86 while adding machine |
| 41 | // models. |
| 42 | static cl::opt<bool> |
| 43 | X86EarlyIfConv("x86-early-ifcvt", cl::Hidden, |
| 44 | cl::desc("Enable early if-conversion on X86")); |
| 45 | |
| 46 | |
Dan Gohman | 7a661179 | 2009-11-20 23:18:13 +0000 | [diff] [blame] | 47 | /// ClassifyBlockAddressReference - Classify a blockaddress reference for the |
| 48 | /// current subtarget according to how we should reference it in a non-pcrel |
| 49 | /// context. |
Eric Christopher | e2fbc67 | 2013-04-02 23:06:40 +0000 | [diff] [blame] | 50 | unsigned char X86Subtarget::ClassifyBlockAddressReference() const { |
Dan Gohman | 7a661179 | 2009-11-20 23:18:13 +0000 | [diff] [blame] | 51 | if (isPICStyleGOT()) // 32-bit ELF targets. |
| 52 | return X86II::MO_GOTOFF; |
Chad Rosier | 24c19d2 | 2012-08-01 18:39:17 +0000 | [diff] [blame] | 53 | |
Dan Gohman | 7a661179 | 2009-11-20 23:18:13 +0000 | [diff] [blame] | 54 | if (isPICStyleStubPIC()) // Darwin/32 in PIC mode. |
| 55 | return X86II::MO_PIC_BASE_OFFSET; |
Chad Rosier | 24c19d2 | 2012-08-01 18:39:17 +0000 | [diff] [blame] | 56 | |
Dan Gohman | 7a661179 | 2009-11-20 23:18:13 +0000 | [diff] [blame] | 57 | // Direct static reference to label. |
| 58 | return X86II::MO_NO_FLAG; |
| 59 | } |
| 60 | |
Chris Lattner | dc842c0 | 2009-07-10 07:20:05 +0000 | [diff] [blame] | 61 | /// ClassifyGlobalReference - Classify a global variable reference for the |
| 62 | /// current subtarget according to how we should reference it in a non-pcrel |
| 63 | /// context. |
| 64 | unsigned char X86Subtarget:: |
| 65 | ClassifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const { |
| 66 | // DLLImport only exists on windows, it is implemented as a load from a |
| 67 | // DLLIMPORT stub. |
Nico Rieck | 7157bb7 | 2014-01-14 15:22:47 +0000 | [diff] [blame] | 68 | if (GV->hasDLLImportStorageClass()) |
Chris Lattner | dc842c0 | 2009-07-10 07:20:05 +0000 | [diff] [blame] | 69 | return X86II::MO_DLLIMPORT; |
| 70 | |
Peter Collingbourne | 6a9d177 | 2015-07-05 20:52:35 +0000 | [diff] [blame] | 71 | bool isDef = GV->isStrongDefinitionForLinker(); |
Evan Cheng | 02a7652 | 2009-07-16 22:53:10 +0000 | [diff] [blame] | 72 | |
Chris Lattner | dc842c0 | 2009-07-10 07:20:05 +0000 | [diff] [blame] | 73 | // X86-64 in PIC mode. |
| 74 | if (isPICStyleRIPRel()) { |
| 75 | // Large model never uses stubs. |
| 76 | if (TM.getCodeModel() == CodeModel::Large) |
| 77 | return X86II::MO_NO_FLAG; |
Chad Rosier | 24c19d2 | 2012-08-01 18:39:17 +0000 | [diff] [blame] | 78 | |
Chris Lattner | 7dce991 | 2009-07-10 21:01:59 +0000 | [diff] [blame] | 79 | if (isTargetDarwin()) { |
| 80 | // If symbol visibility is hidden, the extra load is not needed if |
| 81 | // target is x86-64 or the symbol is definitely defined in the current |
| 82 | // translation unit. |
Peter Collingbourne | 6a9d177 | 2015-07-05 20:52:35 +0000 | [diff] [blame] | 83 | if (GV->hasDefaultVisibility() && !isDef) |
Chris Lattner | 7dce991 | 2009-07-10 21:01:59 +0000 | [diff] [blame] | 84 | return X86II::MO_GOTPCREL; |
Anton Korobeynikov | db9820e | 2010-08-21 17:21:11 +0000 | [diff] [blame] | 85 | } else if (!isTargetWin64()) { |
Chris Lattner | 7dce991 | 2009-07-10 21:01:59 +0000 | [diff] [blame] | 86 | assert(isTargetELF() && "Unknown rip-relative target"); |
Chris Lattner | dc842c0 | 2009-07-10 07:20:05 +0000 | [diff] [blame] | 87 | |
Chris Lattner | 7dce991 | 2009-07-10 21:01:59 +0000 | [diff] [blame] | 88 | // Extra load is needed for all externally visible. |
| 89 | if (!GV->hasLocalLinkage() && GV->hasDefaultVisibility()) |
| 90 | return X86II::MO_GOTPCREL; |
| 91 | } |
Chris Lattner | dc842c0 | 2009-07-10 07:20:05 +0000 | [diff] [blame] | 92 | |
| 93 | return X86II::MO_NO_FLAG; |
| 94 | } |
Chad Rosier | 24c19d2 | 2012-08-01 18:39:17 +0000 | [diff] [blame] | 95 | |
Chris Lattner | dc842c0 | 2009-07-10 07:20:05 +0000 | [diff] [blame] | 96 | if (isPICStyleGOT()) { // 32-bit ELF targets. |
| 97 | // Extra load is needed for all externally visible. |
| 98 | if (GV->hasLocalLinkage() || GV->hasHiddenVisibility()) |
| 99 | return X86II::MO_GOTOFF; |
| 100 | return X86II::MO_GOT; |
| 101 | } |
Chad Rosier | 24c19d2 | 2012-08-01 18:39:17 +0000 | [diff] [blame] | 102 | |
Chris Lattner | 21c2940 | 2009-07-10 21:00:45 +0000 | [diff] [blame] | 103 | if (isPICStyleStubPIC()) { // Darwin/32 in PIC mode. |
Chris Lattner | bd3e560 | 2009-07-10 20:53:38 +0000 | [diff] [blame] | 104 | // Determine whether we have a stub reference and/or whether the reference |
| 105 | // is relative to the PIC base or not. |
Chad Rosier | 24c19d2 | 2012-08-01 18:39:17 +0000 | [diff] [blame] | 106 | |
Chris Lattner | dc842c0 | 2009-07-10 07:20:05 +0000 | [diff] [blame] | 107 | // If this is a strong reference to a definition, it is definitely not |
| 108 | // through a stub. |
Peter Collingbourne | 6a9d177 | 2015-07-05 20:52:35 +0000 | [diff] [blame] | 109 | if (isDef) |
Chris Lattner | bd3e560 | 2009-07-10 20:53:38 +0000 | [diff] [blame] | 110 | return X86II::MO_PIC_BASE_OFFSET; |
Chris Lattner | dc842c0 | 2009-07-10 07:20:05 +0000 | [diff] [blame] | 111 | |
| 112 | // Unless we have a symbol with hidden visibility, we have to go through a |
| 113 | // normal $non_lazy_ptr stub because this symbol might be resolved late. |
Chris Lattner | bd3e560 | 2009-07-10 20:53:38 +0000 | [diff] [blame] | 114 | if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference. |
| 115 | return X86II::MO_DARWIN_NONLAZY_PIC_BASE; |
Chad Rosier | 24c19d2 | 2012-08-01 18:39:17 +0000 | [diff] [blame] | 116 | |
Chris Lattner | dc842c0 | 2009-07-10 07:20:05 +0000 | [diff] [blame] | 117 | // If symbol visibility is hidden, we have a stub for common symbol |
| 118 | // references and external declarations. |
Peter Collingbourne | 6a9d177 | 2015-07-05 20:52:35 +0000 | [diff] [blame] | 119 | if (GV->isDeclarationForLinker() || GV->hasCommonLinkage()) { |
Chris Lattner | dc842c0 | 2009-07-10 07:20:05 +0000 | [diff] [blame] | 120 | // Hidden $non_lazy_ptr reference. |
Chris Lattner | bd3e560 | 2009-07-10 20:53:38 +0000 | [diff] [blame] | 121 | return X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE; |
Chris Lattner | dc842c0 | 2009-07-10 07:20:05 +0000 | [diff] [blame] | 122 | } |
Chad Rosier | 24c19d2 | 2012-08-01 18:39:17 +0000 | [diff] [blame] | 123 | |
Chris Lattner | dc842c0 | 2009-07-10 07:20:05 +0000 | [diff] [blame] | 124 | // Otherwise, no stub. |
Chris Lattner | bd3e560 | 2009-07-10 20:53:38 +0000 | [diff] [blame] | 125 | return X86II::MO_PIC_BASE_OFFSET; |
| 126 | } |
Chad Rosier | 24c19d2 | 2012-08-01 18:39:17 +0000 | [diff] [blame] | 127 | |
Chris Lattner | 21c2940 | 2009-07-10 21:00:45 +0000 | [diff] [blame] | 128 | if (isPICStyleStubNoDynamic()) { // Darwin/32 in -mdynamic-no-pic mode. |
Chris Lattner | bd3e560 | 2009-07-10 20:53:38 +0000 | [diff] [blame] | 129 | // Determine whether we have a stub reference. |
Chad Rosier | 24c19d2 | 2012-08-01 18:39:17 +0000 | [diff] [blame] | 130 | |
Chris Lattner | bd3e560 | 2009-07-10 20:53:38 +0000 | [diff] [blame] | 131 | // If this is a strong reference to a definition, it is definitely not |
| 132 | // through a stub. |
Peter Collingbourne | 6a9d177 | 2015-07-05 20:52:35 +0000 | [diff] [blame] | 133 | if (isDef) |
Chris Lattner | bd3e560 | 2009-07-10 20:53:38 +0000 | [diff] [blame] | 134 | return X86II::MO_NO_FLAG; |
Chad Rosier | 24c19d2 | 2012-08-01 18:39:17 +0000 | [diff] [blame] | 135 | |
Chris Lattner | bd3e560 | 2009-07-10 20:53:38 +0000 | [diff] [blame] | 136 | // Unless we have a symbol with hidden visibility, we have to go through a |
| 137 | // normal $non_lazy_ptr stub because this symbol might be resolved late. |
| 138 | if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference. |
| 139 | return X86II::MO_DARWIN_NONLAZY; |
Evan Cheng | 1b38952 | 2009-09-03 07:04:02 +0000 | [diff] [blame] | 140 | |
Chris Lattner | bd3e560 | 2009-07-10 20:53:38 +0000 | [diff] [blame] | 141 | // Otherwise, no stub. |
| 142 | return X86II::MO_NO_FLAG; |
Chris Lattner | dc842c0 | 2009-07-10 07:20:05 +0000 | [diff] [blame] | 143 | } |
Chad Rosier | 24c19d2 | 2012-08-01 18:39:17 +0000 | [diff] [blame] | 144 | |
Chris Lattner | dc842c0 | 2009-07-10 07:20:05 +0000 | [diff] [blame] | 145 | // Direct static reference to global. |
| 146 | return X86II::MO_NO_FLAG; |
| 147 | } |
| 148 | |
Anton Korobeynikov | 6dbdfe2 | 2006-11-30 22:42:55 +0000 | [diff] [blame] | 149 | |
Bill Wendling | bd09262 | 2008-09-30 21:22:07 +0000 | [diff] [blame] | 150 | /// getBZeroEntry - This function returns the name of a function which has an |
| 151 | /// interface like the non-standard bzero function, if such a function exists on |
| 152 | /// the current subtarget and it is considered prefereable over memset with zero |
| 153 | /// passed as the second argument. Otherwise it returns null. |
Bill Wendling | 1782584 | 2008-09-30 22:05:33 +0000 | [diff] [blame] | 154 | const char *X86Subtarget::getBZeroEntry() const { |
Dan Gohman | 980d720 | 2008-04-01 20:38:36 +0000 | [diff] [blame] | 155 | // Darwin 10 has a __bzero entry point for this purpose. |
Daniel Dunbar | cd01ed5 | 2011-04-20 00:14:25 +0000 | [diff] [blame] | 156 | if (getTargetTriple().isMacOSX() && |
| 157 | !getTargetTriple().isMacOSXVersionLT(10, 6)) |
Bill Wendling | 1782584 | 2008-09-30 22:05:33 +0000 | [diff] [blame] | 158 | return "__bzero"; |
Dan Gohman | 980d720 | 2008-04-01 20:38:36 +0000 | [diff] [blame] | 159 | |
Craig Topper | 062a2ba | 2014-04-25 05:30:21 +0000 | [diff] [blame] | 160 | return nullptr; |
Dan Gohman | 980d720 | 2008-04-01 20:38:36 +0000 | [diff] [blame] | 161 | } |
| 162 | |
Evan Cheng | 0e88c7d | 2013-01-29 02:32:37 +0000 | [diff] [blame] | 163 | bool X86Subtarget::hasSinCos() const { |
| 164 | return getTargetTriple().isMacOSX() && |
Evan Cheng | d2ca4e2 | 2013-01-30 22:56:35 +0000 | [diff] [blame] | 165 | !getTargetTriple().isMacOSXVersionLT(10, 9) && |
| 166 | is64Bit(); |
Evan Cheng | 0e88c7d | 2013-01-29 02:32:37 +0000 | [diff] [blame] | 167 | } |
| 168 | |
Evan Cheng | 9609833 | 2009-05-20 04:53:57 +0000 | [diff] [blame] | 169 | /// IsLegalToCallImmediateAddr - Return true if the subtarget allows calls |
| 170 | /// to immediate address. |
| 171 | bool X86Subtarget::IsLegalToCallImmediateAddr(const TargetMachine &TM) const { |
David Majnemer | 02f2188 | 2014-03-28 21:40:47 +0000 | [diff] [blame] | 172 | // FIXME: I386 PE/COFF supports PC relative calls using IMAGE_REL_I386_REL32 |
| 173 | // but WinCOFFObjectWriter::RecordRelocation cannot emit them. Once it does, |
| 174 | // the following check for Win32 should be removed. |
| 175 | if (In64BitMode || isTargetWin32()) |
Evan Cheng | 9609833 | 2009-05-20 04:53:57 +0000 | [diff] [blame] | 176 | return false; |
| 177 | return isTargetELF() || TM.getRelocationModel() == Reloc::Static; |
| 178 | } |
| 179 | |
Eric Christopher | b68e253 | 2014-09-03 20:36:31 +0000 | [diff] [blame] | 180 | void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) { |
Nadav Rotem | 08ab877 | 2013-02-27 05:56:20 +0000 | [diff] [blame] | 181 | std::string CPUName = CPU; |
Jim Grosbach | 48551fb | 2014-04-12 01:34:29 +0000 | [diff] [blame] | 182 | if (CPUName.empty()) |
| 183 | CPUName = "generic"; |
Evan Cheng | 964cb5f | 2011-07-08 21:14:14 +0000 | [diff] [blame] | 184 | |
Jim Grosbach | 48551fb | 2014-04-12 01:34:29 +0000 | [diff] [blame] | 185 | // Make sure 64-bit features are available in 64-bit mode. (But make sure |
| 186 | // SSE2 can be turned off explicitly.) |
| 187 | std::string FullFS = FS; |
| 188 | if (In64BitMode) { |
| 189 | if (!FullFS.empty()) |
| 190 | FullFS = "+64bit,+sse2," + FullFS; |
| 191 | else |
| 192 | FullFS = "+64bit,+sse2"; |
Evan Cheng | 11b0a5d | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 193 | } |
Evan Cheng | c5e6d2f | 2011-07-11 03:57:24 +0000 | [diff] [blame] | 194 | |
Jim Grosbach | 48551fb | 2014-04-12 01:34:29 +0000 | [diff] [blame] | 195 | // If feature string is not empty, parse features string. |
| 196 | ParseSubtargetFeatures(CPUName, FullFS); |
| 197 | |
| 198 | // Make sure the right MCSchedModel is used. |
Craig Topper | a844234 | 2013-09-18 05:54:09 +0000 | [diff] [blame] | 199 | InitCPUSchedModel(CPUName); |
Preston Gurd | 35fcb54 | 2012-10-03 15:55:13 +0000 | [diff] [blame] | 200 | |
Andrew Trick | e0c83b1 | 2012-08-07 00:25:30 +0000 | [diff] [blame] | 201 | InstrItins = getInstrItineraryForCPU(CPUName); |
Andrew Trick | 8523b16 | 2012-02-01 23:20:51 +0000 | [diff] [blame] | 202 | |
Evan Cheng | c5e6d2f | 2011-07-11 03:57:24 +0000 | [diff] [blame] | 203 | // It's important to keep the MCSubtargetInfo feature bits in sync with |
| 204 | // target data structure which is shared with MC code emitter, etc. |
| 205 | if (In64BitMode) |
| 206 | ToggleFeature(X86::Mode64Bit); |
Craig Topper | 3c80d62 | 2014-01-06 04:55:54 +0000 | [diff] [blame] | 207 | else if (In32BitMode) |
| 208 | ToggleFeature(X86::Mode32Bit); |
| 209 | else if (In16BitMode) |
| 210 | ToggleFeature(X86::Mode16Bit); |
| 211 | else |
| 212 | llvm_unreachable("Not 16-bit, 32-bit or 64-bit mode!"); |
Evan Cheng | c5e6d2f | 2011-07-11 03:57:24 +0000 | [diff] [blame] | 213 | |
David Greene | 0041181 | 2010-01-05 01:29:13 +0000 | [diff] [blame] | 214 | DEBUG(dbgs() << "Subtarget features: SSELevel " << X86SSELevel |
Bill Wendling | 6eecd56 | 2009-08-03 00:11:34 +0000 | [diff] [blame] | 215 | << ", 3DNowLevel " << X863DNowLevel |
| 216 | << ", 64bit " << HasX86_64 << "\n"); |
Evan Cheng | 13bcc6c | 2011-07-07 21:06:52 +0000 | [diff] [blame] | 217 | assert((!In64BitMode || HasX86_64) && |
Dan Gohman | 7403751 | 2009-02-03 00:04:43 +0000 | [diff] [blame] | 218 | "64-bit code requested on a subtarget that doesn't support it!"); |
Evan Cheng | 11b0a5d | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 219 | |
Roman Divacky | 2213567 | 2012-11-09 20:10:44 +0000 | [diff] [blame] | 220 | // Stack alignment is 16 bytes on Darwin, Linux and Solaris (both |
Roman Divacky | e8a93fe8 | 2011-02-22 17:30:05 +0000 | [diff] [blame] | 221 | // 32 and 64 bit) and for all 64-bit targets. |
Evan Cheng | 3a0c5e5 | 2011-06-23 17:54:54 +0000 | [diff] [blame] | 222 | if (StackAlignOverride) |
| 223 | stackAlignment = StackAlignOverride; |
Roman Divacky | 2213567 | 2012-11-09 20:10:44 +0000 | [diff] [blame] | 224 | else if (isTargetDarwin() || isTargetLinux() || isTargetSolaris() || |
| 225 | In64BitMode) |
Nate Begeman | f26625e | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 226 | stackAlignment = 16; |
Dan Gohman | dc53f1c | 2010-05-27 18:43:40 +0000 | [diff] [blame] | 227 | } |
Andrew Trick | 8523b16 | 2012-02-01 23:20:51 +0000 | [diff] [blame] | 228 | |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 229 | void X86Subtarget::initializeEnvironment() { |
| 230 | X86SSELevel = NoMMXSSE; |
| 231 | X863DNowLevel = NoThreeDNow; |
| 232 | HasCMov = false; |
| 233 | HasX86_64 = false; |
| 234 | HasPOPCNT = false; |
| 235 | HasSSE4A = false; |
| 236 | HasAES = false; |
| 237 | HasPCLMUL = false; |
| 238 | HasFMA = false; |
| 239 | HasFMA4 = false; |
| 240 | HasXOP = false; |
Yunzhong Gao | dd36e93 | 2013-09-24 18:21:52 +0000 | [diff] [blame] | 241 | HasTBM = false; |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 242 | HasMOVBE = false; |
| 243 | HasRDRAND = false; |
| 244 | HasF16C = false; |
| 245 | HasFSGSBase = false; |
| 246 | HasLZCNT = false; |
| 247 | HasBMI = false; |
| 248 | HasBMI2 = false; |
| 249 | HasRTM = false; |
Michael Liao | e344ec9 | 2013-03-26 22:46:02 +0000 | [diff] [blame] | 250 | HasHLE = false; |
Elena Demikhovsky | 003e7d7 | 2013-07-28 08:28:38 +0000 | [diff] [blame] | 251 | HasERI = false; |
| 252 | HasCDI = false; |
Craig Topper | 7a8cf01 | 2013-08-20 05:23:59 +0000 | [diff] [blame] | 253 | HasPFI = false; |
Robert Khasanov | bfa0131 | 2014-07-21 14:54:21 +0000 | [diff] [blame] | 254 | HasDQI = false; |
| 255 | HasBWI = false; |
| 256 | HasVLX = false; |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 257 | HasADX = false; |
Ben Langmuir | 1650175 | 2013-09-12 15:51:31 +0000 | [diff] [blame] | 258 | HasSHA = false; |
Michael Liao | 5173ee0 | 2013-03-26 17:47:11 +0000 | [diff] [blame] | 259 | HasPRFCHW = false; |
Michael Liao | a486a11 | 2013-03-28 23:41:26 +0000 | [diff] [blame] | 260 | HasRDSEED = false; |
Elena Demikhovsky | f7e641c | 2015-06-03 10:30:57 +0000 | [diff] [blame] | 261 | HasMPX = false; |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 262 | IsBTMemSlow = false; |
Ekaterina Romanova | d5fa554 | 2013-11-21 23:21:26 +0000 | [diff] [blame] | 263 | IsSHLDSlow = false; |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 264 | IsUAMemFast = false; |
Sanjay Patel | 501890e | 2014-11-21 17:40:04 +0000 | [diff] [blame] | 265 | IsUAMem32Slow = false; |
Sanjay Patel | ffd039b | 2015-02-03 17:13:04 +0000 | [diff] [blame] | 266 | HasSSEUnalignedMem = false; |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 267 | HasCmpxchg16b = false; |
| 268 | UseLeaForSP = false; |
Alexey Volkov | fd1731d | 2014-11-21 11:19:34 +0000 | [diff] [blame] | 269 | HasSlowDivide32 = false; |
| 270 | HasSlowDivide64 = false; |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 271 | PadShortFunctions = false; |
Preston Gurd | 663e6f9 | 2013-03-27 19:14:02 +0000 | [diff] [blame] | 272 | CallRegIndirect = false; |
Preston Gurd | 8b7ab4b | 2013-04-25 20:29:37 +0000 | [diff] [blame] | 273 | LEAUsesAG = false; |
Alexey Volkov | 6226de6 | 2014-05-20 08:55:50 +0000 | [diff] [blame] | 274 | SlowLEA = false; |
Alexey Volkov | 5260dba | 2014-06-09 11:40:41 +0000 | [diff] [blame] | 275 | SlowIncDec = false; |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 276 | stackAlignment = 4; |
| 277 | // FIXME: this is a known good value for Yonah. How about others? |
| 278 | MaxInlineSizeThreshold = 128; |
Eric Christopher | 824f42f | 2015-05-12 01:26:05 +0000 | [diff] [blame] | 279 | UseSoftFloat = false; |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 280 | } |
| 281 | |
Eric Christopher | 1a21203 | 2014-06-11 00:25:19 +0000 | [diff] [blame] | 282 | X86Subtarget &X86Subtarget::initializeSubtargetDependencies(StringRef CPU, |
| 283 | StringRef FS) { |
| 284 | initializeEnvironment(); |
Eric Christopher | b68e253 | 2014-09-03 20:36:31 +0000 | [diff] [blame] | 285 | initSubtargetFeatures(CPU, FS); |
Eric Christopher | 1a21203 | 2014-06-11 00:25:19 +0000 | [diff] [blame] | 286 | return *this; |
| 287 | } |
| 288 | |
Daniel Sanders | a73f1fd | 2015-06-10 12:11:26 +0000 | [diff] [blame] | 289 | X86Subtarget::X86Subtarget(const Triple &TT, const std::string &CPU, |
Eric Christopher | 12f4a78 | 2014-10-01 20:38:22 +0000 | [diff] [blame] | 290 | const std::string &FS, const X86TargetMachine &TM, |
Eric Christopher | a08f30b | 2014-06-09 17:08:19 +0000 | [diff] [blame] | 291 | unsigned StackAlignOverride) |
Eric Christopher | b8f9768 | 2014-05-07 21:05:47 +0000 | [diff] [blame] | 292 | : X86GenSubtargetInfo(TT, CPU, FS), X86ProcFamily(Others), |
| 293 | PICStyle(PICStyles::None), TargetTriple(TT), |
| 294 | StackAlignOverride(StackAlignOverride), |
| 295 | In64BitMode(TargetTriple.getArch() == Triple::x86_64), |
| 296 | In32BitMode(TargetTriple.getArch() == Triple::x86 && |
| 297 | TargetTriple.getEnvironment() != Triple::CODE16), |
| 298 | In16BitMode(TargetTriple.getArch() == Triple::x86 && |
Eric Christopher | a08f30b | 2014-06-09 17:08:19 +0000 | [diff] [blame] | 299 | TargetTriple.getEnvironment() == Triple::CODE16), |
Mehdi Amini | 157e5a6 | 2015-07-09 02:10:08 +0000 | [diff] [blame] | 300 | TSInfo(), InstrInfo(initializeSubtargetDependencies(CPU, FS)), |
| 301 | TLInfo(TM, *this), FrameLowering(*this, getStackAlignment()) { |
Eric Christopher | 4629ed7 | 2014-08-09 01:07:25 +0000 | [diff] [blame] | 302 | // Determine the PICStyle based on the target selected. |
| 303 | if (TM.getRelocationModel() == Reloc::Static) { |
| 304 | // Unless we're in PIC or DynamicNoPIC mode, set the PIC style to None. |
| 305 | setPICStyle(PICStyles::None); |
| 306 | } else if (is64Bit()) { |
| 307 | // PIC in 64 bit mode is always rip-rel. |
| 308 | setPICStyle(PICStyles::RIPRel); |
| 309 | } else if (isTargetCOFF()) { |
| 310 | setPICStyle(PICStyles::None); |
| 311 | } else if (isTargetDarwin()) { |
| 312 | if (TM.getRelocationModel() == Reloc::PIC_) |
| 313 | setPICStyle(PICStyles::StubPIC); |
| 314 | else { |
| 315 | assert(TM.getRelocationModel() == Reloc::DynamicNoPIC); |
| 316 | setPICStyle(PICStyles::StubDynamicNoPIC); |
| 317 | } |
| 318 | } else if (isTargetELF()) { |
| 319 | setPICStyle(PICStyles::GOT); |
| 320 | } |
| 321 | } |
Bill Wendling | aef9c37 | 2013-02-15 22:31:27 +0000 | [diff] [blame] | 322 | |
Sanjay Patel | a2f658d | 2014-07-15 22:39:58 +0000 | [diff] [blame] | 323 | bool X86Subtarget::enableEarlyIfConversion() const { |
Eric Christopher | 3470bbb | 2014-05-21 23:51:57 +0000 | [diff] [blame] | 324 | return hasCMov() && X86EarlyIfConv; |
Eric Christopher | 6b0fcfe | 2014-05-21 23:40:26 +0000 | [diff] [blame] | 325 | } |
Sanjay Patel | a2f658d | 2014-07-15 22:39:58 +0000 | [diff] [blame] | 326 | |