/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===- HexagonTargetTransformInfo.cpp - Hexagon 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 | | /// \file |
9 | | /// This file implements a TargetTransformInfo analysis pass specific to the |
10 | | /// Hexagon target machine. It uses the target's detailed information to provide |
11 | | /// more precise answers to certain TTI queries, while letting the target |
12 | | /// independent and default TTI implementations handle the rest. |
13 | | /// |
14 | | //===----------------------------------------------------------------------===// |
15 | | |
16 | | #include "HexagonTargetTransformInfo.h" |
17 | | #include "HexagonSubtarget.h" |
18 | | #include "llvm/Analysis/TargetTransformInfo.h" |
19 | | #include "llvm/IR/InstrTypes.h" |
20 | | #include "llvm/IR/Instructions.h" |
21 | | #include "llvm/IR/User.h" |
22 | | #include "llvm/Support/Casting.h" |
23 | | #include "llvm/Support/CommandLine.h" |
24 | | |
25 | | using namespace llvm; |
26 | | |
27 | | #define DEBUG_TYPE "hexagontti" |
28 | | |
29 | | static cl::opt<bool> EmitLookupTables("hexagon-emit-lookup-tables", |
30 | | cl::init(true), cl::Hidden, |
31 | | cl::desc("Control lookup table emission on Hexagon target")); |
32 | | |
33 | | TargetTransformInfo::PopcntSupportKind |
34 | 0 | HexagonTTIImpl::getPopcntSupport(unsigned IntTyWidthInBit) const { |
35 | 0 | // Return Fast Hardware support as every input < 64 bits will be promoted |
36 | 0 | // to 64 bits. |
37 | 0 | return TargetTransformInfo::PSK_FastHardware; |
38 | 0 | } |
39 | | |
40 | | // The Hexagon target can unroll loops with run-time trip counts. |
41 | | void HexagonTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE, |
42 | 0 | TTI::UnrollingPreferences &UP) { |
43 | 0 | UP.Runtime = UP.Partial = true; |
44 | 0 | } |
45 | | |
46 | 5.38k | unsigned HexagonTTIImpl::getNumberOfRegisters(bool vector) const { |
47 | 5.38k | return vector ? 015 : 325.36k ; |
48 | 5.38k | } |
49 | | |
50 | 2 | unsigned HexagonTTIImpl::getPrefetchDistance() const { |
51 | 2 | return getST()->getL1PrefetchDistance(); |
52 | 2 | } |
53 | | |
54 | 0 | unsigned HexagonTTIImpl::getCacheLineSize() const { |
55 | 0 | return getST()->getL1CacheLineSize(); |
56 | 0 | } |
57 | | |
58 | | int HexagonTTIImpl::getUserCost(const User *U, |
59 | 50 | ArrayRef<const Value *> Operands) { |
60 | 12 | auto isCastFoldedIntoLoad = [](const CastInst *CI) -> bool { |
61 | 12 | if (!CI->isIntegerCast()) |
62 | 0 | return false; |
63 | 12 | const LoadInst *LI = dyn_cast<const LoadInst>(CI->getOperand(0)); |
64 | 12 | // Technically, this code could allow multiple uses of the load, and |
65 | 12 | // check if all the uses are the same extension operation, but this |
66 | 12 | // should be sufficient for most cases. |
67 | 12 | if (!LI || 12 !LI->hasOneUse()0 ) |
68 | 12 | return false; |
69 | 0 |
|
70 | 0 | // Only extensions from an integer type shorter than 32-bit to i32 |
71 | 0 | // can be folded into the load. |
72 | 0 | unsigned SBW = CI->getSrcTy()->getIntegerBitWidth(); |
73 | 0 | unsigned DBW = CI->getDestTy()->getIntegerBitWidth(); |
74 | 0 | return DBW == 32 && (SBW < DBW); |
75 | 12 | }; |
76 | 50 | |
77 | 50 | if (const CastInst *CI = dyn_cast<const CastInst>(U)) |
78 | 12 | if (12 isCastFoldedIntoLoad(CI)12 ) |
79 | 0 | return TargetTransformInfo::TCC_Free; |
80 | 50 | return BaseT::getUserCost(U, Operands); |
81 | 50 | } |
82 | | |
83 | 6 | bool HexagonTTIImpl::shouldBuildLookupTables() const { |
84 | 6 | return EmitLookupTables; |
85 | 6 | } |