blob: 24a9ef0ef077189a14d480256710cf1f5ddf88dc [file] [log] [blame]
Nate Begeman6cca84e2005-10-16 05:39:50 +00001//===-- PPCTargetMachine.cpp - Define TargetMachine for PowerPC -----------===//
Misha Brukmanb4402432005-04-21 23:30:14 +00002//
Misha Brukmane05203f2004-06-21 16:55:25 +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 Brukmanb4402432005-04-21 23:30:14 +00007//
Misha Brukmane05203f2004-06-21 16:55:25 +00008//===----------------------------------------------------------------------===//
Misha Brukmanb4402432005-04-21 23:30:14 +00009//
Chris Lattner73785d22005-08-15 23:47:04 +000010// Top-level implementation for the PowerPC target.
Misha Brukmane05203f2004-06-21 16:55:25 +000011//
12//===----------------------------------------------------------------------===//
13
Chris Lattner6f3b9542005-10-14 23:59:06 +000014#include "PPCTargetMachine.h"
Craig Topperb25fda92012-03-17 18:46:09 +000015#include "PPC.h"
Chandler Carruthd9903882015-01-14 11:23:27 +000016#include "PPCTargetObjectFile.h"
Chandler Carruth93dcdc42015-01-31 11:17:59 +000017#include "PPCTargetTransformInfo.h"
Andrew Trickccb67362012-02-03 05:12:41 +000018#include "llvm/CodeGen/Passes.h"
Eric Christopher3faf2f12014-10-06 06:45:36 +000019#include "llvm/IR/Function.h"
Chandler Carruth30d69c22015-02-13 10:01:29 +000020#include "llvm/IR/LegacyPassManager.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000021#include "llvm/MC/MCStreamer.h"
Hal Finkel96c2d4d2012-06-08 15:38:21 +000022#include "llvm/Support/CommandLine.h"
David Greenea31f96c2009-07-14 20:18:05 +000023#include "llvm/Support/FormattedStream.h"
Evan Cheng2bb40352011-08-24 18:08:43 +000024#include "llvm/Support/TargetRegistry.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000025#include "llvm/Target/TargetOptions.h"
Hal Finkelf413be12014-11-21 04:35:51 +000026#include "llvm/Transforms/Scalar.h"
Misha Brukmane05203f2004-06-21 16:55:25 +000027using namespace llvm;
28
Hal Finkel96c2d4d2012-06-08 15:38:21 +000029static cl::
Hal Finkelc6b5deb2012-06-08 19:19:53 +000030opt<bool> DisableCTRLoops("disable-ppc-ctrloops", cl::Hidden,
31 cl::desc("Disable CTR loops for PPC"));
Hal Finkel96c2d4d2012-06-08 15:38:21 +000032
Hal Finkelc9dd0202015-02-05 18:43:00 +000033static cl::
34opt<bool> DisablePreIncPrep("disable-ppc-preinc-prep", cl::Hidden,
35 cl::desc("Disable PPC loop preinc prep"));
36
Hal Finkel174e5902014-03-25 23:29:21 +000037static cl::opt<bool>
38VSXFMAMutateEarly("schedule-ppc-vsx-fma-mutation-early",
39 cl::Hidden, cl::desc("Schedule VSX FMA instruction mutation early"));
40
Bill Schmidtfe723b92015-04-27 19:57:34 +000041static cl::
42opt<bool> DisableVSXSwapRemoval("disable-ppc-vsx-swap-removal", cl::Hidden,
43 cl::desc("Disable VSX Swap Removal for PPC"));
44
Bill Schmidt34af5e12015-11-10 21:38:26 +000045static cl::
46opt<bool> DisableMIPeephole("disable-ppc-peephole", cl::Hidden,
47 cl::desc("Disable machine peepholes for PPC"));
48
Hal Finkelf413be12014-11-21 04:35:51 +000049static cl::opt<bool>
50EnableGEPOpt("ppc-gep-opt", cl::Hidden,
51 cl::desc("Enable optimizations on complex GEPs"),
52 cl::init(true));
53
Hal Finkele5aaf3f2015-02-20 05:08:21 +000054static cl::opt<bool>
55EnablePrefetch("enable-ppc-prefetching",
56 cl::desc("disable software prefetching on PPC"),
57 cl::init(false), cl::Hidden);
58
Hal Finkel8340de12015-05-18 06:25:59 +000059static cl::opt<bool>
60EnableExtraTOCRegDeps("enable-ppc-extra-toc-reg-deps",
61 cl::desc("Add extra TOC register dependencies"),
62 cl::init(true), cl::Hidden);
63
Hal Finkel5d36b232015-07-15 08:23:05 +000064static cl::opt<bool>
65EnableMachineCombinerPass("ppc-machine-combiner",
66 cl::desc("Enable the machine combiner pass"),
67 cl::init(true), cl::Hidden);
68
Daniel Dunbar5680b4f2009-07-25 06:49:55 +000069extern "C" void LLVMInitializePowerPCTarget() {
70 // Register the targets
Andrew Trick808a7a62012-02-03 05:12:30 +000071 RegisterTargetMachine<PPC32TargetMachine> A(ThePPC32Target);
Daniel Dunbar5680b4f2009-07-25 06:49:55 +000072 RegisterTargetMachine<PPC64TargetMachine> B(ThePPC64Target);
Bill Schmidt0a9170d2013-07-26 01:35:43 +000073 RegisterTargetMachine<PPC64TargetMachine> C(ThePPC64LETarget);
Daniel Dunbar5680b4f2009-07-25 06:49:55 +000074}
Douglas Gregor1b731d52009-06-16 20:12:29 +000075
Eric Christopher8b770652015-01-26 19:03:15 +000076/// Return the datalayout string of a subtarget.
77static std::string getDataLayoutString(const Triple &T) {
78 bool is64Bit = T.getArch() == Triple::ppc64 || T.getArch() == Triple::ppc64le;
79 std::string Ret;
80
81 // Most PPC* platforms are big endian, PPC64LE is little endian.
82 if (T.getArch() == Triple::ppc64le)
83 Ret = "e";
84 else
85 Ret = "E";
86
87 Ret += DataLayout::getManglingComponent(T);
88
89 // PPC32 has 32 bit pointers. The PS3 (OS Lv2) is a PPC64 machine with 32 bit
90 // pointers.
91 if (!is64Bit || T.getOS() == Triple::Lv2)
92 Ret += "-p:32:32";
93
94 // Note, the alignment values for f64 and i64 on ppc64 in Darwin
95 // documentation are wrong; these are correct (i.e. "what gcc does").
96 if (is64Bit || !T.isOSDarwin())
97 Ret += "-i64:64";
98 else
99 Ret += "-f64:32:64";
100
101 // PPC64 has 32 and 64 bit registers, PPC32 has only 32 bit ones.
102 if (is64Bit)
103 Ret += "-n32:64";
104 else
105 Ret += "-n32";
106
107 return Ret;
108}
109
Daniel Sanders335487a2015-06-16 13:15:50 +0000110static std::string computeFSAdditions(StringRef FS, CodeGenOpt::Level OL,
111 const Triple &TT) {
Eric Christopher36448af2014-10-01 20:38:26 +0000112 std::string FullFS = FS;
Eric Christopher36448af2014-10-01 20:38:26 +0000113
114 // Make sure 64-bit features are available when CPUname is generic
Daniel Sanders335487a2015-06-16 13:15:50 +0000115 if (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le) {
Eric Christopher36448af2014-10-01 20:38:26 +0000116 if (!FullFS.empty())
117 FullFS = "+64bit," + FullFS;
118 else
119 FullFS = "+64bit";
120 }
121
122 if (OL >= CodeGenOpt::Default) {
123 if (!FullFS.empty())
124 FullFS = "+crbits," + FullFS;
125 else
126 FullFS = "+crbits";
127 }
Hal Finkele2ab0f12015-01-15 21:17:34 +0000128
129 if (OL != CodeGenOpt::None) {
NAKAMURA Takumi70ad98a2015-09-22 11:13:55 +0000130 if (!FullFS.empty())
Hal Finkele2ab0f12015-01-15 21:17:34 +0000131 FullFS = "+invariant-function-descriptors," + FullFS;
132 else
133 FullFS = "+invariant-function-descriptors";
134 }
135
Eric Christopher36448af2014-10-01 20:38:26 +0000136 return FullFS;
137}
138
Aditya Nandakumara2719322014-11-13 09:26:31 +0000139static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
140 // If it isn't a Mach-O file then it's going to be a linux ELF
141 // object file.
142 if (TT.isOSDarwin())
143 return make_unique<TargetLoweringObjectFileMachO>();
144
145 return make_unique<PPC64LinuxTargetObjectFile>();
146}
147
Eric Christopherfee6aaf2015-02-17 06:45:15 +0000148static PPCTargetMachine::PPCABI computeTargetABI(const Triple &TT,
149 const TargetOptions &Options) {
150 if (Options.MCOptions.getABIName().startswith("elfv1"))
151 return PPCTargetMachine::PPC_ABI_ELFv1;
152 else if (Options.MCOptions.getABIName().startswith("elfv2"))
153 return PPCTargetMachine::PPC_ABI_ELFv2;
154
155 assert(Options.MCOptions.getABIName().empty() &&
NAKAMURA Takumi0a7d0ad2015-09-22 11:15:07 +0000156 "Unknown target-abi option!");
Eric Christopherfee6aaf2015-02-17 06:45:15 +0000157
158 if (!TT.isMacOSX()) {
159 switch (TT.getArch()) {
160 case Triple::ppc64le:
161 return PPCTargetMachine::PPC_ABI_ELFv2;
162 case Triple::ppc64:
163 return PPCTargetMachine::PPC_ABI_ELFv1;
164 default:
165 // Fallthrough.
166 ;
167 }
168 }
169 return PPCTargetMachine::PPC_ABI_UNKNOWN;
170}
171
NAKAMURA Takumi84965032015-09-22 11:14:12 +0000172// The FeatureString here is a little subtle. We are modifying the feature
173// string with what are (currently) non-function specific overrides as it goes
174// into the LLVMTargetMachine constructor and then using the stored value in the
Eric Christopher36448af2014-10-01 20:38:26 +0000175// Subtarget constructor below it.
Daniel Sanders3e5de882015-06-11 19:41:26 +0000176PPCTargetMachine::PPCTargetMachine(const Target &T, const Triple &TT,
177 StringRef CPU, StringRef FS,
178 const TargetOptions &Options,
Evan Chengefd9b422011-07-20 07:51:56 +0000179 Reloc::Model RM, CodeModel::Model CM,
Eric Christopher3770cf52014-08-09 04:38:56 +0000180 CodeGenOpt::Level OL)
Daniel Sanders3e5de882015-06-11 19:41:26 +0000181 : LLVMTargetMachine(T, getDataLayoutString(TT), TT, CPU,
Daniel Sanders335487a2015-06-16 13:15:50 +0000182 computeFSAdditions(FS, OL, TT), Options, RM, CM, OL),
Daniel Sandersc81f4502015-06-16 15:44:21 +0000183 TLOF(createTLOF(getTargetTriple())),
Hal Finkelcbf08922015-07-12 02:33:57 +0000184 TargetABI(computeTargetABI(TT, Options)),
185 Subtarget(TargetTriple, CPU, computeFSAdditions(FS, OL, TT), *this) {
186
187 // For the estimates, convergence is quadratic, so we essentially double the
188 // number of digits correct after every iteration. For both FRE and FRSQRTE,
189 // the minimum architected relative accuracy is 2^-5. When hasRecipPrec(),
190 // this is 2^-14. IEEE float has 23 digits and double has 52 digits.
191 unsigned RefinementSteps = Subtarget.hasRecipPrec() ? 1 : 3,
192 RefinementSteps64 = RefinementSteps + 1;
193
194 this->Options.Reciprocals.setDefaults("sqrtf", true, RefinementSteps);
195 this->Options.Reciprocals.setDefaults("vec-sqrtf", true, RefinementSteps);
196 this->Options.Reciprocals.setDefaults("divf", true, RefinementSteps);
197 this->Options.Reciprocals.setDefaults("vec-divf", true, RefinementSteps);
198
199 this->Options.Reciprocals.setDefaults("sqrtd", true, RefinementSteps64);
200 this->Options.Reciprocals.setDefaults("vec-sqrtd", true, RefinementSteps64);
201 this->Options.Reciprocals.setDefaults("divd", true, RefinementSteps64);
202 this->Options.Reciprocals.setDefaults("vec-divd", true, RefinementSteps64);
203
Rafael Espindola227144c2013-05-13 01:16:13 +0000204 initAsmInfo();
Nate Begeman6cca84e2005-10-16 05:39:50 +0000205}
206
Reid Kleckner357600e2014-11-20 23:37:18 +0000207PPCTargetMachine::~PPCTargetMachine() {}
208
David Blaikiea379b1812011-12-20 02:50:00 +0000209void PPC32TargetMachine::anchor() { }
210
Daniel Sanders3e5de882015-06-11 19:41:26 +0000211PPC32TargetMachine::PPC32TargetMachine(const Target &T, const Triple &TT,
Evan Chengefd9b422011-07-20 07:51:56 +0000212 StringRef CPU, StringRef FS,
Nick Lewycky50f02cb2011-12-02 22:16:29 +0000213 const TargetOptions &Options,
Evan Chengecb29082011-11-16 08:38:26 +0000214 Reloc::Model RM, CodeModel::Model CM,
215 CodeGenOpt::Level OL)
Daniel Sanders3e5de882015-06-11 19:41:26 +0000216 : PPCTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL) {}
Chris Lattner0c4aa142006-06-16 01:37:27 +0000217
David Blaikiea379b1812011-12-20 02:50:00 +0000218void PPC64TargetMachine::anchor() { }
Chris Lattner0c4aa142006-06-16 01:37:27 +0000219
Daniel Sanders3e5de882015-06-11 19:41:26 +0000220PPC64TargetMachine::PPC64TargetMachine(const Target &T, const Triple &TT,
221 StringRef CPU, StringRef FS,
Nick Lewycky50f02cb2011-12-02 22:16:29 +0000222 const TargetOptions &Options,
Evan Chengecb29082011-11-16 08:38:26 +0000223 Reloc::Model RM, CodeModel::Model CM,
224 CodeGenOpt::Level OL)
Daniel Sanders3e5de882015-06-11 19:41:26 +0000225 : PPCTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL) {}
Chris Lattner0c4aa142006-06-16 01:37:27 +0000226
Eric Christopher3faf2f12014-10-06 06:45:36 +0000227const PPCSubtarget *
228PPCTargetMachine::getSubtargetImpl(const Function &F) const {
Duncan P. N. Exon Smith5bedaf932015-02-14 02:54:07 +0000229 Attribute CPUAttr = F.getFnAttribute("target-cpu");
230 Attribute FSAttr = F.getFnAttribute("target-features");
Eric Christopher3faf2f12014-10-06 06:45:36 +0000231
232 std::string CPU = !CPUAttr.hasAttribute(Attribute::None)
233 ? CPUAttr.getValueAsString().str()
234 : TargetCPU;
235 std::string FS = !FSAttr.hasAttribute(Attribute::None)
236 ? FSAttr.getValueAsString().str()
237 : TargetFS;
238
239 auto &I = SubtargetMap[CPU + FS];
240 if (!I) {
241 // This needs to be done before we create a new subtarget since any
242 // creation will depend on the TM and the code generation flags on the
243 // function that reside in TargetOptions.
244 resetTargetOptions(F);
Eric Christophered1042b2015-03-26 00:50:23 +0000245 I = llvm::make_unique<PPCSubtarget>(
Daniel Sandersc81f4502015-06-16 15:44:21 +0000246 TargetTriple, CPU,
Eric Christophered1042b2015-03-26 00:50:23 +0000247 // FIXME: It would be good to have the subtarget additions here
248 // not necessary. Anything that turns them on/off (overrides) ends
249 // up being put at the end of the feature string, but the defaults
250 // shouldn't require adding them. Fixing this means pulling Feature64Bit
251 // out of most of the target cpus in the .td file and making it set only
252 // as part of initialization via the TargetTriple.
253 computeFSAdditions(FS, getOptLevel(), getTargetTriple()), *this);
Eric Christopher3faf2f12014-10-06 06:45:36 +0000254 }
255 return I.get();
256}
Misha Brukmanb4402432005-04-21 23:30:14 +0000257
Chris Lattner12e97302006-09-04 04:14:57 +0000258//===----------------------------------------------------------------------===//
259// Pass Pipeline Configuration
260//===----------------------------------------------------------------------===//
Nate Begemanf17ea0f2004-08-11 07:40:04 +0000261
Andrew Trickccb67362012-02-03 05:12:41 +0000262namespace {
263/// PPC Code Generator Pass Configuration Options.
264class PPCPassConfig : public TargetPassConfig {
265public:
Andrew Trickf8ea1082012-02-04 02:56:59 +0000266 PPCPassConfig(PPCTargetMachine *TM, PassManagerBase &PM)
267 : TargetPassConfig(TM, PM) {}
Andrew Trickccb67362012-02-03 05:12:41 +0000268
269 PPCTargetMachine &getPPCTargetMachine() const {
270 return getTM<PPCTargetMachine>();
271 }
272
Robin Morisset22129962014-09-23 20:46:49 +0000273 void addIRPasses() override;
Craig Topper0d3fa922014-04-29 07:57:37 +0000274 bool addPreISel() override;
275 bool addILPOpts() override;
276 bool addInstSelector() override;
Bill Schmidtfe723b92015-04-27 19:57:34 +0000277 void addMachineSSAOptimization() override;
Matthias Braun7e37a5f2014-12-11 21:26:47 +0000278 void addPreRegAlloc() override;
279 void addPreSched2() override;
280 void addPreEmitPass() override;
Andrew Trickccb67362012-02-03 05:12:41 +0000281};
282} // namespace
283
Andrew Trickf8ea1082012-02-04 02:56:59 +0000284TargetPassConfig *PPCTargetMachine::createPassConfig(PassManagerBase &PM) {
Hal Finkeleb50c2d2012-06-09 03:14:50 +0000285 return new PPCPassConfig(this, PM);
Andrew Trickccb67362012-02-03 05:12:41 +0000286}
287
Robin Morisset22129962014-09-23 20:46:49 +0000288void PPCPassConfig::addIRPasses() {
289 addPass(createAtomicExpandPass(&getPPCTargetMachine()));
Hal Finkelf413be12014-11-21 04:35:51 +0000290
Hal Finkele5aaf3f2015-02-20 05:08:21 +0000291 // For the BG/Q (or if explicitly requested), add explicit data prefetch
292 // intrinsics.
Daniel Sandersc81f4502015-06-16 15:44:21 +0000293 bool UsePrefetching = TM->getTargetTriple().getVendor() == Triple::BGQ &&
294 getOptLevel() != CodeGenOpt::None;
Hal Finkele5aaf3f2015-02-20 05:08:21 +0000295 if (EnablePrefetch.getNumOccurrences() > 0)
296 UsePrefetching = EnablePrefetch;
297 if (UsePrefetching)
298 addPass(createPPCLoopDataPrefetchPass());
299
Hal Finkelf413be12014-11-21 04:35:51 +0000300 if (TM->getOptLevel() == CodeGenOpt::Aggressive && EnableGEPOpt) {
301 // Call SeparateConstOffsetFromGEP pass to extract constants within indices
302 // and lower a GEP with multiple indices to either arithmetic operations or
303 // multiple GEPs with single index.
304 addPass(createSeparateConstOffsetFromGEPPass(TM, true));
305 // Call EarlyCSE pass to find and remove subexpressions in the lowered
306 // result.
307 addPass(createEarlyCSEPass());
308 // Do loop invariant code motion in case part of the lowered result is
309 // invariant.
310 addPass(createLICMPass());
311 }
312
Robin Morisset22129962014-09-23 20:46:49 +0000313 TargetPassConfig::addIRPasses();
314}
315
Hal Finkel25c19922013-05-15 21:37:41 +0000316bool PPCPassConfig::addPreISel() {
Hal Finkelc9dd0202015-02-05 18:43:00 +0000317 if (!DisablePreIncPrep && getOptLevel() != CodeGenOpt::None)
318 addPass(createPPCLoopPreIncPrepPass(getPPCTargetMachine()));
319
Hal Finkelc6b5deb2012-06-08 19:19:53 +0000320 if (!DisableCTRLoops && getOptLevel() != CodeGenOpt::None)
Hal Finkel25c19922013-05-15 21:37:41 +0000321 addPass(createPPCCTRLoops(getPPCTargetMachine()));
Hal Finkel96c2d4d2012-06-08 15:38:21 +0000322
323 return false;
324}
325
Hal Finkeled6a2852013-04-05 23:29:01 +0000326bool PPCPassConfig::addILPOpts() {
Eric Christopher6b0fcfe2014-05-21 23:40:26 +0000327 addPass(&EarlyIfConverterID);
Hal Finkel5d36b232015-07-15 08:23:05 +0000328
329 if (EnableMachineCombinerPass)
330 addPass(&MachineCombinerID);
331
Eric Christopher6b0fcfe2014-05-21 23:40:26 +0000332 return true;
Hal Finkeled6a2852013-04-05 23:29:01 +0000333}
334
Andrew Trickccb67362012-02-03 05:12:41 +0000335bool PPCPassConfig::addInstSelector() {
Chris Lattnerc6aa8062005-08-17 19:33:30 +0000336 // Install an instruction selector.
Bob Wilsonbbd38dd2012-07-02 19:48:31 +0000337 addPass(createPPCISelDag(getPPCTargetMachine()));
Hal Finkel8ca38842013-05-20 16:08:17 +0000338
339#ifndef NDEBUG
340 if (!DisableCTRLoops && getOptLevel() != CodeGenOpt::None)
341 addPass(createPPCCTRLoopsVerify());
342#endif
343
Eric Christopherd71e4442014-05-22 01:21:35 +0000344 addPass(createPPCVSXCopyPass());
Nate Begemanf17ea0f2004-08-11 07:40:04 +0000345 return false;
346}
347
Bill Schmidtfe723b92015-04-27 19:57:34 +0000348void PPCPassConfig::addMachineSSAOptimization() {
349 TargetPassConfig::addMachineSSAOptimization();
350 // For little endian, remove where possible the vector swap instructions
351 // introduced at code generation to normalize vector element order.
Daniel Sandersc81f4502015-06-16 15:44:21 +0000352 if (TM->getTargetTriple().getArch() == Triple::ppc64le &&
Bill Schmidtfe723b92015-04-27 19:57:34 +0000353 !DisableVSXSwapRemoval)
354 addPass(createPPCVSXSwapRemovalPass());
Bill Schmidt34af5e12015-11-10 21:38:26 +0000355 // Target-specific peephole cleanups performed after instruction
356 // selection.
357 if (!DisableMIPeephole) {
358 addPass(createPPCMIPeepholePass());
359 addPass(&DeadMachineInstructionElimID);
360 }
Bill Schmidtfe723b92015-04-27 19:57:34 +0000361}
362
Matthias Braun7e37a5f2014-12-11 21:26:47 +0000363void PPCPassConfig::addPreRegAlloc() {
Eric Christopherd71e4442014-05-22 01:21:35 +0000364 initializePPCVSXFMAMutatePass(*PassRegistry::getPassRegistry());
365 insertPass(VSXFMAMutateEarly ? &RegisterCoalescerID : &MachineSchedulerID,
366 &PPCVSXFMAMutateID);
Bill Schmidt82f1c772015-02-10 19:09:05 +0000367 if (getPPCTargetMachine().getRelocationModel() == Reloc::PIC_)
368 addPass(createPPCTLSDynamicCallPass());
Hal Finkel8340de12015-05-18 06:25:59 +0000369 if (EnableExtraTOCRegDeps)
370 addPass(createPPCTOCRegDepsPass());
Hal Finkel174e5902014-03-25 23:29:21 +0000371}
372
Matthias Braun7e37a5f2014-12-11 21:26:47 +0000373void PPCPassConfig::addPreSched2() {
Hal Finkel5711eca2013-04-09 22:58:37 +0000374 if (getOptLevel() != CodeGenOpt::None)
375 addPass(&IfConverterID);
Hal Finkel5711eca2013-04-09 22:58:37 +0000376}
377
Matthias Braun7e37a5f2014-12-11 21:26:47 +0000378void PPCPassConfig::addPreEmitPass() {
Hal Finkelb5aa7e52013-04-08 16:24:03 +0000379 if (getOptLevel() != CodeGenOpt::None)
Matthias Braun7e37a5f2014-12-11 21:26:47 +0000380 addPass(createPPCEarlyReturnPass(), false);
Chris Lattner12e97302006-09-04 04:14:57 +0000381 // Must run branch selection immediately preceding the asm printer.
Matthias Braun7e37a5f2014-12-11 21:26:47 +0000382 addPass(createPPCBranchSelectionPass(), false);
Chris Lattner12e97302006-09-04 04:14:57 +0000383}
384
Chandler Carruth8b04c0d2015-02-01 13:20:00 +0000385TargetIRAnalysis PPCTargetMachine::getTargetIRAnalysis() {
Eric Christophera4e5d3c2015-09-16 23:38:13 +0000386 return TargetIRAnalysis([this](const Function &F) {
387 return TargetTransformInfo(PPCTTIImpl(this, F));
388 });
Hal Finkel4e5ca9e2013-01-25 23:05:59 +0000389}