1 //===-- AMDGPUTargetTransformInfo.cpp - AMDGPU specific TTI pass ---------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 // This file implements a TargetTransformInfo analysis pass specific to the
12 // AMDGPU target machine. It uses the target's detailed information to provide
13 // more precise answers to certain TTI queries, while letting the target
14 // independent and default TTI implementations handle the rest.
16 //===----------------------------------------------------------------------===//
18 #define DEBUG_TYPE "AMDGPUtti"
20 #include "AMDGPUTargetMachine.h"
21 #include "llvm/Analysis/TargetTransformInfo.h"
22 #include "llvm/Support/Debug.h"
23 #include "llvm/Target/CostTable.h"
24 #include "llvm/Target/TargetLowering.h"
27 // Declare the pass initialization routine locally as target-specific passes
28 // don't have a target-wide initialization entry point, and so we rely on the
29 // pass constructor initialization.
31 void initializeAMDGPUTTIPass(PassRegistry &);
36 class AMDGPUTTI : public ImmutablePass, public TargetTransformInfo {
37 const AMDGPUTargetMachine *TM;
38 const AMDGPUSubtarget *ST;
39 const AMDGPUTargetLowering *TLI;
41 /// Estimate the overhead of scalarizing an instruction. Insert and Extract
42 /// are set if the result needs to be inserted and/or extracted from vectors.
43 unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract) const;
46 AMDGPUTTI() : ImmutablePass(ID), TM(0), ST(0), TLI(0) {
47 llvm_unreachable("This pass cannot be directly constructed");
50 AMDGPUTTI(const AMDGPUTargetMachine *TM)
51 : ImmutablePass(ID), TM(TM), ST(TM->getSubtargetImpl()),
52 TLI(TM->getTargetLowering()) {
53 initializeAMDGPUTTIPass(*PassRegistry::getPassRegistry());
56 virtual void initializePass() { pushTTIStack(this); }
58 virtual void finalizePass() { popTTIStack(); }
60 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
61 TargetTransformInfo::getAnalysisUsage(AU);
64 /// Pass identification.
67 /// Provide necessary pointer adjustments for the two base classes.
68 virtual void *getAdjustedAnalysisPointer(const void *ID) {
69 if (ID == &TargetTransformInfo::ID)
70 return (TargetTransformInfo *)this;
74 virtual bool hasBranchDivergence() const;
79 } // end anonymous namespace
81 INITIALIZE_AG_PASS(AMDGPUTTI, TargetTransformInfo, "AMDGPUtti",
82 "AMDGPU Target Transform Info", true, true, false)
83 char AMDGPUTTI::ID = 0;
86 llvm::createAMDGPUTargetTransformInfoPass(const AMDGPUTargetMachine *TM) {
87 return new AMDGPUTTI(TM);
90 bool AMDGPUTTI::hasBranchDivergence() const { return true; }