Fix GCC build problem with 288f05f related to SmallVector. (#116958)
[llvm-project.git] / mlir / lib / Conversion / ConvertToLLVM / ToLLVMInterface.cpp
blob3a4e83b2a8838f8f777d2375c3131fd587b3f4f9
1 //===- ToLLVMInterface.cpp - MLIR LLVM Conversion -------------------------===//
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 //===----------------------------------------------------------------------===//
9 #include "mlir/Conversion/ConvertToLLVM/ToLLVMInterface.h"
10 #include "mlir/IR/Dialect.h"
11 #include "mlir/IR/Operation.h"
12 #include "llvm/ADT/DenseSet.h"
14 using namespace mlir;
16 void mlir::populateConversionTargetFromOperation(
17 Operation *root, ConversionTarget &target, LLVMTypeConverter &typeConverter,
18 RewritePatternSet &patterns) {
19 DenseSet<Dialect *> dialects;
20 root->walk([&](Operation *op) {
21 Dialect *dialect = op->getDialect();
22 if (!dialects.insert(dialect).second)
23 return;
24 // First time we encounter this dialect: if it implements the interface,
25 // let's populate patterns !
26 auto *iface = dyn_cast<ConvertToLLVMPatternInterface>(dialect);
27 if (!iface)
28 return;
29 iface->populateConvertToLLVMConversionPatterns(target, typeConverter,
30 patterns);
31 });