Index: include/llvm/CodeGen/MachineLoopInfo.h
===================================================================
--- include/llvm/CodeGen/MachineLoopInfo.h
+++ include/llvm/CodeGen/MachineLoopInfo.h
@@ -56,6 +56,14 @@
void dump() const;
+ //
+ DebugLoc getDebugLoc();
+ MachineFunction* getFunction();
+ void emitOptimizationRemark(const char* PassName, const char* Msg);
+ void emitOptimizationRemarkMissed(const char* PassName, const char* Msg);
+ void emitOptimizationRemarkAnalysis(const char* PassName, const char* Msg);
+ //
+
private:
friend class LoopInfoBase;
explicit MachineLoop(MachineBasicBlock *MBB)
@@ -151,6 +159,7 @@
void removeBlock(MachineBasicBlock *BB) {
LI.removeBlock(BB);
}
+
};
Index: lib/CodeGen/CGLoopInfo.cpp
===================================================================
--- lib/CodeGen/CGLoopInfo.cpp
+++ lib/CodeGen/CGLoopInfo.cpp
@@ -24,6 +24,7 @@
if (!Attrs.IsParallel && Attrs.VectorizeWidth == 0 &&
Attrs.InterleaveCount == 0 && Attrs.UnrollCount == 0 &&
Attrs.VectorizeEnable == LoopAttributes::Unspecified &&
+ Attrs.PipelineEnable == LoopAttributes::Unspecified && //SYNOPSYS
Attrs.UnrollEnable == LoopAttributes::Unspecified)
return nullptr;
@@ -65,6 +66,17 @@
Args.push_back(MDNode::get(Ctx, Vals));
}
+ //
+ // Setting pipelineenable
+ if (Attrs.PipelineEnable != LoopAttributes::Unspecified) {
+ Metadata *Vals[] = {MDString::get(Ctx, "llvm.loop.pipeline"),
+ ConstantAsMetadata::get(ConstantInt::get(
+ Type::getInt1Ty(Ctx), (Attrs.PipelineEnable ==
+ LoopAttributes::Enable)))};
+ Args.push_back(MDNode::get(Ctx, Vals));
+ }
+ //
+
// Setting unroll.full or unroll.disable
if (Attrs.UnrollEnable != LoopAttributes::Unspecified) {
std::string Name;
@@ -143,6 +155,11 @@
case LoopHintAttr::Unroll:
setUnrollState(LoopAttributes::Disable);
break;
+ //
+ case LoopHintAttr::Pipeline://SYNOPSYS
+ setPipelineEnable(false);
+ break;
+ //
case LoopHintAttr::UnrollCount:
case LoopHintAttr::VectorizeWidth:
case LoopHintAttr::InterleaveCount:
@@ -159,6 +176,11 @@
case LoopHintAttr::Unroll:
setUnrollState(LoopAttributes::Enable);
break;
+ //
+ case LoopHintAttr::Pipeline://SYNOPSYS
+ setPipelineEnable(true);
+ break;
+ //
case LoopHintAttr::UnrollCount:
case LoopHintAttr::VectorizeWidth:
case LoopHintAttr::InterleaveCount:
@@ -178,6 +200,7 @@
case LoopHintAttr::UnrollCount:
case LoopHintAttr::VectorizeWidth:
case LoopHintAttr::InterleaveCount:
+ case LoopHintAttr::Pipeline://SYNOPSYS
llvm_unreachable("Options cannot be used to assume mem safety.");
break;
}
@@ -187,6 +210,7 @@
case LoopHintAttr::Unroll:
setUnrollState(LoopAttributes::Full);
break;
+ case LoopHintAttr::Pipeline://SYNOPSYS
case LoopHintAttr::Vectorize:
case LoopHintAttr::Interleave:
case LoopHintAttr::UnrollCount:
@@ -208,6 +232,7 @@
setUnrollCount(ValueInt);
break;
case LoopHintAttr::Unroll:
+ case LoopHintAttr::Pipeline://SYNOPSYS
case LoopHintAttr::Vectorize:
case LoopHintAttr::Interleave:
llvm_unreachable("Options cannot be assigned a value.");
Index: lib/CodeGen/MachineLoopInfo.cpp
===================================================================
--- lib/CodeGen/MachineLoopInfo.cpp
+++ lib/CodeGen/MachineLoopInfo.cpp
@@ -18,6 +18,7 @@
#include "llvm/Analysis/LoopInfoImpl.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/Passes.h"
+#include "llvm/IR/DiagnosticInfo.h" //SYNOPSYS
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
@@ -81,3 +82,36 @@
print(dbgs());
}
#endif
+
+//
+DebugLoc MachineLoop::getDebugLoc() {
+ if (MachineBasicBlock* MBB = getTopBlock())
+ for (auto& MI : *MBB)
+ if (!MI.isDebugValue() && MI.getDebugLoc())
+ return MI.getDebugLoc();
+ return DebugLoc();
+}
+MachineFunction* MachineLoop::getFunction() {
+ if (MachineBasicBlock* MBB = getTopBlock())
+ return MBB->getParent();
+ return nullptr;
+}
+void MachineLoop::emitOptimizationRemark(const char* PassName, const char* Msg) {
+ if (MachineFunction* MF = getFunction())
+ if (const Function* F = MF->getFunction())
+ if (const DebugLoc& DL = getDebugLoc())
+ llvm::emitOptimizationRemark(F->getContext(), PassName, *F, DL, Msg);
+}
+void MachineLoop::emitOptimizationRemarkMissed(const char* PassName, const char* Msg) {
+ if (MachineFunction* MF = getFunction())
+ if (const Function* F = MF->getFunction())
+ if (const DebugLoc& DL = getDebugLoc())
+ llvm::emitOptimizationRemarkMissed(F->getContext(), PassName, *F, DL, Msg);
+}
+void MachineLoop::emitOptimizationRemarkAnalysis(const char* PassName, const char* Msg) {
+ if (MachineFunction* MF = getFunction())
+ if (const Function* F = MF->getFunction())
+ if (const DebugLoc& DL = getDebugLoc())
+ llvm::emitOptimizationRemarkAnalysis(F->getContext(), PassName, *F, DL, Msg);
+}
+//
Index: lib/CodeGen/MachinePipeliner.cpp
===================================================================
--- lib/CodeGen/MachinePipeliner.cpp
+++ lib/CodeGen/MachinePipeliner.cpp
@@ -0,0 +1,4248 @@
+//===-- MachinePipeliner.cpp - Machine Software Pipeliner Pass ------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// An implementation of the Swing Modulo Scheduling (SMS) software pipeliner.
+//
+// Software pipelining is an instruction scheduling technique for loops that
+// overlap loop iterations and explioits ILP via a compiler transformation.
+//
+// Swing Modulo Scheduling (SMS) is an implementation of software pipelining
+// that generates schedules that are near optimal in terms of initiation
+// interval, register requirements, and stage count.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/PriorityQueue.h"
+#include "llvm/ADT/SetVector.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/Statistic.h"
+#include "llvm/Analysis/AliasAnalysis.h"
+#include "llvm/Analysis/ValueTracking.h"
+#include "llvm/CodeGen/DFAPacketizer.h"
+#include "llvm/CodeGen/LiveIntervalAnalysis.h"
+#include "llvm/CodeGen/MachineBasicBlock.h"
+#include "llvm/CodeGen/MachineDominators.h"
+#include "llvm/CodeGen/MachineInstrBuilder.h"
+#include "llvm/CodeGen/MachineLoopInfo.h"
+#include "llvm/CodeGen/MachineRegisterInfo.h"
+#include "llvm/CodeGen/Passes.h"
+#include "llvm/CodeGen/RegisterClassInfo.h"
+#include "llvm/CodeGen/RegisterPressure.h"
+#include "llvm/CodeGen/ScheduleDAGInstrs.h"
+#include "llvm/IR/Metadata.h" //SYNOPSYS
+#include "llvm/MC/MCInstrItineraries.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Target/TargetInstrInfo.h"
+#include "llvm/Target/TargetMachine.h"
+#include "llvm/Target/TargetRegisterInfo.h"
+#include "llvm/Target/TargetSubtargetInfo.h"
+#include "ArcReservationTable.h" //SYNOPSYS
+#include
+#include
+#include