Skip to content

Commit c73620d

Browse files
committed
Add shouldDecomposeStructAllocas to TargetTransformInfo
1 parent 54be865 commit c73620d

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,6 +1977,11 @@ class TargetTransformInfo {
19771977
/// target.
19781978
LLVM_ABI bool allowVectorElementIndexingUsingGEP() const;
19791979

1980+
/// \returns True if the target does not support struct allocas and therefore
1981+
/// requires struct alloca instructions to be scalarized / decomposed into
1982+
/// its components.
1983+
LLVM_ABI bool shouldDecomposeStructAllocas() const;
1984+
19801985
private:
19811986
std::unique_ptr<const TargetTransformInfoImplBase> TTIImpl;
19821987
};

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,8 @@ class TargetTransformInfoImplBase {
11631163

11641164
virtual bool allowVectorElementIndexingUsingGEP() const { return true; }
11651165

1166+
virtual bool shouldDecomposeStructAllocas() const { return false; }
1167+
11661168
protected:
11671169
// Obtain the minimum required size to hold the value (without the sign)
11681170
// In case of a vector it returns the min required size for one element.

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,10 @@ bool TargetTransformInfo::allowVectorElementIndexingUsingGEP() const {
15061506
return TTIImpl->allowVectorElementIndexingUsingGEP();
15071507
}
15081508

1509+
bool TargetTransformInfo::shouldDecomposeStructAllocas() const {
1510+
return TTIImpl->shouldDecomposeStructAllocas();
1511+
}
1512+
15091513
TargetTransformInfoImplBase::~TargetTransformInfoImplBase() = default;
15101514

15111515
TargetIRAnalysis::TargetIRAnalysis() : TTICallback(&getDefaultTTI) {}

llvm/lib/Target/DirectX/DirectXTargetTransformInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,7 @@ bool DirectXTTIImpl::isTargetIntrinsicTriviallyScalarizable(
6565
return false;
6666
}
6767
}
68+
69+
bool DirectXTTIImpl::shouldDecomposeStructAllocas() const {
70+
return true;
71+
}

llvm/lib/Target/DirectX/DirectXTargetTransformInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class DirectXTTIImpl final : public BasicTTIImplBase<DirectXTTIImpl> {
3939
unsigned ScalarOpdIdx) const override;
4040
bool isTargetIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID,
4141
int OpdIdx) const override;
42+
bool shouldDecomposeStructAllocas() const override;
4243
};
4344
} // namespace llvm
4445

0 commit comments

Comments
 (0)