[llvm-commits] [llvm] r150607 - in /llvm/trunk: include/llvm/CodeGen/DFAPacketizer.h lib/CodeGen/DFAPacketizer.cpp

Matt Beaumont-Gay matthewbg at google.com
Wed Feb 15 13:07:49 PST 2012


On Wed, Feb 15, 2012 at 10:55, Andrew Trick <atrick at apple.com> wrote:
> Author: atrick
> Date: Wed Feb 15 12:55:14 2012
> New Revision: 150607
>
> URL: http://llvm.org/viewvc/llvm-project?rev=150607&view=rev
> Log:
> Generic "VLIW" packetizer based on a DFA generated from target itinerary.
>
> Patch by Sundeep!
>
> 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=150607&r1=150606&r2=150607&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/DFAPacketizer.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/DFAPacketizer.h Wed Feb 15 12:55:14 2012
> @@ -26,13 +26,18 @@
>  #ifndef LLVM_CODEGEN_DFAPACKETIZER_H
>  #define LLVM_CODEGEN_DFAPACKETIZER_H
>
> +#include "llvm/CodeGen/MachineBasicBlock.h"
>  #include "llvm/ADT/DenseMap.h"
>
>  namespace llvm {
>
>  class MCInstrDesc;
>  class MachineInstr;
> +class MachineLoopInfo;
> +class MachineDominatorTree;
>  class InstrItineraryData;
> +class DefaultVLIWScheduler;
> +class SUnit;
>
>  class DFAPacketizer {
>  private:
> @@ -73,6 +78,70 @@
>   // instruction and change the current state to reflect that change.
>   void reserveResources(llvm::MachineInstr *MI);
>  };
> +
> +// VLIWPacketizerList - Implements a simple VLIW packetizer using DFA. The
> +// packetizer works on machine basic blocks. For each instruction I in BB, the
> +// packetizer consults the DFA to see if machine resources are available to
> +// execute I. If so, the packetizer checks if I depends on any instruction J in
> +// the current packet. If no dependency is found, I is added to current packet
> +// and machine resource is marked as taken. If any dependency is found, a target
> +// API call is made to prune the dependence.
> +class VLIWPacketizerList {
> +  const TargetMachine &TM;
> +  const MachineFunction &MF;
> +  const TargetInstrInfo *TII;
> +
> +  // The VLIW Scheduler.
> +  DefaultVLIWScheduler *VLIWScheduler;
> +
> +protected:
> +  // Vector of instructions assigned to the current packet.
> +  std::vector<MachineInstr*> CurrentPacketMIs;
> +  // DFA resource tracker.
> +  DFAPacketizer *ResourceTracker;
> +  // Scheduling units.
> +  std::vector<SUnit> SUnits;
> +
> +public:
> +  VLIWPacketizerList(
> +    MachineFunction &MF, MachineLoopInfo &MLI, MachineDominatorTree &MDT,
> +    bool IsPostRA);
> +
> +  virtual ~VLIWPacketizerList();
> +
> +  // PacketizeMIs - Implement this API in the backend to bundle instructions.
> +  void PacketizeMIs(MachineBasicBlock *MBB,
> +                    MachineBasicBlock::iterator BeginItr,
> +                    MachineBasicBlock::iterator EndItr);
> +
> +  // getResourceTracker - return ResourceTracker
> +  DFAPacketizer *getResourceTracker() {return ResourceTracker;}
> +
> +  // addToPacket - Add MI to the current packet.
> +  void addToPacket(MachineInstr *MI);
> +
> +  // endPacket - End the current packet.
> +  void endPacket(MachineBasicBlock *MBB, MachineInstr *I);
> +
> +  // ignorePseudoInstruction - Ignore bundling of pseudo instructions.
> +  bool ignorePseudoInstruction(MachineInstr *I, MachineBasicBlock *MBB);
> +
> +  // isSoloInstruction - return true if instruction I must end previous
> +  // packet.
> +  bool isSoloInstruction(MachineInstr *I);
> +
> +  // isLegalToPacketizeTogether - Is it legal to packetize SUI and SUJ
> +  // together.
> +  virtual bool isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) {
> +    return false;
> +  }
> +
> +  // isLegalToPruneDependencies - Is it legal to prune dependece between SUI
> +  // and SUJ.
> +  virtual bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) {
> +    return false;
> +  }
> +};
>  }
>
>  #endif
>
> Modified: llvm/trunk/lib/CodeGen/DFAPacketizer.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DFAPacketizer.cpp?rev=150607&r1=150606&r2=150607&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/DFAPacketizer.cpp (original)
> +++ llvm/trunk/lib/CodeGen/DFAPacketizer.cpp Wed Feb 15 12:55:14 2012
> @@ -23,8 +23,11 @@
>  //
>  //===----------------------------------------------------------------------===//
>
> +#include "ScheduleDAGInstrs.h"
>  #include "llvm/CodeGen/DFAPacketizer.h"
>  #include "llvm/CodeGen/MachineInstr.h"
> +#include "llvm/CodeGen/MachineInstrBundle.h"
> +#include "llvm/Target/TargetInstrInfo.h"
>  #include "llvm/MC/MCInstrItineraries.h"
>  using namespace llvm;
>
> @@ -96,3 +99,147 @@
>   const llvm::MCInstrDesc &MID = MI->getDesc();
>   reserveResources(&MID);
>  }
> +
> +namespace llvm {
> +// DefaultVLIWScheduler - This class extends ScheduleDAGInstrs and overrides
> +// Schedule method to build the dependence graph.
> +class DefaultVLIWScheduler : public ScheduleDAGInstrs {

Should this have LLVM_LIBRARY_VISIBILITY? GCC complains thusly:
lib/CodeGen/DFAPacketizer.cpp:106:7: error:
'llvm::DefaultVLIWScheduler' declared with greater visibility than the
type of its field 'llvm::DefaultVLIWScheduler::<anonymous>'
[-Werror=attributes]
lib/CodeGen/DFAPacketizer.cpp:106:7: error:
'llvm::DefaultVLIWScheduler' declared with greater visibility than its
base 'llvm::ScheduleDAGInstrs' [-Werror=attributes]

(Shame on GCC for that first diagnostic. Shame on Clang for no diagnostics...)

-Matt




More information about the llvm-commits mailing list