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 /// \p UserBB is the block of the user bundle.
42 Value *createShuffle(Value *VecOp, const ShuffleMask &Mask,
43 BasicBlock *UserBB);
44 /// Packs all elements of \p ToPack into a vector and returns that vector. \p
45 /// UserBB is the block of the user bundle.
46 Value *createPack(ArrayRef<Value *> ToPack, BasicBlock *UserBB);
47 /// After we create vectors for groups of instructions, the original
48 /// instructions are potentially dead and may need to be removed. This
49 /// function helps collect these instructions (along with the pointer operands
50 /// for loads/stores) so that they can be cleaned up later.
51 void collectPotentiallyDeadInstrs(ArrayRef<Value *> Bndl);
52 /// Recursively try to vectorize \p Bndl and its operands.
53 Value *vectorizeRec(ArrayRef<Value *> Bndl, ArrayRef<Value *> UserBndl,
54 unsigned Depth);
55 /// Entry point for vectorization starting from \p Seeds.
56 bool tryVectorize(ArrayRef<Value *> Seeds);
57
58 /// The PM containing the pipeline of region passes.
60
61public:
62 BottomUpVec(StringRef Pipeline);
63 bool runOnFunction(Function &F, const Analyses &A) final;
64 void printPipeline(raw_ostream &OS) const final {
65 OS << getName() << "\n";
66 RPM.printPipeline(OS);
67 }
68};
69
70} // namespace llvm::sandboxir
71
72#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
Contains a list of sandboxir::Instruction's.
Definition: BasicBlock.h:67
void printPipeline(raw_ostream &OS) const final
Similar to print() but adds a newline. Used for testing.
Definition: BottomUpVec.h:64
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