Skip to content

Commit

Permalink
[TTI] Add supportsScalableVectors target hook
Browse files Browse the repository at this point in the history
This is split off from D91718 and adds a new target hook
supportsScalableVectors that can be queried to check if scalable vectors
are supported by the backend. For AArch64 this returns true if SVE is
enabled.

Reviewed By: david-arm

Differential Revision: https://reviews.llvm.org/D93060
  • Loading branch information
c-rhodes committed Dec 18, 2020
1 parent 9899319 commit 7c8796f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions llvm/include/llvm/Analysis/TargetTransformInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,9 @@ class TargetTransformInfo {
/// to a stack reload.
unsigned getGISelRematGlobalCost() const;

/// \returns True if the target supports scalable vectors.
bool supportsScalableVectors() const;

/// \name Vector Predication Information
/// @{
/// Whether the target supports the %evl parameter of VP intrinsic efficiently
Expand Down Expand Up @@ -1634,6 +1637,7 @@ class TargetTransformInfo::Concept {
ReductionFlags) const = 0;
virtual bool shouldExpandReduction(const IntrinsicInst *II) const = 0;
virtual unsigned getGISelRematGlobalCost() const = 0;
virtual bool supportsScalableVectors() const = 0;
virtual bool hasActiveVectorLength() const = 0;
virtual int getInstructionLatency(const Instruction *I) = 0;
};
Expand Down Expand Up @@ -2163,6 +2167,10 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
return Impl.getGISelRematGlobalCost();
}

bool supportsScalableVectors() const override {
return Impl.supportsScalableVectors();
}

bool hasActiveVectorLength() const override {
return Impl.hasActiveVectorLength();
}
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,8 @@ class TargetTransformInfoImplBase {

unsigned getGISelRematGlobalCost() const { return 1; }

bool supportsScalableVectors() const { return false; }

bool hasActiveVectorLength() const { return false; }

protected:
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Analysis/TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,10 @@ unsigned TargetTransformInfo::getGISelRematGlobalCost() const {
return TTIImpl->getGISelRematGlobalCost();
}

bool TargetTransformInfo::supportsScalableVectors() const {
return TTIImpl->supportsScalableVectors();
}

int TargetTransformInfo::getInstructionLatency(const Instruction *I) const {
return TTIImpl->getInstructionLatency(I);
}
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
return 2;
}

bool supportsScalableVectors() const { return ST->hasSVE(); }

bool useReductionIntrinsic(unsigned Opcode, Type *Ty,
TTI::ReductionFlags Flags) const;

Expand Down

0 comments on commit 7c8796f

Please sign in to comment.