Reverts r221772 which fails tests
[oota-llvm.git] / lib / Target / NVPTX / NVPTXTargetTransformInfo.cpp
1 //===-- NVPTXTargetTransformInfo.cpp - NVPTX 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 // 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.
15 //
16 //===----------------------------------------------------------------------===//
17
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"
25 using namespace llvm;
26
27 #define DEBUG_TYPE "NVPTXtti"
28
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.
32 namespace llvm {
33 void initializeNVPTXTTIPass(PassRegistry &);
34 }
35
36 namespace {
37
38 class NVPTXTTI final : public ImmutablePass, public TargetTransformInfo {
39 public:
40   NVPTXTTI() : ImmutablePass(ID) {
41     llvm_unreachable("This pass cannot be directly constructed");
42   }
43
44   NVPTXTTI(const NVPTXTargetMachine *TM) : ImmutablePass(ID) {
45     initializeNVPTXTTIPass(*PassRegistry::getPassRegistry());
46   }
47
48   void initializePass() override { pushTTIStack(this); }
49
50   void getAnalysisUsage(AnalysisUsage &AU) const override {
51     TargetTransformInfo::getAnalysisUsage(AU);
52   }
53
54   /// Pass identification.
55   static char ID;
56
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;
61     return this;
62   }
63
64   bool hasBranchDivergence() const override;
65
66   /// @}
67 };
68
69 } // end anonymous namespace
70
71 INITIALIZE_AG_PASS(NVPTXTTI, TargetTransformInfo, "NVPTXtti",
72                    "NVPTX Target Transform Info", true, true, false)
73 char NVPTXTTI::ID = 0;
74
75 ImmutablePass *
76 llvm::createNVPTXTargetTransformInfoPass(const NVPTXTargetMachine *TM) {
77   return new NVPTXTTI(TM);
78 }
79
80 bool NVPTXTTI::hasBranchDivergence() const { return true; }