|
| 1 | +//===-- Target.cpp - MLIR LLVM XeVM target compilation ----------*- C++ -*-===// |
| 2 | +// |
| 3 | +// This file is licensed under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +// See https://llvm.org/LICENSE.txt for license information. |
| 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | +// |
| 9 | +// This file defines XeVM target related functions including registration |
| 10 | +// calls for the `#xevm.target` compilation attribute. |
| 11 | +// |
| 12 | +//===----------------------------------------------------------------------===// |
| 13 | + |
| 14 | +#include "gc/Target/LLVM/XeVM/Target.h" |
| 15 | + |
| 16 | +#include "gc/Dialect/LLVMIR/XeVMDialect.h" |
| 17 | +#include "mlir/Dialect/GPU/IR/CompilationInterfaces.h" |
| 18 | +#include "mlir/Dialect/GPU/IR/GPUDialect.h" |
| 19 | +#include "mlir/Dialect/LLVMIR/LLVMDialect.h" |
| 20 | +#include "mlir/IR/ExtensibleDialect.h" |
| 21 | +#include "mlir/Target/LLVMIR/Dialect/GPU/GPUToLLVMIRTranslation.h" |
| 22 | +#include "mlir/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.h" |
| 23 | + |
| 24 | +#include "llvm/IR/LegacyPassManager.h" |
| 25 | +#include "llvm/Support/MemoryBuffer.h" |
| 26 | +#include "llvm/Support/TargetSelect.h" |
| 27 | +#include "llvm/Target/TargetMachine.h" |
| 28 | + |
| 29 | +using namespace mlir; |
| 30 | +using namespace mlir::xevm; |
| 31 | + |
| 32 | +namespace { |
| 33 | +// XeVM implementation of the gpu:TargetAttrInterface. |
| 34 | +class XeVMTargetAttrImpl |
| 35 | + : public gpu::TargetAttrInterface::FallbackModel<XeVMTargetAttrImpl> { |
| 36 | +public: |
| 37 | + std::optional<SmallVector<char, 0>> |
| 38 | + serializeToObject(Attribute attribute, Operation *module, |
| 39 | + const gpu::TargetOptions &options) const { /*TODO*/ |
| 40 | + return {}; |
| 41 | + } |
| 42 | + |
| 43 | + Attribute createObject(Attribute attribute, Operation *module, |
| 44 | + const SmallVector<char, 0> &object, |
| 45 | + const gpu::TargetOptions &options) const { /*TODO*/ |
| 46 | + return {}; |
| 47 | + } |
| 48 | +}; |
| 49 | +} // namespace |
| 50 | + |
| 51 | +void mlir::xevm::registerXeVMTargetInterfaceExternalModels( |
| 52 | + DialectRegistry ®istry) { |
| 53 | + registry.addExtension(+[](MLIRContext *ctx, xevm::XeVMDialect *dialect) { |
| 54 | + XeVMTargetAttr::attachInterface<XeVMTargetAttrImpl>(*ctx); |
| 55 | + }); |
| 56 | +} |
| 57 | + |
| 58 | +void mlir::xevm::registerXeVMTargetInterfaceExternalModels( |
| 59 | + MLIRContext &context) { |
| 60 | + DialectRegistry registry; |
| 61 | + registerXeVMTargetInterfaceExternalModels(registry); |
| 62 | + context.appendDialectRegistry(registry); |
| 63 | +} |
0 commit comments