Go to the documentation of this file.
26 #include "llvm/IR/IntrinsicsNVPTX.h"
47 cl::desc(
"Disable load/store vectorizer"),
52 "disable-nvptx-require-structured-cfg",
53 cl::desc(
"Transitional flag to turn off NVPTX's requirement on preserving "
54 "structured CFG. The requirement should be disabled only when "
55 "unexpected regressions happen."),
61 "Use 32-bit pointers for accessing const/local/shared address spaces."),
100 std::string
Ret =
"e";
104 else if (UseShortPointers)
105 Ret +=
"-p3:32:32-p4:32:32-p5:32:32";
107 Ret +=
"-i64:64-i128:128-v16:16-v32:32-n16:32:64";
137 void NVPTXTargetMachine32::anchor() {}
147 void NVPTXTargetMachine64::anchor() {}
165 return getTM<NVPTXTargetMachine>();
168 void addIRPasses()
override;
169 bool addInstSelector()
override;
170 void addPreRegAlloc()
override;
171 void addPostRegAlloc()
override;
172 void addMachineSSAOptimization()
override;
174 FunctionPass *createTargetRegisterAllocator(
bool)
override;
175 void addFastRegAlloc()
override;
176 void addOptimizedRegAlloc()
override;
178 bool addRegAssignAndRewriteFast()
override {
182 bool addRegAssignAndRewriteOptimized()
override {
189 void addEarlyCSEOrGVNPass();
192 void addAddressSpaceInferencePasses();
195 void addStraightLineScalarOptimizationPasses();
201 return new NVPTXPassConfig(*
this, PM);
221 if (
PassName ==
"nvvm-intr-range") {
244 std::pair<const Value *, unsigned>
246 if (
auto *II = dyn_cast<IntrinsicInst>(V)) {
247 switch (II->getIntrinsicID()) {
248 case Intrinsic::nvvm_isspacep_const:
250 case Intrinsic::nvvm_isspacep_global:
252 case Intrinsic::nvvm_isspacep_local:
254 case Intrinsic::nvvm_isspacep_shared:
260 return std::make_pair(
nullptr, -1);
263 void NVPTXPassConfig::addEarlyCSEOrGVNPass() {
270 void NVPTXPassConfig::addAddressSpaceInferencePasses() {
279 void NVPTXPassConfig::addStraightLineScalarOptimizationPasses() {
288 addEarlyCSEOrGVNPass();
296 void NVPTXPassConfig::addIRPasses() {
329 addAddressSpaceInferencePasses();
330 addStraightLineScalarOptimizationPasses();
350 addEarlyCSEOrGVNPass();
357 bool NVPTXPassConfig::addInstSelector() {
364 if (!
ST.hasImageHandles())
370 void NVPTXPassConfig::addPreRegAlloc() {
375 void NVPTXPassConfig::addPostRegAlloc() {
385 FunctionPass *NVPTXPassConfig::createTargetRegisterAllocator(
bool) {
389 void NVPTXPassConfig::addFastRegAlloc() {
394 void NVPTXPassConfig::addOptimizedRegAlloc() {
405 printAndVerify(
"After Machine Scheduling");
413 printAndVerify(
"After StackSlotColoring");
416 void NVPTXPassConfig::addMachineSSAOptimization() {
419 printAndVerify(
"After Pre-RegAlloc TailDuplicate");
438 printAndVerify(
"After codegen DCE pass");
444 printAndVerify(
"After ILP optimizations");
450 printAndVerify(
"After Machine LICM, CSE and Sinking passes");
453 printAndVerify(
"After codegen peephole optimization pass");
char & OptimizePHIsID
OptimizePHIs - This pass optimizes machine instruction PHIs to take advantage of opportunities create...
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createSeparateConstOffsetFromGEPPass(bool LowerGEP=false)
~NVPTXTargetMachine() override
char & PeepholeOptimizerID
PeepholeOptimizer - This pass performs peephole optimizations - like extension and comparison elimina...
void registerPipelineStartEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same< PassT, PassManager >::value > addPass(PassT &&Pass)
char & PHIEliminationID
PHIElimination - This pass eliminates machine instruction PHI nodes by inserting copy instructions.
static bool is64Bit(const char *name)
Target - Wrapper for Target specific information.
void initializeNVPTXAllocaHoistingPass(PassRegistry &)
Triple - Helper class for working with autoconf configuration names.
unsigned int getSmVersion() const
FunctionPass * createEarlyCSEPass(bool UseMemorySSA=false)
MachineFunctionPass * createNVPTXReplaceImageHandlesPass()
NVPTXTargetMachine32(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM, CodeGenOpt::Level OL, bool JIT)
static cl::opt< bool > UseShortPointersOpt("nvptx-short-ptr", cl::desc("Use 32-bit pointers for accessing const/local/shared address spaces."), cl::init(false), cl::Hidden)
void initializeNVPTXProxyRegErasurePass(PassRegistry &)
char & LocalStackSlotAllocationID
LocalStackSlotAllocation - This pass assigns local frame indices to stack slots relative to one anoth...
FunctionPass * createGVNPass(bool NoMemDepAnalysis=false)
Create a legacy GVN pass.
FunctionPass * createNVPTXLowerArgsPass(const NVPTXTargetMachine *TM)
char & StackSlotColoringID
StackSlotColoring - This pass performs stack slot coloring.
void initializeNVPTXAtomicLowerPass(PassRegistry &)
char & MachineCopyPropagationID
MachineCopyPropagation - This pass performs copy propagation on machine instructions.
char & TwoAddressInstructionPassID
TwoAddressInstruction - This pass reduces two-address instructions to use two operands.
ModulePass * createNVPTXAssignValidGlobalNamesPass()
TargetTransformInfo getTargetTransformInfo(const Function &F) const override
Get a TargetTransformInfo implementation for the target.
static std::string computeDataLayout(bool is64Bit, bool UseShortPointers)
void initializeNVPTXLowerAllocaPass(PassRegistry &)
char & LiveDebugValuesID
LiveDebugValues pass.
FunctionPass * createInferAddressSpacesPass(unsigned AddressSpace=~0u)
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
char & PrologEpilogCodeInserterID
PrologEpilogCodeInserter - This pass inserts prolog and epilog code, and eliminates abstract frame re...
FunctionPass * createNaryReassociatePass()
void initializeNVPTXLowerAggrCopiesPass(PassRegistry &)
char & FuncletLayoutID
This pass lays out funclets contiguously.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
This class provides access to building LLVM's passes.
FunctionPass * createLowerAggrCopies()
char & RegisterCoalescerID
RegisterCoalescer - This pass merges live ranges to eliminate copies.
void registerPassBuilderCallbacks(PassBuilder &PB) override
Allow the target to modify the pass pipeline with New Pass Manager (similar to adjustPassManager for ...
FunctionPass * createAtomicExpandPass()
AtomicExpandPass - At IR level this pass replace atomic instructions with __atomic_* library calls,...
RegisterTargetMachine - Helper template for registering a target machine implementation,...
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
MachineFunctionPass * createNVPTXPrologEpilogPass()
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
Pass * createLoadStoreVectorizerPass()
Create a legacy pass manager instance of the LoadStoreVectorizer pass.
char & StackMapLivenessID
StackMapLiveness - This pass analyses the register live-out set of stackmap/patchpoint intrinsics and...
FunctionPass * createSpeculativeExecutionPass()
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
FunctionPass * createNVVMIntrRangePass(unsigned int SmVersion)
Target & getTheNVPTXTarget64()
virtual void add(Pass *P)=0
Add a pass to the queue of passes to run.
PassManagerBuilder - This class is used to set up a standard optimization sequence for languages like...
char & EarlyTailDuplicateID
Duplicate blocks with unconditional branches into tails of their predecessors.
PassBuilder PB(Machine, PassOpts->PTO, None, &PIC)
Target-Independent Code Generator Pass Configuration Options.
char & MachineLoopInfoID
MachineLoopInfo - This pass is a loop analysis pass.
ModuleToFunctionPassAdaptor createModuleToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
char & StackColoringID
StackSlotColoring - This pass performs stack coloring and merging.
NVPTXTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM, CodeGenOpt::Level OP, bool is64bit)
void setRequiresStructuredCFG(bool Value)
#define LLVM_EXTERNAL_VISIBILITY
char & MachineSinkingID
MachineSinking - This pass performs sinking on machine instructions.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
FunctionPass * createNVVMReflectPass(unsigned int SmVersion)
std::pair< const Value *, unsigned > getPredicatedAddrSpace(const Value *V) const override
If the specified predicate checks whether a generic pointer falls within a specified address space,...
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
FunctionPass * createNVPTXAtomicLowerPass()
initializer< Ty > init(const Ty &Val)
char & LiveVariablesID
LiveVariables pass - This pass computes the set of blocks in which each variable is life and sets mac...
char & MachineCSEID
MachineCSE - This pass performs global CSE on machine instructions.
char & ProcessImplicitDefsID
ProcessImpicitDefs pass - This pass removes IMPLICIT_DEFs.
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, CGSCCPassManager &, ArrayRef< PipelineElement >)> &C)
{{@ Register pipeline parsing callbacks with this pass builder instance.
char & PatchableFunctionID
This pass implements the "patchable-function" attribute.
FunctionPass * createNVPTXISelDag(NVPTXTargetMachine &TM, llvm::CodeGenOpt::Level OptLevel)
createNVPTXISelDag - This pass converts a legalized DAG into a NVPTX-specific DAG,...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
StringRef - Represent a constant reference to a string, i.e.
Analysis the ScalarEvolution expression for r is this
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
char & ShrinkWrapID
ShrinkWrap pass. Look for the best place to insert save and restore.
void initializeNVVMReflectPass(PassRegistry &)
CodeModel::Model getEffectiveCodeModel(Optional< CodeModel::Model > CM, CodeModel::Model Default)
Helper method for getting the code model, returning Default if CM does not have a value.
static cl::opt< bool > DisableLoadStoreVectorizer("disable-nvptx-load-store-vectorizer", cl::desc("Disable load/store vectorizer"), cl::init(false), cl::Hidden)
void initializeGenericToNVVMPass(PassRegistry &)
NVPTXTargetMachine64(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM, CodeGenOpt::Level OL, bool JIT)
char & TailDuplicateID
TailDuplicate - Duplicate blocks with unconditional branches into tails of their predecessors.
This class describes a target machine that is implemented with the LLVM target-independent code gener...
char & DeadMachineInstructionElimID
DeadMachineInstructionElim - This pass removes dead machine instructions.
FunctionPass * createNVPTXImageOptimizerPass()
char & MachineSchedulerID
MachineScheduler - This pass schedules machine instructions.
static cl::opt< bool > DisableRequireStructuredCFG("disable-nvptx-require-structured-cfg", cl::desc("Transitional flag to turn off NVPTX's requirement on preserving " "structured CFG. The requirement should be disabled only when " "unexpected regressions happen."), cl::init(false), cl::Hidden)
ModulePass * createGenericToNVVMPass()
@ EP_EarlyAsPossible
EP_EarlyAsPossible - This extension point allows adding passes before any other transformations,...
char & PostRASchedulerID
PostRAScheduler - This pass performs post register allocation scheduling.
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeNVPTXTarget()
FunctionPass * createStraightLineStrengthReducePass()
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
void initializeNVPTXLowerArgsPass(PassRegistry &)
MachineFunctionPass * createNVPTXProxyRegErasurePass()
const char LLVMTargetMachineRef TM
FunctionPass class - This class is used to implement most global optimizations.
MachineFunctionPass * createNVPTXPeephole()
char & EarlyMachineLICMID
This pass performs loop invariant code motion on machine instructions.
void adjustPassManager(PassManagerBuilder &) override
Allow the target to modify the pass manager, e.g.
char & PostRAMachineSinkingID
This pass perform post-ra machine sink for COPY instructions.
FunctionPass * createNVPTXLowerAllocaPass()
FunctionPass * createSROAPass()
LLVM Value Representation.
void initializeNVPTXAssignValidGlobalNamesPass(PassRegistry &)
static const char PassName[]
void initializeNVVMIntrRangePass(PassRegistry &)
FunctionPass * createAllocaHoisting()
Target & getTheNVPTXTarget32()