17 return TTI.getInstructionCost(LLVMI,
Operands, CostKind);
21 auto Cost = getCost(
I);
36 : Ctx(Ctx), Scoreboard(*this,
TTI) {
41 CreateInstCB = Ctx.registerCreateInstrCallback(
43 EraseInstCB = Ctx.registerEraseInstrCallback([
this](
Instruction *ErasedInst) {
45 removeFromAux(ErasedInst);
50 Ctx.unregisterCreateInstrCallback(CreateInstCB);
51 Ctx.unregisterEraseInstrCallback(EraseInstCB);
65 auto &LLVMCtx = Ctx.LLVMCtx;
70 "Instruction already in Aux!");
79 assert((Idx >= Aux.size() || Aux[Idx] ==
nullptr) &&
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)
96 LLVMI->setMetadata(AuxMDKind,
nullptr);
100 auto It =
find(Aux,
I);
109 dropAuxMetadata(Aux[Idx]);
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();
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)) {
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!")
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.
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
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.
BasicBlock(llvm::BasicBlock *BB, Context &SBCtx)
friend class Instruction
Iterator for Instructions in a `BasicBlock.
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,...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.