Mercurial > projects > ldc
annotate gen/irstate.h @ 136:0e28624814e8 trunk
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
author | lindquist |
---|---|
date | Thu, 17 Jan 2008 03:15:12 +0100 |
parents | fd7ad91fd713 |
children | 8f704cb9969b |
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> |
1 | 6 |
7 #include "root.h" | |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
108
diff
changeset
|
8 #include "aggregate.h" |
1 | 9 |
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
|
10 #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
|
11 #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
|
12 #include "ir/irvar.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 |
1 | 14 // global ir state for current module |
15 struct IRState; | |
16 extern IRState* gIR; | |
73 | 17 extern const llvm::TargetData* gTargetData; |
1 | 18 |
19 struct TypeFunction; | |
20 struct TypeStruct; | |
21 struct ClassDeclaration; | |
22 struct FuncDeclaration; | |
23 struct Module; | |
24 struct TypeStruct; | |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
108
diff
changeset
|
25 struct BaseClass; |
1 | 26 |
27 // represents a scope | |
28 struct IRScope | |
29 { | |
30 llvm::BasicBlock* begin; | |
31 llvm::BasicBlock* end; | |
40 | 32 LLVMBuilder builder; |
1 | 33 |
34 IRScope(); | |
35 IRScope(llvm::BasicBlock* b, llvm::BasicBlock* e); | |
36 }; | |
37 | |
40 | 38 struct IRBuilderHelper |
39 { | |
40 IRState* state; | |
41 LLVMBuilder* operator->(); | |
42 }; | |
43 | |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
44 struct IRExp |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
45 { |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
46 Expression* e1; |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
47 Expression* e2; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
48 DValue* v; |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
49 IRExp(); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
50 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
|
51 }; |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
52 |
1 | 53 // represents the module |
40 | 54 struct IRState |
1 | 55 { |
56 IRState(); | |
57 | |
58 // module | |
59 Module* dmodule; | |
60 llvm::Module* module; | |
61 | |
62 // 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
|
63 typedef std::vector<IrFunction*> FunctionVector; |
40 | 64 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
|
65 IrFunction* func(); |
40 | 66 |
1 | 67 llvm::Function* topfunc(); |
68 TypeFunction* topfunctype(); | |
69 llvm::Instruction* topallocapoint(); | |
70 | |
71 // 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
|
72 typedef std::vector<IrStruct*> StructVector; |
1 | 73 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
|
74 IrStruct* topstruct(); |
1 | 75 |
76 // classes TODO move into IRClass | |
77 typedef std::vector<ClassDeclaration*> ClassDeclVec; | |
78 ClassDeclVec classes; | |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
6
diff
changeset
|
79 |
1 | 80 // D main function |
81 bool emitMain; | |
82 llvm::Function* mainFunc; | |
83 | |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
84 // expression l/r value handling |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
85 typedef std::vector<IRExp> ExpVec; |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
86 ExpVec exps; |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
40
diff
changeset
|
87 IRExp* topexp(); |
1 | 88 |
89 // basic block scopes | |
90 std::vector<IRScope> scopes; | |
91 IRScope& scope(); | |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
103
diff
changeset
|
92 llvm::BasicBlock* scopebb(); |
1 | 93 llvm::BasicBlock* scopeend(); |
94 bool scopereturned(); | |
95 | |
96 // loop blocks | |
97 typedef std::vector<IRScope> BBVec; | |
98 BBVec loopbbs; | |
99 | |
100 // this holds the array being indexed or sliced so $ will work | |
101 // might be a better way but it works. problem is I only get a | |
102 // VarDeclaration for __dollar, but I can't see how to get the | |
103 // 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
|
104 std::vector<DValue*> arrays; |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
6
diff
changeset
|
105 |
40 | 106 // builder helper |
107 IRBuilderHelper ir; | |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
94
diff
changeset
|
108 |
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
|
109 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
|
110 // 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
|
111 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
|
112 // 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
|
113 DsymbolList declareList; |
100 | 114 // 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
|
115 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
|
116 // 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
|
117 DsymbolList defineList; |
116
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
118 |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
119 // static ctors/dtors/unittests |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
120 typedef std::vector<FuncDeclaration*> FuncDeclVector; |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
121 FuncDeclVector ctors; |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
122 FuncDeclVector dtors; |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
123 FuncDeclVector unitTests; |
1 | 124 }; |
125 | |
126 #endif // LLVMDC_GEN_IRSTATE_H |