LLVM  8.0.0svn
WebAssemblyTargetTransformInfo.cpp
Go to the documentation of this file.
1 //===-- WebAssemblyTargetTransformInfo.cpp - WebAssembly-specific TTI -----===//
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 defines the WebAssembly-specific TargetTransformInfo
12 /// implementation.
13 ///
14 //===----------------------------------------------------------------------===//
15 
17 #include "llvm/CodeGen/CostTable.h"
18 #include "llvm/Support/Debug.h"
19 using namespace llvm;
20 
21 #define DEBUG_TYPE "wasmtti"
22 
24 WebAssemblyTTIImpl::getPopcntSupport(unsigned TyWidth) const {
25  assert(isPowerOf2_32(TyWidth) && "Ty width must be power of 2");
27 }
28 
30  unsigned Result = BaseT::getNumberOfRegisters(Vector);
31 
32  // For SIMD, use at least 16 registers, as a rough guess.
33  if (Vector)
34  Result = std::max(Result, 16u);
35 
36  return Result;
37 }
38 
39 unsigned WebAssemblyTTIImpl::getRegisterBitWidth(bool Vector) const {
40  if (Vector && getST()->hasSIMD128())
41  return 128;
42 
43  return 64;
44 }
45 
47  unsigned Opcode, Type *Ty, TTI::OperandValueKind Opd1Info,
50 
52  Opcode, Ty, Opd1Info, Opd2Info, Opd1PropInfo, Opd2PropInfo);
53 
54  if (VectorType *VTy = dyn_cast<VectorType>(Ty)) {
55  switch (Opcode) {
56  case Instruction::LShr:
57  case Instruction::AShr:
58  case Instruction::Shl:
59  // SIMD128's shifts currently only accept a scalar shift count. For each
60  // element, we'll need to extract, op, insert. The following is a rough
61  // approxmation.
62  if (Opd2Info != TTI::OK_UniformValue &&
63  Opd2Info != TTI::OK_UniformConstantValue)
64  Cost = VTy->getNumElements() *
66  getArithmeticInstrCost(Opcode, VTy->getElementType()) +
68  break;
69  }
70  }
71  return Cost;
72 }
73 
74 unsigned WebAssemblyTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
75  unsigned Index) {
76  unsigned Cost = BasicTTIImplBase::getVectorInstrCost(Opcode, Val, Index);
77 
78  // SIMD128's insert/extract currently only take constant indices.
79  if (Index == -1u)
80  return Cost + 25 * TargetTransformInfo::TCC_Expensive;
81 
82  return Cost;
83 }
unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::OperandValueKind Opd1Info=TTI::OK_AnyValue, TTI::OperandValueKind Opd2Info=TTI::OK_AnyValue, TTI::OperandValueProperties Opd1PropInfo=TTI::OP_None, TTI::OperandValueProperties Opd2PropInfo=TTI::OP_None, ArrayRef< const Value *> Args=ArrayRef< const Value *>())
Definition: BasicTTIImpl.h:507
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
Cost tables and simple lookup functions.
unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index)
This file a TargetTransformInfo::Concept conforming object specific to the WebAssembly target machine...
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) 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
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition: MathExtras.h:429
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
OperandValueProperties
Additional properties of an operand&#39;s values.
Class to represent vector types.
Definition: DerivedTypes.h:393
unsigned getRegisterBitWidth(bool Vector) const
unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::OperandValueKind Opd1Info=TTI::OK_AnyValue, TTI::OperandValueKind Opd2Info=TTI::OK_AnyValue, TTI::OperandValueProperties Opd1PropInfo=TTI::OP_None, TTI::OperandValueProperties Opd2PropInfo=TTI::OP_None, ArrayRef< const Value *> Args=ArrayRef< const Value *>())
unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index)
Definition: BasicTTIImpl.h:745
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
The cost of a typical &#39;add&#39; instruction.
OperandValueKind
Additional information about an operand&#39;s possible values.
The cost of a &#39;div&#39; instruction on x86.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.