Mercurial > projects > ldc
annotate gen/runtime.cpp @ 191:2900754a6989 trunk
[svn r207] Fixed: the runtime support didn't handle string switch.
author | lindquist |
---|---|
date | Mon, 12 May 2008 14:58:55 +0200 |
parents | db9890b3fb64 |
children | bfcb657756f6 |
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 | |
148 static const llvm::Type* rt_dg1() | |
149 { | |
150 std::vector<const llvm::Type*> types; | |
151 types.push_back(rt_ptr(llvm::Type::Int8Ty)); | |
152 types.push_back(rt_ptr(llvm::Type::Int8Ty)); | |
153 const llvm::FunctionType* fty = llvm::FunctionType::get(llvm::Type::Int32Ty, types, false); | |
154 | |
155 std::vector<const llvm::Type*> t; | |
156 t.push_back(rt_ptr(llvm::Type::Int8Ty)); | |
157 t.push_back(rt_ptr(fty)); | |
158 return rt_ptr(llvm::StructType::get(t)); | |
159 } | |
160 | |
161 static const llvm::Type* rt_dg2() | |
162 { | |
163 std::vector<const llvm::Type*> types; | |
164 types.push_back(rt_ptr(llvm::Type::Int8Ty)); | |
165 types.push_back(rt_ptr(llvm::Type::Int8Ty)); | |
166 types.push_back(rt_ptr(llvm::Type::Int8Ty)); | |
167 const llvm::FunctionType* fty = llvm::FunctionType::get(llvm::Type::Int32Ty, types, false); | |
168 | |
169 std::vector<const llvm::Type*> t; | |
170 t.push_back(rt_ptr(llvm::Type::Int8Ty)); | |
171 t.push_back(rt_ptr(fty)); | |
172 return rt_ptr(llvm::StructType::get(t)); | |
173 } | |
174 | |
175 static void LLVM_D_BuildRuntimeModule() | |
176 { | |
177 M = new llvm::Module("llvmdc internal runtime"); | |
178 | |
179 const llvm::Type* voidTy = llvm::Type::VoidTy; | |
180 const llvm::Type* boolTy = llvm::Type::Int1Ty; | |
181 const llvm::Type* byteTy = llvm::Type::Int8Ty; | |
182 const llvm::Type* shortTy = llvm::Type::Int16Ty; | |
183 const llvm::Type* intTy = llvm::Type::Int32Ty; | |
184 const llvm::Type* longTy = llvm::Type::Int64Ty; | |
185 const llvm::Type* floatTy = llvm::Type::FloatTy; | |
186 const llvm::Type* doubleTy = llvm::Type::DoubleTy; | |
187 const llvm::Type* sizeTy = DtoSize_t(); | |
188 const llvm::Type* voidPtrTy = rt_ptr(byteTy); | |
189 const llvm::Type* stringTy = rt_array(byteTy); | |
190 const llvm::Type* wstringTy = rt_array(shortTy); | |
191 const llvm::Type* dstringTy = rt_array(intTy); | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
192 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
|
193 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
|
194 const llvm::Type* typeInfoTy = rt_ptr(Type::typeinfo->type->ir.type->get()); |
132 | 195 const llvm::Type* aaTy = rt_ptr(llvm::OpaqueType::get()); |
196 | |
197 ///////////////////////////////////////////////////////////////////////////////////// | |
198 ///////////////////////////////////////////////////////////////////////////////////// | |
199 ///////////////////////////////////////////////////////////////////////////////////// | |
200 | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
201 // 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
|
202 // 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
|
203 // void _d_switch_error( char[] file, uint line ) |
132 | 204 { |
205 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
|
206 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
|
207 std::string fname3("_d_switch_error"); |
132 | 208 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
|
209 types.push_back(stringTy); |
132 | 210 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
|
211 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
|
212 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
|
213 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
|
214 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
|
215 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
216 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
217 // 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
|
218 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
219 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
|
220 std::vector<const llvm::Type*> types; |
132 | 221 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
|
222 types.push_back(stringTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
223 types.push_back(intTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
224 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); |
132 | 225 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
226 } | |
227 | |
228 ///////////////////////////////////////////////////////////////////////////////////// | |
229 ///////////////////////////////////////////////////////////////////////////////////// | |
230 ///////////////////////////////////////////////////////////////////////////////////// | |
231 | |
232 // realloc | |
233 // void* _d_realloc(void* ptr, size_t n) | |
234 { | |
235 std::string fname("_d_realloc"); | |
236 std::vector<const llvm::Type*> types; | |
237 types.push_back(voidPtrTy); | |
238 types.push_back(sizeTy); | |
239 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | |
240 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
241 } | |
242 | |
243 // free | |
244 // void _d_free(void* ptr) | |
245 { | |
246 std::string fname("_d_free"); | |
247 std::vector<const llvm::Type*> types; | |
248 types.push_back(voidPtrTy); | |
249 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
250 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
251 } | |
252 | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
253 // 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
|
254 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
255 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
|
256 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
|
257 types.push_back(classInfoTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
258 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
|
259 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
|
260 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
261 |
132 | 262 ///////////////////////////////////////////////////////////////////////////////////// |
263 ///////////////////////////////////////////////////////////////////////////////////// | |
264 ///////////////////////////////////////////////////////////////////////////////////// | |
265 | |
266 #define ARRAY_INIT(TY,suffix) \ | |
267 { \ | |
268 std::string fname("_d_array_init_"); \ | |
269 fname.append(suffix); \ | |
270 std::vector<const llvm::Type*> types; \ | |
271 types.push_back(rt_ptr(TY)); \ | |
272 types.push_back(sizeTy); \ | |
273 types.push_back(TY); \ | |
274 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); \ | |
275 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \ | |
276 } | |
277 | |
278 ARRAY_INIT(boolTy,"i1") | |
279 ARRAY_INIT(byteTy,"i8") | |
280 ARRAY_INIT(shortTy,"i16") | |
281 ARRAY_INIT(intTy,"i32") | |
282 ARRAY_INIT(longTy,"i64") | |
283 ARRAY_INIT(floatTy,"float") | |
284 ARRAY_INIT(doubleTy,"double") | |
285 ARRAY_INIT(voidPtrTy,"pointer") | |
286 | |
287 #undef ARRAY_INIT | |
288 | |
289 // array init mem | |
290 // void _d_array_init_mem(void* a, size_t na, void* v, size_t nv) | |
291 { | |
292 std::string fname("_d_array_init_mem"); | |
293 std::vector<const llvm::Type*> types; | |
294 types.push_back(voidPtrTy); | |
295 types.push_back(sizeTy); | |
296 types.push_back(voidPtrTy); | |
297 types.push_back(sizeTy); | |
298 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
299 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
300 } | |
301 | |
302 ///////////////////////////////////////////////////////////////////////////////////// | |
303 ///////////////////////////////////////////////////////////////////////////////////// | |
304 ///////////////////////////////////////////////////////////////////////////////////// | |
305 | |
306 #define STR_APPLY1(TY,a,b) \ | |
307 { \ | |
308 std::string fname(a); \ | |
309 std::string fname2(b); \ | |
310 std::vector<const llvm::Type*> types; \ | |
311 types.push_back(TY); \ | |
312 types.push_back(rt_dg1()); \ | |
313 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ | |
314 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \ | |
315 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); \ | |
316 } | |
317 STR_APPLY1(stringTy, "_aApplycw1", "_aApplycd1") | |
318 STR_APPLY1(wstringTy, "_aApplywc1", "_aApplywd1") | |
319 STR_APPLY1(dstringTy, "_aApplydc1", "_aApplydw1") | |
320 #undef STR_APPLY | |
321 | |
322 #define STR_APPLY2(TY,a,b) \ | |
323 { \ | |
324 std::string fname(a); \ | |
325 std::string fname2(b); \ | |
326 std::vector<const llvm::Type*> types; \ | |
327 types.push_back(TY); \ | |
328 types.push_back(rt_dg2()); \ | |
329 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ | |
330 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \ | |
331 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); \ | |
332 } | |
333 STR_APPLY2(stringTy, "_aApplycw2", "_aApplycd2") | |
334 STR_APPLY2(wstringTy, "_aApplywc2", "_aApplywd2") | |
335 STR_APPLY2(dstringTy, "_aApplydc2", "_aApplydw2") | |
336 #undef STR_APPLY2 | |
337 | |
338 #define STR_APPLY_R1(TY,a,b) \ | |
339 { \ | |
340 std::string fname(a); \ | |
341 std::string fname2(b); \ | |
342 std::vector<const llvm::Type*> types; \ | |
343 types.push_back(TY); \ | |
344 types.push_back(rt_dg1()); \ | |
345 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ | |
346 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \ | |
347 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); \ | |
348 } | |
349 STR_APPLY_R1(stringTy, "_aApplyRcw1", "_aApplyRcd1") | |
350 STR_APPLY_R1(wstringTy, "_aApplyRwc1", "_aApplyRwd1") | |
351 STR_APPLY_R1(dstringTy, "_aApplyRdc1", "_aApplyRdw1") | |
352 #undef STR_APPLY | |
353 | |
354 #define STR_APPLY_R2(TY,a,b) \ | |
355 { \ | |
356 std::string fname(a); \ | |
357 std::string fname2(b); \ | |
358 std::vector<const llvm::Type*> types; \ | |
359 types.push_back(TY); \ | |
360 types.push_back(rt_dg2()); \ | |
361 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ | |
362 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \ | |
363 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); \ | |
364 } | |
365 STR_APPLY_R2(stringTy, "_aApplyRcw2", "_aApplyRcd2") | |
366 STR_APPLY_R2(wstringTy, "_aApplyRwc2", "_aApplyRwd2") | |
367 STR_APPLY_R2(dstringTy, "_aApplyRdc2", "_aApplyRdw2") | |
368 #undef STR_APPLY2 | |
369 | |
370 ///////////////////////////////////////////////////////////////////////////////////// | |
371 ///////////////////////////////////////////////////////////////////////////////////// | |
372 ///////////////////////////////////////////////////////////////////////////////////// | |
373 | |
374 // fixes the length for dynamic array casts | |
375 // size_t _d_array_cast_len(size_t len, size_t elemsz, size_t newelemsz) | |
376 { | |
377 std::string fname("_d_array_cast_len"); | |
378 std::vector<const llvm::Type*> types; | |
379 types.push_back(sizeTy); | |
380 types.push_back(sizeTy); | |
381 types.push_back(sizeTy); | |
382 const llvm::FunctionType* fty = llvm::FunctionType::get(sizeTy, types, false); | |
383 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
384 } | |
385 | |
386 ///////////////////////////////////////////////////////////////////////////////////// | |
387 ///////////////////////////////////////////////////////////////////////////////////// | |
388 ///////////////////////////////////////////////////////////////////////////////////// | |
389 | |
390 // builds the d string[] for the D main args from the C main args | |
391 // void _d_main_args(uint n, char** args, ref char[][] res) | |
392 { | |
393 std::string fname("_d_main_args"); | |
394 std::vector<const llvm::Type*> types; | |
395 types.push_back(intTy); | |
396 types.push_back(rt_ptr(rt_ptr(byteTy))); | |
397 types.push_back(rt_array(stringTy->getContainedType(0))); | |
398 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
399 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
400 } | |
401 | |
402 ///////////////////////////////////////////////////////////////////////////////////// | |
403 ///////////////////////////////////////////////////////////////////////////////////// | |
404 ///////////////////////////////////////////////////////////////////////////////////// | |
405 | |
406 // cast to object | |
407 // Object _d_toObject(void* p) | |
408 { | |
409 std::string fname("_d_toObject"); | |
410 std::vector<const llvm::Type*> types; | |
411 types.push_back(voidPtrTy); | |
412 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | |
413 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
414 } | |
415 | |
416 // cast interface | |
417 // Object _d_interface_cast(void* p, ClassInfo c) | |
418 { | |
419 std::string fname("_d_interface_cast"); | |
420 std::vector<const llvm::Type*> types; | |
421 types.push_back(voidPtrTy); | |
422 types.push_back(classInfoTy); | |
423 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | |
424 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
425 } | |
426 | |
427 // dynamic cast | |
428 // Object _d_dynamic_cast(Object o, ClassInfo c) | |
429 { | |
430 std::string fname("_d_dynamic_cast"); | |
431 std::vector<const llvm::Type*> types; | |
432 types.push_back(objectTy); | |
433 types.push_back(classInfoTy); | |
434 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | |
435 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
436 } | |
437 | |
438 ///////////////////////////////////////////////////////////////////////////////////// | |
439 ///////////////////////////////////////////////////////////////////////////////////// | |
440 ///////////////////////////////////////////////////////////////////////////////////// | |
441 | |
442 // char[] _adReverseChar(char[] a) | |
443 // char[] _adSortChar(char[] a) | |
444 { | |
445 std::string fname("_adReverseChar"); | |
446 std::string fname2("_adSortChar"); | |
447 std::vector<const llvm::Type*> types; | |
448 types.push_back(stringTy); | |
449 types.push_back(stringTy); | |
450 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
451 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
452 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); | |
453 } | |
454 | |
455 // wchar[] _adReverseWchar(wchar[] a) | |
456 // wchar[] _adSortWchar(wchar[] a) | |
457 { | |
458 std::string fname("_adReverseWchar"); | |
459 std::string fname2("_adSortWchar"); | |
460 std::vector<const llvm::Type*> types; | |
461 types.push_back(wstringTy); | |
462 types.push_back(wstringTy); | |
463 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
464 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
465 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); | |
466 } | |
467 | |
468 // Array _adReverse(Array a, size_t szelem) | |
469 { | |
470 std::string fname("_adReverse"); | |
471 std::vector<const llvm::Type*> types; | |
472 types.push_back(rt_array(byteTy)); | |
473 types.push_back(rt_array(byteTy)); | |
474 types.push_back(sizeTy); | |
475 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
476 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
477 } | |
478 | |
479 // Array _adDupT(TypeInfo ti, Array a) | |
480 { | |
481 std::string fname("_adDupT"); | |
482 std::vector<const llvm::Type*> types; | |
483 types.push_back(rt_array(byteTy)); | |
484 types.push_back(typeInfoTy); | |
485 types.push_back(rt_array(byteTy)); | |
486 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
487 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
488 } | |
489 | |
490 // int _adEq(Array a1, Array a2, TypeInfo ti) | |
491 // int _adCmp(Array a1, Array a2, TypeInfo ti) | |
492 { | |
493 std::string fname("_adEq"); | |
494 std::string fname2("_adCmp"); | |
495 std::vector<const llvm::Type*> types; | |
496 types.push_back(rt_array(byteTy)); | |
497 types.push_back(rt_array(byteTy)); | |
498 types.push_back(typeInfoTy); | |
499 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | |
500 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
501 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); | |
502 } | |
503 | |
504 // int _adCmpChar(Array a1, Array a2) | |
505 { | |
506 std::string fname("_adCmpChar"); | |
507 std::vector<const llvm::Type*> types; | |
508 types.push_back(rt_array(byteTy)); | |
509 types.push_back(rt_array(byteTy)); | |
510 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | |
511 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
512 } | |
513 | |
514 // Array _adSort(Array a, TypeInfo ti) | |
515 { | |
516 std::string fname("_adSort"); | |
517 std::vector<const llvm::Type*> types; | |
518 types.push_back(rt_array(byteTy)); | |
519 types.push_back(rt_array(byteTy)); | |
520 types.push_back(typeInfoTy); | |
521 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
522 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
523 } | |
524 | |
525 ///////////////////////////////////////////////////////////////////////////////////// | |
526 ///////////////////////////////////////////////////////////////////////////////////// | |
527 ///////////////////////////////////////////////////////////////////////////////////// | |
528 | |
529 // size_t _aaLen(AA aa) | |
530 { | |
531 std::string fname("_aaLen"); | |
532 std::vector<const llvm::Type*> types; | |
533 types.push_back(aaTy); | |
534 const llvm::FunctionType* fty = llvm::FunctionType::get(sizeTy, types, false); | |
535 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
536 } | |
537 | |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
157
diff
changeset
|
538 // void* _aaGet(AA* aa, TypeInfo keyti, size_t valuesize, void* pkey) |
132 | 539 { |
540 std::string fname("_aaGet"); | |
541 std::vector<const llvm::Type*> types; | |
542 types.push_back(aaTy); | |
543 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
|
544 types.push_back(sizeTy); |
132 | 545 types.push_back(voidPtrTy); |
546 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | |
547 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
548 } | |
549 | |
550 // void* _aaGetRvalue(AA aa, TypeInfo keyti, size_t valuesize, void* pkey) | |
551 { | |
552 std::string fname("_aaGetRvalue"); | |
553 std::vector<const llvm::Type*> types; | |
554 types.push_back(aaTy); | |
555 types.push_back(typeInfoTy); | |
556 types.push_back(sizeTy); | |
557 types.push_back(voidPtrTy); | |
558 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | |
559 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
560 } | |
561 | |
562 // void* _aaIn(AA aa, TypeInfo keyti, void* pkey) | |
563 { | |
564 std::string fname("_aaIn"); | |
565 std::vector<const llvm::Type*> types; | |
566 types.push_back(aaTy); | |
567 types.push_back(typeInfoTy); | |
568 types.push_back(voidPtrTy); | |
569 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | |
570 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
571 } | |
572 | |
573 // void _aaDel(AA aa, TypeInfo keyti, void* pkey) | |
574 { | |
575 std::string fname("_aaDel"); | |
576 std::vector<const llvm::Type*> types; | |
577 types.push_back(aaTy); | |
578 types.push_back(typeInfoTy); | |
579 types.push_back(voidPtrTy); | |
580 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
581 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
582 } | |
583 | |
584 // ArrayRet_t _aaValues(AA aa, size_t keysize, size_t valuesize) | |
585 { | |
586 std::string fname("_aaValues"); | |
587 std::vector<const llvm::Type*> types; | |
588 types.push_back(rt_array(byteTy)); | |
589 types.push_back(aaTy); | |
590 types.push_back(sizeTy); | |
591 types.push_back(sizeTy); | |
592 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
593 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
594 } | |
595 | |
596 // void* _aaRehash(AA* paa, TypeInfo keyti) | |
597 { | |
598 std::string fname("_aaRehash"); | |
599 std::vector<const llvm::Type*> types; | |
600 types.push_back(aaTy); | |
601 types.push_back(typeInfoTy); | |
602 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | |
603 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
604 } | |
605 | |
606 // ArrayRet_t _aaKeys(AA aa, size_t keysize) | |
607 { | |
608 std::string fname("_aaKeys"); | |
609 std::vector<const llvm::Type*> types; | |
610 types.push_back(rt_array(byteTy)); | |
611 types.push_back(aaTy); | |
612 types.push_back(sizeTy); | |
613 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
614 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
615 } | |
616 | |
617 // int _aaApply(AA aa, size_t keysize, dg_t dg) | |
618 { | |
619 std::string fname("_aaApply"); | |
620 std::vector<const llvm::Type*> types; | |
621 types.push_back(aaTy); | |
622 types.push_back(sizeTy); | |
623 types.push_back(rt_dg1()); | |
624 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | |
625 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
626 } | |
627 | |
628 // int _aaApply2(AA aa, size_t keysize, dg2_t dg) | |
629 { | |
630 std::string fname("_aaApply2"); | |
631 std::vector<const llvm::Type*> types; | |
632 types.push_back(aaTy); | |
633 types.push_back(sizeTy); | |
634 types.push_back(rt_dg1()); | |
635 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | |
636 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
637 } | |
638 | |
639 ///////////////////////////////////////////////////////////////////////////////////// | |
640 ///////////////////////////////////////////////////////////////////////////////////// | |
641 ///////////////////////////////////////////////////////////////////////////////////// | |
642 | |
643 // void _moduleCtor() | |
644 // void _moduleDtor() | |
645 { | |
646 std::string fname("_moduleCtor"); | |
647 std::string fname2("_moduleDtor"); | |
648 std::vector<const llvm::Type*> types; | |
649 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
650 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
651 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); | |
652 } | |
653 | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
654 ///////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
655 ///////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
656 ///////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
657 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
658 // 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
|
659 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
660 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
|
661 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
|
662 types.push_back(voidPtrTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
663 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
|
664 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
|
665 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
666 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
667 // 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
|
668 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
669 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
|
670 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
|
671 types.push_back(objectTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
672 types.push_back(classInfoTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
673 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
|
674 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
|
675 } |
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 // 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
|
678 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
679 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
|
680 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
|
681 types.push_back(voidPtrTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
682 types.push_back(classInfoTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
683 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
|
684 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
|
685 } |
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 ///////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
688 ///////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
689 ///////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
690 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
691 // 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
|
692 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
693 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
|
694 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
|
695 types.push_back(objectTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
696 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
|
697 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
|
698 } |
191
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
699 |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
700 ///////////////////////////////////////////////////////////////////////////////////// |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
701 ///////////////////////////////////////////////////////////////////////////////////// |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
702 ///////////////////////////////////////////////////////////////////////////////////// |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
703 |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
704 // 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
|
705 { |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
706 std::string fname("_d_switch_string"); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
707 std::vector<const llvm::Type*> types; |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
708 types.push_back(rt_array(stringTy)); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
709 types.push_back(stringTy); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
710 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
|
711 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
|
712 } |
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 // 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
|
715 { |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
716 std::string fname("_d_switch_ustring"); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
717 std::vector<const llvm::Type*> types; |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
718 types.push_back(rt_array(wstringTy)); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
719 types.push_back(wstringTy); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
720 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
|
721 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
|
722 } |
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 // 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
|
725 { |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
726 std::string fname("_d_switch_dstring"); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
727 std::vector<const llvm::Type*> types; |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
728 types.push_back(rt_array(dstringTy)); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
729 types.push_back(dstringTy); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
730 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
|
731 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
|
732 } |
132 | 733 } |
734 | |
735 | |
736 | |
737 | |
738 | |
739 |