LLVM 22.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/StringRef.h"
31#include "llvm/CodeGen/Passes.h"
33#include "llvm/IR/Attributes.h"
34#include "llvm/IR/DataLayout.h"
35#include "llvm/IR/Function.h"
38#include "llvm/Pass.h"
46#include <cassert>
47#include <memory>
48#include <optional>
49#include <string>
50
51using namespace llvm;
52
53
54static cl::opt<bool>
55 EnableBranchCoalescing("enable-ppc-branch-coalesce", cl::Hidden,
56 cl::desc("enable coalescing of duplicate branches for PPC"));
57static cl::
58opt<bool> DisableCTRLoops("disable-ppc-ctrloops", cl::Hidden,
59 cl::desc("Disable CTR loops for PPC"));
60
61static cl::
62opt<bool> DisableInstrFormPrep("disable-ppc-instr-form-prep", cl::Hidden,
63 cl::desc("Disable PPC loop instr form prep"));
64
65static cl::opt<bool>
66VSXFMAMutateEarly("schedule-ppc-vsx-fma-mutation-early",
67 cl::Hidden, cl::desc("Schedule VSX FMA instruction mutation early"));
68
69static cl::
70opt<bool> DisableVSXSwapRemoval("disable-ppc-vsx-swap-removal", cl::Hidden,
71 cl::desc("Disable VSX Swap Removal for PPC"));
72
73static cl::
74opt<bool> DisableMIPeephole("disable-ppc-peephole", cl::Hidden,
75 cl::desc("Disable machine peepholes for PPC"));
76
77static cl::opt<bool>
78EnableGEPOpt("ppc-gep-opt", cl::Hidden,
79 cl::desc("Enable optimizations on complex GEPs"),
80 cl::init(true));
81
82static cl::opt<bool>
83EnablePrefetch("enable-ppc-prefetching",
84 cl::desc("enable software prefetching on PPC"),
85 cl::init(false), cl::Hidden);
86
87static cl::opt<bool>
88EnableExtraTOCRegDeps("enable-ppc-extra-toc-reg-deps",
89 cl::desc("Add extra TOC register dependencies"),
90 cl::init(true), cl::Hidden);
91
92static cl::opt<bool>
93EnableMachineCombinerPass("ppc-machine-combiner",
94 cl::desc("Enable the machine combiner pass"),
95 cl::init(true), cl::Hidden);
96
97static cl::opt<bool>
98 ReduceCRLogical("ppc-reduce-cr-logicals",
99 cl::desc("Expand eligible cr-logical binary ops to branches"),
100 cl::init(true), cl::Hidden);
101
103 "enable-ppc-gen-scalar-mass", cl::init(false),
104 cl::desc("Enable lowering math functions to their corresponding MASS "
105 "(scalar) entries"),
106 cl::Hidden);
107
108static cl::opt<bool>
109 EnableGlobalMerge("ppc-global-merge", cl::Hidden, cl::init(false),
110 cl::desc("Enable the global merge pass"));
111
113 GlobalMergeMaxOffset("ppc-global-merge-max-offset", cl::Hidden,
114 cl::init(0x7fff),
115 cl::desc("Maximum global merge offset"));
116
119 // Register the targets
124
126#ifndef NDEBUG
128#endif
150}
151
152static bool isLittleEndianTriple(const Triple &T) {
153 return T.getArch() == Triple::ppc64le || T.getArch() == Triple::ppcle;
154}
155
156/// Return the datalayout string of a subtarget.
157static std::string getDataLayoutString(const Triple &T) {
158 bool is64Bit = T.getArch() == Triple::ppc64 || T.getArch() == Triple::ppc64le;
159 std::string Ret;
160
161 // Most PPC* platforms are big endian, PPC(64)LE is little endian.
163 Ret = "e";
164 else
165 Ret = "E";
166
168
169 // PPC32 has 32 bit pointers. The PS3 (OS Lv2) is a PPC64 machine with 32 bit
170 // pointers.
171 if (!is64Bit || T.getOS() == Triple::Lv2)
172 Ret += "-p:32:32";
173
174 // If the target ABI uses function descriptors, then the alignment of function
175 // pointers depends on the alignment used to emit the descriptor. Otherwise,
176 // function pointers are aligned to 32 bits because the instructions must be.
177 if ((T.getArch() == Triple::ppc64 && !T.isPPC64ELFv2ABI())) {
178 Ret += "-Fi64";
179 } else if (T.isOSAIX()) {
180 Ret += is64Bit ? "-Fi64" : "-Fi32";
181 } else {
182 Ret += "-Fn32";
183 }
184
185 // Note, the alignment values for f64 and i64 on ppc64 in Darwin
186 // documentation are wrong; these are correct (i.e. "what gcc does").
187 Ret += "-i64:64";
188
189 // PPC64 has 32 and 64 bit registers, PPC32 has only 32 bit ones.
190 if (is64Bit)
191 Ret += "-i128:128-n32:64";
192 else
193 Ret += "-n32";
194
195 // Specify the vector alignment explicitly. For v256i1 and v512i1, the
196 // calculated alignment would be 256*alignment(i1) and 512*alignment(i1),
197 // which is 256 and 512 bytes - way over aligned.
198 if (is64Bit && (T.isOSAIX() || T.isOSLinux()))
199 Ret += "-S128-v256:256:256-v512:512:512";
200
201 return Ret;
202}
203
205 const Triple &TT) {
206 std::string FullFS = std::string(FS);
207
208 // Make sure 64-bit features are available when CPUname is generic
209 if (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le) {
210 if (!FullFS.empty())
211 FullFS = "+64bit," + FullFS;
212 else
213 FullFS = "+64bit";
214 }
215
216 if (OL >= CodeGenOptLevel::Default) {
217 if (!FullFS.empty())
218 FullFS = "+crbits," + FullFS;
219 else
220 FullFS = "+crbits";
221 }
222
223 if (OL != CodeGenOptLevel::None) {
224 if (!FullFS.empty())
225 FullFS = "+invariant-function-descriptors," + FullFS;
226 else
227 FullFS = "+invariant-function-descriptors";
228 }
229
230 if (TT.isOSAIX()) {
231 if (!FullFS.empty())
232 FullFS = "+aix," + FullFS;
233 else
234 FullFS = "+aix";
235 }
236
237 return FullFS;
238}
239
240static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
241 if (TT.isOSAIX())
242 return std::make_unique<TargetLoweringObjectFileXCOFF>();
243
244 return std::make_unique<PPC64LinuxTargetObjectFile>();
245}
246
248 const TargetOptions &Options) {
249 if (Options.MCOptions.getABIName().starts_with("elfv1"))
251 else if (Options.MCOptions.getABIName().starts_with("elfv2"))
253
254 assert(Options.MCOptions.getABIName().empty() &&
255 "Unknown target-abi option!");
256
257 switch (TT.getArch()) {
258 case Triple::ppc64le:
260 case Triple::ppc64:
261 if (TT.isPPC64ELFv2ABI())
263 else
265 default:
267 }
268}
269
271 std::optional<Reloc::Model> RM) {
272 if (TT.isOSAIX() && RM && *RM != Reloc::PIC_)
273 report_fatal_error("invalid relocation model, AIX only supports PIC",
274 false);
275
276 if (RM)
277 return *RM;
278
279 // Big Endian PPC and AIX default to PIC.
280 if (TT.getArch() == Triple::ppc64 || TT.isOSAIX())
281 return Reloc::PIC_;
282
283 // Rest are static by default.
284 return Reloc::Static;
285}
286
287static CodeModel::Model
288getEffectivePPCCodeModel(const Triple &TT, std::optional<CodeModel::Model> CM,
289 bool JIT) {
290 if (CM) {
291 if (*CM == CodeModel::Tiny)
292 report_fatal_error("Target does not support the tiny CodeModel", false);
293 if (*CM == CodeModel::Kernel)
294 report_fatal_error("Target does not support the kernel CodeModel", false);
295 return *CM;
296 }
297
298 if (JIT)
299 return CodeModel::Small;
300 if (TT.isOSAIX())
301 return CodeModel::Small;
302
303 assert(TT.isOSBinFormatELF() && "All remaining PPC OSes are ELF based.");
304
305 if (TT.isArch32Bit())
306 return CodeModel::Small;
307
308 assert(TT.isArch64Bit() && "Unsupported PPC architecture.");
309 return CodeModel::Medium;
310}
311
312
314 const PPCSubtarget &ST = C->MF->getSubtarget<PPCSubtarget>();
315 ScheduleDAGMILive *DAG = ST.usePPCPreRASchedStrategy()
316 ? createSchedLive<PPCPreRASchedStrategy>(C)
317 : createSchedLive<GenericScheduler>(C);
318 // add DAG Mutations here.
319 if (ST.hasStoreFusion())
320 DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
321 if (ST.hasFusion())
322 DAG->addMutation(createPowerPCMacroFusionDAGMutation());
323
324 return DAG;
325}
326
327static ScheduleDAGInstrs *
329 const PPCSubtarget &ST = C->MF->getSubtarget<PPCSubtarget>();
330 ScheduleDAGMI *DAG = ST.usePPCPostRASchedStrategy()
331 ? createSchedPostRA<PPCPostRASchedStrategy>(C)
332 : createSchedPostRA<PostGenericScheduler>(C);
333 // add DAG Mutations here.
334 if (ST.hasStoreFusion())
335 DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
336 if (ST.hasFusion())
337 DAG->addMutation(createPowerPCMacroFusionDAGMutation());
338 return DAG;
339}
340
341// The FeatureString here is a little subtle. We are modifying the feature
342// string with what are (currently) non-function specific overrides as it goes
343// into the CodeGenTargetMachineImpl constructor and then using the stored value
344// in the Subtarget constructor below it.
346 StringRef CPU, StringRef FS,
347 const TargetOptions &Options,
348 std::optional<Reloc::Model> RM,
349 std::optional<CodeModel::Model> CM,
350 CodeGenOptLevel OL, bool JIT)
352 computeFSAdditions(FS, OL, TT), Options,
354 getEffectivePPCCodeModel(TT, CM, JIT), OL),
355 TLOF(createTLOF(getTargetTriple())),
356 TargetABI(computeTargetABI(TT, Options)),
357 Endianness(isLittleEndianTriple(TT) ? Endian::LITTLE : Endian::BIG) {
358 initAsmInfo();
359}
360
362
363const PPCSubtarget *
365 Attribute CPUAttr = F.getFnAttribute("target-cpu");
366 Attribute TuneAttr = F.getFnAttribute("tune-cpu");
367 Attribute FSAttr = F.getFnAttribute("target-features");
368
369 std::string CPU =
370 CPUAttr.isValid() ? CPUAttr.getValueAsString().str() : TargetCPU;
371 std::string TuneCPU =
372 TuneAttr.isValid() ? TuneAttr.getValueAsString().str() : CPU;
373 std::string FS =
374 FSAttr.isValid() ? FSAttr.getValueAsString().str() : TargetFS;
375
376 // FIXME: This is related to the code below to reset the target options,
377 // we need to know whether or not the soft float flag is set on the
378 // function before we can generate a subtarget. We also need to use
379 // it as a key for the subtarget since that can be the only difference
380 // between two functions.
381 bool SoftFloat = F.getFnAttribute("use-soft-float").getValueAsBool();
382 // If the soft float attribute is set on the function turn on the soft float
383 // subtarget feature.
384 if (SoftFloat)
385 FS += FS.empty() ? "-hard-float" : ",-hard-float";
386
387 auto &I = SubtargetMap[CPU + TuneCPU + FS];
388 if (!I) {
389 // This needs to be done before we create a new subtarget since any
390 // creation will depend on the TM and the code generation flags on the
391 // function that reside in TargetOptions.
393 I = std::make_unique<PPCSubtarget>(
394 TargetTriple, CPU, TuneCPU,
395 // FIXME: It would be good to have the subtarget additions here
396 // not necessary. Anything that turns them on/off (overrides) ends
397 // up being put at the end of the feature string, but the defaults
398 // shouldn't require adding them. Fixing this means pulling Feature64Bit
399 // out of most of the target cpus in the .td file and making it set only
400 // as part of initialization via the TargetTriple.
402 }
403 return I.get();
404}
405
409}
410
414}
415
416//===----------------------------------------------------------------------===//
417// Pass Pipeline Configuration
418//===----------------------------------------------------------------------===//
419
420namespace {
421
422/// PPC Code Generator Pass Configuration Options.
423class PPCPassConfig : public TargetPassConfig {
424public:
425 PPCPassConfig(PPCTargetMachine &TM, PassManagerBase &PM)
426 : TargetPassConfig(TM, PM) {
427 // At any optimization level above -O0 we use the Machine Scheduler and not
428 // the default Post RA List Scheduler.
429 if (TM.getOptLevel() != CodeGenOptLevel::None)
430 substitutePass(&PostRASchedulerID, &PostMachineSchedulerID);
431 }
432
433 PPCTargetMachine &getPPCTargetMachine() const {
434 return getTM<PPCTargetMachine>();
435 }
436
437 void addIRPasses() override;
438 bool addPreISel() override;
439 bool addILPOpts() override;
440 bool addInstSelector() override;
441 void addMachineSSAOptimization() override;
442 void addPreRegAlloc() override;
443 void addPreSched2() override;
444 void addPreEmitPass() override;
445 void addPreEmitPass2() override;
446 // GlobalISEL
447 bool addIRTranslator() override;
448 bool addLegalizeMachineIR() override;
449 bool addRegBankSelect() override;
450 bool addGlobalInstructionSelect() override;
451};
452
453} // end anonymous namespace
454
456 return new PPCPassConfig(*this, PM);
457}
458
459void PPCPassConfig::addIRPasses() {
460 if (TM->getOptLevel() != CodeGenOptLevel::None)
461 addPass(createPPCBoolRetToIntPass());
463
464 // Lower generic MASSV routines to PowerPC subtarget-specific entries.
466
467 // Generate PowerPC target-specific entries for scalar math functions
468 // that are available in IBM MASS (scalar) library.
469 if (TM->getOptLevel() == CodeGenOptLevel::Aggressive &&
471 TM->Options.PPCGenScalarMASSEntries = EnablePPCGenScalarMASSEntries;
473 }
474
475 // If explicitly requested, add explicit data prefetch intrinsics.
478
479 if (TM->getOptLevel() >= CodeGenOptLevel::Default && EnableGEPOpt) {
480 // Call SeparateConstOffsetFromGEP pass to extract constants within indices
481 // and lower a GEP with multiple indices to either arithmetic operations or
482 // multiple GEPs with single index.
484 // Call EarlyCSE pass to find and remove subexpressions in the lowered
485 // result.
486 addPass(createEarlyCSEPass());
487 // Do loop invariant code motion in case part of the lowered result is
488 // invariant.
489 addPass(createLICMPass());
490 }
491
493}
494
495bool PPCPassConfig::addPreISel() {
496 // The GlobalMerge pass is intended to be on by default on AIX.
497 // Specifying the command line option overrides the AIX default.
500 : getOptLevel() != CodeGenOptLevel::None)
501 addPass(createGlobalMergePass(TM, GlobalMergeMaxOffset, false, false, true,
502 true));
503
504 if (!DisableInstrFormPrep && getOptLevel() != CodeGenOptLevel::None)
505 addPass(createPPCLoopInstrFormPrepPass(getPPCTargetMachine()));
506
507 if (!DisableCTRLoops && getOptLevel() != CodeGenOptLevel::None)
509
510 return false;
511}
512
513bool PPCPassConfig::addILPOpts() {
514 addPass(&EarlyIfConverterLegacyID);
515
517 addPass(&MachineCombinerID);
518
519 return true;
520}
521
522bool PPCPassConfig::addInstSelector() {
523 // Install an instruction selector.
524 addPass(createPPCISelDag(getPPCTargetMachine(), getOptLevel()));
525
526#ifndef NDEBUG
527 if (!DisableCTRLoops && getOptLevel() != CodeGenOptLevel::None)
528 addPass(createPPCCTRLoopsVerify());
529#endif
530
531 addPass(createPPCVSXWACCCopyPass());
532 return false;
533}
534
535void PPCPassConfig::addMachineSSAOptimization() {
536 // Run CTR loops pass before any cfg modification pass to prevent the
537 // canonical form of hardware loop from being destroied.
538 if (!DisableCTRLoops && getOptLevel() != CodeGenOptLevel::None)
539 addPass(createPPCCTRLoopsPass());
540
541 // PPCBranchCoalescingPass need to be done before machine sinking
542 // since it merges empty blocks.
543 if (EnableBranchCoalescing && getOptLevel() != CodeGenOptLevel::None)
546 // For little endian, remove where possible the vector swap instructions
547 // introduced at code generation to normalize vector element order.
548 if (TM->getTargetTriple().getArch() == Triple::ppc64le &&
551 // Reduce the number of cr-logical ops.
552 if (ReduceCRLogical && getOptLevel() != CodeGenOptLevel::None)
554 // Target-specific peephole cleanups performed after instruction
555 // selection.
556 if (!DisableMIPeephole) {
557 addPass(createPPCMIPeepholePass());
559 }
560}
561
562void PPCPassConfig::addPreRegAlloc() {
563 if (getOptLevel() != CodeGenOptLevel::None) {
567 }
568
569 // FIXME: We probably don't need to run these for -fPIE.
570 if (getPPCTargetMachine().isPositionIndependent()) {
571 // FIXME: LiveVariables should not be necessary here!
572 // PPCTLSDynamicCallPass uses LiveIntervals which previously dependent on
573 // LiveVariables. This (unnecessary) dependency has been removed now,
574 // however a stage-2 clang build fails without LiveVariables computed here.
575 addPass(&LiveVariablesID);
577 }
579 addPass(createPPCTOCRegDepsPass());
580
581 if (getOptLevel() != CodeGenOptLevel::None)
582 addPass(&MachinePipelinerID);
583}
584
585void PPCPassConfig::addPreSched2() {
586 if (getOptLevel() != CodeGenOptLevel::None)
587 addPass(&IfConverterID);
588}
589
590void PPCPassConfig::addPreEmitPass() {
592
593 if (getOptLevel() != CodeGenOptLevel::None)
594 addPass(createPPCEarlyReturnPass());
595}
596
597void PPCPassConfig::addPreEmitPass2() {
598 // Schedule the expansion of AMOs at the last possible moment, avoiding the
599 // possibility for other passes to break the requirements for forward
600 // progress in the LL/SC block.
602 // Must run branch selection immediately preceding the asm printer.
604}
605
608 return TargetTransformInfo(std::make_unique<PPCTTIImpl>(this, F));
609}
610
612 assert(Endianness != Endian::NOT_DETECTED &&
613 "Unable to determine endianness");
614 return Endianness == Endian::LITTLE;
615}
616
618 BumpPtrAllocator &Allocator, const Function &F,
619 const TargetSubtargetInfo *STI) const {
620 return PPCFunctionInfo::create<PPCFunctionInfo>(Allocator, F, STI);
621}
622
625 "Run PowerPC PreRA specific scheduler",
627
630 "Run PowerPC PostRA specific scheduler",
632
633// Global ISEL
634bool PPCPassConfig::addIRTranslator() {
635 addPass(new IRTranslator());
636 return false;
637}
638
639bool PPCPassConfig::addLegalizeMachineIR() {
640 addPass(new Legalizer());
641 return false;
642}
643
644bool PPCPassConfig::addRegBankSelect() {
645 addPass(new RegBankSelect());
646 return false;
647}
648
649bool PPCPassConfig::addGlobalInstructionSelect() {
650 addPass(new InstructionSelect(getOptLevel()));
651 return false;
652}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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_ABI
Definition: Compiler.h:213
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:132
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 > 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)
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCTarget()
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"))
This file a TargetTransformInfoImplBase 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...
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)
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
Definition: Attributes.cpp:400
bool isValid() const
Return true if the attribute is any kind of attribute.
Definition: Attributes.h:223
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:67
implements a set of functionality in the TargetMachine class for targets that make use of the indepen...
static LLVM_ABI const char * getManglingComponent(const Triple &T)
Definition: DataLayout.cpp:175
This pass is responsible for selecting generic machine instructions to target-specific instructions.
MachineSchedRegistry provides a selection of available machine instruction schedulers.
Common code between 32-bit and 64-bit PowerPC targets.
ScheduleDAGInstrs * createPostMachineScheduler(MachineSchedContext *C) const override
Similar to createMachineScheduler but used when postRA machine scheduling is enabled.
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.
ScheduleDAGInstrs * createMachineScheduler(MachineSchedContext *C) const override
Create an instance of ScheduleDAGInstrs to be run within the standard MachineScheduler pass for this ...
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:38
static LLVM_ABI 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:55
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:233
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.
const Triple & getTargetTriple() const
std::string TargetFS
std::string TargetCPU
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:47
int getNumOccurrences() const
Definition: CommandLine.h:400
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
template class LLVM_TEMPLATE_ABI opt< bool >
Definition: CommandLine.cpp:79
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:444
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
FunctionPass * createPPCPreEmitPeepholePass()
Target & getThePPC64LETarget()
void initializePPCTLSDynamicCallPass(PassRegistry &)
FunctionPass * createPPCLoopInstrFormPrepPass(PPCTargetMachine &TM)
void initializePPCVSXFMAMutatePass(PassRegistry &)
void initializePPCLowerMASSVEntriesPass(PassRegistry &)
LLVM_ABI Pass * createGlobalMergePass(const TargetMachine *TM, unsigned MaximalOffset, bool OnlyOptimizeForSize=false, bool MergeExternalByDefault=false, bool MergeConstantByDefault=false, bool MergeConstAggressiveByDefault=false)
GlobalMerge - This pass merges internal (by default) globals into structs to enable reuse of a base p...
LLVM_ABI char & PostRASchedulerID
PostRAScheduler - This pass performs post register allocation scheduling.
Target & getThePPC32Target()
FunctionPass * createPPCCTRLoopsPass()
Definition: PPCCTRLoops.cpp:87
LLVM_ABI char & MachineSchedulerID
MachineScheduler - This pass schedules machine instructions.
FunctionPass * createPPCTLSDynamicCallPass()
LLVM_ABI char & PostMachineSchedulerID
PostMachineScheduler - This pass schedules machine instructions postRA.
LLVM_ABI Pass * createLICMPass()
Definition: LICM.cpp:384
FunctionPass * createPPCEarlyReturnPass()
void initializePPCPreEmitPeepholePass(PassRegistry &)
LLVM_ABI char & EarlyIfConverterLegacyID
EarlyIfConverter - This pass performs if-conversion on SSA form by inserting cmov instructions.
FunctionPass * createPPCExpandAtomicPseudoPass()
void initializePPCTOCRegDepsPass(PassRegistry &)
void initializePPCReduceCRLogicalsPass(PassRegistry &)
LLVM_ABI char & MachineCombinerID
This pass performs instruction combining using trace metrics to estimate critical-path and resource d...
void initializePPCCTRLoopsVerifyPass(PassRegistry &)
FunctionPass * createPPCVSXSwapRemovalPass()
void initializePPCAIXAsmPrinterPass(PassRegistry &)
void initializePPCCTRLoopsPass(PassRegistry &)
ModulePass * createPPCLowerMASSVEntriesPass()
LLVM_ABI 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...
LLVM_ABI FunctionPass * createLoopDataPrefetchPass()
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition: Error.cpp:167
void initializePPCDAGToDAGISelLegacyPass(PassRegistry &)
ModulePass * createPPCGenScalarMASSEntriesPass()
void initializePPCEarlyReturnPass(PassRegistry &)
CodeGenOptLevel
Code generation optimization level.
Definition: CodeGen.h:82
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 &)
LLVM_ABI FunctionPass * createSeparateConstOffsetFromGEPPass(bool LowerGEP=false)
FunctionPass * createPPCBranchCoalescingPass()
createPPCBranchCoalescingPass - returns an instance of the Branch Coalescing Pass
Target & getThePPC64Target()
void initializePPCVSXWACCCopyPass(PassRegistry &)
void initializePPCLinuxAsmPrinterPass(PassRegistry &)
LLVM_ABI void initializeGlobalISel(PassRegistry &)
Initialize all passes linked into the GlobalISel library.
Definition: GlobalISel.cpp:17
void initializePPCBSelPass(PassRegistry &)
LLVM_ABI 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 PPCTargetMachin...
void initializePPCVSXSwapRemovalPass(PassRegistry &)
LLVM_ABI char & LiveVariablesID
LiveVariables pass - This pass computes the set of blocks in which each variable is life and sets mac...
Target & getThePPC32LETarget()
char & PPCVSXFMAMutateID
LLVM_ABI char & IfConverterID
IfConverter - This pass performs machine code if conversion.
void initializePPCLoopInstrFormPrepPass(PassRegistry &)
FunctionPass * createPPCVSXWACCCopyPass()
LLVM_ABI char & TwoAddressInstructionPassID
TwoAddressInstruction - This pass reduces two-address instructions to use two operands.
LLVM_ABI FunctionPass * createAtomicExpandLegacyPass()
AtomicExpandPass - At IR level this pass replace atomic instructions with __atomic_* library calls,...
LLVM_ABI FunctionPass * createEarlyCSEPass(bool UseMemorySSA=false)
Definition: EarlyCSE.cpp:1946
FunctionPass * createPPCBranchSelectionPass()
FunctionPass * createPPCBoolRetToIntPass()
LLVM_ABI char & DeadMachineInstructionElimID
DeadMachineInstructionElim - This pass removes dead machine instructions.
LLVM_ABI FunctionPass * createHardwareLoopsLegacyPass()
Create Hardware Loop pass.
FunctionPass * createPPCMIPeepholePass()
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,...