[PATCH] D123561: GlobalISel: Add LegalizeMutations to help use More/FewerElements
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 11 19:06:25 PDT 2022
arsenm created this revision.
arsenm added reviewers: paquette, aemerson, aditya_nandakumar, dsanders, bogner.
Herald added subscribers: hiraditya, rovka.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.
https://reviews.llvm.org/D123561
Files:
llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
llvm/lib/CodeGen/GlobalISel/LegalizeMutations.cpp
Index: llvm/lib/CodeGen/GlobalISel/LegalizeMutations.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/LegalizeMutations.cpp
+++ llvm/lib/CodeGen/GlobalISel/LegalizeMutations.cpp
@@ -43,6 +43,25 @@
};
}
+LegalizeMutation LegalizeMutations::changeElementCountTo(unsigned TypeIdx,
+ unsigned FromTypeIdx) {
+ return [=](const LegalityQuery &Query) {
+ const LLT OldTy = Query.Types[TypeIdx];
+ const LLT NewTy = Query.Types[FromTypeIdx];
+ return std::make_pair(TypeIdx,
+ OldTy.changeElementCount(NewTy.getElementCount()));
+ };
+}
+
+LegalizeMutation LegalizeMutations::changeElementCountTo(unsigned TypeIdx,
+ LLT NewEltTy) {
+ return [=](const LegalityQuery &Query) {
+ const LLT OldTy = Query.Types[TypeIdx];
+ return std::make_pair(TypeIdx,
+ OldTy.changeElementCount(NewEltTy.getElementCount()));
+ };
+}
+
LegalizeMutation LegalizeMutations::changeElementSizeTo(unsigned TypeIdx,
unsigned FromTypeIdx) {
return [=](const LegalityQuery &Query) {
Index: llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
+++ llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
@@ -357,6 +357,14 @@
/// Keep the same scalar or element type as the given type.
LegalizeMutation changeElementTo(unsigned TypeIdx, LLT Ty);
+/// Keep the same scalar or element type as \p TypeIdx, but take the number of
+/// elements from \p FromTypeIdx.
+LegalizeMutation changeElementCountTo(unsigned TypeIdx, unsigned FromTypeIdx);
+
+/// Keep the same scalar or element type as \p TypeIdx, but take the number of
+/// elements from \p Ty.
+LegalizeMutation changeElementCountTo(unsigned TypeIdx, LLT Ty);
+
/// Change the scalar size or element size to have the same scalar size as type
/// index \p FromIndex. Unlike changeElementTo, this discards pointer types and
/// only changes the size.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123561.422098.patch
Type: text/x-patch
Size: 2201 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220412/58d14273/attachment.bin>
More information about the llvm-commits
mailing list