Mercurial > projects > ldc
annotate gen/irstate.h @ 15:37a4fdab33fc trunk
[svn r19] * Added support for reassigning 'this' inside class constructors.
* Added preliminary support for UnrolledLoopStatement. That is foreach on a tuple.
author | lindquist |
---|---|
date | Wed, 03 Oct 2007 04:56:32 +0200 |
parents | 35d93ce68cf4 |
children | 2841234d2aea |
rev | line source |
---|---|
1 | 1 #ifndef LLVMDC_GEN_IRSTATE_H |
2 #define LLVMDC_GEN_IRSTATE_H | |
3 | |
4 #include <stack> | |
5 #include <vector> | |
6 #include <deque> | |
7 | |
8 #include "llvm/DerivedTypes.h" | |
9 #include "llvm/Module.h" | |
10 #include "llvm/Function.h" | |
11 #include "llvm/BasicBlock.h" | |
12 #include "llvm/Target/TargetData.h" | |
13 | |
14 #include "root.h" | |
15 | |
16 // global ir state for current module | |
17 struct IRState; | |
18 extern IRState* gIR; | |
19 extern llvm::TargetData* gTargetData; | |
20 | |
21 struct TypeFunction; | |
22 struct TypeStruct; | |
23 struct ClassDeclaration; | |
24 struct FuncDeclaration; | |
25 struct Module; | |
26 struct TypeStruct; | |
27 | |
28 // represents a scope | |
29 struct IRScope | |
30 { | |
31 llvm::BasicBlock* begin; | |
32 llvm::BasicBlock* end; | |
33 bool returned; | |
34 | |
35 IRScope(); | |
36 IRScope(llvm::BasicBlock* b, llvm::BasicBlock* e); | |
37 }; | |
38 | |
6 | 39 // represents a struct or class |
1 | 40 struct IRStruct : Object |
41 { | |
42 typedef std::vector<const llvm::Type*> TypeVector; | |
43 typedef std::vector<llvm::Constant*> ConstantVector; | |
44 typedef std::vector<llvm::PATypeHolder> PATypeHolderVector; | |
45 | |
46 public: | |
47 IRStruct(); | |
6 | 48 IRStruct(Type*); |
1 | 49 virtual ~IRStruct(); |
50 | |
6 | 51 Type* type; |
1 | 52 TypeVector fields; |
53 ConstantVector inits; | |
54 llvm::PATypeHolder recty; | |
55 }; | |
56 | |
57 // represents the module | |
58 struct IRState : Object | |
59 { | |
60 IRState(); | |
61 | |
62 // module | |
63 Module* dmodule; | |
64 llvm::Module* module; | |
65 | |
66 // functions | |
67 std::stack<llvm::Function*> funcs; | |
68 llvm::Function* topfunc(); | |
69 std::stack<TypeFunction*> functypes; | |
70 TypeFunction* topfunctype(); | |
71 llvm::Instruction* topallocapoint(); | |
72 | |
73 // structs | |
74 typedef std::vector<IRStruct> StructVector; | |
75 StructVector structs; | |
76 IRStruct& topstruct(); | |
77 | |
78 // classes TODO move into IRClass | |
79 typedef std::vector<ClassDeclaration*> ClassDeclVec; | |
80 ClassDeclVec classes; | |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
6
diff
changeset
|
81 |
1 | 82 typedef std::vector<FuncDeclaration*> FuncDeclVec; |
83 typedef std::vector<FuncDeclVec> ClassMethodVec; | |
84 ClassMethodVec classmethods; | |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
6
diff
changeset
|
85 |
1 | 86 typedef std::vector<bool> BoolVec; |
87 BoolVec queueClassMethods; | |
88 | |
89 // D main function | |
90 bool emitMain; | |
91 llvm::Function* mainFunc; | |
92 | |
93 // L-values | |
94 bool inLvalue; | |
95 typedef std::vector<llvm::Value*> LvalVec; | |
96 LvalVec lvals; | |
97 llvm::Value* toplval(); | |
98 | |
99 // basic block scopes | |
100 std::vector<IRScope> scopes; | |
101 IRScope& scope(); | |
102 llvm::BasicBlock* scopebegin(); | |
103 llvm::BasicBlock* scopeend(); | |
104 llvm::BasicBlock* scopebb(); | |
105 bool scopereturned(); | |
106 | |
107 // loop blocks | |
108 typedef std::vector<IRScope> BBVec; | |
109 BBVec loopbbs; | |
110 | |
111 // this holds the array being indexed or sliced so $ will work | |
112 // might be a better way but it works. problem is I only get a | |
113 // VarDeclaration for __dollar, but I can't see how to get the | |
114 // array pointer from this :( | |
115 LvalVec arrays; | |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
6
diff
changeset
|
116 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
6
diff
changeset
|
117 // keeping track of the declaration for the current function body |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
6
diff
changeset
|
118 FuncDeclVec funcdecls; |
1 | 119 }; |
120 | |
121 #endif // LLVMDC_GEN_IRSTATE_H |