mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-29 13:29:28 +00:00
The LDS output queue is accessed via the OQAP register. The OQAP register cannot be live across clauses, so if value is written to the output queue, it must be retrieved before the end of the clause. With the machine scheduler, we cannot statisfy this constraint, because it lacks proper alias analysis and it will mark some LDS accesses as having a chain dependency on vertex fetches. Since vertex fetches require a new clauses, the dependency may end up spiltting OQAP uses and defs so the end up in different clauses. See the lds-output-queue.ll test for a more detailed explanation. To work around this issue, we now combine the LDS read and the OQAP copy into one instruction and expand it after register allocation. This patch also adds some checks to the EmitClauseMarker pass, so that it doesn't end a clause with a value still in the output queue and removes AR.X and OQAP handling from the scheduler (AR.X uses and defs were already being expanded post-RA, so the scheduler will never see them). Reviewed-by: Vincent Lejeune <vljn at ovi.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194755 91177308-0d34-0410-b5e6-96231b3b80d8
105 lines
2.4 KiB
C++
105 lines
2.4 KiB
C++
//===-- 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/ADT/PriorityQueue.h"
|
|
#include "llvm/CodeGen/MachineScheduler.h"
|
|
#include "llvm/Support/Debug.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,
|
|
AluPredX,
|
|
AluTrans,
|
|
AluDiscarded, // LLVM Instructions that are going to be eliminated
|
|
AluLast
|
|
};
|
|
|
|
std::vector<SUnit *> Available[IDLast], Pending[IDLast];
|
|
std::vector<SUnit *> AvailableAlus[AluLast];
|
|
std::vector<SUnit *> PhysicalRegCopy;
|
|
|
|
InstKind CurInstKind;
|
|
int CurEmitted;
|
|
InstKind NextInstKind;
|
|
|
|
unsigned AluInstCount;
|
|
unsigned FetchInstCount;
|
|
|
|
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:
|
|
std::vector<MachineInstr *> InstructionsGroupCandidate;
|
|
bool VLIW5;
|
|
|
|
int getInstKind(SUnit *SU);
|
|
bool regBelongsToClass(unsigned Reg, const TargetRegisterClass *RC) const;
|
|
AluKind getAluKind(SUnit *SU) const;
|
|
void LoadAlu();
|
|
unsigned AvailablesAluCount() const;
|
|
SUnit *AttemptFillSlot (unsigned Slot, bool AnyAlu);
|
|
void PrepareNextSlot();
|
|
SUnit *PopInst(std::vector<SUnit*> &Q, bool AnyALU);
|
|
|
|
void AssignSlot(MachineInstr *MI, unsigned Slot);
|
|
SUnit* pickAlu();
|
|
SUnit* pickOther(int QID);
|
|
void MoveUnits(std::vector<SUnit *> &QSrc, std::vector<SUnit *> &QDst);
|
|
};
|
|
|
|
} // namespace llvm
|
|
|
|
#endif /* R600MACHINESCHEDULER_H_ */
|