blob: 6eb96a5e184e6c4f15d320813e5c02e4b1517efd [file] [log] [blame]
Chris Lattner02a3d832002-10-29 22:37:54 +00001//===-- X86TargetMachine.cpp - Define TargetMachine for the X86 -----------===//
Misha Brukmanc88330a2005-04-21 23:38:14 +00002//
John Criswell482202a2003-10-20 19:43:21 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukmanc88330a2005-04-21 23:38:14 +00007//
John Criswell482202a2003-10-20 19:43:21 +00008//===----------------------------------------------------------------------===//
Misha Brukmanc88330a2005-04-21 23:38:14 +00009//
Chris Lattner02a3d832002-10-29 22:37:54 +000010// This file defines the X86 specific subclass of TargetMachine.
11//
12//===----------------------------------------------------------------------===//
13
14#include "X86TargetMachine.h"
Chris Lattnera32b4052002-12-24 00:04:01 +000015#include "X86.h"
Zvi Rackover76dbf262016-11-15 06:34:33 +000016#include "X86CallLowering.h"
Aditya Nandakumara2719322014-11-13 09:26:31 +000017#include "X86TargetObjectFile.h"
Chandler Carruth93dcdc42015-01-31 11:17:59 +000018#include "X86TargetTransformInfo.h"
Zvi Rackover76dbf262016-11-15 06:34:33 +000019#include "llvm/CodeGen/GlobalISel/GISelAccessor.h"
20#include "llvm/CodeGen/GlobalISel/IRTranslator.h"
Matthias Braun115efcd2016-11-28 20:11:54 +000021#include "llvm/CodeGen/MachineScheduler.h"
Chris Lattner962d5be2003-01-13 00:51:23 +000022#include "llvm/CodeGen/Passes.h"
Matthias Braun31d19d42016-05-10 03:21:59 +000023#include "llvm/CodeGen/TargetPassConfig.h"
Eric Christopher3faf2f12014-10-06 06:45:36 +000024#include "llvm/IR/Function.h"
Chandler Carruth30d69c22015-02-13 10:01:29 +000025#include "llvm/IR/LegacyPassManager.h"
Bruno Cardoso Lopes2a3ffb52011-08-23 01:14:17 +000026#include "llvm/Support/CommandLine.h"
David Greenea31f96c2009-07-14 20:18:05 +000027#include "llvm/Support/FormattedStream.h"
Evan Cheng2bb40352011-08-24 18:08:43 +000028#include "llvm/Support/TargetRegistry.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000029#include "llvm/Target/TargetOptions.h"
Chris Lattner833c3c22003-12-20 01:22:19 +000030using namespace llvm;
Brian Gaeke960707c2003-11-11 22:41:34 +000031
Sanjay Patel08829ba2015-06-10 20:32:21 +000032static cl::opt<bool> EnableMachineCombinerPass("x86-machine-combiner",
33 cl::desc("Enable the machine combiner pass"),
34 cl::init(true), cl::Hidden);
35
David Majnemer0ad363e2015-08-18 19:07:12 +000036namespace llvm {
37void initializeWinEHStatePassPass(PassRegistry &);
38}
39
NAKAMURA Takumi0544fe72011-02-17 12:23:50 +000040extern "C" void LLVMInitializeX86Target() {
Daniel Dunbar5680b4f2009-07-25 06:49:55 +000041 // Register the target.
Mehdi Aminif42454b2016-10-09 23:00:34 +000042 RegisterTargetMachine<X86TargetMachine> X(getTheX86_32Target());
43 RegisterTargetMachine<X86TargetMachine> Y(getTheX86_64Target());
David Majnemer0ad363e2015-08-18 19:07:12 +000044
45 PassRegistry &PR = *PassRegistry::getPassRegistry();
Zvi Rackover76dbf262016-11-15 06:34:33 +000046 initializeGlobalISel(PR);
David Majnemer0ad363e2015-08-18 19:07:12 +000047 initializeWinEHStatePassPass(PR);
Ahmed Bougacha068ac4a2016-05-07 01:11:10 +000048 initializeFixupBWInstPassPass(PR);
Daniel Dunbare8338102009-07-15 20:24:03 +000049}
Douglas Gregor1b731d52009-06-16 20:12:29 +000050
Aditya Nandakumara2719322014-11-13 09:26:31 +000051static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
52 if (TT.isOSBinFormatMachO()) {
53 if (TT.getArch() == Triple::x86_64)
54 return make_unique<X86_64MachoTargetObjectFile>();
55 return make_unique<TargetLoweringObjectFileMachO>();
56 }
57
Davide Italianoa9f85d62016-09-26 22:53:15 +000058 if (TT.isOSFreeBSD())
59 return make_unique<X86FreeBSDTargetObjectFile>();
Derek Schuff072f93f2015-03-11 16:16:09 +000060 if (TT.isOSLinux() || TT.isOSNaCl())
61 return make_unique<X86LinuxNaClTargetObjectFile>();
Petr Hoseke023d622016-10-06 05:17:26 +000062 if (TT.isOSFuchsia())
63 return make_unique<X86FuchsiaTargetObjectFile>();
Aditya Nandakumara2719322014-11-13 09:26:31 +000064 if (TT.isOSBinFormatELF())
Paul Robinson06a8eb82015-03-03 21:01:27 +000065 return make_unique<X86ELFTargetObjectFile>();
Pat Gavlinb3990952015-08-14 22:41:43 +000066 if (TT.isKnownWindowsMSVCEnvironment() || TT.isWindowsCoreCLREnvironment())
Aditya Nandakumara2719322014-11-13 09:26:31 +000067 return make_unique<X86WindowsTargetObjectFile>();
68 if (TT.isOSBinFormatCOFF())
69 return make_unique<TargetLoweringObjectFileCOFF>();
70 llvm_unreachable("unknown subtarget type");
71}
72
Eric Christopher8b770652015-01-26 19:03:15 +000073static std::string computeDataLayout(const Triple &TT) {
74 // X86 is little endian
75 std::string Ret = "e";
76
77 Ret += DataLayout::getManglingComponent(TT);
78 // X86 and x32 have 32 bit pointers.
79 if ((TT.isArch64Bit() &&
80 (TT.getEnvironment() == Triple::GNUX32 || TT.isOSNaCl())) ||
81 !TT.isArch64Bit())
82 Ret += "-p:32:32";
83
84 // Some ABIs align 64 bit integers and doubles to 64 bits, others to 32.
85 if (TT.isArch64Bit() || TT.isOSWindows() || TT.isOSNaCl())
86 Ret += "-i64:64";
Andrey Turetskiy2396c382016-02-10 11:57:06 +000087 else if (TT.isOSIAMCU())
88 Ret += "-i64:32-f64:32";
Eric Christopher8b770652015-01-26 19:03:15 +000089 else
90 Ret += "-f64:32:64";
91
92 // Some ABIs align long double to 128 bits, others to 32.
Andrey Turetskiy2396c382016-02-10 11:57:06 +000093 if (TT.isOSNaCl() || TT.isOSIAMCU())
Eric Christopher8b770652015-01-26 19:03:15 +000094 ; // No f80
95 else if (TT.isArch64Bit() || TT.isOSDarwin())
96 Ret += "-f80:128";
97 else
98 Ret += "-f80:32";
99
Andrey Turetskiy2396c382016-02-10 11:57:06 +0000100 if (TT.isOSIAMCU())
101 Ret += "-f128:32";
102
Eric Christopher8b770652015-01-26 19:03:15 +0000103 // The registers can hold 8, 16, 32 or, in x86-64, 64 bits.
104 if (TT.isArch64Bit())
105 Ret += "-n8:16:32:64";
106 else
107 Ret += "-n8:16:32";
108
109 // The stack is aligned to 32 bits on some ABIs and 128 bits on others.
Andrey Turetskiy2396c382016-02-10 11:57:06 +0000110 if ((!TT.isArch64Bit() && TT.isOSWindows()) || TT.isOSIAMCU())
Reid Kleckner60d52322015-04-30 22:11:59 +0000111 Ret += "-a:0:32-S32";
Eric Christopher8b770652015-01-26 19:03:15 +0000112 else
113 Ret += "-S128";
114
115 return Ret;
116}
117
Rafael Espindola8c34dd82016-05-18 22:04:49 +0000118static Reloc::Model getEffectiveRelocModel(const Triple &TT,
119 Optional<Reloc::Model> RM) {
120 bool is64Bit = TT.getArch() == Triple::x86_64;
121 if (!RM.hasValue()) {
122 // Darwin defaults to PIC in 64 bit mode and dynamic-no-pic in 32 bit mode.
123 // Win64 requires rip-rel addressing, thus we force it to PIC. Otherwise we
124 // use static relocation model by default.
125 if (TT.isOSDarwin()) {
126 if (is64Bit)
127 return Reloc::PIC_;
128 return Reloc::DynamicNoPIC;
129 }
130 if (TT.isOSWindows() && is64Bit)
131 return Reloc::PIC_;
132 return Reloc::Static;
133 }
134
135 // ELF and X86-64 don't have a distinct DynamicNoPIC model. DynamicNoPIC
136 // is defined as a model for code which may be used in static or dynamic
137 // executables but not necessarily a shared library. On X86-32 we just
138 // compile in -static mode, in x86-64 we use PIC.
139 if (*RM == Reloc::DynamicNoPIC) {
140 if (is64Bit)
141 return Reloc::PIC_;
142 if (!TT.isOSDarwin())
143 return Reloc::Static;
144 }
145
146 // If we are on Darwin, disallow static relocation model in X86-64 mode, since
147 // the Mach-O file format doesn't support it.
148 if (*RM == Reloc::Static && TT.isOSDarwin() && is64Bit)
149 return Reloc::PIC_;
150
151 return *RM;
152}
153
Rafael Espindola38af4d62016-05-18 16:00:24 +0000154/// Create an X86 target.
Chris Lattner02a3d832002-10-29 22:37:54 +0000155///
Daniel Sanders3e5de882015-06-11 19:41:26 +0000156X86TargetMachine::X86TargetMachine(const Target &T, const Triple &TT,
157 StringRef CPU, StringRef FS,
158 const TargetOptions &Options,
Rafael Espindola8c34dd82016-05-18 22:04:49 +0000159 Optional<Reloc::Model> RM,
160 CodeModel::Model CM, CodeGenOpt::Level OL)
161 : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options,
162 getEffectiveRelocModel(TT, RM), CM, OL),
Eric Christopher5653e5d2016-09-20 22:19:33 +0000163 TLOF(createTLOF(getTargetTriple())) {
Reid Klecknerae44e872015-10-09 01:13:17 +0000164 // Windows stack unwinder gets confused when execution flow "falls through"
165 // after a call to 'noreturn' function.
166 // To prevent that, we emit a trap for 'unreachable' IR instructions.
167 // (which on X86, happens to be the 'ud2' instruction)
Paul Robinsonf81836b2016-03-24 00:10:03 +0000168 // On PS4, the "return address" of a 'noreturn' call must still be within
169 // the calling function, and TrapUnreachable is an easy way to get that.
Eric Christopheref579d22016-09-20 16:04:59 +0000170 // The check here for 64-bit windows is a bit icky, but as we're unlikely
171 // to ever want to mix 32 and 64-bit windows code in a single module
172 // this should be fine.
173 if ((TT.isOSWindows() && TT.getArch() == Triple::x86_64) || TT.isPS4())
Reid Klecknerae44e872015-10-09 01:13:17 +0000174 this->Options.TrapUnreachable = true;
175
David Woodhouse1c3996a2014-01-08 00:08:50 +0000176 initAsmInfo();
Chris Lattnera1d312c2006-02-03 18:59:39 +0000177}
Chris Lattner02a3d832002-10-29 22:37:54 +0000178
Reid Kleckner357600e2014-11-20 23:37:18 +0000179X86TargetMachine::~X86TargetMachine() {}
180
Zvi Rackover76dbf262016-11-15 06:34:33 +0000181#ifdef LLVM_BUILD_GLOBAL_ISEL
182namespace {
183struct X86GISelActualAccessor : public GISelAccessor {
184 std::unique_ptr<CallLowering> CL;
185 X86GISelActualAccessor(CallLowering* CL): CL(CL) {}
186 const CallLowering *getCallLowering() const override {
187 return CL.get();
188 }
189 const InstructionSelector *getInstructionSelector() const override {
190 //TODO: Implement
191 return nullptr;
192 }
193 const class LegalizerInfo *getLegalizerInfo() const override {
194 //TODO: Implement
195 return nullptr;
196 }
197 const RegisterBankInfo *getRegBankInfo() const override {
198 //TODO: Implement
199 return nullptr;
200 }
201};
202} // End anonymous namespace.
203#endif
Eric Christopher3faf2f12014-10-06 06:45:36 +0000204const X86Subtarget *
205X86TargetMachine::getSubtargetImpl(const Function &F) const {
Duncan P. N. Exon Smith5975a702015-02-14 01:59:52 +0000206 Attribute CPUAttr = F.getFnAttribute("target-cpu");
207 Attribute FSAttr = F.getFnAttribute("target-features");
Eric Christopher3faf2f12014-10-06 06:45:36 +0000208
David Majnemer498f2fd2016-05-20 20:41:24 +0000209 StringRef CPU = !CPUAttr.hasAttribute(Attribute::None)
210 ? CPUAttr.getValueAsString()
211 : (StringRef)TargetCPU;
212 StringRef FS = !FSAttr.hasAttribute(Attribute::None)
213 ? FSAttr.getValueAsString()
214 : (StringRef)TargetFS;
215
216 SmallString<512> Key;
217 Key.reserve(CPU.size() + FS.size());
218 Key += CPU;
219 Key += FS;
Eric Christopher3faf2f12014-10-06 06:45:36 +0000220
221 // FIXME: This is related to the code below to reset the target options,
222 // we need to know whether or not the soft float flag is set on the
223 // function before we can generate a subtarget. We also need to use
224 // it as a key for the subtarget since that can be the only difference
225 // between two functions.
Eric Christopher824f42f2015-05-12 01:26:05 +0000226 bool SoftFloat =
Eric Christopher824f42f2015-05-12 01:26:05 +0000227 F.getFnAttribute("use-soft-float").getValueAsString() == "true";
228 // If the soft float attribute is set on the function turn on the soft float
229 // subtarget feature.
230 if (SoftFloat)
David Majnemer498f2fd2016-05-20 20:41:24 +0000231 Key += FS.empty() ? "+soft-float" : ",+soft-float";
Eric Christopher3faf2f12014-10-06 06:45:36 +0000232
David Majnemer498f2fd2016-05-20 20:41:24 +0000233 FS = Key.substr(CPU.size());
David Majnemerca290232016-05-20 18:16:06 +0000234
235 auto &I = SubtargetMap[Key];
Eric Christopher3faf2f12014-10-06 06:45:36 +0000236 if (!I) {
237 // This needs to be done before we create a new subtarget since any
238 // creation will depend on the TM and the code generation flags on the
239 // function that reside in TargetOptions.
240 resetTargetOptions(F);
Daniel Sandersc81f4502015-06-16 15:44:21 +0000241 I = llvm::make_unique<X86Subtarget>(TargetTriple, CPU, FS, *this,
Eric Christopher3faf2f12014-10-06 06:45:36 +0000242 Options.StackAlignmentOverride);
Zvi Rackover76dbf262016-11-15 06:34:33 +0000243#ifndef LLVM_BUILD_GLOBAL_ISEL
244 GISelAccessor *GISel = new GISelAccessor();
245#else
246 X86GISelActualAccessor *GISel = new X86GISelActualAccessor(
247 new X86CallLowering(*I->getTargetLowering()));
248#endif
249 I->setGISelAccessor(*GISel);
Eric Christopher3faf2f12014-10-06 06:45:36 +0000250 }
251 return I.get();
252}
253
Chris Lattner12e97302006-09-04 04:14:57 +0000254//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes2a3ffb52011-08-23 01:14:17 +0000255// Command line options for x86
256//===----------------------------------------------------------------------===//
Benjamin Kramer7859d2e2011-09-03 03:45:06 +0000257static cl::opt<bool>
Nadav Rotem7f27e0b2013-10-18 23:38:13 +0000258UseVZeroUpper("x86-use-vzeroupper", cl::Hidden,
Bruno Cardoso Lopes2a3ffb52011-08-23 01:14:17 +0000259 cl::desc("Minimize AVX to SSE transition penalty"),
Eli Friedman20439a42011-11-17 00:21:52 +0000260 cl::init(true));
Bruno Cardoso Lopes2a3ffb52011-08-23 01:14:17 +0000261
262//===----------------------------------------------------------------------===//
Chandler Carruth93dcdc42015-01-31 11:17:59 +0000263// X86 TTI query.
Chandler Carruth664e3542013-01-07 01:37:14 +0000264//===----------------------------------------------------------------------===//
265
Chandler Carruth8b04c0d2015-02-01 13:20:00 +0000266TargetIRAnalysis X86TargetMachine::getTargetIRAnalysis() {
Eric Christophera4e5d3c2015-09-16 23:38:13 +0000267 return TargetIRAnalysis([this](const Function &F) {
268 return TargetTransformInfo(X86TTIImpl(this, F));
269 });
Chandler Carruth664e3542013-01-07 01:37:14 +0000270}
271
272
273//===----------------------------------------------------------------------===//
Chris Lattner12e97302006-09-04 04:14:57 +0000274// Pass Pipeline Configuration
275//===----------------------------------------------------------------------===//
Chris Lattner1d6ba3e2003-08-05 16:34:44 +0000276
Andrew Trickccb67362012-02-03 05:12:41 +0000277namespace {
278/// X86 Code Generator Pass Configuration Options.
279class X86PassConfig : public TargetPassConfig {
280public:
Andrew Trickf8ea1082012-02-04 02:56:59 +0000281 X86PassConfig(X86TargetMachine *TM, PassManagerBase &PM)
282 : TargetPassConfig(TM, PM) {}
Andrew Trickccb67362012-02-03 05:12:41 +0000283
284 X86TargetMachine &getX86TargetMachine() const {
285 return getTM<X86TargetMachine>();
286 }
287
Matthias Braun115efcd2016-11-28 20:11:54 +0000288 ScheduleDAGInstrs *
289 createMachineScheduler(MachineSchedContext *C) const override {
290 ScheduleDAGMILive *DAG = createGenericSchedLive(C);
291 DAG->addMutation(createMacroFusionDAGMutation(DAG->TII));
292 return DAG;
293 }
294
Tim Northover277066a2014-07-01 18:53:31 +0000295 void addIRPasses() override;
Craig Topper2d9361e2014-03-09 07:44:38 +0000296 bool addInstSelector() override;
Zvi Rackover76dbf262016-11-15 06:34:33 +0000297#ifdef LLVM_BUILD_GLOBAL_ISEL
298 bool addIRTranslator() override;
299 bool addLegalizeMachineIR() override;
300 bool addRegBankSelect() override;
301 bool addGlobalInstructionSelect() override;
302#endif
303bool addILPOpts() override;
Reid Kleckner0738a9c2015-05-05 17:44:16 +0000304 bool addPreISel() override;
Michael Kuperstein13fbd452015-02-01 16:56:04 +0000305 void addPreRegAlloc() override;
Matthias Braun7e37a5f2014-12-11 21:26:47 +0000306 void addPostRegAlloc() override;
307 void addPreEmitPass() override;
Quentin Colombet494eb602015-05-22 18:10:47 +0000308 void addPreSched2() override;
Andrew Trickccb67362012-02-03 05:12:41 +0000309};
310} // namespace
311
Andrew Trickf8ea1082012-02-04 02:56:59 +0000312TargetPassConfig *X86TargetMachine::createPassConfig(PassManagerBase &PM) {
Jakob Stoklund Olesen213a2f82013-01-17 00:58:38 +0000313 return new X86PassConfig(this, PM);
Andrew Trickccb67362012-02-03 05:12:41 +0000314}
315
Tim Northover277066a2014-07-01 18:53:31 +0000316void X86PassConfig::addIRPasses() {
Robin Morisset25c8e312014-09-17 00:06:58 +0000317 addPass(createAtomicExpandPass(&getX86TargetMachine()));
Tim Northover277066a2014-07-01 18:53:31 +0000318
319 TargetPassConfig::addIRPasses();
David L Kreitzer01a057a2016-10-14 18:20:41 +0000320
321 if (TM->getOptLevel() != CodeGenOpt::None)
322 addPass(createInterleavedAccessPass(TM));
Tim Northover277066a2014-07-01 18:53:31 +0000323}
324
Andrew Trickccb67362012-02-03 05:12:41 +0000325bool X86PassConfig::addInstSelector() {
Nate Begemanbe1f3142005-08-18 23:53:15 +0000326 // Install an instruction selector.
Bob Wilsonbbd38dd2012-07-02 19:48:31 +0000327 addPass(createX86ISelDag(getX86TargetMachine(), getOptLevel()));
Dan Gohman19145312008-10-25 17:46:52 +0000328
Hans Wennborg789acfb2012-06-01 16:27:21 +0000329 // For ELF, cleanup any local-dynamic TLS accesses.
Daniel Sandersc81f4502015-06-16 15:44:21 +0000330 if (TM->getTargetTriple().isOSBinFormatELF() &&
Eric Christopher24f3f652015-02-05 19:27:04 +0000331 getOptLevel() != CodeGenOpt::None)
Bob Wilsonbbd38dd2012-07-02 19:48:31 +0000332 addPass(createCleanupLocalDynamicTLSPass());
Hans Wennborg789acfb2012-06-01 16:27:21 +0000333
Eric Christopher0d5c99e2014-05-22 01:46:02 +0000334 addPass(createX86GlobalBaseRegPass());
Chris Lattner12e97302006-09-04 04:14:57 +0000335 return false;
Brian Gaekeac94bab2003-06-18 21:43:21 +0000336}
337
Zvi Rackover76dbf262016-11-15 06:34:33 +0000338#ifdef LLVM_BUILD_GLOBAL_ISEL
339bool X86PassConfig::addIRTranslator() {
340 addPass(new IRTranslator());
341 return false;
342}
343
344bool X86PassConfig::addLegalizeMachineIR() {
345 //TODO: Implement
346 return false;
347}
348
349bool X86PassConfig::addRegBankSelect() {
350 //TODO: Implement
351 return false;
352}
353
354bool X86PassConfig::addGlobalInstructionSelect() {
355 //TODO: Implement
356 return false;
357}
358#endif
359
Jakob Stoklund Olesen213a2f82013-01-17 00:58:38 +0000360bool X86PassConfig::addILPOpts() {
Eric Christopher6b0fcfe2014-05-21 23:40:26 +0000361 addPass(&EarlyIfConverterID);
Sanjay Patel08829ba2015-06-10 20:32:21 +0000362 if (EnableMachineCombinerPass)
363 addPass(&MachineCombinerID);
Eric Christopher6b0fcfe2014-05-21 23:40:26 +0000364 return true;
Jakob Stoklund Olesen213a2f82013-01-17 00:58:38 +0000365}
366
Reid Kleckner0738a9c2015-05-05 17:44:16 +0000367bool X86PassConfig::addPreISel() {
Reid Kleckner5b8ebfb2015-05-29 20:43:10 +0000368 // Only add this pass for 32-bit x86 Windows.
Daniel Sandersc81f4502015-06-16 15:44:21 +0000369 const Triple &TT = TM->getTargetTriple();
Reid Kleckner5b8ebfb2015-05-29 20:43:10 +0000370 if (TT.isOSWindows() && TT.getArch() == Triple::x86)
Reid Kleckner0738a9c2015-05-05 17:44:16 +0000371 addPass(createX86WinEHStatePass());
372 return true;
373}
374
Michael Kuperstein13fbd452015-02-01 16:56:04 +0000375void X86PassConfig::addPreRegAlloc() {
Michael Kupersteincfbac5f2016-07-11 20:40:44 +0000376 if (getOptLevel() != CodeGenOpt::None) {
Nico Weberead8f8f2016-07-14 15:07:44 +0000377 addPass(createX86FixupSetCC());
378 addPass(createX86OptimizeLEAs());
Nico Weber5bb28422016-07-14 15:40:22 +0000379 addPass(createX86CallFrameOptimization());
Michael Kupersteincfbac5f2016-07-11 20:40:44 +0000380 }
Alexey Bataev7cf32472015-12-04 10:53:15 +0000381
Hans Wennborg8eb336c2016-05-18 16:10:17 +0000382 addPass(createX86WinAllocaExpander());
Michael Kuperstein13fbd452015-02-01 16:56:04 +0000383}
384
Matthias Braun7e37a5f2014-12-11 21:26:47 +0000385void X86PassConfig::addPostRegAlloc() {
Rafael Espindola01c73612014-12-11 20:03:57 +0000386 addPass(createX86FloatingPointStackifierPass());
Rafael Espindola01c73612014-12-11 20:03:57 +0000387}
Bruno Cardoso Lopes2a3ffb52011-08-23 01:14:17 +0000388
Quentin Colombet494eb602015-05-22 18:10:47 +0000389void X86PassConfig::addPreSched2() { addPass(createX86ExpandPseudoPass()); }
390
Matthias Braun7e37a5f2014-12-11 21:26:47 +0000391void X86PassConfig::addPreEmitPass() {
Eric Christopher24f3f652015-02-05 19:27:04 +0000392 if (getOptLevel() != CodeGenOpt::None)
Craig Topperf4151be2016-07-22 05:00:52 +0000393 addPass(createExecutionDependencyFixPass(&X86::VR128XRegClass));
Rafael Espindola01c73612014-12-11 20:03:57 +0000394
Matthias Braun7e37a5f2014-12-11 21:26:47 +0000395 if (UseVZeroUpper)
Matthias Braunb2f23882014-12-11 23:18:03 +0000396 addPass(createX86IssueVZeroUpperPass());
Bruno Cardoso Lopes62d79872011-09-15 18:27:32 +0000397
Eric Christopher0d5c99e2014-05-22 01:46:02 +0000398 if (getOptLevel() != CodeGenOpt::None) {
Kevin B. Smith6a833502016-02-11 19:43:04 +0000399 addPass(createX86FixupBWInsts());
Matthias Braunb2f23882014-12-11 23:18:03 +0000400 addPass(createX86PadShortFunctions());
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000401 addPass(createX86FixupLEAs());
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000402 }
Jakob Stoklund Olesen49e121d2010-03-25 17:25:00 +0000403}