#include "mlir/Target/LLVM/ROCDL/Target.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/Dialect/LLVMIR/ROCDLDialect.h"
#include "mlir/Support/FileUtilities.h"
#include "mlir/Target/LLVM/ROCDL/Utils.h"
#include "mlir/Target/LLVMIR/Export.h"
#include "llvm/IR/Constants.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCCodeEmitter.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCParser/MCTargetAsmParser.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/TargetParser/TargetParser.h"
#include <cstdlib>
#include <optional>
usingnamespacemlir;
usingnamespacemlir::ROCDL;
#ifndef __DEFAULT_ROCM_PATH__
#define __DEFAULT_ROCM_PATH__ …
#endif
namespace {
class ROCDLTargetAttrImpl
: public gpu::TargetAttrInterface::FallbackModel<ROCDLTargetAttrImpl> { … };
}
void mlir::ROCDL::registerROCDLTargetInterfaceExternalModels(
DialectRegistry ®istry) { … }
void mlir::ROCDL::registerROCDLTargetInterfaceExternalModels(
MLIRContext &context) { … }
StringRef mlir::ROCDL::getROCMPath() { … }
SerializeGPUModuleBase::SerializeGPUModuleBase(
Operation &module, ROCDLTargetAttr target,
const gpu::TargetOptions &targetOptions)
: … { … }
void SerializeGPUModuleBase::init() { … }
ROCDLTargetAttr SerializeGPUModuleBase::getTarget() const { … }
StringRef SerializeGPUModuleBase::getToolkitPath() const { … }
ArrayRef<std::string> SerializeGPUModuleBase::getFileList() const { … }
LogicalResult SerializeGPUModuleBase::appendStandardLibs(AMDGCNLibraries libs) { … }
std::optional<SmallVector<std::unique_ptr<llvm::Module>>>
SerializeGPUModuleBase::loadBitcodeFiles(llvm::Module &module) { … }
LogicalResult SerializeGPUModuleBase::handleBitcodeFile(llvm::Module &module) { … }
void SerializeGPUModuleBase::handleModulePreLink(llvm::Module &module) { … }
void SerializeGPUModuleBase::addControlVariables(
llvm::Module &module, AMDGCNLibraries libs, bool wave64, bool daz,
bool finiteOnly, bool unsafeMath, bool fastMath, bool correctSqrt,
StringRef abiVer) { … }
std::optional<SmallVector<char, 0>>
SerializeGPUModuleBase::assembleIsa(StringRef isa) { … }
std::optional<SmallVector<char, 0>>
SerializeGPUModuleBase::compileToBinary(const std::string &serializedISA) { … }
std::optional<SmallVector<char, 0>> SerializeGPUModuleBase::moduleToObjectImpl(
const gpu::TargetOptions &targetOptions, llvm::Module &llvmModule) { … }
#if MLIR_ENABLE_ROCM_CONVERSIONS
namespace {
class AMDGPUSerializer : public SerializeGPUModuleBase { … };
}
AMDGPUSerializer::AMDGPUSerializer(Operation &module, ROCDLTargetAttr target,
const gpu::TargetOptions &targetOptions)
: … { … }
std::optional<SmallVector<char, 0>>
AMDGPUSerializer::moduleToObject(llvm::Module &llvmModule) { … }
#endif
std::optional<SmallVector<char, 0>> ROCDLTargetAttrImpl::serializeToObject(
Attribute attribute, Operation *module,
const gpu::TargetOptions &options) const { … }
Attribute
ROCDLTargetAttrImpl::createObject(Attribute attribute, Operation *module,
const SmallVector<char, 0> &object,
const gpu::TargetOptions &options) const { … }