summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp
diff options
context:
space:
mode:
authorDaniel Sanders <daniel_l_sanders@apple.com>2018-04-27 19:48:53 +0000
committerDaniel Sanders <daniel_l_sanders@apple.com>2018-04-27 19:48:53 +0000
commit27fe8a50110a5249ac68469c9fc27fa75b42ac3c (patch)
treed92526478f1646f66f97ab2f6d2a1720e5a28a28 /llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp
parent3a8a56b8b76a39c24110fc92fc24bbd0549f737e (diff)
downloadbcm5719-llvm-27fe8a50110a5249ac68469c9fc27fa75b42ac3c.tar.gz
bcm5719-llvm-27fe8a50110a5249ac68469c9fc27fa75b42ac3c.zip
[globalisel][legalizerinfo] Add support for legalization based on the MachineMemOperand
Summary: Currently only the memory size is supported but others can be added as needed. narrowScalar for G_LOAD and G_STORE now correctly update the MachineMemOperand and will refuse to legalize atomics since those need more careful expansions to maintain atomicity. Reviewers: ab, aditya_nandakumar, bogner, rtereshin, aemerson, javed.absar Reviewed By: aemerson Subscribers: aemerson, rovka, kristof.beyls, javed.absar, llvm-commits Differential Revision: https://reviews.llvm.org/D45466 llvm-svn: 331071
Diffstat (limited to 'llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp b/llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp
index 0d30e0781cd..d9ec88f4345 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp
@@ -41,6 +41,18 @@ LegalityPredicate LegalityPredicates::typePairInSet(
};
}
+LegalityPredicate LegalityPredicates::typePairAndMemSizeInSet(
+ unsigned TypeIdx0, unsigned TypeIdx1, unsigned MMOIdx,
+ std::initializer_list<std::tuple<LLT, LLT, unsigned>> TypesAndMemSizeInit) {
+ SmallVector<std::tuple<LLT, LLT, unsigned>, 4> TypesAndMemSize = TypesAndMemSizeInit;
+ return [=](const LegalityQuery &Query) {
+ std::tuple<LLT, LLT, unsigned> Match = {
+ Query.Types[TypeIdx0], Query.Types[TypeIdx1], Query.MMODescrs[MMOIdx].Size};
+ return std::find(TypesAndMemSize.begin(), TypesAndMemSize.end(), Match) !=
+ TypesAndMemSize.end();
+ };
+}
+
LegalityPredicate LegalityPredicates::isScalar(unsigned TypeIdx) {
return [=](const LegalityQuery &Query) {
return Query.Types[TypeIdx].isScalar();
@@ -70,6 +82,12 @@ LegalityPredicate LegalityPredicates::sizeNotPow2(unsigned TypeIdx) {
};
}
+LegalityPredicate LegalityPredicates::memSizeInBytesNotPow2(unsigned MMOIdx) {
+ return [=](const LegalityQuery &Query) {
+ return !isPowerOf2_32(Query.MMODescrs[MMOIdx].Size /* In Bytes */);
+ };
+}
+
LegalityPredicate LegalityPredicates::numElementsNotPow2(unsigned TypeIdx) {
return [=](const LegalityQuery &Query) {
const LLT &QueryTy = Query.Types[TypeIdx];
OpenPOWER on IntegriCloud