Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 1 | //===- BasicTargetTransformInfo.cpp - Basic target-independent TTI impl ---===// |
| 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 | /// \file |
| 10 | /// This file provides the implementation of a basic TargetTransformInfo pass |
| 11 | /// predicated on the target abstractions present in the target independent |
| 12 | /// code generator. It uses these (primarily TargetLowering) to model as much |
| 13 | /// of the TTI query interface as possible. It is included by most targets so |
| 14 | /// that they can specialize only a small subset of the query space. |
| 15 | /// |
| 16 | //===----------------------------------------------------------------------===// |
| 17 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame] | 18 | #include "llvm/CodeGen/BasicTTIImpl.h" |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/Passes.h" |
Hal Finkel | 6532c20 | 2014-05-08 09:14:44 +0000 | [diff] [blame] | 20 | #include "llvm/Analysis/LoopInfo.h" |
Chandler Carruth | d3e7355 | 2013-01-07 03:08:10 +0000 | [diff] [blame] | 21 | #include "llvm/Analysis/TargetTransformInfo.h" |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame] | 22 | #include "llvm/Analysis/TargetTransformInfoImpl.h" |
Hal Finkel | 6532c20 | 2014-05-08 09:14:44 +0000 | [diff] [blame] | 23 | #include "llvm/Support/CommandLine.h" |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 24 | #include <utility> |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 25 | using namespace llvm; |
| 26 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame] | 27 | cl::opt<unsigned> |
| 28 | llvm::PartialUnrollingThreshold("partial-unrolling-threshold", cl::init(0), |
| 29 | cl::desc("Threshold for partial unrolling"), |
| 30 | cl::Hidden); |
Hal Finkel | 6532c20 | 2014-05-08 09:14:44 +0000 | [diff] [blame] | 31 | |
Chandler Carruth | 1b9dde0 | 2014-04-22 02:02:50 +0000 | [diff] [blame] | 32 | #define DEBUG_TYPE "basictti" |
| 33 | |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 34 | namespace { |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame] | 35 | class BasicTTIImpl : public BasicTTIImplBase<BasicTTIImpl> { |
| 36 | typedef BasicTTIImplBase<BasicTTIImpl> BaseT; |
Bill Wendling | afc1036 | 2013-06-19 20:51:24 +0000 | [diff] [blame] | 37 | |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 38 | public: |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame] | 39 | explicit BasicTTIImpl(const TargetMachine *TM = nullptr) : BaseT(TM) {} |
| 40 | |
| 41 | // Provide value semantics. MSVC requires that we spell all of these out. |
| 42 | BasicTTIImpl(const BasicTTIImpl &Arg) |
| 43 | : BaseT(static_cast<const BaseT &>(Arg)) {} |
| 44 | BasicTTIImpl(BasicTTIImpl &&Arg) |
| 45 | : BaseT(std::move(static_cast<BaseT &>(Arg))) {} |
| 46 | BasicTTIImpl &operator=(const BasicTTIImpl &RHS) { |
| 47 | BaseT::operator=(static_cast<const BaseT &>(RHS)); |
| 48 | return *this; |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 49 | } |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame] | 50 | BasicTTIImpl &operator=(BasicTTIImpl &&RHS) { |
| 51 | BaseT::operator=(std::move(static_cast<BaseT &>(RHS))); |
| 52 | return *this; |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 53 | } |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 54 | }; |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 55 | } |
| 56 | |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 57 | ImmutablePass * |
Bill Wendling | afc1036 | 2013-06-19 20:51:24 +0000 | [diff] [blame] | 58 | llvm::createBasicTargetTransformInfoPass(const TargetMachine *TM) { |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame] | 59 | return new TargetTransformInfoWrapperPass(BasicTTIImpl(TM)); |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 60 | } |
| 61 | |
Hal Finkel | 8f2e700 | 2013-09-11 19:25:43 +0000 | [diff] [blame] | 62 | |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 63 | //===----------------------------------------------------------------------===// |
| 64 | // |
| 65 | // Calls used by the vectorizers. |
| 66 | // |
| 67 | //===----------------------------------------------------------------------===// |
| 68 | |