1 | //===- RequestCWrappers.cpp - Annotate funcs with wrap attributes ---------===// |
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 | #include "mlir/Dialect/LLVMIR/Transforms/RequestCWrappers.h" |
10 | #include "mlir/Dialect/Func/IR/FuncOps.h" |
11 | #include "mlir/Dialect/LLVMIR/LLVMDialect.h" |
12 | #include "mlir/Pass/Pass.h" |
13 | |
14 | namespace mlir { |
15 | namespace LLVM { |
16 | #define GEN_PASS_DEF_LLVMREQUESTCWRAPPERS |
17 | #include "mlir/Dialect/LLVMIR/Transforms/Passes.h.inc" |
18 | } // namespace LLVM |
19 | } // namespace mlir |
20 | |
21 | using namespace mlir; |
22 | |
23 | namespace { |
24 | class RequestCWrappersPass |
25 | : public LLVM::impl::LLVMRequestCWrappersBase<RequestCWrappersPass> { |
26 | public: |
27 | void runOnOperation() override { |
28 | getOperation()->setAttr(LLVM::LLVMDialect::getEmitCWrapperAttrName(), |
29 | UnitAttr::get(&getContext())); |
30 | } |
31 | }; |
32 | } // namespace |
33 | |
34 | std::unique_ptr<Pass> mlir::LLVM::createRequestCWrappersPass() { |
35 | return std::make_unique<RequestCWrappersPass>(); |
36 | } |
37 | |