21#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_SCHEDULER_H
22#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_SCHEDULER_H
39 bool IsTerm1 = I1->isTerminator();
40 bool IsTerm2 = I2->isTerminator();
41 if (IsTerm1 != IsTerm2)
43 return IsTerm1 > IsTerm2;
44 bool IsPHI1 = isa<PHINode>(I1);
45 bool IsPHI2 = isa<PHINode>(I2);
48 return IsPHI1 < IsPHI2;
50 return I2->comesBefore(I1);
61 std::priority_queue<DGNode *, std::vector<DGNode *>,
PriorityCmp> List;
67 assert(!
N->scheduled() &&
"Don't insert a scheduled node!");
69 while (!ListCopy.empty()) {
70 DGNode *Top = ListCopy.top();
72 assert(Top !=
N &&
"Node already exists in ready list!");
78 auto *Back =
List.top();
90 while (!
List.empty()) {
91 auto *Top =
List.top();
97 for (
auto *KeepN :
Keep)
123 for (
auto *
N : this->Nodes)
124 N->setSchedBundle(*
this);
131 for (
auto *
N : this->Nodes)
132 N->clearSchedBundle();
154 return all_of(Nodes, [](
const auto *
N) {
return N->ready(); });
176 std::optional<BasicBlock::iterator> ScheduleTopItOpt;
182 std::optional<Context::CallbackID> CreateInstrCB;
196 void scheduleAndUpdateReadyList(
SchedBundle &Bndl);
198 enum class BndlSchedState {
202 TemporarilyScheduled,
241 ScheduleTopItOpt = std::nullopt;
242 ScheduledBB =
nullptr;
244 !ScheduleTopItOpt && ScheduledBB ==
nullptr &&
245 "Expected empty state!");
259 using BndlSchedState = Scheduler::BndlSchedState;
262 return Sched.getBndlSchedState(Instrs);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Machine Instruction Scheduler
A private abstract base class describing the concept of an individual alias analysis implementation.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This class implements an extremely fast bulk output stream that can only output to a stream.
Iterator for Instructions in a `BasicBlock.
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)
A DependencyGraph Node that points to an Instruction and contains memory dependency edges.
void setSchedBundle(SchedBundle &SB)
Instruction * getInstruction() const
bool empty() const
\Returns true if the DAG's state is clear. Used in assertions.
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
bool operator()(const DGNode *N1, const DGNode *N2)
The list holding nodes that are ready to schedule. Used by the scheduler.
LLVM_DUMP_METHOD void dump() const
void remove(DGNode *N)
\Removes N if found in the ready list.
The nodes that need to be scheduled back-to-back in a single scheduling cycle form a SchedBundle.
LLVM_ABI DGNode * getBot() const
\Returns the bundle node that comes after the others in program order.
SchedBundle(ContainerTy &&Nodes)
SchedBundle & operator=(const SchedBundle &Other)=delete
Copy Assignment (unimplemented).
LLVM_ABI DGNode * getTop() const
\Returns the bundle node that comes before the others in program order.
bool isSingleton() const
Singleton bundles are created when scheduling instructions temporarily to fill in the schedule until ...
bool ready() const
\Returns true if all nodes in the bundle are ready.
const_iterator begin() const
LLVM_DUMP_METHOD void dump() const
SchedBundle(const SchedBundle &Other)=delete
Copy CTOR (unimplemented).
const_iterator end() const
LLVM_ABI void cluster(BasicBlock::iterator Where)
Move all bundle instructions to Where back-to-back.
A client-attorney class for accessing the Scheduler's internals (used for unit tests).
static BndlSchedState getBndlSchedState(const Scheduler &Sched, ArrayRef< Instruction * > Instrs)
static DependencyGraph & getDAG(Scheduler &Sched)
LLVM_DUMP_METHOD void dump() const
LLVM_ABI bool trySchedule(ArrayRef< Instruction * > Instrs)
Tries to build a schedule that includes all of Instrs scheduled at the same scheduling cycle.
void clear()
Clear the scheduler's state, including the DAG.
Scheduler(AAResults &AA, Context &Ctx)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
void erase(Container &C, ValueType V)
Wrapper function to remove a value from a container:
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
@ Keep
No function return thunk.
Implement std::hash so that hash_code can be used in STL containers.