Mercurial > projects > ldc
comparison gen/irstate.c @ 1:c53b6e3fe49a trunk
[svn r5] Initial commit. Most things are very rough.
author | lindquist |
---|---|
date | Sat, 01 Sep 2007 21:43:27 +0200 |
parents | |
children | e116aa1488e6 |
comparison
equal
deleted
inserted
replaced
0:a9e71648e74d | 1:c53b6e3fe49a |
---|---|
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 "irstate.h" | |
8 | |
9 #include "mtype.h" | |
10 | |
11 IRState* gIR = 0; | |
12 llvm::TargetData* gTargetData = 0; | |
13 | |
14 ////////////////////////////////////////////////////////////////////////////////////////// | |
15 IRScope::IRScope() | |
16 { | |
17 begin = end = 0; | |
18 returned = false; | |
19 } | |
20 | |
21 IRScope::IRScope(llvm::BasicBlock* b, llvm::BasicBlock* e) | |
22 { | |
23 begin = b; | |
24 end = e; | |
25 returned = false; | |
26 } | |
27 | |
28 ////////////////////////////////////////////////////////////////////////////////////////// | |
29 IRState::IRState() | |
30 { | |
31 dmodule = 0; | |
32 module = 0; | |
33 inLvalue = false; | |
34 emitMain = false; | |
35 mainFunc = 0; | |
36 } | |
37 | |
38 llvm::Function* IRState::topfunc() | |
39 { | |
40 assert(!funcs.empty() && "Function stack is empty!"); | |
41 return funcs.top(); | |
42 } | |
43 | |
44 TypeFunction* IRState::topfunctype() | |
45 { | |
46 assert(!functypes.empty() && "TypeFunction stack is empty!"); | |
47 return functypes.top(); | |
48 } | |
49 | |
50 llvm::Instruction* IRState::topallocapoint() | |
51 { | |
52 assert(!functypes.empty() && "AllocaPoint stack is empty!"); | |
53 return functypes.top()->llvmAllocaPoint; | |
54 } | |
55 | |
56 IRStruct& IRState::topstruct() | |
57 { | |
58 assert(!structs.empty() && "Struct vector is empty!"); | |
59 return structs.back(); | |
60 } | |
61 | |
62 llvm::Value* IRState::toplval() | |
63 { | |
64 assert(!lvals.empty() && "Lval vector is empty!"); | |
65 return lvals.back(); | |
66 } | |
67 | |
68 IRScope& IRState::scope() | |
69 { | |
70 assert(!scopes.empty()); | |
71 return scopes.back(); | |
72 } | |
73 | |
74 llvm::BasicBlock* IRState::scopebb() | |
75 { | |
76 return scopebegin(); | |
77 } | |
78 llvm::BasicBlock* IRState::scopebegin() | |
79 { | |
80 IRScope& s = scope(); | |
81 assert(s.begin); | |
82 return s.begin; | |
83 } | |
84 llvm::BasicBlock* IRState::scopeend() | |
85 { | |
86 IRScope& s = scope(); | |
87 assert(s.end); | |
88 return s.end; | |
89 } | |
90 bool IRState::scopereturned() | |
91 { | |
92 return scope().returned; | |
93 } | |
94 | |
95 ////////////////////////////////////////////////////////////////////////////////////////// | |
96 | |
97 IRStruct::IRStruct() | |
98 : recty(llvm::OpaqueType::get()) | |
99 { | |
100 type = 0; | |
101 } | |
102 | |
103 IRStruct::IRStruct(TypeStruct* t) | |
104 : recty(llvm::OpaqueType::get()) | |
105 { | |
106 type = t; | |
107 } | |
108 | |
109 IRStruct::~IRStruct() | |
110 { | |
111 } |