Mercurial > projects > ldc
comparison gen/irstate.h @ 100:5071469303d4 trunk
[svn r104] TONS OF FIXES.
Split up declaration, constant initializer gen and definition for globals, structs, classes and functions.
Improved ClassInfo support (not complete), not in vtable yet.
Fixed a bunch of forward reference problems.
Much more. Major commit! :)
author | lindquist |
---|---|
date | Fri, 16 Nov 2007 08:21:47 +0100 |
parents | 6789050b5ad1 |
children | 027b8d8b71ec |
comparison
equal
deleted
inserted
replaced
99:a676a7743642 | 100:5071469303d4 |
---|---|
37 IRScope(); | 37 IRScope(); |
38 IRScope(llvm::BasicBlock* b, llvm::BasicBlock* e); | 38 IRScope(llvm::BasicBlock* b, llvm::BasicBlock* e); |
39 }; | 39 }; |
40 | 40 |
41 // represents a struct or class | 41 // represents a struct or class |
42 struct IRStruct | 42 struct IRStruct : Object |
43 { | 43 { |
44 struct Offset | 44 struct Offset |
45 { | 45 { |
46 VarDeclaration* var; | 46 VarDeclaration* var; |
47 const llvm::Type* type; | |
47 llvm::Constant* init; | 48 llvm::Constant* init; |
48 | 49 |
49 Offset(VarDeclaration* v, llvm::Constant* i) | 50 Offset(VarDeclaration* v, const llvm::Type* ty) |
50 : var(v), init(i) {} | 51 : var(v), type(ty), init(NULL) {} |
51 }; | 52 }; |
52 | 53 |
53 typedef std::vector<FuncDeclaration*> FuncDeclVector; | |
54 typedef std::multimap<unsigned, Offset> OffsetMap; | 54 typedef std::multimap<unsigned, Offset> OffsetMap; |
55 typedef std::vector<VarDeclaration*> VarDeclVector; | |
55 | 56 |
56 public: | 57 public: |
57 IRStruct(); | 58 IRStruct(); |
58 IRStruct(Type*); | 59 IRStruct(Type*); |
59 | 60 |
60 Type* type; | 61 Type* type; |
61 llvm::PATypeHolder recty; | 62 llvm::PATypeHolder recty; |
62 FuncDeclVector funcs; | 63 OffsetMap offsets; |
63 bool queueFuncs; | 64 VarDeclVector defaultFields; |
64 | 65 |
65 OffsetMap offsets; | 66 bool defined; |
67 bool constinited; | |
66 }; | 68 }; |
67 | 69 |
68 // represents a finally block | 70 // represents a finally block |
69 struct IRFinally | 71 struct IRFinally |
70 { | 72 { |
74 IRFinally(); | 76 IRFinally(); |
75 IRFinally(llvm::BasicBlock* b, llvm::BasicBlock* rb); | 77 IRFinally(llvm::BasicBlock* b, llvm::BasicBlock* rb); |
76 }; | 78 }; |
77 | 79 |
78 // represents a function | 80 // represents a function |
79 struct IRFunction | 81 struct IRFunction : Object |
80 { | 82 { |
81 llvm::Function* func; | 83 llvm::Function* func; |
82 llvm::Instruction* allocapoint; | 84 llvm::Instruction* allocapoint; |
83 FuncDeclaration* decl; | 85 FuncDeclaration* decl; |
84 TypeFunction* type; | 86 TypeFunction* type; |
85 | 87 |
86 // finally blocks | 88 // finally blocks |
87 typedef std::vector<IRFinally> FinallyVec; | 89 typedef std::vector<IRFinally> FinallyVec; |
88 FinallyVec finallys; | 90 FinallyVec finallys; |
89 llvm::Value* finallyretval; | 91 llvm::Value* finallyretval; |
92 | |
93 bool defined; | |
90 | 94 |
91 IRFunction(FuncDeclaration*); | 95 IRFunction(FuncDeclaration*); |
92 }; | 96 }; |
93 | 97 |
94 struct IRBuilderHelper | 98 struct IRBuilderHelper |
104 DValue* v; | 108 DValue* v; |
105 IRExp(); | 109 IRExp(); |
106 IRExp(Expression* l, Expression* r, DValue* val); | 110 IRExp(Expression* l, Expression* r, DValue* val); |
107 }; | 111 }; |
108 | 112 |
113 // represents a global variable | |
114 struct IRGlobal : Object | |
115 { | |
116 VarDeclaration* var; | |
117 llvm::PATypeHolder type; | |
118 | |
119 IRGlobal(VarDeclaration* v); | |
120 }; | |
121 | |
109 // represents the module | 122 // represents the module |
110 struct IRState | 123 struct IRState |
111 { | 124 { |
112 IRState(); | 125 IRState(); |
113 | 126 |
114 // module | 127 // module |
115 Module* dmodule; | 128 Module* dmodule; |
116 llvm::Module* module; | 129 llvm::Module* module; |
117 | 130 |
118 // functions | 131 // functions |
119 typedef std::vector<IRFunction> FunctionVector; | 132 typedef std::vector<IRFunction*> FunctionVector; |
120 FunctionVector functions; | 133 FunctionVector functions; |
121 IRFunction& func(); | 134 IRFunction* func(); |
122 | 135 |
123 llvm::Function* topfunc(); | 136 llvm::Function* topfunc(); |
124 TypeFunction* topfunctype(); | 137 TypeFunction* topfunctype(); |
125 llvm::Instruction* topallocapoint(); | 138 llvm::Instruction* topallocapoint(); |
126 | 139 |
127 // structs | 140 // structs |
128 typedef std::vector<IRStruct> StructVector; | 141 typedef std::vector<IRStruct*> StructVector; |
129 StructVector structs; | 142 StructVector structs; |
130 IRStruct& topstruct(); | 143 IRStruct* topstruct(); |
131 | 144 |
132 // classes TODO move into IRClass | 145 // classes TODO move into IRClass |
133 typedef std::vector<ClassDeclaration*> ClassDeclVec; | 146 typedef std::vector<ClassDeclaration*> ClassDeclVec; |
134 ClassDeclVec classes; | 147 ClassDeclVec classes; |
135 | 148 |
161 std::vector<DValue*> arrays; | 174 std::vector<DValue*> arrays; |
162 | 175 |
163 // builder helper | 176 // builder helper |
164 IRBuilderHelper ir; | 177 IRBuilderHelper ir; |
165 | 178 |
166 // functions queued for lazy definition | 179 typedef std::vector<Dsymbol*> DsymbolVector; |
167 typedef std::vector<FuncDeclaration*> FuncDeclVector; | 180 // dsymbols that need constant initializers constructed |
168 FuncDeclVector funcQueue; | 181 DsymbolVector constInitQueue; |
182 // dsymbols that need definitions (symbols in current module) | |
183 DsymbolVector defineQueue; | |
169 }; | 184 }; |
170 | 185 |
171 #endif // LLVMDC_GEN_IRSTATE_H | 186 #endif // LLVMDC_GEN_IRSTATE_H |