1 //===- ToLLVMInterface.cpp - MLIR LLVM Conversion -------------------------===//
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
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"
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
)
24 // First time we encounter this dialect: if it implements the interface,
25 // let's populate patterns !
26 auto *iface
= dyn_cast
<ConvertToLLVMPatternInterface
>(dialect
);
29 iface
->populateConvertToLLVMConversionPatterns(target
, typeConverter
,