LLVM 20.0.0git
BottomUpVec.h
Go to the documentation of this file.
1//===- BottomUpVec.h --------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// A Bottom-Up Vectorizer pass.
10//
11
12#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_BOTTOMUPVEC_H
13#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_BOTTOMUPVEC_H
14
15#include "llvm/ADT/ArrayRef.h"
16#include "llvm/ADT/StringRef.h"
18#include "llvm/SandboxIR/Pass.h"
23
24namespace llvm::sandboxir {
25
26class BottomUpVec final : public FunctionPass {
27 bool Change = false;
28 std::unique_ptr<LegalityAnalysis> Legality;
29 /// The original instructions that are potentially dead after vectorization.
30 DenseSet<Instruction *> DeadInstrCandidates;
31 /// Maps scalars to vectors.
32 std::unique_ptr<InstrMaps> IMaps;
33
34 /// Creates and returns a vector instruction that replaces the instructions in
35 /// \p Bndl. \p Operands are the already vectorized operands.
36 Value *createVectorInstr(ArrayRef<Value *> Bndl, ArrayRef<Value *> Operands);
37 /// Erases all dead instructions from the dead instruction candidates
38 /// collected during vectorization.
39 void tryEraseDeadInstrs();
40 /// Creates a shuffle instruction that shuffles \p VecOp according to \p Mask.
41 Value *createShuffle(Value *VecOp, const ShuffleMask &Mask);
42 /// Packs all elements of \p ToPack into a vector and returns that vector.
43 Value *createPack(ArrayRef<Value *> ToPack);
44 /// After we create vectors for groups of instructions, the original
45 /// instructions are potentially dead and may need to be removed. This
46 /// function helps collect these instructions (along with the pointer operands
47 /// for loads/stores) so that they can be cleaned up later.
48 void collectPotentiallyDeadInstrs(ArrayRef<Value *> Bndl);
49 /// Recursively try to vectorize \p Bndl and its operands.
50 Value *vectorizeRec(ArrayRef<Value *> Bndl, unsigned Depth);
51 /// Entry point for vectorization starting from \p Seeds.
52 bool tryVectorize(ArrayRef<Value *> Seeds);
53
54 /// The PM containing the pipeline of region passes.
56
57public:
58 BottomUpVec(StringRef Pipeline);
59 bool runOnFunction(Function &F, const Analyses &A) final;
60 void printPipeline(raw_ostream &OS) const final {
61 OS << getName() << "\n";
62 RPM.printPipeline(OS);
63 }
64};
65
66} // namespace llvm::sandboxir
67
68#endif // LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_BOTTOMUPVEC_H
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define F(x, y, z)
Definition: MD5.cpp:55
mir Rename Register Operands
raw_pwrite_stream & OS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Implements a dense probed hash-table based set.
Definition: DenseSet.h:278
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
void printPipeline(raw_ostream &OS) const final
Similar to print() but adds a newline. Used for testing.
Definition: BottomUpVec.h:60
bool runOnFunction(Function &F, const Analyses &A) final
\Returns true if it modifies F.
A pass that runs on a sandbox::Function.
Definition: Pass.h:75
void printPipeline(raw_ostream &OS) const override
Similar to print() but prints one pass per line. Used for testing.
Definition: PassManager.h:197
StringRef getName() const
\Returns the name of the pass.
Definition: Pass.h:61
A SandboxIR Value has users. This is the base class.
Definition: Value.h:63