return *this;
}
+bool HexagonSubtarget::isHVXElementType(MVT Ty, bool IncludeBool) const {
+ if (!useHVXOps())
+ return false;
+ if (Ty.isVector())
+ Ty = Ty.getVectorElementType();
+ if (IncludeBool && Ty == MVT::i1)
+ return true;
+ ArrayRef<MVT> ElemTypes = getHVXElementTypes();
+ return llvm::find(ElemTypes, Ty) != ElemTypes.end();
+}
+
+bool HexagonSubtarget::isHVXVectorType(MVT VecTy, bool IncludeBool) const {
+ if (!VecTy.isVector() || !useHVXOps() || VecTy.isScalableVector())
+ return false;
+ MVT ElemTy = VecTy.getVectorElementType();
+ if (!IncludeBool && ElemTy == MVT::i1)
+ return false;
+
+ unsigned HwLen = getVectorLength();
+ unsigned NumElems = VecTy.getVectorNumElements();
+ ArrayRef<MVT> ElemTypes = getHVXElementTypes();
+
+ if (IncludeBool && ElemTy == MVT::i1) {
+ // Boolean HVX vector types are formed from regular HVX vector types
+ // by replacing the element type with i1.
+ for (MVT T : ElemTypes)
+ if (NumElems * T.getSizeInBits() == 8 * HwLen)
+ return true;
+ return false;
+ }
+
+ unsigned VecWidth = VecTy.getSizeInBits();
+ if (VecWidth != 8 * HwLen && VecWidth != 16 * HwLen)
+ return false;
+ return llvm::find(ElemTypes, ElemTy) != ElemTypes.end();
+}
+
+bool HexagonSubtarget::isTypeForHVX(Type *VecTy, bool IncludeBool) const {
+ if (!VecTy->isVectorTy() || isa<ScalableVectorType>(VecTy))
+ return false;
+ // Avoid types like <2 x i32*>.
+ if (!cast<VectorType>(VecTy)->getElementType()->isIntegerTy())
+ return false;
+ EVT Ty = EVT::getEVT(VecTy, /*HandleUnknown*/false);
+ if (!Ty.isSimple() || Ty.getSizeInBits() <= 64)
+ return false;
+ if (isHVXVectorType(Ty.getSimpleVT(), IncludeBool))
+ return true;
+ auto Action =
+ getTargetLowering()->getPreferredVectorAction(Ty.getSimpleVT());
+ return Action == TargetLoweringBase::TypeWidenVector;
+}
+
void HexagonSubtarget::UsrOverflowMutation::apply(ScheduleDAGInstrs *DAG) {
for (SUnit &SU : DAG->SUnits) {
if (!SU.isInstr())
return makeArrayRef(Types);
}
- bool isHVXElementType(MVT Ty, bool IncludeBool = false) const {
- if (!useHVXOps())
- return false;
- if (Ty.isVector())
- Ty = Ty.getVectorElementType();
- if (IncludeBool && Ty == MVT::i1)
- return true;
- ArrayRef<MVT> ElemTypes = getHVXElementTypes();
- return llvm::find(ElemTypes, Ty) != ElemTypes.end();
- }
-
- bool isHVXVectorType(MVT VecTy, bool IncludeBool = false) const {
- if (!VecTy.isVector() || !useHVXOps() || VecTy.isScalableVector())
- return false;
- MVT ElemTy = VecTy.getVectorElementType();
- if (!IncludeBool && ElemTy == MVT::i1)
- return false;
-
- unsigned HwLen = getVectorLength();
- unsigned NumElems = VecTy.getVectorNumElements();
- ArrayRef<MVT> ElemTypes = getHVXElementTypes();
-
- if (IncludeBool && ElemTy == MVT::i1) {
- // Boolean HVX vector types are formed from regular HVX vector types
- // by replacing the element type with i1.
- for (MVT T : ElemTypes)
- if (NumElems * T.getSizeInBits() == 8*HwLen)
- return true;
- return false;
- }
-
- unsigned VecWidth = VecTy.getSizeInBits();
- if (VecWidth != 8*HwLen && VecWidth != 16*HwLen)
- return false;
- return llvm::find(ElemTypes, ElemTy) != ElemTypes.end();
- }
+ bool isHVXElementType(MVT Ty, bool IncludeBool = false) const;
+ bool isHVXVectorType(MVT VecTy, bool IncludeBool = false) const;
+ bool isTypeForHVX(Type *VecTy, bool IncludeBool = false) const;
unsigned getTypeAlignment(MVT Ty) const {
if (isHVXVectorType(Ty, true))
return ST.useHVXOps() && HexagonAutoHVX;
}
-bool HexagonTTIImpl::isTypeForHVX(Type *VecTy) const {
- if (!VecTy->isVectorTy() || isa<ScalableVectorType>(VecTy))
- return false;
- // Avoid types like <2 x i32*>.
- if (!cast<VectorType>(VecTy)->getElementType()->isIntegerTy())
- return false;
- EVT VecVT = EVT::getEVT(VecTy);
- if (!VecVT.isSimple() || VecVT.getSizeInBits() <= 64)
- return false;
- if (ST.isHVXVectorType(VecVT.getSimpleVT()))
- return true;
- auto Action = TLI.getPreferredVectorAction(VecVT.getSimpleVT());
- return Action == TargetLoweringBase::TypeWidenVector;
-}
-
unsigned HexagonTTIImpl::getTypeNumElements(Type *Ty) const {
if (auto *VTy = dyn_cast<FixedVectorType>(Ty))
return VTy->getNumElements();
if (Src->isVectorTy()) {
VectorType *VecTy = cast<VectorType>(Src);
unsigned VecWidth = VecTy->getPrimitiveSizeInBits().getFixedSize();
- if (useHVX() && isTypeForHVX(VecTy)) {
+ if (useHVX() && ST.isTypeForHVX(VecTy)) {
unsigned RegWidth = getRegisterBitWidth(true);
assert(RegWidth && "Non-zero vector register width expected");
// Cost of HVX loads.
}
bool HexagonTTIImpl::isLegalMaskedStore(Type *DataType, Align /*Alignment*/) {
- return HexagonMaskedVMem && isTypeForHVX(DataType);
+ return HexagonMaskedVMem && ST.isTypeForHVX(DataType);
}
bool HexagonTTIImpl::isLegalMaskedLoad(Type *DataType, Align /*Alignment*/) {
- return HexagonMaskedVMem && isTypeForHVX(DataType);
+ return HexagonMaskedVMem && ST.isTypeForHVX(DataType);
}
/// --- Vector TTI end ---
const HexagonTargetLowering *getTLI() const { return &TLI; }
bool useHVX() const;
- bool isTypeForHVX(Type *VecTy) const;
// Returns the number of vector elements of Ty, if Ty is a vector type,
// or 1 if Ty is a scalar type. It is incorrect to call this function