[Packetizer] Add a check whether an instruction should be packetized now
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>
Wed, 16 Dec 2015 16:38:16 +0000 (16:38 +0000)
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>
Wed, 16 Dec 2015 16:38:16 +0000 (16:38 +0000)
Add a function VLIWPacketizerList::shouldAddToPacket, which will allow
specific implementations to decide if it is profitable to add given
instruction to the current packet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255780 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/DFAPacketizer.h
lib/CodeGen/DFAPacketizer.cpp

index 11d959b2e7f7ad8f8b99587b8f3cd78aaa30e14a..40ec201107e8e784e3bd856f142896db5bb1b65f 100644 (file)
@@ -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) {
index 80e03d985d51b9019bf6e358276708f0c35fa04d..af6b6a392b75919a6de2e55b9bfd03772aa4c8eb 100644 (file)
@@ -239,7 +239,7 @@ void VLIWPacketizerList::PacketizeMIs(MachineBasicBlock *MBB,
 
     // 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(MachineBasicBlock *MBB,
         } // !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);
     }