[llvm] [SandboxVec][BottomUpVec] Implement InstrMaps (PR #122848)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 16 14:01:11 PST 2025
================
@@ -148,6 +165,57 @@ class Pack final : public LegalityResultWithReason {
}
};
+/// Describes how to collect the values needed by each lane.
+class CollectDescr {
+public:
+ /// Describes how to get a value element. If the value is a vector then it
+ /// also provides the index to extract it from.
+ class ExtractElementDescr {
+ Value *V;
+ /// The index in `V` that the value can be extracted from.
+ /// This is nullopt if we need to use `V` as a whole.
+ std::optional<int> ExtractIdx;
+
+ public:
+ ExtractElementDescr(Value *V, int ExtractIdx)
+ : V(V), ExtractIdx(ExtractIdx) {}
+ ExtractElementDescr(Value *V) : V(V), ExtractIdx(std::nullopt) {}
+ Value *getValue() const { return V; }
+ bool needsExtract() const { return ExtractIdx.has_value(); }
+ int getExtractIdx() const { return *ExtractIdx; }
+ };
+
+ using DescrVecT = SmallVector<ExtractElementDescr, 4>;
+ DescrVecT Descrs;
+
+public:
+ CollectDescr(SmallVectorImpl<ExtractElementDescr> &&Descrs)
+ : Descrs(std::move(Descrs)) {}
+ std::optional<std::pair<Value *, bool>> getSingleInput() const {
----------------
vporpo wrote:
This function tells us whether all the scalars come from a single vector and if we need a shuffle to get them in the right order. In a future patch this will also return the actual shuffle mask we need to get the elements in the right order.
I added a comment.
https://github.com/llvm/llvm-project/pull/122848
More information about the llvm-commits
mailing list