Mercurial > projects > ldc
annotate gen/irstate.c @ 20:42bf2eb2973b trunk
[svn r24] * Added a simple std.traits by downs
author | lindquist |
---|---|
date | Thu, 04 Oct 2007 04:28:30 +0200 |
parents | 0e86428ee567 |
children | 2841234d2aea |
rev | line source |
---|---|
1 | 1 /* DMDFE backend stubs |
2 * This file contains the implementations of the backend routines. | |
3 * For dmdfe these do nothing but print a message saying the module | |
4 * has been parsed. Substitute your own behaviors for these routimes. | |
5 */ | |
6 | |
7 #include "mtype.h" | |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
8 #include "gen/irstate.h" |
1 | 9 |
10 IRState* gIR = 0; | |
11 llvm::TargetData* gTargetData = 0; | |
12 | |
13 ////////////////////////////////////////////////////////////////////////////////////////// | |
14 IRScope::IRScope() | |
15 { | |
16 begin = end = 0; | |
17 returned = false; | |
18 } | |
19 | |
20 IRScope::IRScope(llvm::BasicBlock* b, llvm::BasicBlock* e) | |
21 { | |
22 begin = b; | |
23 end = e; | |
24 returned = false; | |
25 } | |
26 | |
27 ////////////////////////////////////////////////////////////////////////////////////////// | |
28 IRState::IRState() | |
29 { | |
30 dmodule = 0; | |
31 module = 0; | |
32 inLvalue = false; | |
33 emitMain = false; | |
34 mainFunc = 0; | |
35 } | |
36 | |
37 llvm::Function* IRState::topfunc() | |
38 { | |
39 assert(!funcs.empty() && "Function stack is empty!"); | |
40 return funcs.top(); | |
41 } | |
42 | |
43 TypeFunction* IRState::topfunctype() | |
44 { | |
45 assert(!functypes.empty() && "TypeFunction stack is empty!"); | |
46 return functypes.top(); | |
47 } | |
48 | |
49 llvm::Instruction* IRState::topallocapoint() | |
50 { | |
51 assert(!functypes.empty() && "AllocaPoint stack is empty!"); | |
52 return functypes.top()->llvmAllocaPoint; | |
53 } | |
54 | |
55 IRStruct& IRState::topstruct() | |
56 { | |
57 assert(!structs.empty() && "Struct vector is empty!"); | |
58 return structs.back(); | |
59 } | |
60 | |
61 llvm::Value* IRState::toplval() | |
62 { | |
63 assert(!lvals.empty() && "Lval vector is empty!"); | |
64 return lvals.back(); | |
65 } | |
66 | |
67 IRScope& IRState::scope() | |
68 { | |
69 assert(!scopes.empty()); | |
70 return scopes.back(); | |
71 } | |
72 | |
73 llvm::BasicBlock* IRState::scopebb() | |
74 { | |
75 return scopebegin(); | |
76 } | |
77 llvm::BasicBlock* IRState::scopebegin() | |
78 { | |
79 IRScope& s = scope(); | |
80 assert(s.begin); | |
81 return s.begin; | |
82 } | |
83 llvm::BasicBlock* IRState::scopeend() | |
84 { | |
85 IRScope& s = scope(); | |
86 assert(s.end); | |
87 return s.end; | |
88 } | |
89 bool IRState::scopereturned() | |
90 { | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
6
diff
changeset
|
91 //return scope().returned; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
6
diff
changeset
|
92 return !scopebb()->empty() && scopebb()->back().isTerminator(); |
1 | 93 } |
94 | |
95 ////////////////////////////////////////////////////////////////////////////////////////// | |
96 | |
97 IRStruct::IRStruct() | |
98 : recty(llvm::OpaqueType::get()) | |
99 { | |
100 type = 0; | |
101 } | |
102 | |
6 | 103 IRStruct::IRStruct(Type* t) |
1 | 104 : recty(llvm::OpaqueType::get()) |
105 { | |
106 type = t; | |
107 } | |
108 | |
109 IRStruct::~IRStruct() | |
110 { | |
111 } |