diff options
author | Andrew Trick <atrick@apple.com> | 2012-02-15 18:55:14 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2012-02-15 18:55:14 +0000 |
commit | ebafa0c61170682ec0d7025f46f187a164b0db7e (patch) | |
tree | 6ec8db0e249e5a54bf0a498cee71dcbab7f66082 /include/llvm/CodeGen | |
parent | ab7955b9ce3197215406bc9fc97b22074127d035 (diff) | |
download | external_llvm-ebafa0c61170682ec0d7025f46f187a164b0db7e.zip external_llvm-ebafa0c61170682ec0d7025f46f187a164b0db7e.tar.gz external_llvm-ebafa0c61170682ec0d7025f46f187a164b0db7e.tar.bz2 |
Generic "VLIW" packetizer based on a DFA generated from target itinerary.
Patch by Sundeep!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150607 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen')
-rw-r--r-- | include/llvm/CodeGen/DFAPacketizer.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/include/llvm/CodeGen/DFAPacketizer.h b/include/llvm/CodeGen/DFAPacketizer.h index 0a11e0c..9036bcd 100644 --- a/include/llvm/CodeGen/DFAPacketizer.h +++ b/include/llvm/CodeGen/DFAPacketizer.h @@ -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 @@ public: // 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 |