forked from OSchip/llvm-project
[WebAssembly] Basic TargetTransformInfo support for SIMD128.
llvm-svn: 270508
This commit is contained in:
parent
478c1a25fd
commit
73d7a555b9
|
@ -25,3 +25,59 @@ WebAssemblyTTIImpl::getPopcntSupport(unsigned TyWidth) const {
|
|||
assert(isPowerOf2_32(TyWidth) && "Ty width must be power of 2");
|
||||
return TargetTransformInfo::PSK_FastHardware;
|
||||
}
|
||||
|
||||
unsigned WebAssemblyTTIImpl::getNumberOfRegisters(bool Vector) {
|
||||
unsigned Result = BaseT::getNumberOfRegisters(Vector);
|
||||
|
||||
// For SIMD, use at least 16 registers, as a rough guess.
|
||||
if (Vector)
|
||||
Result = std::max(Result, 16u);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
unsigned WebAssemblyTTIImpl::getRegisterBitWidth(bool Vector) {
|
||||
if (Vector && getST()->hasSIMD128())
|
||||
return 128;
|
||||
|
||||
return 64;
|
||||
}
|
||||
|
||||
unsigned WebAssemblyTTIImpl::getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty, TTI::OperandValueKind Opd1Info,
|
||||
TTI::OperandValueKind Opd2Info, TTI::OperandValueProperties Opd1PropInfo,
|
||||
TTI::OperandValueProperties Opd2PropInfo) {
|
||||
|
||||
unsigned Cost = BasicTTIImplBase<WebAssemblyTTIImpl>::getArithmeticInstrCost(
|
||||
Opcode, Ty, Opd1Info, Opd2Info, Opd1PropInfo, Opd2PropInfo);
|
||||
|
||||
if (VectorType *VTy = dyn_cast<VectorType>(Ty)) {
|
||||
switch (Opcode) {
|
||||
case Instruction::LShr:
|
||||
case Instruction::AShr:
|
||||
case Instruction::Shl:
|
||||
// SIMD128's shifts currently only accept a scalar shift count. For each
|
||||
// element, we'll need to extract, op, insert. The following is a rough
|
||||
// approxmation.
|
||||
if (Opd2Info != TTI::OK_UniformValue &&
|
||||
Opd2Info != TTI::OK_UniformConstantValue)
|
||||
Cost = VTy->getNumElements() *
|
||||
(TargetTransformInfo::TCC_Basic +
|
||||
getArithmeticInstrCost(Opcode, VTy->getElementType()) +
|
||||
TargetTransformInfo::TCC_Basic);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return Cost;
|
||||
}
|
||||
|
||||
unsigned WebAssemblyTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
|
||||
unsigned Index) {
|
||||
unsigned Cost = BasicTTIImplBase::getVectorInstrCost(Opcode, Val, Index);
|
||||
|
||||
// SIMD128's insert/extract currently only take constant indices.
|
||||
if (Index == -1u)
|
||||
return Cost + 25 * TargetTransformInfo::TCC_Expensive;
|
||||
|
||||
return Cost;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,15 @@ public:
|
|||
/// \name Vector TTI Implementations
|
||||
/// @{
|
||||
|
||||
// TODO: Implement Vector TTI for WebAssembly
|
||||
unsigned getNumberOfRegisters(bool Vector);
|
||||
unsigned getRegisterBitWidth(bool Vector);
|
||||
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);
|
||||
unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
|
||||
|
||||
/// @}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue