[llvm] [SandboxVec][Scheduler] Boilerplate and initial implementation. (PR #112449)
Sriraman Tallam via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 17 22:58:10 PDT 2024
================
@@ -0,0 +1,161 @@
+//===- Scheduler.cpp ------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Transforms/Vectorize/SandboxVectorizer/Scheduler.h"
+
+namespace llvm::sandboxir {
+
+// TODO: Check if we can cache top/bottom to reduce compile-time.
+DGNode *SchedBundle::getTop() const {
+ DGNode *TopN = Nodes.front();
+ for (auto *N : drop_begin(Nodes)) {
+ if (N->getInstruction()->comesBefore(TopN->getInstruction()))
+ TopN = N;
+ }
+ return TopN;
+}
+
+DGNode *SchedBundle::getBot() const {
+ DGNode *BotN = Nodes.front();
+ for (auto *N : drop_begin(Nodes)) {
+ if (BotN->getInstruction()->comesBefore(N->getInstruction()))
+ BotN = N;
+ }
+ return BotN;
+}
+
+void SchedBundle::cluster(BasicBlock::iterator Where) {
+ for (auto *N : Nodes) {
+ auto *I = N->getInstruction();
+ if (I->getIterator() == Where)
+ ++Where; // Try to maintain bundle order.
+ I->moveBefore(*Where.getNodeParent(), Where);
----------------
tmsri wrote:
Ignore this, I get why I am wrong.
https://github.com/llvm/llvm-project/pull/112449
More information about the llvm-commits
mailing list