1 //===-- NVPTXTargetTransformInfo.cpp - NVPTX 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 // NVPTX 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 #include "NVPTXTargetMachine.h"
19 #include "llvm/Analysis/LoopInfo.h"
20 #include "llvm/Analysis/TargetTransformInfo.h"
21 #include "llvm/Analysis/ValueTracking.h"
22 #include "llvm/Support/Debug.h"
23 #include "llvm/Target/CostTable.h"
24 #include "llvm/Target/TargetLowering.h"
27 #define DEBUG_TYPE "NVPTXtti"
29 // Declare the pass initialization routine locally as target-specific passes
30 // don't have a target-wide initialization entry point, and so we rely on the
31 // pass constructor initialization.
33 void initializeNVPTXTTIPass(PassRegistry &);
38 class NVPTXTTI final : public ImmutablePass, public TargetTransformInfo {
40 NVPTXTTI() : ImmutablePass(ID) {
41 llvm_unreachable("This pass cannot be directly constructed");
44 NVPTXTTI(const NVPTXTargetMachine *TM) : ImmutablePass(ID) {
45 initializeNVPTXTTIPass(*PassRegistry::getPassRegistry());
48 void initializePass() override { pushTTIStack(this); }
50 void getAnalysisUsage(AnalysisUsage &AU) const override {
51 TargetTransformInfo::getAnalysisUsage(AU);
54 /// Pass identification.
57 /// Provide necessary pointer adjustments for the two base classes.
58 void *getAdjustedAnalysisPointer(const void *ID) override {
59 if (ID == &TargetTransformInfo::ID)
60 return (TargetTransformInfo *)this;
64 bool hasBranchDivergence() const override;
69 } // end anonymous namespace
71 INITIALIZE_AG_PASS(NVPTXTTI, TargetTransformInfo, "NVPTXtti",
72 "NVPTX Target Transform Info", true, true, false)
73 char NVPTXTTI::ID = 0;
76 llvm::createNVPTXTargetTransformInfoPass(const NVPTXTargetMachine *TM) {
77 return new NVPTXTTI(TM);
80 bool NVPTXTTI::hasBranchDivergence() const { return true; }