Skip to content

Commit

Permalink
Merge branch 'vhls-opt' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
JianyiCheng committed Sep 11, 2021
2 parents f731c7a + 1006587 commit f0fcfb0
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions lib/llvm/Transforms/VhlsLLVMRewriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,20 @@ struct XilinxRewriteMathInstPass : public ModulePass {

} // namespace

static void unrollLoop(Loop *loop) {
LLVMContext &Context = loop->getHeader()->getContext();
MDNode *EnableUnrollMD =
MDNode::get(Context, MDString::get(Context, "llvm.loop.unroll.full"));
MDNode *LoopID = loop->getLoopID();
MDNode *NewLoopID = makePostTransformationMetadata(
Context, LoopID, {"llvm.loop.unroll."}, {EnableUnrollMD});
loop->setLoopID(NewLoopID);

if (!loop->isInnermost())
for (auto &subloop : loop->getSubLoops())
unrollLoop(subloop);
}

namespace {

/// Unroll all the loops in a specified function for Xilinx Vitis.
Expand All @@ -983,15 +997,8 @@ struct XilinxUnrollPass : public ModulePass {
auto DT = llvm::DominatorTree(F);
LoopInfo LI(DT);

for (auto &loop : LI) {
LLVMContext &Context = loop->getHeader()->getContext();
MDNode *EnableUnrollMD = MDNode::get(
Context, MDString::get(Context, "llvm.loop.unroll.full"));
MDNode *LoopID = loop->getLoopID();
MDNode *NewLoopID = makePostTransformationMetadata(
Context, LoopID, {"llvm.loop.unroll."}, {EnableUnrollMD});
loop->setLoopID(NewLoopID);
}
for (auto &loop : LI)
unrollLoop(loop);
}

return false;
Expand Down

0 comments on commit f0fcfb0

Please sign in to comment.