LLVM 20.0.0git
PPCTargetMachine.cpp
Go to the documentation of this file.
1//===-- PPCTargetMachine.cpp - Define TargetMachine for PowerPC -----------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Top-level implementation for the PowerPC target.
10//
11//===----------------------------------------------------------------------===//
12
13#include "PPCTargetMachine.h"
15#include "PPC.h"
17#include "PPCMachineScheduler.h"
18#include "PPCMacroFusion.h"
19#include "PPCSubtarget.h"
20#include "PPCTargetObjectFile.h"
23#include "llvm/ADT/STLExtras.h"
24#include "llvm/ADT/StringRef.h"
33#include "llvm/CodeGen/Passes.h"
35#include "llvm/IR/Attributes.h"
36#include "llvm/IR/DataLayout.h"
37#include "llvm/IR/Function.h"
40#include "llvm/Pass.h"
47#include <cassert>
48#include <memory>
49#include <optional>
50#include <string>
51
52using namespace llvm;
53
54
55static cl::opt<bool>
56 EnableBranchCoalescing("enable-ppc-branch-coalesce", cl::Hidden,
57 cl::desc("enable coalescing of duplicate branches for PPC"));
58static cl::
59opt<bool> DisableCTRLoops("disable-ppc-ctrloops", cl::Hidden,
60 cl::desc("Disable CTR loops for PPC"));
61
62static cl::
63opt<bool> DisableInstrFormPrep("disable-ppc-instr-form-prep", cl::Hidden,
64 cl::desc("Disable PPC loop instr form prep"));
65
66static cl::opt<bool>
67VSXFMAMutateEarly("schedule-ppc-vsx-fma-mutation-early",
68 cl::Hidden, cl::desc("Schedule VSX FMA instruction mutation early"));
69
70static cl::
71opt<bool> DisableVSXSwapRemoval("disable-ppc-vsx-swap-removal", cl::Hidden,
72 cl::desc("Disable VSX Swap Removal for PPC"));
73
74static cl::
75opt<bool> DisableMIPeephole("disable-ppc-peephole", cl::Hidden,
76 cl::desc("Disable machine peepholes for PPC"));
77
78static cl::opt<bool>
79EnableGEPOpt("ppc-gep-opt", cl::Hidden,
80 cl::desc("Enable optimizations on complex GEPs"),
81 cl::init(true));
82
83static cl::opt<bool>
84EnablePrefetch("enable-ppc-prefetching",
85 cl::desc("enable software prefetching on PPC"),
86 cl::init(false), cl::Hidden);
87
88static cl::opt<bool>
89EnableExtraTOCRegDeps("enable-ppc-extra-toc-reg-deps",
90 cl::desc("Add extra TOC register dependencies"),
91 cl::init(true), cl::Hidden);
92
93static cl::opt<bool>
94EnableMachineCombinerPass("ppc-machine-combiner",
95 cl::desc("Enable the machine combiner pass"),
96 cl::init(true), cl::Hidden);
97
98static cl::opt<bool>
99 ReduceCRLogical("ppc-reduce-cr-logicals",
100 cl::desc("Expand eligible cr-logical binary ops to branches"),
101 cl::init(true), cl::Hidden);
102
104 "ppc-merge-string-pool",
105 cl::desc("Merge all of the strings in a module into one pool"),
106 cl::init(true), cl::Hidden);
107
109 "enable-ppc-gen-scalar-mass", cl::init(false),
110 cl::desc("Enable lowering math functions to their corresponding MASS "
111 "(scalar) entries"),
112 cl::Hidden);
113
114static cl::opt<bool>
115 EnableGlobalMerge("ppc-global-merge", cl::Hidden, cl::init(false),
116 cl::desc("Enable the global merge pass"));
117
119 GlobalMergeMaxOffset("ppc-global-merge-max-offset", cl::Hidden,
120 cl::init(0x7fff),
121 cl::desc("Maximum global merge offset"));
122
124 // Register the targets
129
131#ifndef NDEBUG
133#endif
155}
156
157static bool isLittleEndianTriple(const Triple &T) {
158 return T.getArch() == Triple::ppc64le || T.getArch() == Triple::ppcle;
159}
160
161/// Return the datalayout string of a subtarget.
162static std::string getDataLayoutString(const Triple &T) {
163 bool is64Bit = T.getArch() == Triple::ppc64 || T.getArch() == Triple::ppc64le;
164 std::string Ret;
165
166 // Most PPC* platforms are big endian, PPC(64)LE is little endian.
168 Ret = "e";
169 else
170 Ret = "E";
171
173
174 // PPC32 has 32 bit pointers. The PS3 (OS Lv2) is a PPC64 machine with 32 bit
175 // pointers.
176 if (!is64Bit || T.getOS() == Triple::Lv2)
177 Ret += "-p:32:32";
178
179 // If the target ABI uses function descriptors, then the alignment of function
180 // pointers depends on the alignment used to emit the descriptor. Otherwise,
181 // function pointers are aligned to 32 bits because the instructions must be.
182 if ((T.getArch() == Triple::ppc64 && !T.isPPC64ELFv2ABI())) {
183 Ret += "-Fi64";
184 } else if (T.isOSAIX()) {
185 Ret += is64Bit ? "-Fi64" : "-Fi32";
186 } else {
187 Ret += "-Fn32";
188 }
189
190 // Note, the alignment values for f64 and i64 on ppc64 in Darwin
191 // documentation are wrong; these are correct (i.e. "what gcc does").
192 Ret += "-i64:64";
193
194 // PPC64 has 32 and 64 bit registers, PPC32 has only 32 bit ones.
195 if (is64Bit)
196 Ret += "-n32:64";
197 else
198 Ret += "-n32";
199
200 // Specify the vector alignment explicitly. For v256i1 and v512i1, the
201 // calculated alignment would be 256*alignment(i1) and 512*alignment(i1),
202 // which is 256 and 512 bytes - way over aligned.
203 if (is64Bit && (T.isOSAIX() || T.isOSLinux()))
204 Ret += "-S128-v256:256:256-v512:512:512";
205
206 return Ret;
207}
208
210 const Triple &TT) {
211 std::string FullFS = std::string(FS);
212
213 // Make sure 64-bit features are available when CPUname is generic
214 if (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le) {
215 if (!FullFS.empty())
216 FullFS = "+64bit," + FullFS;
217 else
218 FullFS = "+64bit";
219 }
220
221 if (OL >= CodeGenOptLevel::Default) {
222 if (!FullFS.empty())
223 FullFS = "+crbits," + FullFS;
224 else
225 FullFS = "+crbits";
226 }
227
228 if (OL != CodeGenOptLevel::None) {
229 if (!FullFS.empty())
230 FullFS = "+invariant-function-descriptors," + FullFS;
231 else
232 FullFS = "+invariant-function-descriptors";
233 }
234
235 if (TT.isOSAIX()) {
236 if (!FullFS.empty())
237 FullFS = "+aix," + FullFS;
238 else
239 FullFS = "+aix";
240 }
241
242 return FullFS;
243}
244
245static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
246 if (TT.isOSAIX())
247 return std::make_unique<TargetLoweringObjectFileXCOFF>();
248
249 return std::make_unique<PPC64LinuxTargetObjectFile>();
250}
251
253 const TargetOptions &Options) {
254 if (Options.MCOptions.getABIName().starts_with("elfv1"))
256 else if (Options.MCOptions.getABIName().starts_with("elfv2"))
258
259 assert(Options.MCOptions.getABIName().empty() &&
260 "Unknown target-abi option!");
261
262 switch (TT.getArch()) {
263 case Triple::ppc64le:
265 case Triple::ppc64:
266 if (TT.isPPC64ELFv2ABI())
268 else
270 default:
272 }
273}
274
276 std::optional<Reloc::Model> RM) {
277 if (TT.isOSAIX() && RM && *RM != Reloc::PIC_)
278 report_fatal_error("invalid relocation model, AIX only supports PIC",
279 false);
280
281 if (RM)
282 return *RM;
283
284 // Big Endian PPC and AIX default to PIC.
285 if (TT.getArch() == Triple::ppc64 || TT.isOSAIX())
286 return Reloc::PIC_;
287
288 // Rest are static by default.
289 return Reloc::Static;
290}
291
292static CodeModel::Model
293getEffectivePPCCodeModel(const Triple &TT, std::optional<CodeModel::Model> CM,
294 bool JIT) {
295 if (CM) {
296 if (*CM == CodeModel::Tiny)
297 report_fatal_error("Target does not support the tiny CodeModel", false);
298 if (*CM == CodeModel::Kernel)
299 report_fatal_error("Target does not support the kernel CodeModel", false);
300 return *CM;
301 }
302
303 if (JIT)
304 return CodeModel::Small;
305 if (TT.isOSAIX())
306 return CodeModel::Small;
307
308 assert(TT.isOSBinFormatELF() && "All remaining PPC OSes are ELF based.");
309
310 if (TT.isArch32Bit())
311 return CodeModel::Small;
312
313 assert(TT.isArch64Bit() && "Unsupported PPC architecture.");
314 return CodeModel::Medium;
315}
316
317
319 const PPCSubtarget &ST = C->MF->getSubtarget<PPCSubtarget>();
320 ScheduleDAGMILive *DAG =
321 new ScheduleDAGMILive(C, ST.usePPCPreRASchedStrategy() ?
322 std::make_unique<PPCPreRASchedStrategy>(C) :
323 std::make_unique<GenericScheduler>(C));
324 // add DAG Mutations here.
325 DAG->addMutation(createCopyConstrainDAGMutation(DAG->TII, DAG->TRI));
326 if (ST.hasStoreFusion())
327 DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
328 if (ST.hasFusion())
329 DAG->addMutation(createPowerPCMacroFusionDAGMutation());
330
331 return DAG;
332}
333
336 const PPCSubtarget &ST = C->MF->getSubtarget<PPCSubtarget>();
337 ScheduleDAGMI *DAG =
338 new ScheduleDAGMI(C, ST.usePPCPostRASchedStrategy() ?
339 std::make_unique<PPCPostRASchedStrategy>(C) :
340 std::make_unique<PostGenericScheduler>(C), true);
341 // add DAG Mutations here.
342 if (ST.hasStoreFusion())
343 DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
344 if (ST.hasFusion())
345 DAG->addMutation(createPowerPCMacroFusionDAGMutation());
346 return DAG;
347}
348
349// The FeatureString here is a little subtle. We are modifying the feature
350// string with what are (currently) non-function specific overrides as it goes
351// into the LLVMTargetMachine constructor and then using the stored value in the
352// Subtarget constructor below it.
354 StringRef CPU, StringRef FS,
355 const TargetOptions &Options,
356 std::optional<Reloc::Model> RM,
357 std::optional<CodeModel::Model> CM,
358 CodeGenOptLevel OL, bool JIT)
360 computeFSAdditions(FS, OL, TT), Options,
362 getEffectivePPCCodeModel(TT, CM, JIT), OL),
363 TLOF(createTLOF(getTargetTriple())),
364 TargetABI(computeTargetABI(TT, Options)),
365 Endianness(isLittleEndianTriple(TT) ? Endian::LITTLE : Endian::BIG) {
366 initAsmInfo();
367}
368
370
371const PPCSubtarget *
373 Attribute CPUAttr = F.getFnAttribute("target-cpu");
374 Attribute TuneAttr = F.getFnAttribute("tune-cpu");
375 Attribute FSAttr = F.getFnAttribute("target-features");
376
377 std::string CPU =
378 CPUAttr.isValid() ? CPUAttr.getValueAsString().str() : TargetCPU;
379 std::string TuneCPU =
380 TuneAttr.isValid() ? TuneAttr.getValueAsString().str() : CPU;
381 std::string FS =
382 FSAttr.isValid() ? FSAttr.getValueAsString().str() : TargetFS;
383
384 // FIXME: This is related to the code below to reset the target options,
385 // we need to know whether or not the soft float flag is set on the
386 // function before we can generate a subtarget. We also need to use
387 // it as a key for the subtarget since that can be the only difference
388 // between two functions.
389 bool SoftFloat = F.getFnAttribute("use-soft-float").getValueAsBool();
390 // If the soft float attribute is set on the function turn on the soft float
391 // subtarget feature.
392 if (SoftFloat)
393 FS += FS.empty() ? "-hard-float" : ",-hard-float";
394
395 auto &I = SubtargetMap[CPU + TuneCPU + FS];
396 if (!I) {
397 // This needs to be done before we create a new subtarget since any
398 // creation will depend on the TM and the code generation flags on the
399 // function that reside in TargetOptions.
401 I = std::make_unique<PPCSubtarget>(
402 TargetTriple, CPU, TuneCPU,
403 // FIXME: It would be good to have the subtarget additions here
404 // not necessary. Anything that turns them on/off (overrides) ends
405 // up being put at the end of the feature string, but the defaults
406 // shouldn't require adding them. Fixing this means pulling Feature64Bit
407 // out of most of the target cpus in the .td file and making it set only
408 // as part of initialization via the TargetTriple.
410 }
411 return I.get();
412}
413
414//===----------------------------------------------------------------------===//
415// Pass Pipeline Configuration
416//===----------------------------------------------------------------------===//
417
418namespace {
419
420/// PPC Code Generator Pass Configuration Options.
421class PPCPassConfig : public TargetPassConfig {
422public:
423 PPCPassConfig(PPCTargetMachine &TM, PassManagerBase &PM)
424 : TargetPassConfig(TM, PM) {
425 // At any optimization level above -O0 we use the Machine Scheduler and not
426 // the default Post RA List Scheduler.
427 if (TM.getOptLevel() != CodeGenOptLevel::None)
428 substitutePass(&PostRASchedulerID, &PostMachineSchedulerID);
429 }
430
431 PPCTargetMachine &getPPCTargetMachine() const {
432 return getTM<PPCTargetMachine>();
433 }
434
435 void addIRPasses() override;
436 bool addPreISel() override;
437 bool addILPOpts() override;
438 bool addInstSelector() override;
439 void addMachineSSAOptimization() override;
440 void addPreRegAlloc() override;
441 void addPreSched2() override;
442 void addPreEmitPass() override;
443 void addPreEmitPass2() override;
444 // GlobalISEL
445 bool addIRTranslator() override;
446 bool addLegalizeMachineIR() override;
447 bool addRegBankSelect() override;
448 bool addGlobalInstructionSelect() override;
449
451 createMachineScheduler(MachineSchedContext *C) const override {
453 }
455 createPostMachineScheduler(MachineSchedContext *C) const override {
457 }
458};
459
460} // end anonymous namespace
461
463 return new PPCPassConfig(*this, PM);
464}
465
466void PPCPassConfig::addIRPasses() {
467 if (TM->getOptLevel() != CodeGenOptLevel::None)
468 addPass(createPPCBoolRetToIntPass());
470
471 // Lower generic MASSV routines to PowerPC subtarget-specific entries.
473
474 // Generate PowerPC target-specific entries for scalar math functions
475 // that are available in IBM MASS (scalar) library.
476 if (TM->getOptLevel() == CodeGenOptLevel::Aggressive &&
478 TM->Options.PPCGenScalarMASSEntries = EnablePPCGenScalarMASSEntries;
480 }
481
482 // If explicitly requested, add explicit data prefetch intrinsics.
483 if (EnablePrefetch.getNumOccurrences() > 0)
485
486 if (TM->getOptLevel() >= CodeGenOptLevel::Default && EnableGEPOpt) {
487 // Call SeparateConstOffsetFromGEP pass to extract constants within indices
488 // and lower a GEP with multiple indices to either arithmetic operations or
489 // multiple GEPs with single index.
491 // Call EarlyCSE pass to find and remove subexpressions in the lowered
492 // result.
493 addPass(createEarlyCSEPass());
494 // Do loop invariant code motion in case part of the lowered result is
495 // invariant.
496 addPass(createLICMPass());
497 }
498
500}
501
502bool PPCPassConfig::addPreISel() {
503 // The GlobalMerge pass is intended to be on by default on AIX.
504 // Specifying the command line option overrides the AIX default.
505 if ((EnableGlobalMerge.getNumOccurrences() > 0)
507 : (TM->getTargetTriple().isOSAIX() &&
508 getOptLevel() != CodeGenOptLevel::None))
509 addPass(
510 createGlobalMergePass(TM, GlobalMergeMaxOffset, false, false, true));
511
512 if (MergeStringPool && getOptLevel() != CodeGenOptLevel::None)
514
515 if (!DisableInstrFormPrep && getOptLevel() != CodeGenOptLevel::None)
516 addPass(createPPCLoopInstrFormPrepPass(getPPCTargetMachine()));
517
518 if (!DisableCTRLoops && getOptLevel() != CodeGenOptLevel::None)
520
521 return false;
522}
523
524bool PPCPassConfig::addILPOpts() {
525 addPass(&EarlyIfConverterID);
526
528 addPass(&MachineCombinerID);
529
530 return true;
531}
532
533bool PPCPassConfig::addInstSelector() {
534 // Install an instruction selector.
535 addPass(createPPCISelDag(getPPCTargetMachine(), getOptLevel()));
536
537#ifndef NDEBUG
538 if (!DisableCTRLoops && getOptLevel() != CodeGenOptLevel::None)
539 addPass(createPPCCTRLoopsVerify());
540#endif
541
542 addPass(createPPCVSXCopyPass());
543 return false;
544}
545
546void PPCPassConfig::addMachineSSAOptimization() {
547 // Run CTR loops pass before any cfg modification pass to prevent the
548 // canonical form of hardware loop from being destroied.
549 if (!DisableCTRLoops && getOptLevel() != CodeGenOptLevel::None)
550 addPass(createPPCCTRLoopsPass());
551
552 // PPCBranchCoalescingPass need to be done before machine sinking
553 // since it merges empty blocks.
554 if (EnableBranchCoalescing && getOptLevel() != CodeGenOptLevel::None)
557 // For little endian, remove where possible the vector swap instructions
558 // introduced at code generation to normalize vector element order.
559 if (TM->getTargetTriple().getArch() == Triple::ppc64le &&
562 // Reduce the number of cr-logical ops.
563 if (ReduceCRLogical && getOptLevel() != CodeGenOptLevel::None)
565 // Target-specific peephole cleanups performed after instruction
566 // selection.
567 if (!DisableMIPeephole) {
568 addPass(createPPCMIPeepholePass());
570 }
571}
572
573void PPCPassConfig::addPreRegAlloc() {
574 if (getOptLevel() != CodeGenOptLevel::None) {
578 }
579
580 // FIXME: We probably don't need to run these for -fPIE.
581 if (getPPCTargetMachine().isPositionIndependent()) {
582 // FIXME: LiveVariables should not be necessary here!
583 // PPCTLSDynamicCallPass uses LiveIntervals which previously dependent on
584 // LiveVariables. This (unnecessary) dependency has been removed now,
585 // however a stage-2 clang build fails without LiveVariables computed here.
586 addPass(&LiveVariablesID);
588 }
590 addPass(createPPCTOCRegDepsPass());
591
592 if (getOptLevel() != CodeGenOptLevel::None)
593 addPass(&MachinePipelinerID);
594}
595
596void PPCPassConfig::addPreSched2() {
597 if (getOptLevel() != CodeGenOptLevel::None)
598 addPass(&IfConverterID);
599}
600
601void PPCPassConfig::addPreEmitPass() {
603 addPass(createPPCExpandISELPass());
604
605 if (getOptLevel() != CodeGenOptLevel::None)
606 addPass(createPPCEarlyReturnPass());
607}
608
609void PPCPassConfig::addPreEmitPass2() {
610 // Schedule the expansion of AMOs at the last possible moment, avoiding the
611 // possibility for other passes to break the requirements for forward
612 // progress in the LL/SC block.
614 // Must run branch selection immediately preceding the asm printer.
616}
617
620 return TargetTransformInfo(PPCTTIImpl(this, F));
621}
622
624 assert(Endianness != Endian::NOT_DETECTED &&
625 "Unable to determine endianness");
626 return Endianness == Endian::LITTLE;
627}
628
630 BumpPtrAllocator &Allocator, const Function &F,
631 const TargetSubtargetInfo *STI) const {
632 return PPCFunctionInfo::create<PPCFunctionInfo>(Allocator, F, STI);
633}
634
637 "Run PowerPC PreRA specific scheduler",
639
642 "Run PowerPC PostRA specific scheduler",
644
645// Global ISEL
646bool PPCPassConfig::addIRTranslator() {
647 addPass(new IRTranslator());
648 return false;
649}
650
651bool PPCPassConfig::addLegalizeMachineIR() {
652 addPass(new Legalizer());
653 return false;
654}
655
656bool PPCPassConfig::addRegBankSelect() {
657 addPass(new RegBankSelect());
658 return false;
659}
660
661bool PPCPassConfig::addGlobalInstructionSelect() {
662 addPass(new InstructionSelect(getOptLevel()));
663 return false;
664}
static cl::opt< bool > EnableGEPOpt("aarch64-enable-gep-opt", cl::Hidden, cl::desc("Enable optimizations on complex GEPs"), cl::init(false))
This file contains the simple types necessary to represent the attributes associated with functions a...
static cl::opt< bool > DisableMIPeephole("disable-bpf-peephole", cl::Hidden, cl::desc("Disable machine peepholes for BPF"))
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:131
static cl::opt< unsigned > GlobalMergeMaxOffset("global-merge-max-offset", cl::Hidden, cl::desc("Set maximum offset for global merge pass"), cl::init(0))
static cl::opt< bool > EnableGlobalMerge("enable-global-merge", cl::Hidden, cl::desc("Enable the global merge pass"), cl::init(true))
This file declares the IRTranslator pass.
static LVOptions Options
Definition: LVOptions.cpp:25
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
static cl::opt< bool > MergeStringPool("ppc-merge-string-pool", cl::desc("Merge all of the strings in a module into one pool"), cl::init(true), cl::Hidden)
static cl::opt< bool > VSXFMAMutateEarly("schedule-ppc-vsx-fma-mutation-early", cl::Hidden, cl::desc("Schedule VSX FMA instruction mutation early"))
static cl::opt< bool > EnableMachineCombinerPass("ppc-machine-combiner", cl::desc("Enable the machine combiner pass"), cl::init(true), cl::Hidden)
static bool isLittleEndianTriple(const Triple &T)
static MachineSchedRegistry PPCPostRASchedRegistry("ppc-postra", "Run PowerPC PostRA specific scheduler", createPPCPostMachineScheduler)
static cl::opt< bool > DisableCTRLoops("disable-ppc-ctrloops", cl::Hidden, cl::desc("Disable CTR loops for PPC"))
static cl::opt< bool > DisableMIPeephole("disable-ppc-peephole", cl::Hidden, cl::desc("Disable machine peepholes for PPC"))
static cl::opt< bool > EnableExtraTOCRegDeps("enable-ppc-extra-toc-reg-deps", cl::desc("Add extra TOC register dependencies"), cl::init(true), cl::Hidden)
static PPCTargetMachine::PPCABI computeTargetABI(const Triple &TT, const TargetOptions &Options)
static cl::opt< bool > EnablePrefetch("enable-ppc-prefetching", cl::desc("enable software prefetching on PPC"), cl::init(false), cl::Hidden)
static cl::opt< bool > EnablePPCGenScalarMASSEntries("enable-ppc-gen-scalar-mass", cl::init(false), cl::desc("Enable lowering math functions to their corresponding MASS " "(scalar) entries"), cl::Hidden)
static cl::opt< bool > ReduceCRLogical("ppc-reduce-cr-logicals", cl::desc("Expand eligible cr-logical binary ops to branches"), cl::init(true), cl::Hidden)
static cl::opt< bool > EnableGEPOpt("ppc-gep-opt", cl::Hidden, cl::desc("Enable optimizations on complex GEPs"), cl::init(true))
static ScheduleDAGInstrs * createPPCPostMachineScheduler(MachineSchedContext *C)
static CodeModel::Model getEffectivePPCCodeModel(const Triple &TT, std::optional< CodeModel::Model > CM, bool JIT)
static std::string getDataLayoutString(const Triple &T)
Return the datalayout string of a subtarget.
static cl::opt< bool > DisableInstrFormPrep("disable-ppc-instr-form-prep", cl::Hidden, cl::desc("Disable PPC loop instr form prep"))
static std::string computeFSAdditions(StringRef FS, CodeGenOptLevel OL, const Triple &TT)
static MachineSchedRegistry PPCPreRASchedRegistry("ppc-prera", "Run PowerPC PreRA specific scheduler", createPPCMachineScheduler)
static cl::opt< unsigned > GlobalMergeMaxOffset("ppc-global-merge-max-offset", cl::Hidden, cl::init(0x7fff), cl::desc("Maximum global merge offset"))
static cl::opt< bool > DisableVSXSwapRemoval("disable-ppc-vsx-swap-removal", cl::Hidden, cl::desc("Disable VSX Swap Removal for PPC"))
static Reloc::Model getEffectiveRelocModel(const Triple &TT, std::optional< Reloc::Model > RM)
static cl::opt< bool > EnableBranchCoalescing("enable-ppc-branch-coalesce", cl::Hidden, cl::desc("enable coalescing of duplicate branches for PPC"))
static ScheduleDAGInstrs * createPPCMachineScheduler(MachineSchedContext *C)
static cl::opt< bool > EnableGlobalMerge("ppc-global-merge", cl::Hidden, cl::init(false), cl::desc("Enable the global merge pass"))
LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCTarget()
This file a TargetTransformInfo::Concept conforming object specific to the PPC target machine.
Basic Register Allocator
This file describes the interface of the MachineFunctionPass responsible for assigning the generic vi...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains some templates that are useful if you are working with the STL at all.
Target-Independent Code Generator Pass Configuration Options pass.
This pass exposes codegen information to IR-level passes.
static std::unique_ptr< TargetLoweringObjectFile > createTLOF()
static bool is64Bit(const char *name)
StringRef getValueAsString() const
Return the attribute's value as a string.
Definition: Attributes.cpp:392
bool isValid() const
Return true if the attribute is any kind of attribute.
Definition: Attributes.h:203
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:66
static const char * getManglingComponent(const Triple &T)
Definition: DataLayout.cpp:175
This pass is responsible for selecting generic machine instructions to target-specific instructions.
This class describes a target machine that is implemented with the LLVM target-independent code gener...
MachineSchedRegistry provides a selection of available machine instruction schedulers.
Common code between 32-bit and 64-bit PowerPC targets.
const PPCSubtarget * getSubtargetImpl() const =delete
~PPCTargetMachine() override
PPCTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM, CodeGenOptLevel OL, bool JIT)
TargetTransformInfo getTargetTransformInfo(const Function &F) const override
Get a TargetTransformInfo implementation for the target.
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
MachineFunctionInfo * createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, const TargetSubtargetInfo *STI) const override
Create the target's instance of MachineFunctionInfo.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:37
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This pass implements the reg bank selector pass used in the GlobalISel pipeline.
Definition: RegBankSelect.h:91
A ScheduleDAG for scheduling lists of MachineInstr.
ScheduleDAGMILive is an implementation of ScheduleDAGInstrs that schedules machine instructions while...
ScheduleDAGMI is an implementation of ScheduleDAGInstrs that simply schedules machine instructions ac...
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:215
CodeGenOptLevel getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with.
Definition: TargetMachine.h:96
const Triple & getTargetTriple() const
std::string TargetFS
Definition: TargetMachine.h:98
std::string TargetCPU
Definition: TargetMachine.h:97
std::unique_ptr< const MCSubtargetInfo > STI
void resetTargetOptions(const Function &F) const
Reset the target options based on the function's attributes.
Target-Independent Code Generator Pass Configuration Options.
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
virtual void addMachineSSAOptimization()
addMachineSSAOptimization - Add standard passes that optimize machine instructions in SSA form.
TargetSubtargetInfo - Generic base class for all target subtargets.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
ModulePass * createPPCMergeStringPoolPass()
FunctionPass * createPPCPreEmitPeepholePass()
Target & getThePPC64LETarget()
void initializePPCTLSDynamicCallPass(PassRegistry &)
char & RegisterCoalescerID
RegisterCoalescer - This pass merges live ranges to eliminate copies.
FunctionPass * createPPCLoopInstrFormPrepPass(PPCTargetMachine &TM)
void initializePPCVSXFMAMutatePass(PassRegistry &)
void initializePPCLowerMASSVEntriesPass(PassRegistry &)
char & PostRASchedulerID
PostRAScheduler - This pass performs post register allocation scheduling.
Target & getThePPC32Target()
FunctionPass * createPPCCTRLoopsPass()
Definition: PPCCTRLoops.cpp:93
char & MachineSchedulerID
MachineScheduler - This pass schedules machine instructions.
FunctionPass * createPPCTLSDynamicCallPass()
char & PostMachineSchedulerID
PostMachineScheduler - This pass schedules machine instructions postRA.
void initializePPCMergeStringPoolPass(PassRegistry &)
Pass * createLICMPass()
Definition: LICM.cpp:381
FunctionPass * createPPCEarlyReturnPass()
void initializePPCPreEmitPeepholePass(PassRegistry &)
FunctionPass * createPPCExpandAtomicPseudoPass()
void initializePPCTOCRegDepsPass(PassRegistry &)
void initializePPCReduceCRLogicalsPass(PassRegistry &)
char & MachineCombinerID
This pass performs instruction combining using trace metrics to estimate critical-path and resource d...
void initializePPCVSXCopyPass(PassRegistry &)
FunctionPass * createPPCVSXCopyPass()
void initializePPCCTRLoopsVerifyPass(PassRegistry &)
FunctionPass * createPPCVSXSwapRemovalPass()
void initializePPCCTRLoopsPass(PassRegistry &)
ModulePass * createPPCLowerMASSVEntriesPass()
std::unique_ptr< ScheduleDAGMutation > createStoreClusterDAGMutation(const TargetInstrInfo *TII, const TargetRegisterInfo *TRI, bool ReorderWhileClustering=false)
If ReorderWhileClustering is set to true, no attempt will be made to reduce reordering due to store c...
FunctionPass * createLoopDataPrefetchPass()
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:167
void initializePPCDAGToDAGISelLegacyPass(PassRegistry &)
ModulePass * createPPCGenScalarMASSEntriesPass()
void initializePPCEarlyReturnPass(PassRegistry &)
CodeGenOptLevel
Code generation optimization level.
Definition: CodeGen.h:54
void initializePPCGenScalarMASSEntriesPass(PassRegistry &)
FunctionPass * createPPCReduceCRLogicalsPass()
FunctionPass * createPPCISelDag(PPCTargetMachine &TM, CodeGenOptLevel OL)
createPPCISelDag - This pass converts a legalized DAG into a PowerPC-specific DAG,...
void initializePPCExpandAtomicPseudoPass(PassRegistry &)
FunctionPass * createSeparateConstOffsetFromGEPPass(bool LowerGEP=false)
FunctionPass * createPPCBranchCoalescingPass()
createPPCBranchCoalescingPass - returns an instance of the Branch Coalescing Pass
char & EarlyIfConverterID
EarlyIfConverter - This pass performs if-conversion on SSA form by inserting cmov instructions.
Target & getThePPC64Target()
void initializeGlobalISel(PassRegistry &)
Initialize all passes linked into the GlobalISel library.
Definition: GlobalISel.cpp:17
void initializePPCBSelPass(PassRegistry &)
char & MachinePipelinerID
This pass performs software pipelining on machine instructions.
FunctionPass * createPPCTOCRegDepsPass()
FunctionPass * createPPCCTRLoopsVerify()
void initializePPCBranchCoalescingPass(PassRegistry &)
void initializePPCBoolRetToIntPass(PassRegistry &)
void initializePPCMIPeepholePass(PassRegistry &)
std::unique_ptr< ScheduleDAGMutation > createPowerPCMacroFusionDAGMutation()
Note that you have to add: DAG.addMutation(createPowerPCMacroFusionDAGMutation()); to PPCPassConfig::...
void initializePPCVSXSwapRemovalPass(PassRegistry &)
char & LiveVariablesID
LiveVariables pass - This pass computes the set of blocks in which each variable is life and sets mac...
Target & getThePPC32LETarget()
char & PPCVSXFMAMutateID
char & IfConverterID
IfConverter - This pass performs machine code if conversion.
Pass * createGlobalMergePass(const TargetMachine *TM, unsigned MaximalOffset, bool OnlyOptimizeForSize=false, bool MergeExternalByDefault=false, bool MergeConstantByDefault=false)
GlobalMerge - This pass merges internal (by default) globals into structs to enable reuse of a base p...
void initializePPCLoopInstrFormPrepPass(PassRegistry &)
FunctionPass * createPPCExpandISELPass()
FunctionPass * createAtomicExpandLegacyPass()
AtomicExpandPass - At IR level this pass replace atomic instructions with __atomic_* library calls,...
FunctionPass * createEarlyCSEPass(bool UseMemorySSA=false)
Definition: EarlyCSE.cpp:1932
std::unique_ptr< ScheduleDAGMutation > createCopyConstrainDAGMutation(const TargetInstrInfo *TII, const TargetRegisterInfo *TRI)
FunctionPass * createPPCBranchSelectionPass()
FunctionPass * createPPCBoolRetToIntPass()
char & DeadMachineInstructionElimID
DeadMachineInstructionElim - This pass removes dead machine instructions.
FunctionPass * createHardwareLoopsLegacyPass()
Create Hardware Loop pass.
FunctionPass * createPPCMIPeepholePass()
void initializePPCExpandISELPass(PassRegistry &)
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
MachineSchedContext provides enough context from the MachineScheduler pass for the target to instanti...
RegisterTargetMachine - Helper template for registering a target machine implementation,...