comparison ir/irtype.h @ 1192:3251ce06c820

Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Fri, 03 Apr 2009 16:34:11 +0200
parents
children 79758fd2f48a
comparison
equal deleted inserted replaced
1191:d68796be59fd 1192:3251ce06c820
1 #ifndef __LDC_IR_IRTYPE_H__
2 #define __LDC_IR_IRTYPE_H__
3
4 #include "llvm/Type.h"
5
6 //////////////////////////////////////////////////////////////////////////////
7
8 // forward declarations
9
10 struct Type;
11
12 class IrTypeArray;
13 class IrTypeBasic;
14 class IrTypePointer;
15 class IrTypeSArray;
16
17 //////////////////////////////////////////////////////////////////////////////
18
19 /// Base class for IrTypeS.
20 class IrType
21 {
22 public:
23 ///
24 IrType(Type* dt, const llvm::Type* lt);
25
26 ///
27 Type* getD() { return dtype; }
28
29 ///
30 const llvm::Type* get() { return pa.get(); }
31
32 ///
33 virtual IrTypeArray* isArray() { return NULL; }
34 ///
35 virtual IrTypeBasic* isBasic() { return NULL; }
36 ///
37 virtual IrTypePointer* isPointer() { return NULL; }
38 ///
39 virtual IrTypeSArray* isSArray() { return NULL; }
40
41 protected:
42 ///
43 Type* dtype;
44
45 /// LLVM type holder.
46 llvm::PATypeHolder pa;
47 };
48
49 //////////////////////////////////////////////////////////////////////////////
50
51 /// IrType for basic D types.
52 class IrTypeBasic : public IrType
53 {
54 public:
55 ///
56 IrTypeBasic(Type* dt);
57
58 ///
59 IrTypeBasic* isBasic() { return this; }
60
61 protected:
62 ///
63 const llvm::Type* basic2llvm(Type* t);
64 };
65
66 //////////////////////////////////////////////////////////////////////////////
67
68 /// IrType from pointers.
69 class IrTypePointer : public IrType
70 {
71 public:
72 ///
73 IrTypePointer(Type* dt);
74
75 ///
76 IrTypePointer* isPointer() { return this; }
77
78 protected:
79 ///
80 const llvm::Type* pointer2llvm(Type* t);
81 };
82
83 //////////////////////////////////////////////////////////////////////////////
84
85 /// IrType for static arrays
86 class IrTypeSArray : public IrType
87 {
88 public:
89 ///
90 IrTypeSArray(Type* dt);
91
92 ///
93 IrTypeSArray* isSArray() { return this; }
94
95 protected:
96 ///
97 const llvm::Type* sarray2llvm(Type* t);
98
99 /// Dimension.
100 uint64_t dim;
101 };
102
103 //////////////////////////////////////////////////////////////////////////////
104
105 /// IrType for dynamic arrays
106 class IrTypeArray : public IrType
107 {
108 public:
109 ///
110 IrTypeArray(Type* dt);
111
112 ///
113 IrTypeArray* isArray() { return this; }
114
115 protected:
116 ///
117 const llvm::Type* array2llvm(Type* t);
118 };
119
120 //////////////////////////////////////////////////////////////////////////////
121
122 #endif