[rtsan] Remove mkfifoat interceptor (#116997)
[llvm-project.git] / mlir / lib / Conversion / VectorToSPIRV / VectorToSPIRVPass.cpp
blob1932de1be603b617aad33d5e00117290dad47d0c
1 //===- VectorToSPIRVPass.cpp - Vector to SPIR-V Passes --------------------===//
2 //
3 // Part of the LLVM Project, 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 implements a pass to convert Vector dialect to SPIRV dialect.
11 //===----------------------------------------------------------------------===//
13 #include "mlir/Conversion/VectorToSPIRV/VectorToSPIRVPass.h"
15 #include "mlir/Conversion/VectorToSPIRV/VectorToSPIRV.h"
16 #include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
17 #include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
18 #include "mlir/Pass/Pass.h"
19 #include "mlir/Transforms/DialectConversion.h"
21 namespace mlir {
22 #define GEN_PASS_DEF_CONVERTVECTORTOSPIRV
23 #include "mlir/Conversion/Passes.h.inc"
24 } // namespace mlir
26 using namespace mlir;
28 namespace {
29 struct ConvertVectorToSPIRVPass
30 : public impl::ConvertVectorToSPIRVBase<ConvertVectorToSPIRVPass> {
31 void runOnOperation() override;
33 } // namespace
35 void ConvertVectorToSPIRVPass::runOnOperation() {
36 MLIRContext *context = &getContext();
37 Operation *op = getOperation();
39 auto targetAttr = spirv::lookupTargetEnvOrDefault(op);
40 std::unique_ptr<ConversionTarget> target =
41 SPIRVConversionTarget::get(targetAttr);
43 SPIRVTypeConverter typeConverter(targetAttr);
45 // Use UnrealizedConversionCast as the bridge so that we don't need to pull in
46 // patterns for other dialects.
47 target->addLegalOp<UnrealizedConversionCastOp>();
49 RewritePatternSet patterns(context);
50 populateVectorToSPIRVPatterns(typeConverter, patterns);
52 if (failed(applyPartialConversion(op, *target, std::move(patterns))))
53 return signalPassFailure();
56 std::unique_ptr<OperationPass<>> mlir::createConvertVectorToSPIRVPass() {
57 return std::make_unique<ConvertVectorToSPIRVPass>();