LLVM 24.0.0git
LoadStoreVec.h
Go to the documentation of this file.
1//===- LoadStoreVec.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 pass that vectorizes short store-load chains.
10// Unlike generic bundle vectorization, this pass can vectorize instructions
11// of different types.
12//
13
14#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_LOADSTOREVEC_H
15#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_LOADSTOREVEC_H
16
17#include "llvm/ADT/ArrayRef.h"
18#include "llvm/SandboxIR/Pass.h"
20
21namespace llvm {
22
23class DataLayout;
24
25namespace sandboxir {
26
27class Value;
28class Instruction;
29class Scheduler;
30class Type;
31
32class LLVM_ABI LoadStoreVec final : public RegionPass {
33 const DataLayout *DL = nullptr;
34 /// The region saved by saveIR(), used by acceptOrRevert().
35 Region *SavedRgn = nullptr;
36 /// The region's cost at the time of saveIR().
37 InstructionCost CostBefore = 0;
38
39 /// Saves the IR along with the current cost of \p Rgn, so that
40 /// acceptOrRevert() can tell whether vectorizing was profitable.
41 void saveIR(Region &Rgn);
42
43 /// Accepts the transaction saved by saveIR() if vectorizing was profitable,
44 /// reverts it otherwise. \Returns true if the transaction was accepted.
45 bool acceptOrRevert();
46
47 /// Checks legality of vectorization and \returns the vector type on success,
48 /// nullopt otherwise.
49 std::optional<Type *> canVectorize(ArrayRef<Instruction *> Bndl,
51
52 void tryEraseDeadInstrs(ArrayRef<Instruction *> Stores,
54
55 /// Tries to vectorize the load/store/constant ops chain \p Bndl
56 /// into a single vector store. \Returns whether it succeeded.
57 bool vectorizeStores(ArrayRef<Instruction *> Bndl, Region &Rgn,
58 Scheduler &Sched, const Analyses &A);
59
60public:
61 LoadStoreVec(StringRef AuxArg) : RegionPass("load-store-vec") {
62 assert(AuxArg.empty() && "This pass ignores aux arg!");
63 }
64 bool runOnRegion(Region &Rgn, const Analyses &A) final;
65};
66
67} // namespace sandboxir
68
69} // namespace llvm
70
71#endif // LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_STRUCTINITVEC_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_ABI
Definition Compiler.h:215
This file defines an InstructionCost class that is used when calculating the cost of an instruction,...
static bool canVectorize(const CharMatrix &DepMatrix, unsigned LoopId)
Return true if we can vectorize the loop specified by LoopId.
SI Fold Operands
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
constexpr bool empty() const
Check if the string is empty.
Definition StringRef.h:141
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
Definition Instruction.h:43
LoadStoreVec(StringRef AuxArg)
RegionPass(StringRef Name)
Name can't contain any spaces or start with '-'.
Definition Pass.h:87
The list scheduler.
Definition Scheduler.h:302
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
Definition Type.h:50
A SandboxIR Value has users. This is the base class.
Definition Value.h:72
This is an optimization pass for GlobalISel generic memory operations.