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
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_R600_R600MACHINESCHEDULER_H
|
|
|
|
#define LLVM_LIB_TARGET_R600_R600MACHINESCHEDULER_H
|
2013-03-06 02:41:32 +08:00
|
|
|
|
|
|
|
#include "R600InstrInfo.h"
|
2013-05-24 01:10:37 +08:00
|
|
|
#include "llvm/ADT/PriorityQueue.h"
|
2013-03-06 02:41:32 +08:00
|
|
|
#include "llvm/CodeGen/MachineScheduler.h"
|
|
|
|
#include "llvm/Support/Debug.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class R600SchedStrategy : public MachineSchedStrategy {
|
|
|
|
|
2013-12-29 05:56:47 +08:00
|
|
|
const ScheduleDAGMILive *DAG;
|
2013-03-06 02:41:32 +08:00
|
|
|
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,
|
2013-05-18 00:50:56 +08:00
|
|
|
AluPredX,
|
2013-06-30 03:32:43 +08:00
|
|
|
AluTrans,
|
2013-03-06 02:41:32 +08:00
|
|
|
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];
|
2013-06-06 04:27:35 +08:00
|
|
|
std::vector<SUnit *> PhysicalRegCopy;
|
2013-03-06 02:41:32 +08:00
|
|
|
|
|
|
|
InstKind CurInstKind;
|
|
|
|
int CurEmitted;
|
|
|
|
InstKind NextInstKind;
|
|
|
|
|
2013-06-08 07:30:34 +08:00
|
|
|
unsigned AluInstCount;
|
|
|
|
unsigned FetchInstCount;
|
|
|
|
|
2013-03-06 02:41:32 +08:00
|
|
|
int InstKindLimit[IDLast];
|
|
|
|
|
|
|
|
int OccupedSlotsMask;
|
|
|
|
|
|
|
|
public:
|
|
|
|
R600SchedStrategy() :
|
2014-04-28 12:05:08 +08:00
|
|
|
DAG(nullptr), TII(nullptr), TRI(nullptr), MRI(nullptr) {
|
2013-03-06 02:41:32 +08:00
|
|
|
}
|
|
|
|
|
2014-04-29 15:57:24 +08:00
|
|
|
virtual ~R600SchedStrategy() {}
|
2013-03-06 02:41:32 +08:00
|
|
|
|
2014-04-29 15:57:24 +08:00
|
|
|
void initialize(ScheduleDAGMI *dag) override;
|
|
|
|
SUnit *pickNode(bool &IsTopNode) override;
|
|
|
|
void schedNode(SUnit *SU, bool IsTopNode) override;
|
|
|
|
void releaseTopNode(SUnit *SU) override;
|
|
|
|
void releaseBottomNode(SUnit *SU) override;
|
2013-03-06 02:41:32 +08:00
|
|
|
|
|
|
|
private:
|
2013-03-14 23:50:45 +08:00
|
|
|
std::vector<MachineInstr *> InstructionsGroupCandidate;
|
2013-09-05 03:53:46 +08:00
|
|
|
bool VLIW5;
|
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();
|
2013-06-08 07:30:34 +08:00
|
|
|
unsigned AvailablesAluCount() const;
|
2013-09-05 03:53:46 +08:00
|
|
|
SUnit *AttemptFillSlot (unsigned Slot, bool AnyAlu);
|
2013-03-06 02:41:32 +08:00
|
|
|
void PrepareNextSlot();
|
2013-09-05 03:53:46 +08:00
|
|
|
SUnit *PopInst(std::vector<SUnit*> &Q, bool AnyALU);
|
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_ */
|