Mercurial > projects > ldc
annotate gen/irstate.h @ 161:3a891cfcd249 trunk
[svn r177] moved variable for interface info type from being local static to being within IRState
author | ChristianK |
---|---|
date | Sun, 04 May 2008 21:25:48 +0200 |
parents | 5c17f81fc1c1 |
children | db9890b3fb64 |
rev | line source |
---|---|
1 | 1 #ifndef LLVMDC_GEN_IRSTATE_H |
2 #define LLVMDC_GEN_IRSTATE_H | |
3 | |
4 #include <vector> | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
5 #include <list> |
155
7f92f477ff53
[svn r171] starting to move IR data from AST nodes into IRState; started with IrFunction
ChristianK
parents:
148
diff
changeset
|
6 #include <map> |
1 | 7 |
8 #include "root.h" | |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
108
diff
changeset
|
9 #include "aggregate.h" |
1 | 10 |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
116
diff
changeset
|
11 #include "ir/irfunction.h" |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
116
diff
changeset
|
12 #include "ir/irstruct.h" |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
116
diff
changeset
|
13 #include "ir/irvar.h" |
156
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
14 #include "ir/irsymbol.h" |
157
5c17f81fc1c1
[svn r173] moved IR state previously stored in Type into IrType and a Type->IrType map; fixes #7
ChristianK
parents:
156
diff
changeset
|
15 #include "ir/irtype.h" |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
116
diff
changeset
|
16 |
1 | 17 // global ir state for current module |
18 struct IRState; | |
19 extern IRState* gIR; | |
73 | 20 extern const llvm::TargetData* gTargetData; |
1 | 21 |
22 struct TypeFunction; | |
23 struct TypeStruct; | |
24 struct ClassDeclaration; | |
25 struct FuncDeclaration; | |
26 struct Module; | |
27 struct TypeStruct; | |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
108
diff
changeset
|
28 struct BaseClass; |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
136
diff
changeset
|
29 struct TryFinallyStatement; |
1 | 30 |
156
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
31 struct IrModule; |
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
32 |
1 | 33 // represents a scope |
34 struct IRScope | |
35 { | |
36 llvm::BasicBlock* begin; | |
37 llvm::BasicBlock* end; | |
40 | 38 LLVMBuilder builder; |
1 | 39 |
40 IRScope(); | |
41 IRScope(llvm::BasicBlock* b, llvm::BasicBlock* e); | |
42 }; | |
43 | |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
136
diff
changeset
|
44 // scope for loops |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
136
diff
changeset
|
45 struct IRLoopScope : IRScope |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
136
diff
changeset
|
46 { |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
136
diff
changeset
|
47 // generating statement |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
136
diff
changeset
|
48 Statement* s; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
136
diff
changeset
|
49 // the try of a TryFinally that encloses the loop |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
145
diff
changeset
|
50 TryFinallyStatement* enclosingtryfinally; |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
136
diff
changeset
|
51 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
136
diff
changeset
|
52 IRLoopScope(); |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
145
diff
changeset
|
53 IRLoopScope(Statement* s, TryFinallyStatement* enclosingtryfinally, llvm::BasicBlock* b, llvm::BasicBlock* e); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
136
diff
changeset
|
54 }; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
136
diff
changeset
|
55 |
40 | 56 struct IRBuilderHelper |
57 { | |
58 IRState* state; | |
59 LLVMBuilder* operator->(); | |
60 }; | |
61 | |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
62 struct IRExp |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
63 { |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
64 Expression* e1; |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
65 Expression* e2; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
66 DValue* v; |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
67 IRExp(); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
68 IRExp(Expression* l, Expression* r, DValue* val); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
69 }; |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
70 |
1 | 71 // represents the module |
40 | 72 struct IRState |
1 | 73 { |
74 IRState(); | |
75 | |
76 // module | |
77 Module* dmodule; | |
78 llvm::Module* module; | |
79 | |
161
3a891cfcd249
[svn r177] moved variable for interface info type from being local static to being within IRState
ChristianK
parents:
157
diff
changeset
|
80 // interface info type, used in DtoInterfaceInfoType |
3a891cfcd249
[svn r177] moved variable for interface info type from being local static to being within IRState
ChristianK
parents:
157
diff
changeset
|
81 llvm::StructType* interfaceInfoType; |
3a891cfcd249
[svn r177] moved variable for interface info type from being local static to being within IRState
ChristianK
parents:
157
diff
changeset
|
82 |
156
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
83 // ir data associated with DMD Dsymbol nodes |
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
84 std::map<Dsymbol*, IrDsymbol> irDsymbol; |
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
85 |
157
5c17f81fc1c1
[svn r173] moved IR state previously stored in Type into IrType and a Type->IrType map; fixes #7
ChristianK
parents:
156
diff
changeset
|
86 // ir data associated with DMD Type instances |
5c17f81fc1c1
[svn r173] moved IR state previously stored in Type into IrType and a Type->IrType map; fixes #7
ChristianK
parents:
156
diff
changeset
|
87 std::map<Type*, IrType> irType; |
5c17f81fc1c1
[svn r173] moved IR state previously stored in Type into IrType and a Type->IrType map; fixes #7
ChristianK
parents:
156
diff
changeset
|
88 |
1 | 89 // functions |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
116
diff
changeset
|
90 typedef std::vector<IrFunction*> FunctionVector; |
40 | 91 FunctionVector functions; |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
116
diff
changeset
|
92 IrFunction* func(); |
40 | 93 |
1 | 94 llvm::Function* topfunc(); |
95 TypeFunction* topfunctype(); | |
96 llvm::Instruction* topallocapoint(); | |
97 | |
98 // structs | |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
116
diff
changeset
|
99 typedef std::vector<IrStruct*> StructVector; |
1 | 100 StructVector structs; |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
116
diff
changeset
|
101 IrStruct* topstruct(); |
1 | 102 |
103 // classes TODO move into IRClass | |
104 typedef std::vector<ClassDeclaration*> ClassDeclVec; | |
105 ClassDeclVec classes; | |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
6
diff
changeset
|
106 |
1 | 107 // D main function |
108 bool emitMain; | |
109 llvm::Function* mainFunc; | |
110 | |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
111 // expression l/r value handling |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
112 typedef std::vector<IRExp> ExpVec; |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
113 ExpVec exps; |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
114 IRExp* topexp(); |
1 | 115 |
116 // basic block scopes | |
117 std::vector<IRScope> scopes; | |
118 IRScope& scope(); | |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
103
diff
changeset
|
119 llvm::BasicBlock* scopebb(); |
1 | 120 llvm::BasicBlock* scopeend(); |
121 bool scopereturned(); | |
122 | |
123 // loop blocks | |
124 typedef std::vector<IRScope> BBVec; | |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
136
diff
changeset
|
125 typedef std::vector<IRLoopScope> LoopScopeVec; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
136
diff
changeset
|
126 LoopScopeVec loopbbs; |
1 | 127 |
128 // this holds the array being indexed or sliced so $ will work | |
129 // might be a better way but it works. problem is I only get a | |
130 // VarDeclaration for __dollar, but I can't see how to get the | |
131 // array pointer from this :( | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
132 std::vector<DValue*> arrays; |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
6
diff
changeset
|
133 |
40 | 134 // builder helper |
135 IRBuilderHelper ir; | |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
94
diff
changeset
|
136 |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
137 typedef std::list<Dsymbol*> DsymbolList; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
138 // dsymbols that need to be resolved |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
139 DsymbolList resolveList; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
140 // dsymbols that need to be declared |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
141 DsymbolList declareList; |
100 | 142 // dsymbols that need constant initializers constructed |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
143 DsymbolList constInitList; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
144 // dsymbols that need definitions |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
145 DsymbolList defineList; |
116
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
146 |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
147 // static ctors/dtors/unittests |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
148 typedef std::vector<FuncDeclaration*> FuncDeclVector; |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
149 FuncDeclVector ctors; |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
150 FuncDeclVector dtors; |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
151 FuncDeclVector unitTests; |
1 | 152 }; |
153 | |
154 #endif // LLVMDC_GEN_IRSTATE_H |