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"
|
2014-09-24 01:33:17 +00:00
|
|
|
#include "AMDGPUSubtarget.h"
|
2014-05-02 15:41:42 +00:00
|
|
|
#include "SIInstrInfo.h"
|
2014-09-24 01:33:17 +00:00
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
2014-08-21 20:40:54 +00:00
|
|
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
2013-11-27 21:23:35 +00:00
|
|
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
2014-05-02 15:41:42 +00:00
|
|
|
#include "llvm/IR/Function.h"
|
|
|
|
#include "llvm/IR/LLVMContext.h"
|
2013-11-27 21:23:35 +00:00
|
|
|
|
|
|
|
#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),
|
2014-09-24 01:33:17 +00:00
|
|
|
TIDReg(AMDGPU::NoRegister),
|
2015-01-14 15:42:31 +00:00
|
|
|
HasSpilledVGPRs(false),
|
2013-11-27 21:23:35 +00:00
|
|
|
PSInputAddr(0),
|
2014-09-24 01:33:17 +00:00
|
|
|
NumUserSGPRs(0),
|
|
|
|
LDSWaveSpillSize(0) { }
|
2014-08-21 20:40:54 +00:00
|
|
|
|
|
|
|
SIMachineFunctionInfo::SpilledReg SIMachineFunctionInfo::getSpilledReg(
|
|
|
|
MachineFunction *MF,
|
|
|
|
unsigned FrameIndex,
|
|
|
|
unsigned SubIdx) {
|
|
|
|
const MachineFrameInfo *FrameInfo = MF->getFrameInfo();
|
2015-02-19 01:10:55 +00:00
|
|
|
const SIRegisterInfo *TRI = static_cast<const SIRegisterInfo *>(
|
|
|
|
MF->getSubtarget<AMDGPUSubtarget>().getRegisterInfo());
|
2014-08-21 20:40:54 +00:00
|
|
|
MachineRegisterInfo &MRI = MF->getRegInfo();
|
|
|
|
int64_t Offset = FrameInfo->getObjectOffset(FrameIndex);
|
|
|
|
Offset += SubIdx * 4;
|
|
|
|
|
|
|
|
unsigned LaneVGPRIdx = Offset / (64 * 4);
|
|
|
|
unsigned Lane = (Offset / 4) % 64;
|
|
|
|
|
|
|
|
struct SpilledReg Spill;
|
|
|
|
|
|
|
|
if (!LaneVGPRs.count(LaneVGPRIdx)) {
|
2015-01-14 15:42:31 +00:00
|
|
|
unsigned LaneVGPR = TRI->findUnusedRegister(MRI, &AMDGPU::VGPR_32RegClass);
|
2014-08-21 20:40:54 +00:00
|
|
|
LaneVGPRs[LaneVGPRIdx] = LaneVGPR;
|
|
|
|
|
|
|
|
// Add this register as live-in to all blocks to avoid machine verifer
|
|
|
|
// complaining about use of an undefined physical register.
|
|
|
|
for (MachineFunction::iterator BI = MF->begin(), BE = MF->end();
|
|
|
|
BI != BE; ++BI) {
|
|
|
|
BI->addLiveIn(LaneVGPR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Spill.VGPR = LaneVGPRs[LaneVGPRIdx];
|
|
|
|
Spill.Lane = Lane;
|
|
|
|
return Spill;
|
2013-11-27 21:23:35 +00:00
|
|
|
}
|
2014-09-24 01:33:17 +00:00
|
|
|
|
|
|
|
unsigned SIMachineFunctionInfo::getMaximumWorkGroupSize(
|
|
|
|
const MachineFunction &MF) const {
|
2015-02-19 01:10:55 +00:00
|
|
|
const AMDGPUSubtarget &ST = MF.getSubtarget<AMDGPUSubtarget>();
|
2014-09-24 01:33:17 +00:00
|
|
|
// FIXME: We should get this information from kernel attributes if it
|
|
|
|
// is available.
|
|
|
|
return getShaderType() == ShaderType::COMPUTE ? 256 : ST.getWavefrontSize();
|
|
|
|
}
|