summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
diff options
context:
space:
mode:
authorKonstantin Zhuravlyov <kzhuravl_dev@outlook.com>2017-10-14 19:03:51 +0000
committerKonstantin Zhuravlyov <kzhuravl_dev@outlook.com>2017-10-14 19:03:51 +0000
commita01d8b0b63fff7824edd82bc92ee11720d29eaf3 (patch)
treefe44a8a6e5152c23e236c96bf946764ceecf4b00 /llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
parentb3c605d680b1213de314dcd9cca30208748a1695 (diff)
downloadbcm5719-llvm-a01d8b0b63fff7824edd82bc92ee11720d29eaf3.tar.gz
bcm5719-llvm-a01d8b0b63fff7824edd82bc92ee11720d29eaf3.zip
AMDGPU: Bring HSA metadata on par with the specification
Differential Revision: https://reviews.llvm.org/D38753 llvm-svn: 315821
Diffstat (limited to 'llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp')
-rw-r--r--llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp51
1 files changed, 50 insertions, 1 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
index ca828b45c54..b3650b4ac89 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -199,7 +199,9 @@ void AMDGPUAsmPrinter::EmitFunctionBodyStart() {
if (TM.getTargetTriple().getOS() != Triple::AMDHSA)
return;
- HSAMetadataStream.emitKernel(*MF->getFunction(), KernelCode);
+ HSAMetadataStream.emitKernel(*MF->getFunction(),
+ getHSACodeProps(*MF, CurrentProgramInfo),
+ getHSADebugProps(*MF, CurrentProgramInfo));
}
void AMDGPUAsmPrinter::EmitFunctionEntryLabel() {
@@ -1155,6 +1157,53 @@ void AMDGPUAsmPrinter::getAmdKernelCode(amd_kernel_code_t &Out,
}
}
+AMDGPU::HSAMD::Kernel::CodeProps::Metadata AMDGPUAsmPrinter::getHSACodeProps(
+ const MachineFunction &MF,
+ const SIProgramInfo &ProgramInfo) const {
+ const SISubtarget &STM = MF.getSubtarget<SISubtarget>();
+ const SIMachineFunctionInfo &MFI = *MF.getInfo<SIMachineFunctionInfo>();
+ HSAMD::Kernel::CodeProps::Metadata HSACodeProps;
+
+ HSACodeProps.mKernargSegmentSize =
+ STM.getKernArgSegmentSize(MF, MFI.getABIArgOffset());
+ HSACodeProps.mGroupSegmentFixedSize = ProgramInfo.LDSSize;
+ HSACodeProps.mPrivateSegmentFixedSize = ProgramInfo.ScratchSize;
+ HSACodeProps.mKernargSegmentAlign =
+ std::max(uint32_t(4), MFI.getMaxKernArgAlign());
+ HSACodeProps.mWavefrontSize = STM.getWavefrontSize();
+ HSACodeProps.mNumSGPRs = CurrentProgramInfo.NumSGPR;
+ HSACodeProps.mNumVGPRs = CurrentProgramInfo.NumVGPR;
+ // TODO: Emit HSACodeProps.mMaxFlatWorkgroupSize.
+ HSACodeProps.mIsDynamicCallStack = ProgramInfo.DynamicCallStack;
+ HSACodeProps.mIsXNACKEnabled = STM.isXNACKEnabled();
+
+ return HSACodeProps;
+}
+
+AMDGPU::HSAMD::Kernel::DebugProps::Metadata AMDGPUAsmPrinter::getHSADebugProps(
+ const MachineFunction &MF,
+ const SIProgramInfo &ProgramInfo) const {
+ const SISubtarget &STM = MF.getSubtarget<SISubtarget>();
+ HSAMD::Kernel::DebugProps::Metadata HSADebugProps;
+
+ if (!STM.debuggerSupported())
+ return HSADebugProps;
+
+ HSADebugProps.mDebuggerABIVersion.push_back(1);
+ HSADebugProps.mDebuggerABIVersion.push_back(0);
+ HSADebugProps.mReservedNumVGPRs = ProgramInfo.ReservedVGPRCount;
+ HSADebugProps.mReservedFirstVGPR = ProgramInfo.ReservedVGPRFirst;
+
+ if (STM.debuggerEmitPrologue()) {
+ HSADebugProps.mPrivateSegmentBufferSGPR =
+ ProgramInfo.DebuggerPrivateSegmentBufferSGPR;
+ HSADebugProps.mWavefrontPrivateSegmentOffsetSGPR =
+ ProgramInfo.DebuggerWavefrontPrivateSegmentOffsetSGPR;
+ }
+
+ return HSADebugProps;
+}
+
bool AMDGPUAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
unsigned AsmVariant,
const char *ExtraCode, raw_ostream &O) {
OpenPOWER on IntegriCloud