DFAPacketizer.h (234982) | DFAPacketizer.h (239462) |
---|---|
1//=- llvm/CodeGen/DFAPacketizer.h - DFA Packetizer for VLIW ---*- C++ -*-=====// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 14 unchanged lines hidden (view full) --- 23// 24//===----------------------------------------------------------------------===// 25 26#ifndef LLVM_CODEGEN_DFAPACKETIZER_H 27#define LLVM_CODEGEN_DFAPACKETIZER_H 28 29#include "llvm/CodeGen/MachineBasicBlock.h" 30#include "llvm/ADT/DenseMap.h" | 1//=- llvm/CodeGen/DFAPacketizer.h - DFA Packetizer for VLIW ---*- C++ -*-=====// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 14 unchanged lines hidden (view full) --- 23// 24//===----------------------------------------------------------------------===// 25 26#ifndef LLVM_CODEGEN_DFAPACKETIZER_H 27#define LLVM_CODEGEN_DFAPACKETIZER_H 28 29#include "llvm/CodeGen/MachineBasicBlock.h" 30#include "llvm/ADT/DenseMap.h" |
31#include <map> |
|
31 32namespace llvm { 33 34class MCInstrDesc; 35class MachineInstr; 36class MachineLoopInfo; 37class MachineDominatorTree; 38class InstrItineraryData; | 32 33namespace llvm { 34 35class MCInstrDesc; 36class MachineInstr; 37class MachineLoopInfo; 38class MachineDominatorTree; 39class InstrItineraryData; |
39class ScheduleDAGInstrs; | 40class DefaultVLIWScheduler; |
40class SUnit; 41 42class DFAPacketizer { 43private: 44 typedef std::pair<unsigned, unsigned> UnsignPair; 45 const InstrItineraryData *InstrItins; 46 int CurrentState; 47 const int (*DFAStateInputTable)[2]; --- 24 unchanged lines hidden (view full) --- 72 73 // canReserveResources - Check if the resources occupied by a machine 74 // instruction are available in the current state. 75 bool canReserveResources(llvm::MachineInstr *MI); 76 77 // reserveResources - Reserve the resources occupied by a machine 78 // instruction and change the current state to reflect that change. 79 void reserveResources(llvm::MachineInstr *MI); | 41class SUnit; 42 43class DFAPacketizer { 44private: 45 typedef std::pair<unsigned, unsigned> UnsignPair; 46 const InstrItineraryData *InstrItins; 47 int CurrentState; 48 const int (*DFAStateInputTable)[2]; --- 24 unchanged lines hidden (view full) --- 73 74 // canReserveResources - Check if the resources occupied by a machine 75 // instruction are available in the current state. 76 bool canReserveResources(llvm::MachineInstr *MI); 77 78 // reserveResources - Reserve the resources occupied by a machine 79 // instruction and change the current state to reflect that change. 80 void reserveResources(llvm::MachineInstr *MI); |
81 82 const InstrItineraryData *getInstrItins() const { return InstrItins; } |
|
80}; 81 82// VLIWPacketizerList - Implements a simple VLIW packetizer using DFA. The 83// packetizer works on machine basic blocks. For each instruction I in BB, the 84// packetizer consults the DFA to see if machine resources are available to 85// execute I. If so, the packetizer checks if I depends on any instruction J in 86// the current packet. If no dependency is found, I is added to current packet 87// and machine resource is marked as taken. If any dependency is found, a target 88// API call is made to prune the dependence. 89class VLIWPacketizerList { | 83}; 84 85// VLIWPacketizerList - Implements a simple VLIW packetizer using DFA. The 86// packetizer works on machine basic blocks. For each instruction I in BB, the 87// packetizer consults the DFA to see if machine resources are available to 88// execute I. If so, the packetizer checks if I depends on any instruction J in 89// the current packet. If no dependency is found, I is added to current packet 90// and machine resource is marked as taken. If any dependency is found, a target 91// API call is made to prune the dependence. 92class VLIWPacketizerList { |
93protected: |
|
90 const TargetMachine &TM; 91 const MachineFunction &MF; 92 const TargetInstrInfo *TII; 93 | 94 const TargetMachine &TM; 95 const MachineFunction &MF; 96 const TargetInstrInfo *TII; 97 |
94 // Encapsulate data types not exposed to the target interface. 95 ScheduleDAGInstrs *SchedulerImpl; | 98 // The VLIW Scheduler. 99 DefaultVLIWScheduler *VLIWScheduler; |
96 | 100 |
97protected: | |
98 // Vector of instructions assigned to the current packet. 99 std::vector<MachineInstr*> CurrentPacketMIs; 100 // DFA resource tracker. 101 DFAPacketizer *ResourceTracker; | 101 // Vector of instructions assigned to the current packet. 102 std::vector<MachineInstr*> CurrentPacketMIs; 103 // DFA resource tracker. 104 DFAPacketizer *ResourceTracker; |
102 // Scheduling units. 103 std::vector<SUnit> SUnits; | |
104 | 105 |
106 // Generate MI -> SU map. 107 std::map<MachineInstr*, SUnit*> MIToSUnit; 108 |
|
105public: 106 VLIWPacketizerList( 107 MachineFunction &MF, MachineLoopInfo &MLI, MachineDominatorTree &MDT, 108 bool IsPostRA); 109 110 virtual ~VLIWPacketizerList(); 111 112 // PacketizeMIs - Implement this API in the backend to bundle instructions. 113 void PacketizeMIs(MachineBasicBlock *MBB, 114 MachineBasicBlock::iterator BeginItr, 115 MachineBasicBlock::iterator EndItr); 116 117 // getResourceTracker - return ResourceTracker 118 DFAPacketizer *getResourceTracker() {return ResourceTracker;} 119 120 // addToPacket - Add MI to the current packet. | 109public: 110 VLIWPacketizerList( 111 MachineFunction &MF, MachineLoopInfo &MLI, MachineDominatorTree &MDT, 112 bool IsPostRA); 113 114 virtual ~VLIWPacketizerList(); 115 116 // PacketizeMIs - Implement this API in the backend to bundle instructions. 117 void PacketizeMIs(MachineBasicBlock *MBB, 118 MachineBasicBlock::iterator BeginItr, 119 MachineBasicBlock::iterator EndItr); 120 121 // getResourceTracker - return ResourceTracker 122 DFAPacketizer *getResourceTracker() {return ResourceTracker;} 123 124 // addToPacket - Add MI to the current packet. |
121 void addToPacket(MachineInstr *MI); | 125 virtual MachineBasicBlock::iterator addToPacket(MachineInstr *MI) { 126 MachineBasicBlock::iterator MII = MI; 127 CurrentPacketMIs.push_back(MI); 128 ResourceTracker->reserveResources(MI); 129 return MII; 130 } |
122 123 // endPacket - End the current packet. | 131 132 // endPacket - End the current packet. |
124 void endPacket(MachineBasicBlock *MBB, MachineInstr *I); | 133 void endPacket(MachineBasicBlock *MBB, MachineInstr *MI); |
125 | 134 |
135 // initPacketizerState - perform initialization before packetizing 136 // an instruction. This function is supposed to be overrided by 137 // the target dependent packetizer. 138 virtual void initPacketizerState(void) { return; } 139 |
|
126 // ignorePseudoInstruction - Ignore bundling of pseudo instructions. | 140 // ignorePseudoInstruction - Ignore bundling of pseudo instructions. |
127 bool ignorePseudoInstruction(MachineInstr *I, MachineBasicBlock *MBB); | 141 virtual bool ignorePseudoInstruction(MachineInstr *I, 142 MachineBasicBlock *MBB) { 143 return false; 144 } |
128 | 145 |
129 // isSoloInstruction - return true if instruction I must end previous 130 // packet. 131 bool isSoloInstruction(MachineInstr *I); | 146 // isSoloInstruction - return true if instruction MI can not be packetized 147 // with any other instruction, which means that MI itself is a packet. 148 virtual bool isSoloInstruction(MachineInstr *MI) { 149 return true; 150 } |
132 133 // isLegalToPacketizeTogether - Is it legal to packetize SUI and SUJ 134 // together. 135 virtual bool isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) { 136 return false; 137 } 138 139 // isLegalToPruneDependencies - Is it legal to prune dependece between SUI 140 // and SUJ. 141 virtual bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) { 142 return false; 143 } | 151 152 // isLegalToPacketizeTogether - Is it legal to packetize SUI and SUJ 153 // together. 154 virtual bool isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) { 155 return false; 156 } 157 158 // isLegalToPruneDependencies - Is it legal to prune dependece between SUI 159 // and SUJ. 160 virtual bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) { 161 return false; 162 } |
163 |
|
144}; 145} 146 147#endif | 164}; 165} 166 167#endif |