LLVM  5.0.0
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 "llvm/IR/Instructions.h"
18 #include "llvm/Support/Debug.h"
19 
20 using namespace llvm;
21 
22 #define DEBUG_TYPE "hexagontti"
23 
24 static cl::opt<bool> EmitLookupTables("hexagon-emit-lookup-tables",
25  cl::init(true), cl::Hidden,
26  cl::desc("Control lookup table emission on Hexagon target"));
27 
29 HexagonTTIImpl::getPopcntSupport(unsigned IntTyWidthInBit) const {
30  // Return Fast Hardware support as every input < 64 bits will be promoted
31  // to 64 bits.
33 }
34 
35 // The Hexagon target can unroll loops with run-time trip counts.
38  UP.Runtime = UP.Partial = true;
39 }
40 
41 unsigned HexagonTTIImpl::getNumberOfRegisters(bool vector) const {
42  return vector ? 0 : 32;
43 }
44 
46  return getST()->getL1PrefetchDistance();
47 }
48 
50  return getST()->getL1CacheLineSize();
51 }
52 
54  ArrayRef<const Value *> Operands) {
55  auto isCastFoldedIntoLoad = [](const CastInst *CI) -> bool {
56  if (!CI->isIntegerCast())
57  return false;
58  const LoadInst *LI = dyn_cast<const LoadInst>(CI->getOperand(0));
59  // Technically, this code could allow multiple uses of the load, and
60  // check if all the uses are the same extension operation, but this
61  // should be sufficient for most cases.
62  if (!LI || !LI->hasOneUse())
63  return false;
64 
65  // Only extensions from an integer type shorter than 32-bit to i32
66  // can be folded into the load.
67  unsigned SBW = CI->getSrcTy()->getIntegerBitWidth();
68  unsigned DBW = CI->getDestTy()->getIntegerBitWidth();
69  return DBW == 32 && (SBW < DBW);
70  };
71 
72  if (const CastInst *CI = dyn_cast<const CastInst>(U))
73  if (isCastFoldedIntoLoad(CI))
75  return BaseT::getUserCost(U, Operands);
76 }
77 
79  return EmitLookupTables;
80 }
MachineLoop * L
bool Partial
Allow partial unrolling (unrolling of loops to expand the size of the loop body, not only to eliminat...
The main scalar evolution driver.
An instruction for reading from memory.
Definition: Instructions.h:164
This is the base class for all instructions that perform data casts.
Definition: InstrTypes.h:560
unsigned getL1CacheLineSize() 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
unsigned getUserCost(const User *U, ArrayRef< const Value * > Operands)
This file implements a TargetTransformInfo analysis pass specific to the Hexagon target machine...
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:401
Expected to fold away in lowering.
unsigned getL1PrefetchDistance() const
int getUserCost(const User *U, ArrayRef< const Value * > Operands)
unsigned getNumberOfRegisters(bool vector) const
bool Runtime
Allow runtime unrolling (unrolling of loops to expand the size of the loop body even when the number ...
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:360
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"))
bool hasOneUse() const
Return true if there is exactly one user of this value.
Definition: Value.h:408
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)
TTI::PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) const