clang 22.0.0git
CIRGenVTables.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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 contains code dealing with C++ code generation of virtual tables.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef CLANG_LIB_CIR_CODEGEN_CIRGENVTABLES_H
14#define CLANG_LIB_CIR_CODEGEN_CIRGENVTABLES_H
15
16#include "mlir/IR/Types.h"
20
21namespace clang {
22class CXXRecordDecl;
23}
24
25namespace clang::CIRGen {
26class CIRGenModule;
27
29 CIRGenModule &cgm;
30
31 clang::VTableContextBase *vtContext;
32
33 /// Address points for a single vtable.
34 using VTableAddressPointsMapTy = clang::VTableLayout::AddressPointsMapTy;
35
36 mlir::Attribute
37 getVTableComponent(const VTableLayout &layout, unsigned componentIndex,
38 mlir::Attribute rtti, unsigned &nextVTableThunkIndex,
39 unsigned vtableAddressPoint, bool vtableHasLocalLinkage);
40
41 mlir::Type getVTableComponentType();
42
43public:
45
46 /// Add vtable components for the given vtable layout to the given
47 /// global initializer.
48 void createVTableInitializer(cir::GlobalOp &vtable,
49 const clang::VTableLayout &layout,
50 mlir::Attribute rtti,
51 bool vtableHasLocalLinkage);
52
54 return *llvm::cast<clang::ItaniumVTableContext>(vtContext);
55 }
56
58 return *llvm::cast<clang::ItaniumVTableContext>(vtContext);
59 }
60
61 /// Generate a construction vtable for the given base subobject.
62 cir::GlobalOp
64 bool baseIsVirtual, cir::GlobalLinkageKind linkage,
65 VTableAddressPointsMapTy &addressPoints);
66
67 /// Get the address of the VTT for the given record decl.
68 cir::GlobalOp getAddrOfVTT(const CXXRecordDecl *rd);
69
70 /// Emit the definition of the given vtable.
71 void emitVTTDefinition(cir::GlobalOp vttOp, cir::GlobalLinkageKind linkage,
72 const CXXRecordDecl *rd);
73
74 /// Emit the associated thunks for the given global decl.
75 void emitThunks(GlobalDecl gd);
76
77 /// Generate all the class data required to be generated upon definition of a
78 /// KeyFunction. This includes the vtable, the RTTI data structure (if RTTI
79 /// is enabled) and the VTT (if the class has virtual bases).
80 void generateClassData(const CXXRecordDecl *rd);
81
82 /// Returns the type of a vtable with the given layout. Normally a struct of
83 /// arrays of pointers, with one struct element for each vtable in the vtable
84 /// group.
85 cir::RecordType getVTableType(const clang::VTableLayout &layout);
86};
87
88} // namespace clang::CIRGen
89
90#endif // CLANG_LIB_CIR_CODEGEN_CIRGENVTABLES_H
This class organizes the cross-function state that is used while generating CIR code.
Definition: CIRGenModule.h:56
cir::RecordType getVTableType(const clang::VTableLayout &layout)
Returns the type of a vtable with the given layout.
void createVTableInitializer(cir::GlobalOp &vtable, const clang::VTableLayout &layout, mlir::Attribute rtti, bool vtableHasLocalLinkage)
Add vtable components for the given vtable layout to the given global initializer.
cir::GlobalOp generateConstructionVTable(const CXXRecordDecl *rd, const BaseSubobject &base, bool baseIsVirtual, cir::GlobalLinkageKind linkage, VTableAddressPointsMapTy &addressPoints)
Generate a construction vtable for the given base subobject.
void emitThunks(GlobalDecl gd)
Emit the associated thunks for the given global decl.
void emitVTTDefinition(cir::GlobalOp vttOp, cir::GlobalLinkageKind linkage, const CXXRecordDecl *rd)
Emit the definition of the given vtable.
const clang::ItaniumVTableContext & getItaniumVTableContext() const
Definition: CIRGenVTables.h:57
void generateClassData(const CXXRecordDecl *rd)
Generate all the class data required to be generated upon definition of a KeyFunction.
cir::GlobalOp getAddrOfVTT(const CXXRecordDecl *rd)
Get the address of the VTT for the given record decl.
clang::ItaniumVTableContext & getItaniumVTableContext()
Definition: CIRGenVTables.h:53
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
GlobalDecl - represents a global declaration.
Definition: GlobalDecl.h:57
llvm::DenseMap< BaseSubobject, AddressPointLocation > AddressPointsMapTy
The JSON file list parser is used to communicate input to InstallAPI.