clang 23.0.0git
CIRABIRewriteContext.h
Go to the documentation of this file.
1//===- CIRABIRewriteContext.h - CIR ABI rewrite context ---------*- 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// Defines CIRABIRewriteContext, the CIR dialect's implementation of the
10// generic mlir::abi::ABIRewriteContext. Given a FunctionClassification it
11// rewrites a cir.func signature, the function body, and call sites to match
12// the ABI-lowered shape.
13//
14// This file currently handles only Direct (pass-through) and Ignore. Other
15// ArgKind handlers (Extend, Direct-with-coercion, Indirect, Expand) are
16// added by subsequent PRs in the calling-convention-lowering split series.
17//
18//===----------------------------------------------------------------------===//
19
20#ifndef CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_CIRABIREWRITECONTEXT_H
21#define CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_CIRABIREWRITECONTEXT_H
22
23#include "mlir/ABI/ABIRewriteContext.h"
24#include "mlir/IR/BuiltinOps.h"
26
27namespace cir {
28
29/// CIR-specific implementation of mlir::abi::ABIRewriteContext.
30///
31/// The driver pass (CallConvLoweringPass) computes a FunctionClassification
32/// for each cir.func / cir.call and dispatches to this class to perform the
33/// actual IR rewriting using cir dialect operations.
35public:
36 explicit CIRABIRewriteContext(mlir::ModuleOp module) : module(module) {}
37
38 mlir::LogicalResult
39 rewriteFunctionDefinition(mlir::FunctionOpInterface funcOp,
40 const mlir::abi::FunctionClassification &fc,
41 mlir::OpBuilder &builder) override;
42
43 mlir::LogicalResult
44 rewriteCallSite(mlir::Operation *callOp,
45 const mlir::abi::FunctionClassification &fc,
46 mlir::OpBuilder &builder) override;
47
48 mlir::StringRef getDialectNamespace() const override { return "cir"; }
49
50private:
51 mlir::ModuleOp module;
52};
53
54} // namespace cir
55
56#endif // CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_CIRABIREWRITECONTEXT_H
mlir::StringRef getDialectNamespace() const override
CIRABIRewriteContext(mlir::ModuleOp module)
mlir::LogicalResult rewriteFunctionDefinition(mlir::FunctionOpInterface funcOp, const mlir::abi::FunctionClassification &fc, mlir::OpBuilder &builder) override
mlir::LogicalResult rewriteCallSite(mlir::Operation *callOp, const mlir::abi::FunctionClassification &fc, mlir::OpBuilder &builder) override