LLVM  6.0.0svn
HexagonTargetTransformInfo.cpp
Go to the documentation of this file.
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 
17 #include "HexagonSubtarget.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"
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 
34 HexagonTTIImpl::getPopcntSupport(unsigned IntTyWidthInBit) const {
35  // Return Fast Hardware support as every input < 64 bits will be promoted
36  // to 64 bits.
38 }
39 
40 // The Hexagon target can unroll loops with run-time trip counts.
43  UP.Runtime = UP.Partial = true;
44 }
45 
46 unsigned HexagonTTIImpl::getNumberOfRegisters(bool vector) const {
47  return vector ? 0 : 32;
48 }
49 
51  return getST()->getL1PrefetchDistance();
52 }
53 
55  return getST()->getL1CacheLineSize();
56 }
57 
59  ArrayRef<const Value *> Operands) {
60  auto isCastFoldedIntoLoad = [](const CastInst *CI) -> bool {
61  if (!CI->isIntegerCast())
62  return false;
63  const LoadInst *LI = dyn_cast<const LoadInst>(CI->getOperand(0));
64  // Technically, this code could allow multiple uses of the load, and
65  // check if all the uses are the same extension operation, but this
66  // should be sufficient for most cases.
67  if (!LI || !LI->hasOneUse())
68  return false;
69 
70  // Only extensions from an integer type shorter than 32-bit to i32
71  // can be folded into the load.
72  unsigned SBW = CI->getSrcTy()->getIntegerBitWidth();
73  unsigned DBW = CI->getDestTy()->getIntegerBitWidth();
74  return DBW == 32 && (SBW < DBW);
75  };
76 
77  if (const CastInst *CI = dyn_cast<const CastInst>(U))
78  if (isCastFoldedIntoLoad(CI))
80  return BaseT::getUserCost(U, Operands);
81 }
82 
84  return EmitLookupTables;
85 }
bool Partial
Allow partial unrolling (unrolling of loops to expand the size of the loop body, not only to eliminat...
int getUserCost(const User *U, ArrayRef< const Value *> Operands)
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
The main scalar evolution driver.
An instruction for reading from memory.
Definition: Instructions.h:164
unsigned getL1CacheLineSize() const
This is the base class for all instructions that perform data casts.
Definition: InstrTypes.h:560
unsigned getL1PrefetchDistance() const
PopcntSupportKind
Flags indicating the kind of support for population count.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
This file implements a TargetTransformInfo analysis pass specific to the Hexagon target machine...
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:406
Expected to fold away in lowering.
unsigned getUserCost(const User *U, ArrayRef< const Value * > Operands)
bool Runtime
Allow runtime unrolling (unrolling of loops to expand the size of the loop body even when the number ...
unsigned getNumberOfRegisters(bool vector) const
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:439
Parameters that control the generic loop unrolling transformation.
static cl::opt< bool > EmitLookupTables("hexagon-emit-lookup-tables", cl::init(true), cl::Hidden, cl::desc("Control lookup table emission on Hexagon target"))
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:323
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP)
bool hasOneUse() const
Return true if there is exactly one user of this value.
Definition: Value.h:414
TTI::PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) const
This pass exposes codegen information to IR-level passes.