mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-14 07:09:08 +00:00
AMDGPU/NFC: Rename code object metadata as HSA metadata
- Rename AMDGPUCodeObjectMetadata to AMDGPUMetadata (PAL metadata will be included in this file in the follow up change) - Rename AMDGPUCodeObjectMetadataStreamer to AMDGPUHSAMetadataStreamer - Introduce HSAMD namespace - Other minor name changes in function and test names llvm-svn: 315522
This commit is contained in:
parent
4ac9a5dcba
commit
bea150402f
@ -1,4 +1,4 @@
|
||||
//===--- AMDGPUCodeObjectMetadata.h -----------------------------*- C++ -*-===//
|
||||
//===--- AMDGPUMetadata.h ---------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -8,14 +8,13 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
/// \file
|
||||
/// \brief AMDGPU Code Object Metadata definitions and in-memory
|
||||
/// representations.
|
||||
/// \brief AMDGPU metadata definitions and in-memory representations.
|
||||
///
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_SUPPORT_AMDGPUCODEOBJECTMETADATA_H
|
||||
#define LLVM_SUPPORT_AMDGPUCODEOBJECTMETADATA_H
|
||||
#ifndef LLVM_SUPPORT_AMDGPUMETADATA_H
|
||||
#define LLVM_SUPPORT_AMDGPUMETADATA_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
@ -26,21 +25,19 @@ namespace llvm {
|
||||
namespace AMDGPU {
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Code Object Metadata.
|
||||
// HSA metadata.
|
||||
//===----------------------------------------------------------------------===//
|
||||
namespace CodeObject {
|
||||
namespace HSAMD {
|
||||
|
||||
/// \brief Code object metadata major version.
|
||||
constexpr uint32_t MetadataVersionMajor = 1;
|
||||
/// \brief Code object metadata minor version.
|
||||
constexpr uint32_t MetadataVersionMinor = 0;
|
||||
/// \brief HSA metadata major version.
|
||||
constexpr uint32_t VersionMajor = 1;
|
||||
/// \brief HSA metadata minor version.
|
||||
constexpr uint32_t VersionMinor = 0;
|
||||
|
||||
/// \brief Code object metadata beginning assembler directive.
|
||||
constexpr char MetadataAssemblerDirectiveBegin[] =
|
||||
".amdgpu_code_object_metadata";
|
||||
/// \brief Code object metadata ending assembler directive.
|
||||
constexpr char MetadataAssemblerDirectiveEnd[] =
|
||||
".end_amdgpu_code_object_metadata";
|
||||
/// \brief HSA metadata beginning assembler directive.
|
||||
constexpr char AssemblerDirectiveBegin[] = ".amd_amdgpu_hsa_metadata";
|
||||
/// \brief HSA metadata ending assembler directive.
|
||||
constexpr char AssemblerDirectiveEnd[] = ".end_amd_amdgpu_hsa_metadata";
|
||||
|
||||
/// \brief Access qualifiers.
|
||||
enum class AccessQualifier : uint8_t {
|
||||
@ -390,17 +387,17 @@ struct Metadata final {
|
||||
} // end namespace Kernel
|
||||
|
||||
namespace Key {
|
||||
/// \brief Key for CodeObject::Metadata::mVersion.
|
||||
/// \brief Key for HSA::Metadata::mVersion.
|
||||
constexpr char Version[] = "Version";
|
||||
/// \brief Key for CodeObject::Metadata::mPrintf.
|
||||
/// \brief Key for HSA::Metadata::mPrintf.
|
||||
constexpr char Printf[] = "Printf";
|
||||
/// \brief Key for CodeObject::Metadata::mKernels.
|
||||
/// \brief Key for HSA::Metadata::mKernels.
|
||||
constexpr char Kernels[] = "Kernels";
|
||||
} // end namespace Key
|
||||
|
||||
/// \brief In-memory representation of code object metadata.
|
||||
/// \brief In-memory representation of HSA metadata.
|
||||
struct Metadata final {
|
||||
/// \brief Code object metadata version. Required.
|
||||
/// \brief HSA metadata version. Required.
|
||||
std::vector<uint32_t> mVersion = std::vector<uint32_t>();
|
||||
/// \brief Printf metadata. Optional.
|
||||
std::vector<std::string> mPrintf = std::vector<std::string>();
|
||||
@ -410,17 +407,17 @@ struct Metadata final {
|
||||
/// \brief Default constructor.
|
||||
Metadata() = default;
|
||||
|
||||
/// \brief Converts \p YamlString to \p CodeObjectMetadata.
|
||||
/// \brief Converts \p YamlString to \p HSAMetadata.
|
||||
static std::error_code fromYamlString(std::string YamlString,
|
||||
Metadata &CodeObjectMetadata);
|
||||
Metadata &HSAMetadata);
|
||||
|
||||
/// \brief Converts \p CodeObjectMetadata to \p YamlString.
|
||||
static std::error_code toYamlString(Metadata CodeObjectMetadata,
|
||||
/// \brief Converts \p HSAMetadata to \p YamlString.
|
||||
static std::error_code toYamlString(Metadata HSAMetadata,
|
||||
std::string &YamlString);
|
||||
};
|
||||
|
||||
} // end namespace CodeObject
|
||||
} // end namespace HSAMD
|
||||
} // end namespace AMDGPU
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_SUPPORT_AMDGPUCODEOBJECTMETADATA_H
|
||||
#endif // LLVM_SUPPORT_AMDGPUMETADATA_H
|
@ -1,4 +1,4 @@
|
||||
//===--- AMDGPUCodeObjectMetadata.cpp ---------------------------*- C++ -*-===//
|
||||
//===--- AMDGPUMetadata.cpp -------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -8,17 +8,16 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
/// \file
|
||||
/// \brief AMDGPU Code Object Metadata definitions and in-memory
|
||||
/// representations.
|
||||
/// \brief AMDGPU metadata definitions and in-memory representations.
|
||||
///
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Support/AMDGPUCodeObjectMetadata.h"
|
||||
#include "llvm/Support/AMDGPUMetadata.h"
|
||||
#include "llvm/Support/YAMLTraits.h"
|
||||
|
||||
using namespace llvm::AMDGPU;
|
||||
using namespace llvm::AMDGPU::CodeObject;
|
||||
using namespace llvm::AMDGPU::HSAMD;
|
||||
|
||||
LLVM_YAML_IS_SEQUENCE_VECTOR(Kernel::Arg::Metadata)
|
||||
LLVM_YAML_IS_SEQUENCE_VECTOR(Kernel::Metadata)
|
||||
@ -182,8 +181,8 @@ struct MappingTraits<Kernel::Metadata> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct MappingTraits<CodeObject::Metadata> {
|
||||
static void mapping(IO &YIO, CodeObject::Metadata &MD) {
|
||||
struct MappingTraits<HSAMD::Metadata> {
|
||||
static void mapping(IO &YIO, HSAMD::Metadata &MD) {
|
||||
YIO.mapRequired(Key::Version, MD.mVersion);
|
||||
YIO.mapOptional(Key::Printf, MD.mPrintf, std::vector<std::string>());
|
||||
if (!MD.mKernels.empty() || !YIO.outputting())
|
||||
@ -194,25 +193,25 @@ struct MappingTraits<CodeObject::Metadata> {
|
||||
} // end namespace yaml
|
||||
|
||||
namespace AMDGPU {
|
||||
namespace CodeObject {
|
||||
namespace HSAMD {
|
||||
|
||||
/* static */
|
||||
std::error_code Metadata::fromYamlString(
|
||||
std::string YamlString, Metadata &CodeObjectMetadata) {
|
||||
std::string YamlString, Metadata &HSAMetadata) {
|
||||
yaml::Input YamlInput(YamlString);
|
||||
YamlInput >> CodeObjectMetadata;
|
||||
YamlInput >> HSAMetadata;
|
||||
return YamlInput.error();
|
||||
}
|
||||
|
||||
/* static */
|
||||
std::error_code Metadata::toYamlString(
|
||||
Metadata CodeObjectMetadata, std::string &YamlString) {
|
||||
Metadata HSAMetadata, std::string &YamlString) {
|
||||
raw_string_ostream YamlStream(YamlString);
|
||||
yaml::Output YamlOutput(YamlStream, nullptr, std::numeric_limits<int>::max());
|
||||
YamlOutput << CodeObjectMetadata;
|
||||
YamlOutput << HSAMetadata;
|
||||
return std::error_code();
|
||||
}
|
||||
|
||||
} // end namespace CodeObject
|
||||
} // end namespace HSAMD
|
||||
} // end namespace AMDGPU
|
||||
} // end namespace llvm
|
@ -30,7 +30,7 @@ elseif( CMAKE_HOST_UNIX )
|
||||
endif( MSVC OR MINGW )
|
||||
|
||||
add_llvm_library(LLVMSupport
|
||||
AMDGPUCodeObjectMetadata.cpp
|
||||
AMDGPUMetadata.cpp
|
||||
APFloat.cpp
|
||||
APInt.cpp
|
||||
APSInt.cpp
|
||||
|
@ -125,7 +125,7 @@ void AMDGPUAsmPrinter::EmitStartOfAsmFile(Module &M) {
|
||||
getTargetStreamer().EmitDirectiveHSACodeObjectVersion(2, 1);
|
||||
getTargetStreamer().EmitDirectiveHSACodeObjectISA(
|
||||
ISA.Major, ISA.Minor, ISA.Stepping, "AMD", "AMDGPU");
|
||||
getTargetStreamer().EmitStartOfCodeObjectMetadata(M);
|
||||
getTargetStreamer().EmitStartOfHSAMetadata(M);
|
||||
}
|
||||
|
||||
void AMDGPUAsmPrinter::EmitEndOfAsmFile(Module &M) {
|
||||
@ -143,7 +143,7 @@ void AMDGPUAsmPrinter::EmitEndOfAsmFile(Module &M) {
|
||||
if (TM.getTargetTriple().getOS() != Triple::AMDHSA)
|
||||
return;
|
||||
|
||||
getTargetStreamer().EmitEndOfCodeObjectMetadata();
|
||||
getTargetStreamer().EmitEndOfHSAMetadata();
|
||||
}
|
||||
|
||||
bool AMDGPUAsmPrinter::isBlockOnlyReachableByFallthrough(
|
||||
@ -176,8 +176,7 @@ void AMDGPUAsmPrinter::EmitFunctionBodyStart() {
|
||||
|
||||
if (TM.getTargetTriple().getOS() != Triple::AMDHSA)
|
||||
return;
|
||||
getTargetStreamer().EmitKernelCodeObjectMetadata(*MF->getFunction(),
|
||||
KernelCode);
|
||||
getTargetStreamer().EmitKernelHSAMetadata(*MF->getFunction(), KernelCode);
|
||||
}
|
||||
|
||||
void AMDGPUAsmPrinter::EmitFunctionEntryLabel() {
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include "llvm/MC/MCStreamer.h"
|
||||
#include "llvm/MC/MCSubtargetInfo.h"
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#include "llvm/Support/AMDGPUCodeObjectMetadata.h"
|
||||
#include "llvm/Support/AMDGPUMetadata.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
@ -827,7 +827,7 @@ private:
|
||||
bool ParseDirectiveMajorMinor(uint32_t &Major, uint32_t &Minor);
|
||||
bool ParseDirectiveHSACodeObjectVersion();
|
||||
bool ParseDirectiveHSACodeObjectISA();
|
||||
bool ParseDirectiveCodeObjectMetadata();
|
||||
bool ParseDirectiveHSAMetadata();
|
||||
bool ParseAMDKernelCodeTValue(StringRef ID, amd_kernel_code_t &Header);
|
||||
bool ParseDirectiveAMDKernelCodeT();
|
||||
bool subtargetHasRegister(const MCRegisterInfo &MRI, unsigned RegNo) const;
|
||||
@ -2398,7 +2398,7 @@ bool AMDGPUAsmParser::ParseDirectiveHSACodeObjectISA() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AMDGPUAsmParser::ParseDirectiveCodeObjectMetadata() {
|
||||
bool AMDGPUAsmParser::ParseDirectiveHSAMetadata() {
|
||||
std::string YamlString;
|
||||
raw_string_ostream YamlStream(YamlString);
|
||||
|
||||
@ -2413,7 +2413,7 @@ bool AMDGPUAsmParser::ParseDirectiveCodeObjectMetadata() {
|
||||
|
||||
if (getLexer().is(AsmToken::Identifier)) {
|
||||
StringRef ID = getLexer().getTok().getIdentifier();
|
||||
if (ID == AMDGPU::CodeObject::MetadataAssemblerDirectiveEnd) {
|
||||
if (ID == AMDGPU::HSAMD::AssemblerDirectiveEnd) {
|
||||
Lex();
|
||||
FoundEnd = true;
|
||||
break;
|
||||
@ -2430,12 +2430,12 @@ bool AMDGPUAsmParser::ParseDirectiveCodeObjectMetadata() {
|
||||
|
||||
if (getLexer().is(AsmToken::Eof) && !FoundEnd) {
|
||||
return TokError(
|
||||
"expected directive .end_amdgpu_code_object_metadata not found");
|
||||
"expected directive .end_amd_amdgpu_hsa_metadata not found");
|
||||
}
|
||||
|
||||
YamlStream.flush();
|
||||
|
||||
if (!getTargetStreamer().EmitCodeObjectMetadata(YamlString))
|
||||
if (!getTargetStreamer().EmitHSAMetadata(YamlString))
|
||||
return Error(getParser().getTok().getLoc(), "invalid code object metadata");
|
||||
|
||||
return false;
|
||||
@ -2517,8 +2517,8 @@ bool AMDGPUAsmParser::ParseDirective(AsmToken DirectiveID) {
|
||||
if (IDVal == ".hsa_code_object_isa")
|
||||
return ParseDirectiveHSACodeObjectISA();
|
||||
|
||||
if (IDVal == AMDGPU::CodeObject::MetadataAssemblerDirectiveBegin)
|
||||
return ParseDirectiveCodeObjectMetadata();
|
||||
if (IDVal == AMDGPU::HSAMD::AssemblerDirectiveBegin)
|
||||
return ParseDirectiveHSAMetadata();
|
||||
|
||||
if (IDVal == ".amd_kernel_code_t")
|
||||
return ParseDirectiveAMDKernelCodeT();
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===--- AMDGPUCodeObjectMetadataStreamer.cpp -------------------*- C++ -*-===//
|
||||
//===--- AMDGPUHSAMetadataStreamer.cpp --------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -8,12 +8,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
/// \file
|
||||
/// \brief AMDGPU Code Object Metadata Streamer.
|
||||
/// \brief AMDGPU HSA Metadata Streamer.
|
||||
///
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "AMDGPUCodeObjectMetadataStreamer.h"
|
||||
#include "AMDGPUHSAMetadataStreamer.h"
|
||||
#include "AMDGPU.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
#include "llvm/IR/Constants.h"
|
||||
@ -22,24 +22,24 @@
|
||||
|
||||
namespace llvm {
|
||||
|
||||
static cl::opt<bool> DumpCodeObjectMetadata(
|
||||
"amdgpu-dump-comd",
|
||||
cl::desc("Dump AMDGPU Code Object Metadata"));
|
||||
static cl::opt<bool> VerifyCodeObjectMetadata(
|
||||
"amdgpu-verify-comd",
|
||||
cl::desc("Verify AMDGPU Code Object Metadata"));
|
||||
static cl::opt<bool> DumpHSAMetadata(
|
||||
"amdgpu-dump-hsa-metadata",
|
||||
cl::desc("Dump AMDGPU HSA Metadata"));
|
||||
static cl::opt<bool> VerifyHSAMetadata(
|
||||
"amdgpu-verify-hsa-metadata",
|
||||
cl::desc("Verify AMDGPU HSA Metadata"));
|
||||
|
||||
namespace AMDGPU {
|
||||
namespace CodeObject {
|
||||
namespace HSAMD {
|
||||
|
||||
void MetadataStreamer::dump(StringRef YamlString) const {
|
||||
errs() << "AMDGPU Code Object Metadata:\n" << YamlString << '\n';
|
||||
errs() << "AMDGPU HSA Metadata:\n" << YamlString << '\n';
|
||||
}
|
||||
|
||||
void MetadataStreamer::verify(StringRef YamlString) const {
|
||||
errs() << "AMDGPU Code Object Metadata Parser Test: ";
|
||||
errs() << "AMDGPU HSA Metadata Parser Test: ";
|
||||
|
||||
CodeObject::Metadata FromYamlString;
|
||||
HSAMD::Metadata FromYamlString;
|
||||
if (Metadata::fromYamlString(YamlString, FromYamlString)) {
|
||||
errs() << "FAIL\n";
|
||||
return;
|
||||
@ -196,14 +196,14 @@ std::vector<uint32_t> MetadataStreamer::getWorkGroupDimensions(
|
||||
}
|
||||
|
||||
void MetadataStreamer::emitVersion() {
|
||||
auto &Version = CodeObjectMetadata.mVersion;
|
||||
auto &Version = HSAMetadata.mVersion;
|
||||
|
||||
Version.push_back(MetadataVersionMajor);
|
||||
Version.push_back(MetadataVersionMinor);
|
||||
Version.push_back(VersionMajor);
|
||||
Version.push_back(VersionMinor);
|
||||
}
|
||||
|
||||
void MetadataStreamer::emitPrintf(const Module &Mod) {
|
||||
auto &Printf = CodeObjectMetadata.mPrintf;
|
||||
auto &Printf = HSAMetadata.mPrintf;
|
||||
|
||||
auto Node = Mod.getNamedMetadata("llvm.printf.fmts");
|
||||
if (!Node)
|
||||
@ -215,7 +215,7 @@ void MetadataStreamer::emitPrintf(const Module &Mod) {
|
||||
}
|
||||
|
||||
void MetadataStreamer::emitKernelLanguage(const Function &Func) {
|
||||
auto &Kernel = CodeObjectMetadata.mKernels.back();
|
||||
auto &Kernel = HSAMetadata.mKernels.back();
|
||||
|
||||
// TODO: What about other languages?
|
||||
auto Node = Func.getParent()->getNamedMetadata("opencl.ocl.version");
|
||||
@ -233,7 +233,7 @@ void MetadataStreamer::emitKernelLanguage(const Function &Func) {
|
||||
}
|
||||
|
||||
void MetadataStreamer::emitKernelAttrs(const Function &Func) {
|
||||
auto &Attrs = CodeObjectMetadata.mKernels.back().mAttrs;
|
||||
auto &Attrs = HSAMetadata.mKernels.back().mAttrs;
|
||||
|
||||
if (auto Node = Func.getMetadata("reqd_work_group_size"))
|
||||
Attrs.mReqdWorkGroupSize = getWorkGroupDimensions(Node);
|
||||
@ -317,8 +317,8 @@ void MetadataStreamer::emitKernelArg(const DataLayout &DL, Type *Ty,
|
||||
ValueKind ValueKind, StringRef TypeQual,
|
||||
StringRef BaseTypeName, StringRef AccQual,
|
||||
StringRef Name, StringRef TypeName) {
|
||||
CodeObjectMetadata.mKernels.back().mArgs.push_back(Kernel::Arg::Metadata());
|
||||
auto &Arg = CodeObjectMetadata.mKernels.back().mArgs.back();
|
||||
HSAMetadata.mKernels.back().mArgs.push_back(Kernel::Arg::Metadata());
|
||||
auto &Arg = HSAMetadata.mKernels.back().mArgs.back();
|
||||
|
||||
Arg.mSize = DL.getTypeAllocSize(Ty);
|
||||
Arg.mAlign = DL.getABITypeAlignment(Ty);
|
||||
@ -355,7 +355,7 @@ void MetadataStreamer::emitKernelArg(const DataLayout &DL, Type *Ty,
|
||||
|
||||
void MetadataStreamer::emitKernelCodeProps(
|
||||
const amd_kernel_code_t &KernelCode) {
|
||||
auto &CodeProps = CodeObjectMetadata.mKernels.back().mCodeProps;
|
||||
auto &CodeProps = HSAMetadata.mKernels.back().mCodeProps;
|
||||
|
||||
CodeProps.mKernargSegmentSize = KernelCode.kernarg_segment_byte_size;
|
||||
CodeProps.mWorkgroupGroupSegmentSize =
|
||||
@ -375,7 +375,7 @@ void MetadataStreamer::emitKernelDebugProps(
|
||||
if (!(KernelCode.code_properties & AMD_CODE_PROPERTY_IS_DEBUG_SUPPORTED))
|
||||
return;
|
||||
|
||||
auto &DebugProps = CodeObjectMetadata.mKernels.back().mDebugProps;
|
||||
auto &DebugProps = HSAMetadata.mKernels.back().mDebugProps;
|
||||
|
||||
// FIXME: Need to pass down debugger ABI version through features. This is ok
|
||||
// for now because we only have one version.
|
||||
@ -400,8 +400,8 @@ void MetadataStreamer::emitKernel(const Function &Func,
|
||||
if (Func.getCallingConv() != CallingConv::AMDGPU_KERNEL)
|
||||
return;
|
||||
|
||||
CodeObjectMetadata.mKernels.push_back(Kernel::Metadata());
|
||||
auto &Kernel = CodeObjectMetadata.mKernels.back();
|
||||
HSAMetadata.mKernels.push_back(Kernel::Metadata());
|
||||
auto &Kernel = HSAMetadata.mKernels.back();
|
||||
|
||||
Kernel.mName = Func.getName();
|
||||
emitKernelLanguage(Func);
|
||||
@ -412,25 +412,25 @@ void MetadataStreamer::emitKernel(const Function &Func,
|
||||
}
|
||||
|
||||
ErrorOr<std::string> MetadataStreamer::toYamlString() {
|
||||
std::string YamlString;
|
||||
if (auto Error = Metadata::toYamlString(CodeObjectMetadata, YamlString))
|
||||
std::string ToYamlString;
|
||||
if (auto Error = Metadata::toYamlString(HSAMetadata, ToYamlString))
|
||||
return Error;
|
||||
|
||||
if (DumpCodeObjectMetadata)
|
||||
dump(YamlString);
|
||||
if (VerifyCodeObjectMetadata)
|
||||
verify(YamlString);
|
||||
if (DumpHSAMetadata)
|
||||
dump(ToYamlString);
|
||||
if (VerifyHSAMetadata)
|
||||
verify(ToYamlString);
|
||||
|
||||
return YamlString;
|
||||
return ToYamlString;
|
||||
}
|
||||
|
||||
ErrorOr<std::string> MetadataStreamer::toYamlString(StringRef YamlString) {
|
||||
if (auto Error = Metadata::fromYamlString(YamlString, CodeObjectMetadata))
|
||||
if (auto Error = Metadata::fromYamlString(YamlString, HSAMetadata))
|
||||
return Error;
|
||||
|
||||
return toYamlString();
|
||||
}
|
||||
|
||||
} // end namespace CodeObject
|
||||
} // end namespace HSAMD
|
||||
} // end namespace AMDGPU
|
||||
} // end namespace llvm
|
@ -1,4 +1,4 @@
|
||||
//===--- AMDGPUCodeObjectMetadataStreamer.h ---------------------*- C++ -*-===//
|
||||
//===--- AMDGPUHSAMetadataStreamer.h ----------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -8,18 +8,18 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
/// \file
|
||||
/// \brief AMDGPU Code Object Metadata Streamer.
|
||||
/// \brief AMDGPU HSA Metadata Streamer.
|
||||
///
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUCODEOBJECTMETADATASTREAMER_H
|
||||
#define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUCODEOBJECTMETADATASTREAMER_H
|
||||
#ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUHSAMETADATASTREAMER_H
|
||||
#define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUHSAMETADATASTREAMER_H
|
||||
|
||||
#include "AMDGPU.h"
|
||||
#include "AMDKernelCodeT.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/AMDGPUCodeObjectMetadata.h"
|
||||
#include "llvm/Support/AMDGPUMetadata.h"
|
||||
#include "llvm/Support/ErrorOr.h"
|
||||
|
||||
namespace llvm {
|
||||
@ -32,11 +32,11 @@ class Module;
|
||||
class Type;
|
||||
|
||||
namespace AMDGPU {
|
||||
namespace CodeObject {
|
||||
namespace HSAMD {
|
||||
|
||||
class MetadataStreamer final {
|
||||
private:
|
||||
Metadata CodeObjectMetadata;
|
||||
Metadata HSAMetadata;
|
||||
AMDGPUAS AMDGPUASI;
|
||||
|
||||
void dump(StringRef YamlString) const;
|
||||
@ -92,8 +92,8 @@ public:
|
||||
ErrorOr<std::string> toYamlString(StringRef YamlString);
|
||||
};
|
||||
|
||||
} // end namespace CodeObject
|
||||
} // end namespace HSAMD
|
||||
} // end namespace AMDGPU
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUCODEOBJECTMETADATASTREAMER_H
|
||||
#endif // LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUHSAMETADATASTREAMER_H
|
@ -42,18 +42,18 @@ using namespace llvm::AMDGPU;
|
||||
AMDGPUTargetStreamer::AMDGPUTargetStreamer(MCStreamer &S)
|
||||
: MCTargetStreamer(S) {}
|
||||
|
||||
void AMDGPUTargetStreamer::EmitStartOfCodeObjectMetadata(const Module &Mod) {
|
||||
CodeObjectMetadataStreamer.begin(Mod);
|
||||
void AMDGPUTargetStreamer::EmitStartOfHSAMetadata(const Module &Mod) {
|
||||
HSAMetadataStreamer.begin(Mod);
|
||||
}
|
||||
|
||||
void AMDGPUTargetStreamer::EmitKernelCodeObjectMetadata(
|
||||
void AMDGPUTargetStreamer::EmitKernelHSAMetadata(
|
||||
const Function &Func, const amd_kernel_code_t &KernelCode) {
|
||||
CodeObjectMetadataStreamer.emitKernel(Func, KernelCode);
|
||||
HSAMetadataStreamer.emitKernel(Func, KernelCode);
|
||||
}
|
||||
|
||||
void AMDGPUTargetStreamer::EmitEndOfCodeObjectMetadata() {
|
||||
CodeObjectMetadataStreamer.end();
|
||||
EmitCodeObjectMetadata(CodeObjectMetadataStreamer.toYamlString().get());
|
||||
void AMDGPUTargetStreamer::EmitEndOfHSAMetadata() {
|
||||
HSAMetadataStreamer.end();
|
||||
EmitHSAMetadata(HSAMetadataStreamer.toYamlString().get());
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -100,14 +100,14 @@ void AMDGPUTargetAsmStreamer::EmitAMDGPUSymbolType(StringRef SymbolName,
|
||||
}
|
||||
}
|
||||
|
||||
bool AMDGPUTargetAsmStreamer::EmitCodeObjectMetadata(StringRef YamlString) {
|
||||
auto VerifiedYamlString = CodeObjectMetadataStreamer.toYamlString(YamlString);
|
||||
bool AMDGPUTargetAsmStreamer::EmitHSAMetadata(StringRef YamlString) {
|
||||
auto VerifiedYamlString = HSAMetadataStreamer.toYamlString(YamlString);
|
||||
if (!VerifiedYamlString)
|
||||
return false;
|
||||
|
||||
OS << '\t' << AMDGPU::CodeObject::MetadataAssemblerDirectiveBegin << '\n';
|
||||
OS << '\t' << AMDGPU::HSAMD::AssemblerDirectiveBegin << '\n';
|
||||
OS << VerifiedYamlString.get();
|
||||
OS << '\t' << AMDGPU::CodeObject::MetadataAssemblerDirectiveEnd << '\n';
|
||||
OS << '\t' << AMDGPU::HSAMD::AssemblerDirectiveEnd << '\n';
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -212,8 +212,8 @@ void AMDGPUTargetELFStreamer::EmitAMDGPUSymbolType(StringRef SymbolName,
|
||||
Symbol->setType(ELF::STT_AMDGPU_HSA_KERNEL);
|
||||
}
|
||||
|
||||
bool AMDGPUTargetELFStreamer::EmitCodeObjectMetadata(StringRef YamlString) {
|
||||
auto VerifiedYamlString = CodeObjectMetadataStreamer.toYamlString(YamlString);
|
||||
bool AMDGPUTargetELFStreamer::EmitHSAMetadata(StringRef YamlString) {
|
||||
auto VerifiedYamlString = HSAMetadataStreamer.toYamlString(YamlString);
|
||||
if (!VerifiedYamlString)
|
||||
return false;
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
#ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUTARGETSTREAMER_H
|
||||
#define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUTARGETSTREAMER_H
|
||||
|
||||
#include "AMDGPUCodeObjectMetadataStreamer.h"
|
||||
#include "AMDGPUHSAMetadataStreamer.h"
|
||||
#include "AMDKernelCodeT.h"
|
||||
#include "llvm/MC/MCStreamer.h"
|
||||
|
||||
@ -27,7 +27,7 @@ class Type;
|
||||
|
||||
class AMDGPUTargetStreamer : public MCTargetStreamer {
|
||||
protected:
|
||||
AMDGPU::CodeObject::MetadataStreamer CodeObjectMetadataStreamer;
|
||||
AMDGPU::HSAMD::MetadataStreamer HSAMetadataStreamer;
|
||||
MCContext &getContext() const { return Streamer.getContext(); }
|
||||
|
||||
public:
|
||||
@ -44,15 +44,15 @@ public:
|
||||
|
||||
virtual void EmitAMDGPUSymbolType(StringRef SymbolName, unsigned Type) = 0;
|
||||
|
||||
virtual void EmitStartOfCodeObjectMetadata(const Module &Mod);
|
||||
virtual void EmitStartOfHSAMetadata(const Module &Mod);
|
||||
|
||||
virtual void EmitKernelCodeObjectMetadata(
|
||||
virtual void EmitKernelHSAMetadata(
|
||||
const Function &Func, const amd_kernel_code_t &KernelCode);
|
||||
|
||||
virtual void EmitEndOfCodeObjectMetadata();
|
||||
virtual void EmitEndOfHSAMetadata();
|
||||
|
||||
/// \returns True on success, false on failure.
|
||||
virtual bool EmitCodeObjectMetadata(StringRef YamlString) = 0;
|
||||
virtual bool EmitHSAMetadata(StringRef YamlString) = 0;
|
||||
|
||||
virtual bool EmitPalMetadata(ArrayRef<uint32_t> Data) = 0;
|
||||
};
|
||||
@ -73,7 +73,7 @@ public:
|
||||
void EmitAMDGPUSymbolType(StringRef SymbolName, unsigned Type) override;
|
||||
|
||||
/// \returns True on success, false on failure.
|
||||
bool EmitCodeObjectMetadata(StringRef YamlString) override;
|
||||
bool EmitHSAMetadata(StringRef YamlString) override;
|
||||
|
||||
bool EmitPalMetadata(ArrayRef<uint32_t> data) override;
|
||||
};
|
||||
@ -102,7 +102,7 @@ public:
|
||||
void EmitAMDGPUSymbolType(StringRef SymbolName, unsigned Type) override;
|
||||
|
||||
/// \returns True on success, false on failure.
|
||||
bool EmitCodeObjectMetadata(StringRef YamlString) override;
|
||||
bool EmitHSAMetadata(StringRef YamlString) override;
|
||||
|
||||
bool EmitPalMetadata(ArrayRef<uint32_t> data) override;
|
||||
};
|
||||
|
@ -1,8 +1,8 @@
|
||||
add_llvm_library(LLVMAMDGPUDesc
|
||||
AMDGPUAsmBackend.cpp
|
||||
AMDGPUCodeObjectMetadataStreamer.cpp
|
||||
AMDGPUELFObjectWriter.cpp
|
||||
AMDGPUELFStreamer.cpp
|
||||
AMDGPUHSAMetadataStreamer.cpp
|
||||
AMDGPUMCAsmInfo.cpp
|
||||
AMDGPUMCCodeEmitter.cpp
|
||||
AMDGPUMCTargetDesc.cpp
|
||||
|
@ -1,9 +1,9 @@
|
||||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx700 -filetype=obj -o - < %s | llvm-readobj -amdgpu-code-object-metadata -elf-output-style=GNU -notes | FileCheck --check-prefix=CHECK --check-prefix=GFX700 --check-prefix=NOTES %s
|
||||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx800 -filetype=obj -o - < %s | llvm-readobj -amdgpu-code-object-metadata -elf-output-style=GNU -notes | FileCheck --check-prefix=CHECK --check-prefix=GFX800 --check-prefix=NOTES %s
|
||||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -filetype=obj -o - < %s | llvm-readobj -amdgpu-code-object-metadata -elf-output-style=GNU -notes | FileCheck --check-prefix=CHECK --check-prefix=GFX900 --check-prefix=NOTES %s
|
||||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx700 -amdgpu-dump-comd -amdgpu-verify-comd -filetype=obj -o - < %s 2>&1 | FileCheck --check-prefix=PARSER %s
|
||||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx800 -amdgpu-dump-comd -amdgpu-verify-comd -filetype=obj -o - < %s 2>&1 | FileCheck --check-prefix=PARSER %s
|
||||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -amdgpu-dump-comd -amdgpu-verify-comd -filetype=obj -o - < %s 2>&1 | FileCheck --check-prefix=PARSER %s
|
||||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx700 -amdgpu-dump-hsa-metadata -amdgpu-verify-hsa-metadata -filetype=obj -o - < %s 2>&1 | FileCheck --check-prefix=PARSER %s
|
||||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx800 -amdgpu-dump-hsa-metadata -amdgpu-verify-hsa-metadata -filetype=obj -o - < %s 2>&1 | FileCheck --check-prefix=PARSER %s
|
||||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -amdgpu-dump-hsa-metadata -amdgpu-verify-hsa-metadata -filetype=obj -o - < %s 2>&1 | FileCheck --check-prefix=PARSER %s
|
||||
|
||||
%struct.A = type { i8, float }
|
||||
%opencl.image1d_t = type opaque
|
||||
@ -1203,7 +1203,7 @@ define amdgpu_kernel void @test_pointee_align(i64 addrspace(1)* %a,
|
||||
; CHECK-NEXT: Language: OpenCL C
|
||||
; CHECK-NEXT: LanguageVersion: [ 2, 0 ]
|
||||
; CHECK-NEXT: Attrs:
|
||||
; CHECK-NEXT: RuntimeHandle: __test_block_invoke_kernel_runtime_handle
|
||||
; CHECK-NEXT: RuntimeHandle: __test_block_invoke_kernel_runtime_handle
|
||||
; CHECK-NEXT: Args:
|
||||
; CHECK-NEXT: - Size: 25
|
||||
; CHECK-NEXT: Align: 1
|
||||
@ -1229,13 +1229,13 @@ define amdgpu_kernel void @test_pointee_align(i64 addrspace(1)* %a,
|
||||
; CHECK-NEXT: ValueType: I8
|
||||
; CHECK-NEXT: AddrSpaceQual: Global
|
||||
define amdgpu_kernel void @__test_block_invoke_kernel(
|
||||
<{ i32, i32, i8 addrspace(4)*, i8 addrspace(1)*, i8 }> %arg) #1
|
||||
<{ i32, i32, i8 addrspace(4)*, i8 addrspace(1)*, i8 }> %arg) #0
|
||||
!kernel_arg_addr_space !1 !kernel_arg_access_qual !2 !kernel_arg_type !110
|
||||
!kernel_arg_base_type !110 !kernel_arg_type_qual !4 {
|
||||
ret void
|
||||
}
|
||||
|
||||
attributes #1 = { "runtime-handle"="__test_block_invoke_kernel_runtime_handle" }
|
||||
attributes #0 = { "runtime-handle"="__test_block_invoke_kernel_runtime_handle" }
|
||||
|
||||
!llvm.printf.fmts = !{!100, !101}
|
||||
|
||||
@ -1300,4 +1300,4 @@ attributes #1 = { "runtime-handle"="__test_block_invoke_kernel_runtime_handle" }
|
||||
; GFX800: AMD 0x000092e4 Unknown note type: (0x0000000a)
|
||||
; GFX900: AMD 0x00008f64 Unknown note type: (0x0000000a)
|
||||
|
||||
; PARSER: AMDGPU Code Object Metadata Parser Test: PASS
|
||||
; PARSER: AMDGPU HSA Metadata Parser Test: PASS
|
@ -2,7 +2,7 @@
|
||||
// RUN: llvm-mc -triple=amdgcn-amd-amdhsa -mcpu=gfx800 -show-encoding %s | FileCheck --check-prefix=CHECK --check-prefix=GFX800 %s
|
||||
// RUN: llvm-mc -triple=amdgcn-amd-amdhsa -mcpu=gfx900 -show-encoding %s | FileCheck --check-prefix=CHECK --check-prefix=GFX900 %s
|
||||
|
||||
// CHECK: .amdgpu_code_object_metadata
|
||||
// CHECK: .amd_amdgpu_hsa_metadata
|
||||
// CHECK: Version: [ 1, 0 ]
|
||||
// CHECK: Printf:
|
||||
// CHECK: - '1:1:4:%d\n'
|
||||
@ -35,8 +35,8 @@
|
||||
// CHECK: ValueKind: HiddenPrintfBuffer
|
||||
// CHECK: ValueType: I8
|
||||
// CHECK: AddrSpaceQual: Global
|
||||
// CHECK: .end_amdgpu_code_object_metadata
|
||||
.amdgpu_code_object_metadata
|
||||
// CHECK: .end_amd_amdgpu_hsa_metadata
|
||||
.amd_amdgpu_hsa_metadata
|
||||
Version: [ 1, 0 ]
|
||||
Printf: [ '1:1:4:%d\n', '2:1:8:%g\n' ]
|
||||
Kernels:
|
||||
@ -67,4 +67,4 @@
|
||||
ValueKind: HiddenPrintfBuffer
|
||||
ValueType: I8
|
||||
AddrSpaceQual: Global
|
||||
.end_amdgpu_code_object_metadata
|
||||
.end_amd_amdgpu_hsa_metadata
|
@ -2,7 +2,7 @@
|
||||
// RUN: llvm-mc -triple=amdgcn-amd-amdhsa -mcpu=gfx800 -show-encoding %s | FileCheck --check-prefix=CHECK --check-prefix=GFX800 %s
|
||||
// RUN: llvm-mc -triple=amdgcn-amd-amdhsa -mcpu=gfx900 -show-encoding %s | FileCheck --check-prefix=CHECK --check-prefix=GFX900 %s
|
||||
|
||||
// CHECK: .amdgpu_code_object_metadata
|
||||
// CHECK: .amd_amdgpu_hsa_metadata
|
||||
// CHECK: Version: [ 1, 0 ]
|
||||
// CHECK: Printf:
|
||||
// CHECK: - '1:1:4:%d\n'
|
||||
@ -15,8 +15,8 @@
|
||||
// CHECK: ReqdWorkGroupSize: [ 1, 2, 4 ]
|
||||
// CHECK: WorkGroupSizeHint: [ 8, 16, 32 ]
|
||||
// CHECK: VecTypeHint: int
|
||||
// CHECK: .end_amdgpu_code_object_metadata
|
||||
.amdgpu_code_object_metadata
|
||||
// CHECK: .end_amd_amdgpu_hsa_metadata
|
||||
.amd_amdgpu_hsa_metadata
|
||||
Version: [ 1, 0 ]
|
||||
Printf: [ '1:1:4:%d\n', '2:1:8:%g\n' ]
|
||||
Kernels:
|
||||
@ -27,4 +27,4 @@
|
||||
ReqdWorkGroupSize: [ 1, 2, 4 ]
|
||||
WorkGroupSizeHint: [ 8, 16, 32 ]
|
||||
VecTypeHint: int
|
||||
.end_amdgpu_code_object_metadata
|
||||
.end_amd_amdgpu_hsa_metadata
|
@ -2,7 +2,7 @@
|
||||
// RUN: llvm-mc -triple=amdgcn-amd-amdhsa -mcpu=gfx800 -show-encoding %s | FileCheck --check-prefix=CHECK --check-prefix=GFX800 %s
|
||||
// RUN: llvm-mc -triple=amdgcn-amd-amdhsa -mcpu=gfx900 -show-encoding %s | FileCheck --check-prefix=CHECK --check-prefix=GFX900 %s
|
||||
|
||||
// CHECK: .amdgpu_code_object_metadata
|
||||
// CHECK: .amd_amdgpu_hsa_metadata
|
||||
// CHECK: Version: [ 1, 0 ]
|
||||
// CHECK: Kernels:
|
||||
// CHECK: - Name: test_kernel
|
||||
@ -11,7 +11,7 @@
|
||||
// CHECK: WorkitemPrivateSegmentSize: 16
|
||||
// CHECK: WavefrontNumSGPRs: 6
|
||||
// CHECK: WorkitemNumVGPRs: 12
|
||||
.amdgpu_code_object_metadata
|
||||
.amd_amdgpu_hsa_metadata
|
||||
Version: [ 1, 0 ]
|
||||
Printf: [ '1:1:4:%d\n', '2:1:8:%g\n' ]
|
||||
Kernels:
|
||||
@ -21,4 +21,4 @@
|
||||
WorkitemPrivateSegmentSize: 16
|
||||
WavefrontNumSGPRs: 6
|
||||
WorkitemNumVGPRs: 12
|
||||
.end_amdgpu_code_object_metadata
|
||||
.end_amd_amdgpu_hsa_metadata
|
@ -2,7 +2,7 @@
|
||||
// RUN: llvm-mc -triple=amdgcn-amd-amdhsa -mcpu=gfx800 -show-encoding %s | FileCheck --check-prefix=CHECK --check-prefix=GFX800 %s
|
||||
// RUN: llvm-mc -triple=amdgcn-amd-amdhsa -mcpu=gfx900 -show-encoding %s | FileCheck --check-prefix=CHECK --check-prefix=GFX900 %s
|
||||
|
||||
// CHECK: .amdgpu_code_object_metadata
|
||||
// CHECK: .amd_amdgpu_hsa_metadata
|
||||
// CHECK: Version: [ 1, 0 ]
|
||||
// CHECK: Kernels:
|
||||
// CHECK: - Name: test_kernel
|
||||
@ -12,7 +12,7 @@
|
||||
// CHECK: ReservedFirstVGPR: 11
|
||||
// CHECK: PrivateSegmentBufferSGPR: 0
|
||||
// CHECK: WavefrontPrivateSegmentOffsetSGPR: 11
|
||||
.amdgpu_code_object_metadata
|
||||
.amd_amdgpu_hsa_metadata
|
||||
Version: [ 1, 0 ]
|
||||
Printf: [ '1:1:4:%d\n', '2:1:8:%g\n' ]
|
||||
Kernels:
|
||||
@ -23,4 +23,4 @@
|
||||
ReservedFirstVGPR: 11
|
||||
PrivateSegmentBufferSGPR: 0
|
||||
WavefrontPrivateSegmentOffsetSGPR: 11
|
||||
.end_amdgpu_code_object_metadata
|
||||
.end_amd_amdgpu_hsa_metadata
|
@ -6,7 +6,7 @@
|
||||
// RUN: not llvm-mc -triple=amdgcn-amd-amdhsa -mcpu=gfx900 -filetype=obj %s 2>&1 | FileCheck %s
|
||||
|
||||
// CHECK: error: unknown key 'UnknownKey'
|
||||
.amdgpu_code_object_metadata
|
||||
.amd_amdgpu_hsa_metadata
|
||||
UnknownKey: [ 2, 0 ]
|
||||
Version: [ 1, 0 ]
|
||||
Printf: [ '1:1:4:%d\n', '2:1:8:%g\n' ]
|
||||
@ -38,4 +38,4 @@
|
||||
ValueKind: HiddenPrintfBuffer
|
||||
ValueType: I8
|
||||
AddrSpaceQual: Global
|
||||
.end_amdgpu_code_object_metadata
|
||||
.end_amd_amdgpu_hsa_metadata
|
@ -37,19 +37,19 @@
|
||||
.hsa_code_object_isa 7,0,0,"AMD","AMDGPU"
|
||||
// ASM: .hsa_code_object_isa 7,0,0,"AMD","AMDGPU"
|
||||
|
||||
.amdgpu_code_object_metadata
|
||||
.amd_amdgpu_hsa_metadata
|
||||
Version: [ 3, 0 ]
|
||||
Kernels:
|
||||
- Name: amd_kernel_code_t_test_all
|
||||
- Name: amd_kernel_code_t_minimal
|
||||
.end_amdgpu_code_object_metadata
|
||||
.end_amd_amdgpu_hsa_metadata
|
||||
|
||||
// ASM: .amdgpu_code_object_metadata
|
||||
// ASM: .amd_amdgpu_hsa_metadata
|
||||
// ASM: Version: [ 3, 0 ]
|
||||
// ASM: Kernels:
|
||||
// ASM: - Name: amd_kernel_code_t_test_all
|
||||
// ASM: - Name: amd_kernel_code_t_minimal
|
||||
// ASM: .end_amdgpu_code_object_metadata
|
||||
// ASM: .end_amd_amdgpu_hsa_metadata
|
||||
|
||||
.amdgpu_hsa_kernel amd_kernel_code_t_test_all
|
||||
.amdgpu_hsa_kernel amd_kernel_code_t_minimal
|
||||
|
Loading…
Reference in New Issue
Block a user