2013-03-06 02:41:32 +08:00
|
|
|
//===-- R600MachineScheduler.h - R600 Scheduler Interface -*- C++ -*-------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
/// \file
|
|
|
|
/// \brief R600 Machine Scheduler interface
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef R600MACHINESCHEDULER_H_
|
|
|
|
#define R600MACHINESCHEDULER_H_
|
|
|
|
|
|
|
|
#include "R600InstrInfo.h"
|
|
|
|
#include "llvm/CodeGen/MachineScheduler.h"
|
|
|
|
#include "llvm/Support/Debug.h"
|
|
|
|
#include "llvm/ADT/PriorityQueue.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class R600SchedStrategy : public MachineSchedStrategy {
|
|
|
|
|
|
|
|
const ScheduleDAGMI *DAG;
|
|
|
|
const R600InstrInfo *TII;
|
|
|
|
const R600RegisterInfo *TRI;
|
|
|
|
MachineRegisterInfo *MRI;
|
|
|
|
|
|
|
|
enum InstKind {
|
|
|
|
IDAlu,
|
|
|
|
IDFetch,
|
|
|
|
IDOther,
|
|
|
|
IDLast
|
|
|
|
};
|
|
|
|
|
|
|
|
enum AluKind {
|
|
|
|
AluAny,
|
|
|
|
AluT_X,
|
|
|
|
AluT_Y,
|
|
|
|
AluT_Z,
|
|
|
|
AluT_W,
|
|
|
|
AluT_XYZW,
|
|
|
|
AluDiscarded, // LLVM Instructions that are going to be eliminated
|
|
|
|
AluLast
|
|
|
|
};
|
|
|
|
|
2013-05-18 00:50:44 +08:00
|
|
|
std::vector<SUnit *> Available[IDLast], Pending[IDLast];
|
|
|
|
std::vector<SUnit *> AvailableAlus[AluLast];
|
|
|
|
std::vector<SUnit *> FakeCopy;
|
2013-03-06 02:41:32 +08:00
|
|
|
|
|
|
|
InstKind CurInstKind;
|
|
|
|
int CurEmitted;
|
|
|
|
InstKind NextInstKind;
|
|
|
|
|
|
|
|
int InstKindLimit[IDLast];
|
|
|
|
|
|
|
|
int OccupedSlotsMask;
|
|
|
|
|
|
|
|
public:
|
|
|
|
R600SchedStrategy() :
|
|
|
|
DAG(0), TII(0), TRI(0), MRI(0) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~R600SchedStrategy() {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void initialize(ScheduleDAGMI *dag);
|
|
|
|
virtual SUnit *pickNode(bool &IsTopNode);
|
|
|
|
virtual void schedNode(SUnit *SU, bool IsTopNode);
|
|
|
|
virtual void releaseTopNode(SUnit *SU);
|
|
|
|
virtual void releaseBottomNode(SUnit *SU);
|
|
|
|
|
|
|
|
private:
|
2013-03-14 23:50:45 +08:00
|
|
|
std::vector<MachineInstr *> InstructionsGroupCandidate;
|
2013-03-06 02:41:32 +08:00
|
|
|
|
|
|
|
int getInstKind(SUnit *SU);
|
|
|
|
bool regBelongsToClass(unsigned Reg, const TargetRegisterClass *RC) const;
|
|
|
|
AluKind getAluKind(SUnit *SU) const;
|
|
|
|
void LoadAlu();
|
|
|
|
bool isAvailablesAluEmpty() const;
|
|
|
|
SUnit *AttemptFillSlot (unsigned Slot);
|
|
|
|
void PrepareNextSlot();
|
2013-05-18 00:50:44 +08:00
|
|
|
SUnit *PopInst(std::vector<SUnit*> &Q);
|
2013-03-06 02:41:32 +08:00
|
|
|
|
|
|
|
void AssignSlot(MachineInstr *MI, unsigned Slot);
|
|
|
|
SUnit* pickAlu();
|
|
|
|
SUnit* pickOther(int QID);
|
2013-05-18 00:50:44 +08:00
|
|
|
void MoveUnits(std::vector<SUnit *> &QSrc, std::vector<SUnit *> &QDst);
|
2013-03-06 02:41:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace llvm
|
|
|
|
|
|
|
|
#endif /* R600MACHINESCHEDULER_H_ */
|