| 1 |
#ifndef __LDC_GEN_RTTIBUILDER_H__ |
|---|
| 2 |
#define __LDC_GEN_RTTIBUILDER_H__ |
|---|
| 3 |
|
|---|
| 4 |
#include "llvm/Constant.h" |
|---|
| 5 |
#include "llvm/ADT/SmallVector.h" |
|---|
| 6 |
|
|---|
| 7 |
struct ClassDeclaration; |
|---|
| 8 |
struct TypeClass; |
|---|
| 9 |
struct Type; |
|---|
| 10 |
|
|---|
| 11 |
struct IrStruct; |
|---|
| 12 |
|
|---|
| 13 |
struct RTTIBuilder |
|---|
| 14 |
{ |
|---|
| 15 |
ClassDeclaration* base; |
|---|
| 16 |
TypeClass* basetype; |
|---|
| 17 |
IrStruct* baseir; |
|---|
| 18 |
|
|---|
| 19 |
// 10 is enough for any D1 TypeInfo |
|---|
| 20 |
// 14 is enough for any D1 ClassInfo |
|---|
| 21 |
llvm::SmallVector<llvm::Constant*, 14> inits; |
|---|
| 22 |
|
|---|
| 23 |
RTTIBuilder(ClassDeclaration* base_class); |
|---|
| 24 |
|
|---|
| 25 |
void push(llvm::Constant* C); |
|---|
| 26 |
void push_null(Type* T); |
|---|
| 27 |
void push_null_vp(); |
|---|
| 28 |
void push_null_void_array(); |
|---|
| 29 |
void push_uint(unsigned u); |
|---|
| 30 |
void push_size(uint64_t s); |
|---|
| 31 |
void push_string(const char* str); |
|---|
| 32 |
void push_typeinfo(Type* t); |
|---|
| 33 |
void push_classinfo(ClassDeclaration* cd); |
|---|
| 34 |
|
|---|
| 35 |
/// pushes the function pointer or a null void* if it cannot. |
|---|
| 36 |
void push_funcptr(FuncDeclaration* fd, Type* castto = NULL); |
|---|
| 37 |
|
|---|
| 38 |
/// pushes the array slice given. |
|---|
| 39 |
void push_array(uint64_t dim, llvm::Constant * ptr); |
|---|
| 40 |
|
|---|
| 41 |
/// pushes void[] slice, dim is used directly, ptr is cast to void* . |
|---|
| 42 |
void push_void_array(uint64_t dim, llvm::Constant* ptr); |
|---|
| 43 |
|
|---|
| 44 |
/// pushes void[] slice with data. |
|---|
| 45 |
/// CI is the constant initializer the array should point to, the length |
|---|
| 46 |
/// and ptr are resolved automatically |
|---|
| 47 |
void push_void_array(llvm::Constant* CI, Type* valtype, Dsymbol* mangle_sym); |
|---|
| 48 |
|
|---|
| 49 |
/// pushes valtype[] slice with data. |
|---|
| 50 |
/// CI is the constant initializer that .ptr should point to |
|---|
| 51 |
/// dim is .length member directly |
|---|
| 52 |
/// valtype provides the D element type, .ptr is cast to valtype->pointerTo() |
|---|
| 53 |
/// mangle_sym provides the mangle prefix for the symbol generated. |
|---|
| 54 |
void push_array(llvm::Constant* CI, uint64_t dim, Type* valtype, Dsymbol* mangle_sym); |
|---|
| 55 |
|
|---|
| 56 |
/// Creates the initializer constant and assigns it to the global. |
|---|
| 57 |
void finalize(IrGlobal* tid); |
|---|
| 58 |
|
|---|
| 59 |
/// Creates the initializer constant and assigns it to the global. |
|---|
| 60 |
llvm::Constant* get_constant(); |
|---|
| 61 |
}; |
|---|
| 62 |
|
|---|
| 63 |
#endif |
|---|