LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AMDGPUTargetTransformInfo.cpp
Go to the documentation of this file.
1 //===-- AMDGPUTargetTransformInfo.cpp - AMDGPU specific TTI pass ---------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // \file
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.
15 //
16 //===----------------------------------------------------------------------===//
17 
18 #define DEBUG_TYPE "AMDGPUtti"
19 #include "AMDGPU.h"
20 #include "AMDGPUTargetMachine.h"
22 #include "llvm/Support/Debug.h"
24 #include "llvm/Target/CostTable.h"
25 using namespace llvm;
26 
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.
30 namespace llvm {
32 }
33 
34 namespace {
35 
36 class AMDGPUTTI : public ImmutablePass, public TargetTransformInfo {
37  const AMDGPUTargetMachine *TM;
38  const AMDGPUSubtarget *ST;
39  const AMDGPUTargetLowering *TLI;
40 
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;
44 
45 public:
46  AMDGPUTTI() : ImmutablePass(ID), TM(0), ST(0), TLI(0) {
47  llvm_unreachable("This pass cannot be directly constructed");
48  }
49 
50  AMDGPUTTI(const AMDGPUTargetMachine *TM)
51  : ImmutablePass(ID), TM(TM), ST(TM->getSubtargetImpl()),
52  TLI(TM->getTargetLowering()) {
54  }
55 
56  virtual void initializePass() { pushTTIStack(this); }
57 
58  virtual void finalizePass() { popTTIStack(); }
59 
60  virtual void getAnalysisUsage(AnalysisUsage &AU) const {
62  }
63 
64  /// Pass identification.
65  static char ID;
66 
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;
71  return this;
72  }
73 
74  virtual bool hasBranchDivergence() const;
75 
76  /// @}
77 };
78 
79 } // end anonymous namespace
80 
81 INITIALIZE_AG_PASS(AMDGPUTTI, TargetTransformInfo, "AMDGPUtti",
82  "AMDGPU Target Transform Info", true, true, false)
83 char AMDGPUTTI::ID = 0;
84 
87  return new AMDGPUTTI(TM);
88 }
89 
90 bool AMDGPUTTI::hasBranchDivergence() const { return true; }
static PassRegistry * getPassRegistry()
Cost tables and simple lookup functions.
ImmutablePass * createAMDGPUTargetTransformInfoPass(const AMDGPUTargetMachine *TM)
Creates an AMDGPU-specific Target Transformation Info pass.
#define llvm_unreachable(msg)
ID
LLVM Calling Convention Representation.
Definition: CallingConv.h:26
void initializeAMDGPUTTIPass(PassRegistry &)
static char ID
Analysis group identification.
The AMDGPU TargetMachine interface definition for hw codgen targets.
#define INITIALIZE_AG_PASS(passName, agName, arg, name, cfg, analysis, def)
Definition: PassSupport.h:268
virtual void getAnalysisUsage(AnalysisUsage &AU) const
All pass subclasses must call TargetTransformInfo::getAnalysisUsage.