Mercurial > projects > ldc
annotate gen/runtime.cpp @ 197:bfcb657756f6 trunk
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
Fixed: string switch runtime support had wrong param types.
Fixed: string switch on a temporary slice was broken.
author | lindquist |
---|---|
date | Mon, 12 May 2008 20:02:52 +0200 |
parents | 2900754a6989 |
children | e881c9b1c738 |
rev | line source |
---|---|
1 | 1 #include <cassert> |
2 | |
52 | 3 #include "gen/llvm.h" |
1 | 4 #include "llvm/Module.h" |
5 #include "llvm/Bitcode/ReaderWriter.h" | |
6 #include "llvm/Support/MemoryBuffer.h" | |
7 | |
8 #include "root.h" | |
9 #include "mars.h" | |
132 | 10 #include "lexer.h" |
11 #include "dsymbol.h" | |
12 #include "mtype.h" | |
13 #include "aggregate.h" | |
1 | 14 |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
15 #include "gen/runtime.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
16 #include "gen/logger.h" |
132 | 17 #include "gen/tollvm.h" |
157
5c17f81fc1c1
[svn r173] moved IR state previously stored in Type into IrType and a Type->IrType map; fixes #7
ChristianK
parents:
133
diff
changeset
|
18 #include "gen/irstate.h" |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
19 |
1 | 20 static llvm::Module* M = NULL; |
21 static bool runtime_failed = false; | |
22 | |
132 | 23 static void LLVM_D_BuildRuntimeModule(); |
24 | |
52 | 25 ////////////////////////////////////////////////////////////////////////////////////////////////// |
26 | |
1 | 27 bool LLVM_D_InitRuntime() |
28 { | |
132 | 29 Logger::println("*** Initializing D runtime declarations ***"); |
1 | 30 LOG_SCOPE; |
31 | |
132 | 32 LLVM_D_BuildRuntimeModule(); |
33 return true; | |
34 | |
35 /* | |
35
3cfcb944304e
[svn r39] * Updated to DMD 1.022 with the exception of:
lindquist
parents:
4
diff
changeset
|
36 if (!global.params.runtimeImppath) { |
3cfcb944304e
[svn r39] * Updated to DMD 1.022 with the exception of:
lindquist
parents:
4
diff
changeset
|
37 error("You must set the runtime import path with -E"); |
3cfcb944304e
[svn r39] * Updated to DMD 1.022 with the exception of:
lindquist
parents:
4
diff
changeset
|
38 fatal(); |
3cfcb944304e
[svn r39] * Updated to DMD 1.022 with the exception of:
lindquist
parents:
4
diff
changeset
|
39 } |
1 | 40 std::string filename(global.params.runtimeImppath); |
41 filename.append("/llvmdcore.bc"); | |
42 llvm::MemoryBuffer* buffer = llvm::MemoryBuffer::getFile(filename.c_str(), filename.length()); | |
43 if (!buffer) { | |
44 Logger::println("Failed to load runtime library from disk"); | |
45 runtime_failed = true; | |
46 return false; | |
47 } | |
48 | |
49 std::string errstr; | |
50 bool retval = false; | |
51 M = llvm::ParseBitcodeFile(buffer, &errstr); | |
52 if (M) { | |
53 retval = true; | |
54 } | |
55 else { | |
56 Logger::println("Failed to load runtime: %s", errstr.c_str()); | |
57 runtime_failed = true; | |
58 } | |
52 | 59 |
1 | 60 delete buffer; |
61 return retval; | |
132 | 62 */ |
1 | 63 } |
64 | |
65 void LLVM_D_FreeRuntime() | |
66 { | |
67 if (M) { | |
132 | 68 Logger::println("*** Freeing D runtime declarations ***"); |
1 | 69 delete M; |
132 | 70 M = NULL; |
1 | 71 } |
72 } | |
73 | |
52 | 74 ////////////////////////////////////////////////////////////////////////////////////////////////// |
75 | |
1 | 76 llvm::Function* LLVM_D_GetRuntimeFunction(llvm::Module* target, const char* name) |
77 { | |
78 if (global.params.noruntime) { | |
79 error("No implicit runtime calls allowed with -noruntime option enabled"); | |
80 fatal(); | |
81 } | |
52 | 82 |
1 | 83 if (!M) { |
84 assert(!runtime_failed); | |
85 LLVM_D_InitRuntime(); | |
86 } | |
52 | 87 |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
86
diff
changeset
|
88 llvm::Function* fn = target->getFunction(name); |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
86
diff
changeset
|
89 if (fn) |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
86
diff
changeset
|
90 return fn; |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
86
diff
changeset
|
91 |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
86
diff
changeset
|
92 fn = M->getFunction(name); |
40 | 93 if (!fn) { |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
86
diff
changeset
|
94 printf("Runtime function '%s' was not found\n", name); |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
86
diff
changeset
|
95 assert(0); |
40 | 96 //return NULL; |
97 } | |
52 | 98 |
1 | 99 const llvm::FunctionType* fnty = fn->getFunctionType(); |
100 return llvm::cast<llvm::Function>(target->getOrInsertFunction(name, fnty)); | |
101 } | |
40 | 102 |
52 | 103 ////////////////////////////////////////////////////////////////////////////////////////////////// |
104 | |
105 llvm::GlobalVariable* LLVM_D_GetRuntimeGlobal(llvm::Module* target, const char* name) | |
106 { | |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
52
diff
changeset
|
107 llvm::GlobalVariable* gv = target->getNamedGlobal(name); |
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
52
diff
changeset
|
108 if (gv) { |
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
52
diff
changeset
|
109 return gv; |
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
52
diff
changeset
|
110 } |
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
52
diff
changeset
|
111 |
52 | 112 if (global.params.noruntime) { |
113 error("No implicit runtime calls allowed with -noruntime option enabled"); | |
114 fatal(); | |
115 } | |
116 | |
117 if (!M) { | |
118 assert(!runtime_failed); | |
119 LLVM_D_InitRuntime(); | |
120 } | |
121 | |
122 llvm::GlobalVariable* g = M->getNamedGlobal(name); | |
123 if (!g) { | |
124 error("Runtime global '%s' was not found", name); | |
125 fatal(); | |
126 //return NULL; | |
127 } | |
128 | |
129 const llvm::PointerType* t = g->getType(); | |
130 return new llvm::GlobalVariable(t->getElementType(),g->isConstant(),g->getLinkage(),NULL,g->getName(),target); | |
131 } | |
132 | 132 |
133 ////////////////////////////////////////////////////////////////////////////////////////////////// | |
134 | |
135 static const llvm::Type* rt_ptr(const llvm::Type* t) | |
136 { | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
137 return getPtrToType(t); |
132 | 138 } |
139 | |
140 static const llvm::Type* rt_array(const llvm::Type* elemty) | |
141 { | |
142 std::vector<const llvm::Type*> t; | |
143 t.push_back(DtoSize_t()); | |
144 t.push_back(rt_ptr(elemty)); | |
145 return rt_ptr(llvm::StructType::get(t)); | |
146 } | |
147 | |
197
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
148 static const llvm::Type* rt_array2(const llvm::Type* elemty) |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
149 { |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
150 std::vector<const llvm::Type*> t; |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
151 t.push_back(DtoSize_t()); |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
152 t.push_back(rt_ptr(elemty)); |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
153 return llvm::StructType::get(t); |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
154 } |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
155 |
132 | 156 static const llvm::Type* rt_dg1() |
157 { | |
158 std::vector<const llvm::Type*> types; | |
159 types.push_back(rt_ptr(llvm::Type::Int8Ty)); | |
160 types.push_back(rt_ptr(llvm::Type::Int8Ty)); | |
161 const llvm::FunctionType* fty = llvm::FunctionType::get(llvm::Type::Int32Ty, types, false); | |
162 | |
163 std::vector<const llvm::Type*> t; | |
164 t.push_back(rt_ptr(llvm::Type::Int8Ty)); | |
165 t.push_back(rt_ptr(fty)); | |
166 return rt_ptr(llvm::StructType::get(t)); | |
167 } | |
168 | |
169 static const llvm::Type* rt_dg2() | |
170 { | |
171 std::vector<const llvm::Type*> types; | |
172 types.push_back(rt_ptr(llvm::Type::Int8Ty)); | |
173 types.push_back(rt_ptr(llvm::Type::Int8Ty)); | |
174 types.push_back(rt_ptr(llvm::Type::Int8Ty)); | |
175 const llvm::FunctionType* fty = llvm::FunctionType::get(llvm::Type::Int32Ty, types, false); | |
176 | |
177 std::vector<const llvm::Type*> t; | |
178 t.push_back(rt_ptr(llvm::Type::Int8Ty)); | |
179 t.push_back(rt_ptr(fty)); | |
180 return rt_ptr(llvm::StructType::get(t)); | |
181 } | |
182 | |
183 static void LLVM_D_BuildRuntimeModule() | |
184 { | |
185 M = new llvm::Module("llvmdc internal runtime"); | |
186 | |
187 const llvm::Type* voidTy = llvm::Type::VoidTy; | |
188 const llvm::Type* boolTy = llvm::Type::Int1Ty; | |
189 const llvm::Type* byteTy = llvm::Type::Int8Ty; | |
190 const llvm::Type* shortTy = llvm::Type::Int16Ty; | |
191 const llvm::Type* intTy = llvm::Type::Int32Ty; | |
192 const llvm::Type* longTy = llvm::Type::Int64Ty; | |
193 const llvm::Type* floatTy = llvm::Type::FloatTy; | |
194 const llvm::Type* doubleTy = llvm::Type::DoubleTy; | |
195 const llvm::Type* sizeTy = DtoSize_t(); | |
196 const llvm::Type* voidPtrTy = rt_ptr(byteTy); | |
197 const llvm::Type* stringTy = rt_array(byteTy); | |
198 const llvm::Type* wstringTy = rt_array(shortTy); | |
199 const llvm::Type* dstringTy = rt_array(intTy); | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
200 const llvm::Type* objectTy = rt_ptr(ClassDeclaration::object->type->ir.type->get()); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
201 const llvm::Type* classInfoTy = rt_ptr(ClassDeclaration::classinfo->type->ir.type->get()); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
202 const llvm::Type* typeInfoTy = rt_ptr(Type::typeinfo->type->ir.type->get()); |
132 | 203 const llvm::Type* aaTy = rt_ptr(llvm::OpaqueType::get()); |
204 | |
205 ///////////////////////////////////////////////////////////////////////////////////// | |
206 ///////////////////////////////////////////////////////////////////////////////////// | |
207 ///////////////////////////////////////////////////////////////////////////////////// | |
208 | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
209 // void _d_assert( char[] file, uint line ) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
210 // void _d_array_bounds( char[] file, uint line ) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
211 // void _d_switch_error( char[] file, uint line ) |
132 | 212 { |
213 std::string fname("_d_assert"); | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
214 std::string fname2("_d_array_bounds"); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
215 std::string fname3("_d_switch_error"); |
132 | 216 std::vector<const llvm::Type*> types; |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
217 types.push_back(stringTy); |
132 | 218 types.push_back(intTy); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
219 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
220 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
221 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
222 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname3, M); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
223 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
224 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
225 // void _d_assert_msg( char[] msg, char[] file, uint line ) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
226 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
227 std::string fname("_d_assert_msg"); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
228 std::vector<const llvm::Type*> types; |
132 | 229 types.push_back(stringTy); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
230 types.push_back(stringTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
231 types.push_back(intTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
232 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); |
132 | 233 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
234 } | |
235 | |
236 ///////////////////////////////////////////////////////////////////////////////////// | |
237 ///////////////////////////////////////////////////////////////////////////////////// | |
238 ///////////////////////////////////////////////////////////////////////////////////// | |
239 | |
240 // realloc | |
241 // void* _d_realloc(void* ptr, size_t n) | |
242 { | |
243 std::string fname("_d_realloc"); | |
244 std::vector<const llvm::Type*> types; | |
245 types.push_back(voidPtrTy); | |
246 types.push_back(sizeTy); | |
247 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | |
248 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
249 } | |
250 | |
251 // free | |
252 // void _d_free(void* ptr) | |
253 { | |
254 std::string fname("_d_free"); | |
255 std::vector<const llvm::Type*> types; | |
256 types.push_back(voidPtrTy); | |
257 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
258 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
259 } | |
260 | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
261 // Object _d_newclass(ClassInfo ci) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
262 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
263 std::string fname("_d_newclass"); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
264 std::vector<const llvm::Type*> types; |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
265 types.push_back(classInfoTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
266 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
267 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
268 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
269 |
132 | 270 ///////////////////////////////////////////////////////////////////////////////////// |
271 ///////////////////////////////////////////////////////////////////////////////////// | |
272 ///////////////////////////////////////////////////////////////////////////////////// | |
273 | |
274 #define ARRAY_INIT(TY,suffix) \ | |
275 { \ | |
276 std::string fname("_d_array_init_"); \ | |
277 fname.append(suffix); \ | |
278 std::vector<const llvm::Type*> types; \ | |
279 types.push_back(rt_ptr(TY)); \ | |
280 types.push_back(sizeTy); \ | |
281 types.push_back(TY); \ | |
282 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); \ | |
283 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \ | |
284 } | |
285 | |
286 ARRAY_INIT(boolTy,"i1") | |
287 ARRAY_INIT(byteTy,"i8") | |
288 ARRAY_INIT(shortTy,"i16") | |
289 ARRAY_INIT(intTy,"i32") | |
290 ARRAY_INIT(longTy,"i64") | |
291 ARRAY_INIT(floatTy,"float") | |
292 ARRAY_INIT(doubleTy,"double") | |
293 ARRAY_INIT(voidPtrTy,"pointer") | |
294 | |
295 #undef ARRAY_INIT | |
296 | |
297 // array init mem | |
298 // void _d_array_init_mem(void* a, size_t na, void* v, size_t nv) | |
299 { | |
300 std::string fname("_d_array_init_mem"); | |
301 std::vector<const llvm::Type*> types; | |
302 types.push_back(voidPtrTy); | |
303 types.push_back(sizeTy); | |
304 types.push_back(voidPtrTy); | |
305 types.push_back(sizeTy); | |
306 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
307 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
308 } | |
309 | |
310 ///////////////////////////////////////////////////////////////////////////////////// | |
311 ///////////////////////////////////////////////////////////////////////////////////// | |
312 ///////////////////////////////////////////////////////////////////////////////////// | |
313 | |
314 #define STR_APPLY1(TY,a,b) \ | |
315 { \ | |
316 std::string fname(a); \ | |
317 std::string fname2(b); \ | |
318 std::vector<const llvm::Type*> types; \ | |
319 types.push_back(TY); \ | |
320 types.push_back(rt_dg1()); \ | |
321 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ | |
322 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \ | |
323 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); \ | |
324 } | |
325 STR_APPLY1(stringTy, "_aApplycw1", "_aApplycd1") | |
326 STR_APPLY1(wstringTy, "_aApplywc1", "_aApplywd1") | |
327 STR_APPLY1(dstringTy, "_aApplydc1", "_aApplydw1") | |
328 #undef STR_APPLY | |
329 | |
330 #define STR_APPLY2(TY,a,b) \ | |
331 { \ | |
332 std::string fname(a); \ | |
333 std::string fname2(b); \ | |
334 std::vector<const llvm::Type*> types; \ | |
335 types.push_back(TY); \ | |
336 types.push_back(rt_dg2()); \ | |
337 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ | |
338 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \ | |
339 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); \ | |
340 } | |
341 STR_APPLY2(stringTy, "_aApplycw2", "_aApplycd2") | |
342 STR_APPLY2(wstringTy, "_aApplywc2", "_aApplywd2") | |
343 STR_APPLY2(dstringTy, "_aApplydc2", "_aApplydw2") | |
344 #undef STR_APPLY2 | |
345 | |
346 #define STR_APPLY_R1(TY,a,b) \ | |
347 { \ | |
348 std::string fname(a); \ | |
349 std::string fname2(b); \ | |
350 std::vector<const llvm::Type*> types; \ | |
351 types.push_back(TY); \ | |
352 types.push_back(rt_dg1()); \ | |
353 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ | |
354 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \ | |
355 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); \ | |
356 } | |
357 STR_APPLY_R1(stringTy, "_aApplyRcw1", "_aApplyRcd1") | |
358 STR_APPLY_R1(wstringTy, "_aApplyRwc1", "_aApplyRwd1") | |
359 STR_APPLY_R1(dstringTy, "_aApplyRdc1", "_aApplyRdw1") | |
360 #undef STR_APPLY | |
361 | |
362 #define STR_APPLY_R2(TY,a,b) \ | |
363 { \ | |
364 std::string fname(a); \ | |
365 std::string fname2(b); \ | |
366 std::vector<const llvm::Type*> types; \ | |
367 types.push_back(TY); \ | |
368 types.push_back(rt_dg2()); \ | |
369 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ | |
370 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \ | |
371 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); \ | |
372 } | |
373 STR_APPLY_R2(stringTy, "_aApplyRcw2", "_aApplyRcd2") | |
374 STR_APPLY_R2(wstringTy, "_aApplyRwc2", "_aApplyRwd2") | |
375 STR_APPLY_R2(dstringTy, "_aApplyRdc2", "_aApplyRdw2") | |
376 #undef STR_APPLY2 | |
377 | |
378 ///////////////////////////////////////////////////////////////////////////////////// | |
379 ///////////////////////////////////////////////////////////////////////////////////// | |
380 ///////////////////////////////////////////////////////////////////////////////////// | |
381 | |
382 // fixes the length for dynamic array casts | |
383 // size_t _d_array_cast_len(size_t len, size_t elemsz, size_t newelemsz) | |
384 { | |
385 std::string fname("_d_array_cast_len"); | |
386 std::vector<const llvm::Type*> types; | |
387 types.push_back(sizeTy); | |
388 types.push_back(sizeTy); | |
389 types.push_back(sizeTy); | |
390 const llvm::FunctionType* fty = llvm::FunctionType::get(sizeTy, types, false); | |
391 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
392 } | |
393 | |
394 ///////////////////////////////////////////////////////////////////////////////////// | |
395 ///////////////////////////////////////////////////////////////////////////////////// | |
396 ///////////////////////////////////////////////////////////////////////////////////// | |
397 | |
398 // builds the d string[] for the D main args from the C main args | |
399 // void _d_main_args(uint n, char** args, ref char[][] res) | |
400 { | |
401 std::string fname("_d_main_args"); | |
402 std::vector<const llvm::Type*> types; | |
403 types.push_back(intTy); | |
404 types.push_back(rt_ptr(rt_ptr(byteTy))); | |
405 types.push_back(rt_array(stringTy->getContainedType(0))); | |
406 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
407 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
408 } | |
409 | |
410 ///////////////////////////////////////////////////////////////////////////////////// | |
411 ///////////////////////////////////////////////////////////////////////////////////// | |
412 ///////////////////////////////////////////////////////////////////////////////////// | |
413 | |
414 // cast to object | |
415 // Object _d_toObject(void* p) | |
416 { | |
417 std::string fname("_d_toObject"); | |
418 std::vector<const llvm::Type*> types; | |
419 types.push_back(voidPtrTy); | |
420 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | |
421 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
422 } | |
423 | |
424 // cast interface | |
425 // Object _d_interface_cast(void* p, ClassInfo c) | |
426 { | |
427 std::string fname("_d_interface_cast"); | |
428 std::vector<const llvm::Type*> types; | |
429 types.push_back(voidPtrTy); | |
430 types.push_back(classInfoTy); | |
431 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | |
432 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
433 } | |
434 | |
435 // dynamic cast | |
436 // Object _d_dynamic_cast(Object o, ClassInfo c) | |
437 { | |
438 std::string fname("_d_dynamic_cast"); | |
439 std::vector<const llvm::Type*> types; | |
440 types.push_back(objectTy); | |
441 types.push_back(classInfoTy); | |
442 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | |
443 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
444 } | |
445 | |
446 ///////////////////////////////////////////////////////////////////////////////////// | |
447 ///////////////////////////////////////////////////////////////////////////////////// | |
448 ///////////////////////////////////////////////////////////////////////////////////// | |
449 | |
450 // char[] _adReverseChar(char[] a) | |
451 // char[] _adSortChar(char[] a) | |
452 { | |
453 std::string fname("_adReverseChar"); | |
454 std::string fname2("_adSortChar"); | |
455 std::vector<const llvm::Type*> types; | |
456 types.push_back(stringTy); | |
457 types.push_back(stringTy); | |
458 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
459 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
460 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); | |
461 } | |
462 | |
463 // wchar[] _adReverseWchar(wchar[] a) | |
464 // wchar[] _adSortWchar(wchar[] a) | |
465 { | |
466 std::string fname("_adReverseWchar"); | |
467 std::string fname2("_adSortWchar"); | |
468 std::vector<const llvm::Type*> types; | |
469 types.push_back(wstringTy); | |
470 types.push_back(wstringTy); | |
471 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
472 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
473 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); | |
474 } | |
475 | |
476 // Array _adReverse(Array a, size_t szelem) | |
477 { | |
478 std::string fname("_adReverse"); | |
479 std::vector<const llvm::Type*> types; | |
480 types.push_back(rt_array(byteTy)); | |
481 types.push_back(rt_array(byteTy)); | |
482 types.push_back(sizeTy); | |
483 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
484 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
485 } | |
486 | |
487 // Array _adDupT(TypeInfo ti, Array a) | |
488 { | |
489 std::string fname("_adDupT"); | |
490 std::vector<const llvm::Type*> types; | |
491 types.push_back(rt_array(byteTy)); | |
492 types.push_back(typeInfoTy); | |
493 types.push_back(rt_array(byteTy)); | |
494 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
495 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
496 } | |
497 | |
498 // int _adEq(Array a1, Array a2, TypeInfo ti) | |
499 // int _adCmp(Array a1, Array a2, TypeInfo ti) | |
500 { | |
501 std::string fname("_adEq"); | |
502 std::string fname2("_adCmp"); | |
503 std::vector<const llvm::Type*> types; | |
504 types.push_back(rt_array(byteTy)); | |
505 types.push_back(rt_array(byteTy)); | |
506 types.push_back(typeInfoTy); | |
507 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | |
508 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
509 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); | |
510 } | |
511 | |
512 // int _adCmpChar(Array a1, Array a2) | |
513 { | |
514 std::string fname("_adCmpChar"); | |
515 std::vector<const llvm::Type*> types; | |
516 types.push_back(rt_array(byteTy)); | |
517 types.push_back(rt_array(byteTy)); | |
518 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | |
519 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
520 } | |
521 | |
522 // Array _adSort(Array a, TypeInfo ti) | |
523 { | |
524 std::string fname("_adSort"); | |
525 std::vector<const llvm::Type*> types; | |
526 types.push_back(rt_array(byteTy)); | |
527 types.push_back(rt_array(byteTy)); | |
528 types.push_back(typeInfoTy); | |
529 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
530 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
531 } | |
532 | |
533 ///////////////////////////////////////////////////////////////////////////////////// | |
534 ///////////////////////////////////////////////////////////////////////////////////// | |
535 ///////////////////////////////////////////////////////////////////////////////////// | |
536 | |
537 // size_t _aaLen(AA aa) | |
538 { | |
539 std::string fname("_aaLen"); | |
540 std::vector<const llvm::Type*> types; | |
541 types.push_back(aaTy); | |
542 const llvm::FunctionType* fty = llvm::FunctionType::get(sizeTy, types, false); | |
543 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
544 } | |
545 | |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
157
diff
changeset
|
546 // void* _aaGet(AA* aa, TypeInfo keyti, size_t valuesize, void* pkey) |
132 | 547 { |
548 std::string fname("_aaGet"); | |
549 std::vector<const llvm::Type*> types; | |
550 types.push_back(aaTy); | |
551 types.push_back(typeInfoTy); | |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
157
diff
changeset
|
552 types.push_back(sizeTy); |
132 | 553 types.push_back(voidPtrTy); |
554 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | |
555 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
556 } | |
557 | |
558 // void* _aaGetRvalue(AA aa, TypeInfo keyti, size_t valuesize, void* pkey) | |
559 { | |
560 std::string fname("_aaGetRvalue"); | |
561 std::vector<const llvm::Type*> types; | |
562 types.push_back(aaTy); | |
563 types.push_back(typeInfoTy); | |
564 types.push_back(sizeTy); | |
565 types.push_back(voidPtrTy); | |
566 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | |
567 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
568 } | |
569 | |
570 // void* _aaIn(AA aa, TypeInfo keyti, void* pkey) | |
571 { | |
572 std::string fname("_aaIn"); | |
573 std::vector<const llvm::Type*> types; | |
574 types.push_back(aaTy); | |
575 types.push_back(typeInfoTy); | |
576 types.push_back(voidPtrTy); | |
577 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | |
578 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
579 } | |
580 | |
581 // void _aaDel(AA aa, TypeInfo keyti, void* pkey) | |
582 { | |
583 std::string fname("_aaDel"); | |
584 std::vector<const llvm::Type*> types; | |
585 types.push_back(aaTy); | |
586 types.push_back(typeInfoTy); | |
587 types.push_back(voidPtrTy); | |
588 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
589 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
590 } | |
591 | |
592 // ArrayRet_t _aaValues(AA aa, size_t keysize, size_t valuesize) | |
593 { | |
594 std::string fname("_aaValues"); | |
595 std::vector<const llvm::Type*> types; | |
596 types.push_back(rt_array(byteTy)); | |
597 types.push_back(aaTy); | |
598 types.push_back(sizeTy); | |
599 types.push_back(sizeTy); | |
600 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
601 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
602 } | |
603 | |
604 // void* _aaRehash(AA* paa, TypeInfo keyti) | |
605 { | |
606 std::string fname("_aaRehash"); | |
607 std::vector<const llvm::Type*> types; | |
608 types.push_back(aaTy); | |
609 types.push_back(typeInfoTy); | |
610 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | |
611 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
612 } | |
613 | |
614 // ArrayRet_t _aaKeys(AA aa, size_t keysize) | |
615 { | |
616 std::string fname("_aaKeys"); | |
617 std::vector<const llvm::Type*> types; | |
618 types.push_back(rt_array(byteTy)); | |
619 types.push_back(aaTy); | |
620 types.push_back(sizeTy); | |
621 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
622 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
623 } | |
624 | |
625 // int _aaApply(AA aa, size_t keysize, dg_t dg) | |
626 { | |
627 std::string fname("_aaApply"); | |
628 std::vector<const llvm::Type*> types; | |
629 types.push_back(aaTy); | |
630 types.push_back(sizeTy); | |
631 types.push_back(rt_dg1()); | |
632 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | |
633 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
634 } | |
635 | |
636 // int _aaApply2(AA aa, size_t keysize, dg2_t dg) | |
637 { | |
638 std::string fname("_aaApply2"); | |
639 std::vector<const llvm::Type*> types; | |
640 types.push_back(aaTy); | |
641 types.push_back(sizeTy); | |
642 types.push_back(rt_dg1()); | |
643 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | |
644 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
645 } | |
646 | |
647 ///////////////////////////////////////////////////////////////////////////////////// | |
648 ///////////////////////////////////////////////////////////////////////////////////// | |
649 ///////////////////////////////////////////////////////////////////////////////////// | |
650 | |
651 // void _moduleCtor() | |
652 // void _moduleDtor() | |
653 { | |
654 std::string fname("_moduleCtor"); | |
655 std::string fname2("_moduleDtor"); | |
656 std::vector<const llvm::Type*> types; | |
657 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
658 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
659 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); | |
660 } | |
661 | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
662 ///////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
663 ///////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
664 ///////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
665 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
666 // Object _d_toObject(void* p) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
667 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
668 std::string fname("_d_toObject"); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
669 std::vector<const llvm::Type*> types; |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
670 types.push_back(voidPtrTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
671 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
672 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
673 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
674 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
675 // Object _d_dynamic_cast(Object o, ClassInfo c) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
676 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
677 std::string fname("_d_dynamic_cast"); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
678 std::vector<const llvm::Type*> types; |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
679 types.push_back(objectTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
680 types.push_back(classInfoTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
681 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
682 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
683 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
684 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
685 // Object _d_interface_cast(void* p, ClassInfo c) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
686 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
687 std::string fname("_d_interface_cast"); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
688 std::vector<const llvm::Type*> types; |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
689 types.push_back(voidPtrTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
690 types.push_back(classInfoTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
691 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
692 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
693 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
694 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
695 ///////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
696 ///////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
697 ///////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
698 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
699 // void _d_throw_exception(Object e) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
700 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
701 std::string fname("_d_throw_exception"); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
702 std::vector<const llvm::Type*> types; |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
703 types.push_back(objectTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
704 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
705 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
706 } |
191
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
707 |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
708 ///////////////////////////////////////////////////////////////////////////////////// |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
709 ///////////////////////////////////////////////////////////////////////////////////// |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
710 ///////////////////////////////////////////////////////////////////////////////////// |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
711 |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
712 // int _d_switch_string(char[][] table, char[] ca) |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
713 { |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
714 std::string fname("_d_switch_string"); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
715 std::vector<const llvm::Type*> types; |
197
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
716 types.push_back(rt_array(rt_array2(byteTy))); |
191
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
717 types.push_back(stringTy); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
718 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
719 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
720 } |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
721 |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
722 // int _d_switch_ustring(wchar[][] table, wchar[] ca) |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
723 { |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
724 std::string fname("_d_switch_ustring"); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
725 std::vector<const llvm::Type*> types; |
197
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
726 types.push_back(rt_array(rt_array2(shortTy))); |
191
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
727 types.push_back(wstringTy); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
728 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
729 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
730 } |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
731 |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
732 // int _d_switch_dstring(dchar[][] table, dchar[] ca) |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
733 { |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
734 std::string fname("_d_switch_dstring"); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
735 std::vector<const llvm::Type*> types; |
197
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
736 types.push_back(rt_array(rt_array2(intTy))); |
191
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
737 types.push_back(dstringTy); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
738 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
739 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
740 } |
132 | 741 } |
742 | |
743 | |
744 | |
745 | |
746 | |
747 |