2012-12-11 21:25:42 +00:00
|
|
|
//===-- SIMachineFunctionInfo.cpp - SI Machine Function Info -------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
/// \file
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
|
|
#include "SIMachineFunctionInfo.h"
|
2013-11-27 21:23:35 +00:00
|
|
|
#include "SIRegisterInfo.h"
|
|
|
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
|
|
|
|
|
|
|
#define MAX_LANES 64
|
2012-12-11 21:25:42 +00:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2013-11-19 00:57:56 +00:00
|
|
|
|
|
|
|
// Pin the vtable to this file.
|
|
|
|
void SIMachineFunctionInfo::anchor() {}
|
|
|
|
|
2012-12-11 21:25:42 +00:00
|
|
|
SIMachineFunctionInfo::SIMachineFunctionInfo(const MachineFunction &MF)
|
2013-04-01 21:47:53 +00:00
|
|
|
: AMDGPUMachineFunction(MF),
|
2013-11-27 21:23:35 +00:00
|
|
|
PSInputAddr(0),
|
|
|
|
SpillTracker() { }
|
|
|
|
|
|
|
|
static unsigned createLaneVGPR(MachineRegisterInfo &MRI) {
|
|
|
|
return MRI.createVirtualRegister(&AMDGPU::VReg_32RegClass);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned SIMachineFunctionInfo::RegSpillTracker::getNextLane(MachineRegisterInfo &MRI) {
|
|
|
|
if (!LaneVGPR) {
|
|
|
|
LaneVGPR = createLaneVGPR(MRI);
|
|
|
|
} else {
|
|
|
|
CurrentLane++;
|
|
|
|
if (CurrentLane == MAX_LANES) {
|
|
|
|
CurrentLane = 0;
|
|
|
|
LaneVGPR = createLaneVGPR(MRI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return CurrentLane;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SIMachineFunctionInfo::RegSpillTracker::addSpilledReg(unsigned FrameIndex,
|
|
|
|
unsigned Reg,
|
|
|
|
int Lane) {
|
|
|
|
SpilledRegisters[FrameIndex] = SpilledReg(Reg, Lane);
|
|
|
|
}
|
|
|
|
|
|
|
|
const SIMachineFunctionInfo::SpilledReg&
|
|
|
|
SIMachineFunctionInfo::RegSpillTracker::getSpilledReg(unsigned FrameIndex) {
|
|
|
|
return SpilledRegisters[FrameIndex];
|
|
|
|
}
|