[llvm] r255780 - [Packetizer] Add a check whether an instruction should be packetized now

Krzysztof Parzyszek via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 16 08:38:16 PST 2015


Author: kparzysz
Date: Wed Dec 16 10:38:16 2015
New Revision: 255780

URL: http://llvm.org/viewvc/llvm-project?rev=255780&view=rev
Log:
[Packetizer] Add a check whether an instruction should be packetized now

Add a function VLIWPacketizerList::shouldAddToPacket, which will allow
specific implementations to decide if it is profitable to add given
instruction to the current packet.

Modified:
    llvm/trunk/include/llvm/CodeGen/DFAPacketizer.h
    llvm/trunk/lib/CodeGen/DFAPacketizer.cpp

Modified: llvm/trunk/include/llvm/CodeGen/DFAPacketizer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DFAPacketizer.h?rev=255780&r1=255779&r2=255780&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/DFAPacketizer.h (original)
+++ llvm/trunk/include/llvm/CodeGen/DFAPacketizer.h Wed Dec 16 10:38:16 2015
@@ -186,6 +186,16 @@ public:
     return true;
   }
 
+  // Check if the packetizer should try to add the given instruction to
+  // the current packet. One reasons for which it may not be desirable
+  // to include an instruction in the current packet could be that it
+  // would cause a stall.
+  // If this function returns "false", the current packet will be ended,
+  // and the instruction will be added to the next packet.
+  virtual bool shouldAddToPacket(const MachineInstr *MI) {
+    return true;
+  }
+
   // isLegalToPacketizeTogether - Is it legal to packetize SUI and SUJ
   // together.
   virtual bool isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) {

Modified: llvm/trunk/lib/CodeGen/DFAPacketizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DFAPacketizer.cpp?rev=255780&r1=255779&r2=255780&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/DFAPacketizer.cpp (original)
+++ llvm/trunk/lib/CodeGen/DFAPacketizer.cpp Wed Dec 16 10:38:16 2015
@@ -239,7 +239,7 @@ void VLIWPacketizerList::PacketizeMIs(Ma
 
     // Ask DFA if machine resource is available for MI.
     bool ResourceAvail = ResourceTracker->canReserveResources(MI);
-    if (ResourceAvail) {
+    if (ResourceAvail && shouldAddToPacket(MI)) {
       // Dependency check for MI with instructions in CurrentPacketMIs.
       for (std::vector<MachineInstr*>::iterator VI = CurrentPacketMIs.begin(),
            VE = CurrentPacketMIs.end(); VI != VE; ++VI) {
@@ -258,7 +258,8 @@ void VLIWPacketizerList::PacketizeMIs(Ma
         } // !isLegalToPacketizeTogether.
       } // For all instructions in CurrentPacketMIs.
     } else {
-      // End the packet if resource is not available.
+      // End the packet if resource is not available, or if the instruction
+      // shoud not be added to the current packet.
       endPacket(MBB, MI);
     }
 




More information about the llvm-commits mailing list