R600/SI: Print code size along with used registers

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206336 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Matt Arsenault 2014-04-15 22:40:47 +00:00
parent bec5c611e1
commit d66d570796
2 changed files with 19 additions and 13 deletions

View File

@ -64,7 +64,7 @@ bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
const AMDGPUSubtarget &STM = TM.getSubtarget<AMDGPUSubtarget>(); const AMDGPUSubtarget &STM = TM.getSubtarget<AMDGPUSubtarget>();
SIProgramInfo KernelInfo; SIProgramInfo KernelInfo;
if (STM.getGeneration() > AMDGPUSubtarget::NORTHERN_ISLANDS) { if (STM.getGeneration() > AMDGPUSubtarget::NORTHERN_ISLANDS) {
findNumUsedRegistersSI(MF, KernelInfo.NumSGPR, KernelInfo.NumVGPR); getSIProgramInfo(KernelInfo, MF);
EmitProgramInfoSI(MF, KernelInfo); EmitProgramInfoSI(MF, KernelInfo);
} else { } else {
EmitProgramInfoR600(MF); EmitProgramInfoR600(MF);
@ -84,8 +84,10 @@ bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
SectionKind::getReadOnly()); SectionKind::getReadOnly());
OutStreamer.SwitchSection(CommentSection); OutStreamer.SwitchSection(CommentSection);
if (STM.getGeneration() > AMDGPUSubtarget::NORTHERN_ISLANDS) { if (STM.getGeneration() >= AMDGPUSubtarget::SOUTHERN_ISLANDS) {
OutStreamer.emitRawComment(" Kernel info:", false); OutStreamer.emitRawComment(" Kernel info:", false);
OutStreamer.emitRawComment(" codeLenInByte = " + Twine(KernelInfo.CodeLen),
false);
OutStreamer.emitRawComment(" NumSgprs: " + Twine(KernelInfo.NumSGPR), OutStreamer.emitRawComment(" NumSgprs: " + Twine(KernelInfo.NumSGPR),
false); false);
OutStreamer.emitRawComment(" NumVgprs: " + Twine(KernelInfo.NumVGPR), OutStreamer.emitRawComment(" NumVgprs: " + Twine(KernelInfo.NumVGPR),
@ -184,9 +186,9 @@ void AMDGPUAsmPrinter::EmitProgramInfoR600(MachineFunction &MF) {
} }
} }
void AMDGPUAsmPrinter::findNumUsedRegistersSI(MachineFunction &MF, void AMDGPUAsmPrinter::getSIProgramInfo(SIProgramInfo &ProgInfo,
unsigned &NumSGPR, MachineFunction &MF) const {
unsigned &NumVGPR) const { uint64_t CodeSize = 0;
unsigned MaxSGPR = 0; unsigned MaxSGPR = 0;
unsigned MaxVGPR = 0; unsigned MaxVGPR = 0;
bool VCCUsed = false; bool VCCUsed = false;
@ -200,6 +202,9 @@ void AMDGPUAsmPrinter::findNumUsedRegistersSI(MachineFunction &MF,
I != E; ++I) { I != E; ++I) {
MachineInstr &MI = *I; MachineInstr &MI = *I;
// TODO: CodeSize should account for multiple functions.
CodeSize += MI.getDesc().Size;
unsigned numOperands = MI.getNumOperands(); unsigned numOperands = MI.getNumOperands();
for (unsigned op_idx = 0; op_idx < numOperands; op_idx++) { for (unsigned op_idx = 0; op_idx < numOperands; op_idx++) {
MachineOperand &MO = MI.getOperand(op_idx); MachineOperand &MO = MI.getOperand(op_idx);
@ -274,13 +279,9 @@ void AMDGPUAsmPrinter::findNumUsedRegistersSI(MachineFunction &MF,
if (VCCUsed) if (VCCUsed)
MaxSGPR += 2; MaxSGPR += 2;
NumSGPR = MaxSGPR; ProgInfo.CodeLen = CodeSize;
NumVGPR = MaxVGPR; ProgInfo.NumSGPR = MaxSGPR;
} ProgInfo.NumVGPR = MaxVGPR;
void AMDGPUAsmPrinter::getSIProgramInfo(SIProgramInfo &Out,
MachineFunction &MF) const {
findNumUsedRegistersSI(MF, Out.NumSGPR, Out.NumVGPR);
} }
void AMDGPUAsmPrinter::EmitProgramInfoSI(MachineFunction &MF, void AMDGPUAsmPrinter::EmitProgramInfoSI(MachineFunction &MF,

View File

@ -24,7 +24,12 @@ namespace llvm {
class AMDGPUAsmPrinter : public AsmPrinter { class AMDGPUAsmPrinter : public AsmPrinter {
private: private:
struct SIProgramInfo { struct SIProgramInfo {
SIProgramInfo() : NumSGPR(0), NumVGPR(0) {} SIProgramInfo() :
CodeLen(0),
NumSGPR(0),
NumVGPR(0) {}
uint64_t CodeLen;
unsigned NumSGPR; unsigned NumSGPR;
unsigned NumVGPR; unsigned NumVGPR;
}; };