#include "AMDGPU.h"
#include "GCNSubtarget.h"
#include "SIMachineFunctionInfo.h"
#include "SIRegisterInfo.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/LiveIntervals.h"
#include "llvm/CodeGen/LiveRegMatrix.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/VirtRegMap.h"
#include "llvm/InitializePasses.h"
usingnamespacellvm;
#define DEBUG_TYPE …
STATISTIC(NumNSAInstructions,
"Number of NSA instructions with non-sequential address found");
STATISTIC(NumNSAConverted,
"Number of NSA instructions changed to sequential");
namespace {
class GCNNSAReassign : public MachineFunctionPass { … };
}
INITIALIZE_PASS_BEGIN(GCNNSAReassign, DEBUG_TYPE, "GCN NSA Reassign",
false, false)
INITIALIZE_PASS_DEPENDENCY(LiveIntervalsWrapperPass)
INITIALIZE_PASS_DEPENDENCY(VirtRegMap)
INITIALIZE_PASS_DEPENDENCY(LiveRegMatrix)
INITIALIZE_PASS_END(GCNNSAReassign, DEBUG_TYPE, "GCN NSA Reassign",
false, false)
char GCNNSAReassign::ID = …;
char &llvm::GCNNSAReassignID = …;
bool
GCNNSAReassign::tryAssignRegisters(SmallVectorImpl<LiveInterval *> &Intervals,
unsigned StartReg) const { … }
bool GCNNSAReassign::canAssign(unsigned StartReg, unsigned NumRegs) const { … }
bool
GCNNSAReassign::scavengeRegs(SmallVectorImpl<LiveInterval *> &Intervals) const { … }
GCNNSAReassign::NSA_Status
GCNNSAReassign::CheckNSA(const MachineInstr &MI, bool Fast) const { … }
bool GCNNSAReassign::runOnMachineFunction(MachineFunction &MF) { … }