Mercurial > projects > ldc
annotate gen/irstate.h @ 31:2841234d2aea trunk
[svn r35] * Attributes on struct fields/methods now work
* Updated object.d to 1.021
* Added -novalidate command line option. this is sometimes useful when debugging as it may let you read the .ll even if it's invalid.
author | lindquist |
---|---|
date | Thu, 04 Oct 2007 16:44:07 +0200 |
parents | 37a4fdab33fc |
children | 8b0e809563df |
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; | |
31
2841234d2aea
[svn r35] * Attributes on struct fields/methods now work
lindquist
parents:
15
diff
changeset
|
44 typedef std::vector<FuncDeclaration*> FuncDeclVec; |
1 | 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; | |
31
2841234d2aea
[svn r35] * Attributes on struct fields/methods now work
lindquist
parents:
15
diff
changeset
|
55 FuncDeclVec funcs; |
2841234d2aea
[svn r35] * Attributes on struct fields/methods now work
lindquist
parents:
15
diff
changeset
|
56 bool queueFuncs; |
1 | 57 }; |
58 | |
59 // represents the module | |
60 struct IRState : Object | |
61 { | |
62 IRState(); | |
63 | |
64 // module | |
65 Module* dmodule; | |
66 llvm::Module* module; | |
67 | |
68 // functions | |
69 std::stack<llvm::Function*> funcs; | |
70 llvm::Function* topfunc(); | |
71 std::stack<TypeFunction*> functypes; | |
72 TypeFunction* topfunctype(); | |
73 llvm::Instruction* topallocapoint(); | |
74 | |
75 // structs | |
76 typedef std::vector<IRStruct> StructVector; | |
77 StructVector structs; | |
78 IRStruct& topstruct(); | |
79 | |
80 // classes TODO move into IRClass | |
81 typedef std::vector<ClassDeclaration*> ClassDeclVec; | |
82 ClassDeclVec classes; | |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
6
diff
changeset
|
83 |
1 | 84 // D main function |
85 bool emitMain; | |
86 llvm::Function* mainFunc; | |
87 | |
88 // L-values | |
89 bool inLvalue; | |
90 typedef std::vector<llvm::Value*> LvalVec; | |
91 LvalVec lvals; | |
92 llvm::Value* toplval(); | |
93 | |
94 // basic block scopes | |
95 std::vector<IRScope> scopes; | |
96 IRScope& scope(); | |
97 llvm::BasicBlock* scopebegin(); | |
98 llvm::BasicBlock* scopeend(); | |
99 llvm::BasicBlock* scopebb(); | |
100 bool scopereturned(); | |
101 | |
102 // loop blocks | |
103 typedef std::vector<IRScope> BBVec; | |
104 BBVec loopbbs; | |
105 | |
106 // this holds the array being indexed or sliced so $ will work | |
107 // might be a better way but it works. problem is I only get a | |
108 // VarDeclaration for __dollar, but I can't see how to get the | |
109 // array pointer from this :( | |
110 LvalVec arrays; | |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
6
diff
changeset
|
111 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
6
diff
changeset
|
112 // keeping track of the declaration for the current function body |
31
2841234d2aea
[svn r35] * Attributes on struct fields/methods now work
lindquist
parents:
15
diff
changeset
|
113 typedef std::vector<FuncDeclaration*> FuncDeclVec; |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
6
diff
changeset
|
114 FuncDeclVec funcdecls; |
1 | 115 }; |
116 | |
117 #endif // LLVMDC_GEN_IRSTATE_H |