#include "AMDGPU.h"
#include "AMDGPUTargetMachine.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/UniformityAnalysis.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstVisitor.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Transforms/Utils/Local.h"
#define DEBUG_TYPE …
usingnamespacellvm;
static cl::opt<bool>
WidenLoads("amdgpu-late-codegenprepare-widen-constant-loads",
cl::desc("Widen sub-dword constant address space loads in "
"AMDGPULateCodeGenPrepare"),
cl::ReallyHidden, cl::init(true));
namespace {
class AMDGPULateCodeGenPrepare
: public InstVisitor<AMDGPULateCodeGenPrepare, bool> { … };
ValueToValueMap;
class LiveRegOptimizer { … };
}
bool AMDGPULateCodeGenPrepare::run(Function &F) { … }
Type *LiveRegOptimizer::calculateConvertType(Type *OriginalType) { … }
Value *LiveRegOptimizer::convertToOptType(Instruction *V,
BasicBlock::iterator &InsertPt) { … }
Value *LiveRegOptimizer::convertFromOptType(Type *ConvertType, Instruction *V,
BasicBlock::iterator &InsertPt,
BasicBlock *InsertBB) { … }
bool LiveRegOptimizer::optimizeLiveType(
Instruction *I, SmallVectorImpl<WeakTrackingVH> &DeadInsts) { … }
bool AMDGPULateCodeGenPrepare::canWidenScalarExtLoad(LoadInst &LI) const { … }
bool AMDGPULateCodeGenPrepare::visitLoadInst(LoadInst &LI) { … }
PreservedAnalyses
AMDGPULateCodeGenPreparePass::run(Function &F, FunctionAnalysisManager &FAM) { … }
class AMDGPULateCodeGenPrepareLegacy : public FunctionPass { … };
bool AMDGPULateCodeGenPrepareLegacy::runOnFunction(Function &F) { … }
INITIALIZE_PASS_BEGIN(AMDGPULateCodeGenPrepareLegacy, DEBUG_TYPE,
"AMDGPU IR late optimizations", false, false)
INITIALIZE_PASS_DEPENDENCY(TargetPassConfig)
INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
INITIALIZE_PASS_DEPENDENCY(UniformityInfoWrapperPass)
INITIALIZE_PASS_END(AMDGPULateCodeGenPrepareLegacy, DEBUG_TYPE,
"AMDGPU IR late optimizations", false, false)
char AMDGPULateCodeGenPrepareLegacy::ID = …;
FunctionPass *llvm::createAMDGPULateCodeGenPrepareLegacyPass() { … }