57 cl::desc(
"enable coalescing of duplicate branches for PPC"));
60 cl::desc(
"Disable CTR loops for PPC"));
64 cl::desc(
"Disable PPC loop instr form prep"));
72 cl::desc(
"Disable VSX Swap Removal for PPC"));
76 cl::desc(
"Disable machine peepholes for PPC"));
80 cl::desc(
"Enable optimizations on complex GEPs"),
85 cl::desc(
"enable software prefetching on PPC"),
90 cl::desc(
"Add extra TOC register dependencies"),
95 cl::desc(
"Enable the machine combiner pass"),
100 cl::desc(
"Expand eligible cr-logical binary ops to branches"),
104 "ppc-merge-string-pool",
105 cl::desc(
"Merge all of the strings in a module into one pool"),
109 "enable-ppc-gen-scalar-mass",
cl::init(
false),
110 cl::desc(
"Enable lowering math functions to their corresponding MASS "
116 cl::desc(
"Enable the global merge pass"));
121 cl::desc(
"Maximum global merge offset"));
184 }
else if (
T.isOSAIX()) {
185 Ret +=
is64Bit ?
"-Fi64" :
"-Fi32";
203 if (
is64Bit && (
T.isOSAIX() ||
T.isOSLinux()))
204 Ret +=
"-S128-v256:256:256-v512:512:512";
211 std::string FullFS = std::string(FS);
216 FullFS =
"+64bit," + FullFS;
221 if (OL >= CodeGenOptLevel::Default) {
223 FullFS =
"+crbits," + FullFS;
228 if (OL != CodeGenOptLevel::None) {
230 FullFS =
"+invariant-function-descriptors," + FullFS;
232 FullFS =
"+invariant-function-descriptors";
237 FullFS =
"+aix," + FullFS;
247 return std::make_unique<TargetLoweringObjectFileXCOFF>();
249 return std::make_unique<PPC64LinuxTargetObjectFile>();
254 if (
Options.MCOptions.getABIName().starts_with(
"elfv1"))
256 else if (
Options.MCOptions.getABIName().starts_with(
"elfv2"))
260 "Unknown target-abi option!");
262 switch (TT.getArch()) {
266 if (TT.isPPC64ELFv2ABI())
276 std::optional<Reloc::Model> RM) {
308 assert(TT.isOSBinFormatELF() &&
"All remaining PPC OSes are ELF based.");
310 if (TT.isArch32Bit())
313 assert(TT.isArch64Bit() &&
"Unsupported PPC architecture.");
322 std::make_unique<PPCPreRASchedStrategy>(
C) :
323 std::make_unique<GenericScheduler>(
C));
326 if (ST.hasStoreFusion())
339 std::make_unique<PPCPostRASchedStrategy>(
C) :
340 std::make_unique<PostGenericScheduler>(
C),
true);
342 if (ST.hasStoreFusion())
356 std::optional<Reloc::Model> RM,
357 std::optional<CodeModel::Model> CM,
373 Attribute CPUAttr =
F.getFnAttribute(
"target-cpu");
374 Attribute TuneAttr =
F.getFnAttribute(
"tune-cpu");
375 Attribute FSAttr =
F.getFnAttribute(
"target-features");
379 std::string TuneCPU =
389 bool SoftFloat =
F.getFnAttribute(
"use-soft-float").getValueAsBool();
393 FS += FS.empty() ?
"-hard-float" :
",-hard-float";
395 auto &
I = SubtargetMap[CPU + TuneCPU + FS];
401 I = std::make_unique<PPCSubtarget>(
427 if (TM.getOptLevel() != CodeGenOptLevel::None)
432 return getTM<PPCTargetMachine>();
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;
445 bool addIRTranslator()
override;
446 bool addLegalizeMachineIR()
override;
447 bool addRegBankSelect()
override;
448 bool addGlobalInstructionSelect()
override;
463 return new PPCPassConfig(*
this, PM);
466void PPCPassConfig::addIRPasses() {
502bool PPCPassConfig::addPreISel() {
507 : (
TM->getTargetTriple().isOSAIX() &&
524bool PPCPassConfig::addILPOpts() {
533bool PPCPassConfig::addInstSelector() {
546void PPCPassConfig::addMachineSSAOptimization() {
573void PPCPassConfig::addPreRegAlloc() {
581 if (getPPCTargetMachine().isPositionIndependent()) {
596void PPCPassConfig::addPreSched2() {
601void PPCPassConfig::addPreEmitPass() {
609void PPCPassConfig::addPreEmitPass2() {
625 "Unable to determine endianness");
632 return PPCFunctionInfo::create<PPCFunctionInfo>(
Allocator,
F,
STI);
637 "Run PowerPC PreRA specific scheduler",
642 "Run PowerPC PostRA specific scheduler",
646bool PPCPassConfig::addIRTranslator() {
651bool PPCPassConfig::addLegalizeMachineIR() {
656bool PPCPassConfig::addRegBankSelect() {
661bool PPCPassConfig::addGlobalInstructionSelect() {
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
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 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 describes the interface of the MachineFunctionPass responsible for assigning the generic vi...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Target-Independent Code Generator Pass Configuration Options pass.
static std::unique_ptr< TargetLoweringObjectFile > createTLOF()
static bool is64Bit(const char *name)
StringRef getValueAsString() const
Return the attribute's value as a string.
bool isValid() const
Return true if the attribute is any kind of attribute.
Allocate memory in an ever growing pool, as if by bump-pointer.
static const char * getManglingComponent(const Triple &T)
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
bool isLittleEndian() const
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...
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.
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.
std::string str() const
str - Get the contents as an std::string.
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::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.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
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.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
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()
char & MachineSchedulerID
MachineScheduler - This pass schedules machine instructions.
FunctionPass * createPPCTLSDynamicCallPass()
char & PostMachineSchedulerID
PostMachineScheduler - This pass schedules machine instructions postRA.
void initializePPCMergeStringPoolPass(PassRegistry &)
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.
void initializePPCDAGToDAGISelLegacyPass(PassRegistry &)
ModulePass * createPPCGenScalarMASSEntriesPass()
void initializePPCEarlyReturnPass(PassRegistry &)
CodeGenOptLevel
Code generation optimization level.
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.
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 & 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)
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,...