Fix GCC build problem with 288f05f related to SmallVector. (#116958)
[llvm-project.git] / mlir / test / lib / Dialect / ControlFlow / TestAssert.cpp
blobdb769741117aa37b4070923831f87658cb909cec
1 //===- TestAssert.cpp - Test cf.assert Lowering ----------------*- c++ -*-===//
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 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"
23 using namespace mlir;
25 namespace {
26 struct TestAssertPass
27 : public PassWrapper<TestAssertPass, OperationPass<ModuleOp>> {
28 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestAssertPass)
30 void getDependentDialects(DialectRegistry &registry) 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))))
48 signalPassFailure();
51 } // namespace
53 namespace mlir::test {
54 void registerTestCfAssertPass() { PassRegistration<TestAssertPass>(); }
55 } // namespace mlir::test