1 //===- TestAssert.cpp - Test cf.assert Lowering ----------------*- c++ -*-===//
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 // This file implements a pass for integration testing of wide integer
10 // emulation patterns. Applies conversion patterns only to functions whose
11 // names start with a specified prefix.
13 //===----------------------------------------------------------------------===//
15 #include "mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h"
16 #include "mlir/Conversion/LLVMCommon/ConversionTarget.h"
17 #include "mlir/Conversion/LLVMCommon/TypeConverter.h"
18 #include "mlir/Dialect/ControlFlow/IR/ControlFlow.h"
19 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
20 #include "mlir/Pass/Pass.h"
21 #include "mlir/Transforms/DialectConversion.h"
27 : public PassWrapper
<TestAssertPass
, OperationPass
<ModuleOp
>> {
28 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestAssertPass
)
30 void getDependentDialects(DialectRegistry
®istry
) const override
{
31 registry
.insert
<cf::ControlFlowDialect
, LLVM::LLVMDialect
>();
33 StringRef
getArgument() const final
{ return "test-cf-assert"; }
34 StringRef
getDescription() const final
{
35 return "Function pass to test cf.assert lowering to LLVM without abort";
38 void runOnOperation() override
{
39 LLVMConversionTarget
target(getContext());
40 RewritePatternSet
patterns(&getContext());
42 LLVMTypeConverter
converter(&getContext());
43 mlir::cf::populateAssertToLLVMConversionPattern(converter
, patterns
,
44 /*abortOnFailure=*/false);
46 if (failed(applyPartialConversion(getOperation(), target
,
47 std::move(patterns
))))
53 namespace mlir::test
{
54 void registerTestCfAssertPass() { PassRegistration
<TestAssertPass
>(); }
55 } // namespace mlir::test