summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPURuntimeMD.cpp
diff options
context:
space:
mode:
authorKonstantin Zhuravlyov <kzhuravl_dev@outlook.com>2017-02-27 07:55:17 +0000
committerKonstantin Zhuravlyov <kzhuravl_dev@outlook.com>2017-02-27 07:55:17 +0000
commit972948b36eecc591cff85391bf11635750c1c88e (patch)
tree8ab64d2de4b2a745e0dbfd18bea623103fba2189 /llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPURuntimeMD.cpp
parent50aa37b96cf9686b87ef675f3614ab5980e33d3b (diff)
downloadbcm5719-llvm-972948b36eecc591cff85391bf11635750c1c88e.tar.gz
bcm5719-llvm-972948b36eecc591cff85391bf11635750c1c88e.zip
[AMDGPU] Runtime metadata fixes:
- Verify that runtime metadata is actually valid runtime metadata when assembling, otherwise we could accept the following when assembling, but ocl runtime will reject it: .amdgpu_runtime_metadata { amd.MDVersion: [ 2, 1 ], amd.RandomUnknownKey, amd.IsaInfo: ... - Make IsaInfo optional, and always emit it. Differential Revision: https://reviews.llvm.org/D30349 llvm-svn: 296324
Diffstat (limited to 'llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPURuntimeMD.cpp')
-rw-r--r--llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPURuntimeMD.cpp45
1 files changed, 31 insertions, 14 deletions
diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPURuntimeMD.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPURuntimeMD.cpp
index 9bd8eddb60a..0e87d750f5d 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPURuntimeMD.cpp
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPURuntimeMD.cpp
@@ -38,6 +38,7 @@
#include <vector>
using namespace llvm;
+using namespace llvm::AMDGPU::IsaInfo;
using namespace ::AMDGPU::RuntimeMD;
static cl::opt<bool>
@@ -88,7 +89,7 @@ template <> struct MappingTraits<Kernel::Metadata> {
INVALID_KERNEL_INDEX);
YamlIO.mapOptional(KeyName::NoPartialWorkGroups, K.NoPartialWorkGroups,
uint8_t(0));
- YamlIO.mapRequired(KeyName::Args, K.Args);
+ YamlIO.mapOptional(KeyName::Args, K.Args);
}
static const bool flow = true;
};
@@ -116,7 +117,7 @@ template <> struct MappingTraits<IsaInfo::Metadata> {
template <> struct MappingTraits<Program::Metadata> {
static void mapping(IO &YamlIO, Program::Metadata &Prog) {
YamlIO.mapRequired(KeyName::MDVersion, Prog.MDVersionSeq);
- YamlIO.mapRequired(KeyName::IsaInfo, Prog.IsaInfo);
+ YamlIO.mapOptional(KeyName::IsaInfo, Prog.IsaInfo);
YamlIO.mapOptional(KeyName::PrintfInfo, Prog.PrintfInfo);
YamlIO.mapOptional(KeyName::Kernels, Prog.Kernels);
}
@@ -375,6 +376,20 @@ static Kernel::Metadata getRuntimeMDForKernel(const Function &F) {
return Kernel;
}
+static void getIsaInfo(const FeatureBitset &Features, IsaInfo::Metadata &IIM) {
+ IIM.WavefrontSize = getWavefrontSize(Features);
+ IIM.LocalMemorySize = getLocalMemorySize(Features);
+ IIM.EUsPerCU = getEUsPerCU(Features);
+ IIM.MaxWavesPerEU = getMaxWavesPerEU(Features);
+ IIM.MaxFlatWorkGroupSize = getMaxFlatWorkGroupSize(Features);
+ IIM.SGPRAllocGranule = getSGPRAllocGranule(Features);
+ IIM.TotalNumSGPRs = getTotalNumSGPRs(Features);
+ IIM.AddressableNumSGPRs = getAddressableNumSGPRs(Features);
+ IIM.VGPRAllocGranule = getVGPRAllocGranule(Features);
+ IIM.TotalNumVGPRs = getTotalNumVGPRs(Features);
+ IIM.AddressableNumVGPRs = getAddressableNumVGPRs(Features);
+}
+
Program::Metadata::Metadata(const std::string &YAML) {
yaml::Input Input(YAML);
Input >> *this;
@@ -411,18 +426,7 @@ std::string llvm::getRuntimeMDYAMLString(const FeatureBitset &Features,
Prog.MDVersionSeq.push_back(MDVersion);
Prog.MDVersionSeq.push_back(MDRevision);
- IsaInfo::Metadata &IIM = Prog.IsaInfo;
- IIM.WavefrontSize = AMDGPU::IsaInfo::getWavefrontSize(Features);
- IIM.LocalMemorySize = AMDGPU::IsaInfo::getLocalMemorySize(Features);
- IIM.EUsPerCU = AMDGPU::IsaInfo::getEUsPerCU(Features);
- IIM.MaxWavesPerEU = AMDGPU::IsaInfo::getMaxWavesPerEU(Features);
- IIM.MaxFlatWorkGroupSize = AMDGPU::IsaInfo::getMaxFlatWorkGroupSize(Features);
- IIM.SGPRAllocGranule = AMDGPU::IsaInfo::getSGPRAllocGranule(Features);
- IIM.TotalNumSGPRs = AMDGPU::IsaInfo::getTotalNumSGPRs(Features);
- IIM.AddressableNumSGPRs = AMDGPU::IsaInfo::getAddressableNumSGPRs(Features);
- IIM.VGPRAllocGranule = AMDGPU::IsaInfo::getVGPRAllocGranule(Features);
- IIM.TotalNumVGPRs = AMDGPU::IsaInfo::getTotalNumVGPRs(Features);
- IIM.AddressableNumVGPRs = AMDGPU::IsaInfo::getAddressableNumVGPRs(Features);
+ getIsaInfo(Features, Prog.IsaInfo);
// Set PrintfInfo.
if (auto MD = M.getNamedMetadata("llvm.printf.fmts")) {
@@ -451,3 +455,16 @@ std::string llvm::getRuntimeMDYAMLString(const FeatureBitset &Features,
return YAML;
}
+
+ErrorOr<std::string> llvm::getRuntimeMDYAMLString(const FeatureBitset &Features,
+ StringRef YAML) {
+ Program::Metadata Prog;
+ yaml::Input Input(YAML);
+ Input >> Prog;
+
+ getIsaInfo(Features, Prog.IsaInfo);
+
+ if (Input.error())
+ return Input.error();
+ return Prog.toYAML();
+}
OpenPOWER on IntegriCloud