15 auto *LLVMI = cast<llvm::Instruction>(
I->Val);
16 SmallVector<const llvm::Value *>
Operands(LLVMI->operands());
21 auto Cost = getCost(
I);
36 : Ctx(Ctx), Scoreboard(*this,
TTI) {
45 removeFromAux(ErasedInst);
57 cast<llvm::Instruction>(
I->Val)->setMetadata(MDKind, RegionMDN);
69 assert(cast<llvm::Instruction>(
I->Val)->getMetadata(AuxMDKind) ==
nullptr &&
70 "Instruction already in Aux!");
71 cast<llvm::Instruction>(
I->Val)->setMetadata(
80 "There is already an Instruction at Idx in Aux!");
81 unsigned ExpectedSz =
Idx + 1;
82 if (Aux.size() < ExpectedSz) {
83 auto SzBefore = Aux.size();
84 Aux.resize(ExpectedSz);
86 for (
unsigned Idx = SzBefore;
Idx + 1 < ExpectedSz; ++
Idx)
94void Region::dropAuxMetadata(Instruction *
I) {
95 auto *LLVMI = cast<llvm::Instruction>(
I->Val);
96 LLVMI->setMetadata(AuxMDKind,
nullptr);
99void Region::removeFromAux(Instruction *
I) {
100 auto It =
find(Aux,
I);
108 for (
unsigned Idx : seq<unsigned>(0, Aux.size()))
109 dropAuxMetadata(Aux[
Idx]);
119 cast<llvm::Instruction>(
I->Val)->setMetadata(MDKind,
nullptr);
124 if (Insts.size() !=
Other.Insts.size())
126 if (!std::is_permutation(Insts.begin(), Insts.end(),
Other.Insts.begin()))
132 for (
auto *
I : Insts)
136 for (
auto *
I : Aux) {
155 auto &Ctx =
F.getContext();
158 auto *LLVMI = cast<llvm::Instruction>(Inst.Val);
160 if (
auto *MDN = LLVMI->getMetadata(MDKind)) {
161 auto [It, Inserted] = MDNToRegion.
try_emplace(MDN);
164 R = Regions.
back().get();
169 R->addImpl(&Inst,
true);
171 if (
auto *AuxMDN = LLVMI->getMetadata(AuxMDKind)) {
173 dyn_cast<ConstantAsMetadata>(AuxMDN->getOperand(0))->getValue();
174 auto Idx = cast<llvm::ConstantInt>(IdxC)->getSExtValue();
176 errs() <<
"No region specified for Aux: '" << *LLVMI <<
"'\n";
179 R->setAux(
Idx, &Inst);
185 for (
auto &RPtr : Regions)
186 for (
auto *
I : RPtr->getAux())
187 assert(
I !=
nullptr &&
"Gap in Aux!");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
mir Rename Register Operands
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This is the shared class of boolean and integer constants.
This is an important base class in LLVM.
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
This is an important class for using LLVM in a threaded context.
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
This class implements an extremely fast bulk output stream that can only output to a stream.
Contains a list of sandboxir::Instruction's.
LLVM_ABI CallbackID registerCreateInstrCallback(CreateInstrCallback CB)
Register a callback that gets called right after a SandboxIR instruction is created.
LLVM_ABI void unregisterCreateInstrCallback(CallbackID ID)
LLVM_ABI void unregisterEraseInstrCallback(CallbackID ID)
LLVM_ABI CallbackID registerEraseInstrCallback(EraseInstrCallback CB)
Register a callback that gets called when a SandboxIR instruction is about to be removed from its par...
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
The main job of the Region is to point to new instructions generated by vectorization passes.
bool contains(Instruction *I) const
Returns true if I is in the Region.
bool operator==(const Region &Other) const
This is an expensive check, meant for testing.
LLVM_ABI Region(Context &Ctx, TargetTransformInfo &TTI)
static LLVM_ABI SmallVector< std::unique_ptr< Region > > createRegionsFromMD(Function &F, TargetTransformInfo &TTI)
LLVM_ABI void clearAux()
Clears all auxiliary data.
LLVM_ABI void remove(Instruction *I)
Mark I as a deleted instruction from the region.
LLVM_DUMP_METHOD void dump() const
void add(Instruction *I)
Mark I as a newly added instruction to the region.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.