clang 23.0.0git
CIRCXXABI.h
Go to the documentation of this file.
1//===----- CIRCXXABI.h - Interface to C++ ABIs for CIR Dialect --*- 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 partially mimics the CodeGen/CGCXXABI.h class. The main difference
10// is that this is adapted to operate on the CIR dialect.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_CIRCXXABI_H
15#define CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_CIRCXXABI_H
16
17#include "mlir/Transforms/DialectConversion.h"
20
21namespace cir {
22
23// Forward declarations.
24class LowerModule;
25
26class CIRCXXABI {
27 friend class LowerModule;
28
29protected:
31
33
34public:
35 virtual ~CIRCXXABI();
36
37 /// Lower the given data member pointer type to its ABI type. The returned
38 /// type is also a CIR type.
39 virtual mlir::Type
40 lowerDataMemberType(cir::DataMemberType type,
41 const mlir::TypeConverter &typeConverter) const = 0;
42
43 /// Lower the given member function pointer type to its ABI type. The returned
44 /// type is also a CIR type.
45 virtual mlir::Type
46 lowerMethodType(cir::MethodType type,
47 const mlir::TypeConverter &typeConverter) const = 0;
48
49 /// Lower the given data member pointer constant to a constant of the ABI
50 /// type. The returned constant is represented as an attribute as well.
51 virtual mlir::TypedAttr
52 lowerDataMemberConstant(cir::DataMemberAttr attr,
53 const mlir::DataLayout &layout,
54 const mlir::TypeConverter &typeConverter) const = 0;
55
56 /// Lower the given member function pointer constant to a constant of the ABI
57 /// type. The returned constant is represented as an attribute as well.
58 virtual mlir::TypedAttr
59 lowerMethodConstant(cir::MethodAttr attr, const mlir::DataLayout &layout,
60 const mlir::TypeConverter &typeConverter) const = 0;
61
62 /// Lower the given cir.get_runtime_member op to a sequence of more
63 /// "primitive" CIR operations that act on the ABI types.
64 virtual mlir::Operation *
65 lowerGetRuntimeMember(cir::GetRuntimeMemberOp op, mlir::Type loweredResultTy,
66 mlir::Value loweredAddr, mlir::Value loweredMember,
67 mlir::OpBuilder &builder) const = 0;
68
69 /// Lower the given cir.get_method op to a sequence of more "primitive" CIR
70 /// operations that act on the ABI types. The lowered result values will be
71 /// stored in the given loweredResults array.
72 virtual void
73 lowerGetMethod(cir::GetMethodOp op, mlir::Value &callee, mlir::Value &thisArg,
74 mlir::Value loweredMethod, mlir::Value loweredObjectPtr,
75 mlir::ConversionPatternRewriter &rewriter) const = 0;
76
77 /// Lower the given cir.base_data_member op to a sequence of more "primitive"
78 /// CIR operations that act on the ABI types.
79 virtual mlir::Value lowerBaseDataMember(cir::BaseDataMemberOp op,
80 mlir::Value loweredSrc,
81 mlir::OpBuilder &builder) const = 0;
82
83 /// Lower the given cir.derived_data_member op to a sequence of more
84 /// "primitive" CIR operations that act on the ABI types.
85 virtual mlir::Value
86 lowerDerivedDataMember(cir::DerivedDataMemberOp op, mlir::Value loweredSrc,
87 mlir::OpBuilder &builder) const = 0;
88
89 virtual mlir::Value lowerBaseMethod(cir::BaseMethodOp op,
90 mlir::Value loweredSrc,
91 mlir::OpBuilder &builder) const = 0;
92
93 virtual mlir::Value lowerDerivedMethod(cir::DerivedMethodOp op,
94 mlir::Value loweredSrc,
95 mlir::OpBuilder &builder) const = 0;
96
97 virtual mlir::Value lowerDataMemberCmp(cir::CmpOp op, mlir::Value loweredLhs,
98 mlir::Value loweredRhs,
99 mlir::OpBuilder &builder) const = 0;
100
101 virtual mlir::Value lowerMethodCmp(cir::CmpOp op, mlir::Value loweredLhs,
102 mlir::Value loweredRhs,
103 mlir::OpBuilder &builder) const = 0;
104
105 virtual mlir::Value
106 lowerDataMemberBitcast(cir::CastOp op, mlir::Type loweredDstTy,
107 mlir::Value loweredSrc,
108 mlir::OpBuilder &builder) const = 0;
109
110 virtual mlir::Value
111 lowerDataMemberToBoolCast(cir::CastOp op, mlir::Value loweredSrc,
112 mlir::OpBuilder &builder) const = 0;
113
114 virtual mlir::Value lowerMethodBitcast(cir::CastOp op,
115 mlir::Type loweredDstTy,
116 mlir::Value loweredSrc,
117 mlir::OpBuilder &builder) const = 0;
118
119 virtual mlir::Value lowerMethodToBoolCast(cir::CastOp op,
120 mlir::Value loweredSrc,
121 mlir::OpBuilder &builder) const = 0;
122
123 virtual mlir::Value lowerDynamicCast(cir::DynamicCastOp op,
124 mlir::OpBuilder &builder) const = 0;
125};
126
127/// Creates an Itanium-family ABI.
128std::unique_ptr<CIRCXXABI> createItaniumCXXABI(LowerModule &lm);
129
130} // namespace cir
131
132#endif // CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_CIRCXXABI_H
virtual mlir::Value lowerDynamicCast(cir::DynamicCastOp op, mlir::OpBuilder &builder) const =0
virtual ~CIRCXXABI()
Definition CIRCXXABI.cpp:18
virtual mlir::Type lowerMethodType(cir::MethodType type, const mlir::TypeConverter &typeConverter) const =0
Lower the given member function pointer type to its ABI type.
virtual void lowerGetMethod(cir::GetMethodOp op, mlir::Value &callee, mlir::Value &thisArg, mlir::Value loweredMethod, mlir::Value loweredObjectPtr, mlir::ConversionPatternRewriter &rewriter) const =0
Lower the given cir.get_method op to a sequence of more "primitive" CIR operations that act on the AB...
virtual mlir::Value lowerDataMemberBitcast(cir::CastOp op, mlir::Type loweredDstTy, mlir::Value loweredSrc, mlir::OpBuilder &builder) const =0
virtual mlir::Operation * lowerGetRuntimeMember(cir::GetRuntimeMemberOp op, mlir::Type loweredResultTy, mlir::Value loweredAddr, mlir::Value loweredMember, mlir::OpBuilder &builder) const =0
Lower the given cir.get_runtime_member op to a sequence of more "primitive" CIR operations that act o...
virtual mlir::Value lowerMethodToBoolCast(cir::CastOp op, mlir::Value loweredSrc, mlir::OpBuilder &builder) const =0
virtual mlir::Value lowerDataMemberCmp(cir::CmpOp op, mlir::Value loweredLhs, mlir::Value loweredRhs, mlir::OpBuilder &builder) const =0
virtual mlir::TypedAttr lowerDataMemberConstant(cir::DataMemberAttr attr, const mlir::DataLayout &layout, const mlir::TypeConverter &typeConverter) const =0
Lower the given data member pointer constant to a constant of the ABI type.
virtual mlir::Value lowerDataMemberToBoolCast(cir::CastOp op, mlir::Value loweredSrc, mlir::OpBuilder &builder) const =0
CIRCXXABI(LowerModule &lm)
Definition CIRCXXABI.h:32
LowerModule & lm
Definition CIRCXXABI.h:30
virtual mlir::Value lowerBaseMethod(cir::BaseMethodOp op, mlir::Value loweredSrc, mlir::OpBuilder &builder) const =0
virtual mlir::Value lowerDerivedMethod(cir::DerivedMethodOp op, mlir::Value loweredSrc, mlir::OpBuilder &builder) const =0
virtual mlir::Value lowerBaseDataMember(cir::BaseDataMemberOp op, mlir::Value loweredSrc, mlir::OpBuilder &builder) const =0
Lower the given cir.base_data_member op to a sequence of more "primitive" CIR operations that act on ...
friend class LowerModule
Definition CIRCXXABI.h:27
virtual mlir::TypedAttr lowerMethodConstant(cir::MethodAttr attr, const mlir::DataLayout &layout, const mlir::TypeConverter &typeConverter) const =0
Lower the given member function pointer constant to a constant of the ABI type.
virtual mlir::Value lowerMethodCmp(cir::CmpOp op, mlir::Value loweredLhs, mlir::Value loweredRhs, mlir::OpBuilder &builder) const =0
virtual mlir::Value lowerMethodBitcast(cir::CastOp op, mlir::Type loweredDstTy, mlir::Value loweredSrc, mlir::OpBuilder &builder) const =0
virtual mlir::Type lowerDataMemberType(cir::DataMemberType type, const mlir::TypeConverter &typeConverter) const =0
Lower the given data member pointer type to its ABI type.
virtual mlir::Value lowerDerivedDataMember(cir::DerivedDataMemberOp op, mlir::Value loweredSrc, mlir::OpBuilder &builder) const =0
Lower the given cir.derived_data_member op to a sequence of more "primitive" CIR operations that act ...
std::unique_ptr< CIRCXXABI > createItaniumCXXABI(LowerModule &lm)
Creates an Itanium-family ABI.