Skip to content

Commit 76eead1

Browse files
silee2akroviakov
andauthored
[MLIR][Conversion] Add convert-xevm-to-llvm pass. (#147375)
Although XeVM is an LLVM extension dialect, SPIR-V backend relies on [function calls](https://llvm.org/docs/SPIRVUsage.html#instructions-as-function-calls) instead of defining LLVM intrinsics to represent SPIR-V instructions. convert-xevm-to-llvm pass lowers xevm ops to function declarations and calls using the above naming convention. In the future, most part of the pass should be replaced with llvmBuilder and handled as part of translation to LLVM instead. --------- Co-authored-by: Artem Kroviakov <artem.kroviakov@intel.com>
1 parent 14b2d2c commit 76eead1

File tree

8 files changed

+938
-0
lines changed

8 files changed

+938
-0
lines changed

mlir/include/mlir/Conversion/Passes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
#include "mlir/Conversion/VectorToSCF/VectorToSCF.h"
8181
#include "mlir/Conversion/VectorToSPIRV/VectorToSPIRVPass.h"
8282
#include "mlir/Conversion/VectorToXeGPU/VectorToXeGPU.h"
83+
#include "mlir/Conversion/XeVMToLLVM/XeVMToLLVM.h"
8384

8485
namespace mlir {
8586

mlir/include/mlir/Conversion/Passes.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,4 +1495,13 @@ def ConvertVectorToXeGPU : Pass<"convert-vector-to-xegpu"> {
14951495
];
14961496
}
14971497

1498+
//===----------------------------------------------------------------------===//
1499+
// XeVMToLLVM
1500+
//===----------------------------------------------------------------------===//
1501+
1502+
def ConvertXeVMToLLVMPass : Pass<"convert-xevm-to-llvm"> {
1503+
let summary = "Convert XeVM to LLVM dialect";
1504+
let dependentDialects = ["LLVM::LLVMDialect"];
1505+
}
1506+
14981507
#endif // MLIR_CONVERSION_PASSES
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//===-- XeVMToLLVM.h - Convert XeVM to LLVM dialect -------------*- 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+
#ifndef MLIR_CONVERSION_XEVMTOLLVM_XEVMTOLLVMPASS_H_
9+
#define MLIR_CONVERSION_XEVMTOLLVM_XEVMTOLLVMPASS_H_
10+
11+
#include <memory>
12+
13+
namespace mlir {
14+
class DialectRegistry;
15+
class LLVMTypeConverter;
16+
class RewritePatternSet;
17+
class Pass;
18+
19+
#define GEN_PASS_DECL_CONVERTXEVMTOLLVMPASS
20+
#include "mlir/Conversion/Passes.h.inc"
21+
22+
void populateXeVMToLLVMConversionPatterns(RewritePatternSet &patterns);
23+
24+
void registerConvertXeVMToLLVMInterface(DialectRegistry &registry);
25+
} // namespace mlir
26+
27+
#endif // MLIR_CONVERSION_XEVMTOLLVM_XEVMTOLLVMPASS_H_

mlir/include/mlir/InitAllExtensions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "mlir/Conversion/SCFToEmitC/SCFToEmitC.h"
3333
#include "mlir/Conversion/UBToLLVM/UBToLLVM.h"
3434
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h"
35+
#include "mlir/Conversion/XeVMToLLVM/XeVMToLLVM.h"
3536
#include "mlir/Dialect/AMX/Transforms.h"
3637
#include "mlir/Dialect/Affine/TransformOps/AffineTransformOps.h"
3738
#include "mlir/Dialect/ArmNeon/TransformOps/ArmNeonVectorTransformOps.h"
@@ -91,6 +92,7 @@ inline void registerAllExtensions(DialectRegistry &registry) {
9192
gpu::registerConvertGpuToLLVMInterface(registry);
9293
NVVM::registerConvertGpuToNVVMInterface(registry);
9394
vector::registerConvertVectorToLLVMInterface(registry);
95+
registerConvertXeVMToLLVMInterface(registry);
9496

9597
// Register all transform dialect extensions.
9698
affine::registerTransformDialectExtension(registry);

mlir/lib/Conversion/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,4 @@ add_subdirectory(VectorToLLVM)
7373
add_subdirectory(VectorToSCF)
7474
add_subdirectory(VectorToSPIRV)
7575
add_subdirectory(VectorToXeGPU)
76+
add_subdirectory(XeVMToLLVM)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
add_mlir_conversion_library(MLIRXeVMToLLVM
2+
XeVMToLLVM.cpp
3+
4+
ADDITIONAL_HEADER_DIRS
5+
${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/XeVMToLLVM
6+
7+
DEPENDS
8+
MLIRConversionPassIncGen
9+
10+
LINK_COMPONENTS
11+
Core
12+
13+
LINK_LIBS PUBLIC
14+
MLIRFuncDialect
15+
MLIRGPUDialect
16+
MLIRLLVMCommonConversion
17+
MLIRLLVMDialect
18+
MLIRXeVMDialect
19+
MLIRPass
20+
MLIRTransforms
21+
)

0 commit comments

Comments
 (0)