| 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" |
| 18 |
#include "clang/CIR/Dialect/IR/CIRDialect.h" |
| 19 |
#include "clang/CIR/Dialect/IR/CIRTypes.h" |
| 20 |
|
| 21 |
namespace cir { |
| 22 |
|
| 23 |
// Forward declarations. |
| 24 |
class LowerModule; |
| 25 |
|
| 26 |
class CIRCXXABI { |
| 27 |
friend class LowerModule; |
| 28 |
|
| 29 |
protected: |
| 30 |
LowerModule &lm; |
| 31 |
|
| 32 |
CIRCXXABI(LowerModule &lm) : lm(lm) {} |
| 33 |
|
| 34 |
public: |
| 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 cir.get_runtime_member op to a sequence of more |
| 57 |
/// "primitive" CIR operations that act on the ABI types. |
| 58 |
virtual mlir::Operation * |
| 59 |
lowerGetRuntimeMember(cir::GetRuntimeMemberOp op, mlir::Type loweredResultTy, |
| 60 |
mlir::Value loweredAddr, mlir::Value loweredMember, |
| 61 |
mlir::OpBuilder &builder) const = 0; |
| 62 |
|
| 63 |
/// Lower the given cir.base_data_member op to a sequence of more "primitive" |
| 64 |
/// CIR operations that act on the ABI types. |
| 65 |
virtual mlir::Value lowerBaseDataMember(cir::BaseDataMemberOp op, |
| 66 |
mlir::Value loweredSrc, |
| 67 |
mlir::OpBuilder &builder) const = 0; |
| 68 |
|
| 69 |
/// Lower the given cir.derived_data_member op to a sequence of more |
| 70 |
/// "primitive" CIR operations that act on the ABI types. |
| 71 |
virtual mlir::Value |
| 72 |
lowerDerivedDataMember(cir::DerivedDataMemberOp op, mlir::Value loweredSrc, |
| 73 |
mlir::OpBuilder &builder) const = 0; |
| 74 |
|
| 75 |
virtual mlir::Value lowerDataMemberCmp(cir::CmpOp op, mlir::Value loweredLhs, |
| 76 |
mlir::Value loweredRhs, |
| 77 |
mlir::OpBuilder &builder) const = 0; |
| 78 |
}; |
| 79 |
|
| 80 |
/// Creates an Itanium-family ABI. |
| 81 |
std::unique_ptr<CIRCXXABI> createItaniumCXXABI(LowerModule &lm); |
| 82 |
|
| 83 |
} // namespace cir |
| 84 |
|
| 85 |
#endif // CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_CIRCXXABI_H |