comparison gen/runtime.cpp @ 205:9d44ec83acd1 trunk

[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 . Fixed: Implemented volatile statements. Uses the LLVM memory barrier intrinsic, closes #21 .
author lindquist
date Tue, 13 May 2008 17:58:11 +0200
parents e881c9b1c738
children c4c9b4ac021b
comparison
equal deleted inserted replaced
204:11fe364b9a3e 205:9d44ec83acd1
215 std::string fname3("_d_switch_error"); 215 std::string fname3("_d_switch_error");
216 std::vector<const llvm::Type*> types; 216 std::vector<const llvm::Type*> types;
217 types.push_back(stringTy); 217 types.push_back(stringTy);
218 types.push_back(intTy); 218 types.push_back(intTy);
219 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); 219 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
220 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 220 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
221 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); 221 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M);
222 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname3, M); 222 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname3, M);
223 } 223 }
224 224
225 // void _d_assert_msg( char[] msg, char[] file, uint line ) 225 // void _d_assert_msg( char[] msg, char[] file, uint line )
226 { 226 {
227 std::string fname("_d_assert_msg"); 227 std::string fname("_d_assert_msg");
228 std::vector<const llvm::Type*> types; 228 std::vector<const llvm::Type*> types;
229 types.push_back(stringTy); 229 types.push_back(stringTy);
230 types.push_back(stringTy); 230 types.push_back(stringTy);
231 types.push_back(intTy); 231 types.push_back(intTy);
232 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); 232 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false);
233 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 233 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
234 } 234 }
235 235
236 ///////////////////////////////////////////////////////////////////////////////////// 236 /////////////////////////////////////////////////////////////////////////////////////
237 ///////////////////////////////////////////////////////////////////////////////////// 237 /////////////////////////////////////////////////////////////////////////////////////
238 ///////////////////////////////////////////////////////////////////////////////////// 238 /////////////////////////////////////////////////////////////////////////////////////
241 { 241 {
242 std::string fname("_d_allocmemoryT"); 242 std::string fname("_d_allocmemoryT");
243 std::vector<const llvm::Type*> types; 243 std::vector<const llvm::Type*> types;
244 types.push_back(typeInfoTy); 244 types.push_back(typeInfoTy);
245 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); 245 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false);
246 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 246 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
247 } 247 }
248 248
249 // void* _d_newarrayT(TypeInfo ti, size_t length) 249 // void* _d_newarrayT(TypeInfo ti, size_t length)
250 // void* _d_newarrayiT(TypeInfo ti, size_t length) 250 // void* _d_newarrayiT(TypeInfo ti, size_t length)
251 { 251 {
253 std::string fname2("_d_newarrayiT"); 253 std::string fname2("_d_newarrayiT");
254 std::vector<const llvm::Type*> types; 254 std::vector<const llvm::Type*> types;
255 types.push_back(typeInfoTy); 255 types.push_back(typeInfoTy);
256 types.push_back(sizeTy); 256 types.push_back(sizeTy);
257 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); 257 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false);
258 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 258 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
259 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); 259 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M);
260 } 260 }
261 261
262 // void* _d_arraysetlengthT(TypeInfo ti, size_t newlength, size_t plength, void* pdata) 262 // void* _d_arraysetlengthT(TypeInfo ti, size_t newlength, size_t plength, void* pdata)
263 // void* _d_arraysetlengthiT(TypeInfo ti, size_t newlength, size_t plength, void* pdata) 263 // void* _d_arraysetlengthiT(TypeInfo ti, size_t newlength, size_t plength, void* pdata)
264 { 264 {
268 types.push_back(typeInfoTy); 268 types.push_back(typeInfoTy);
269 types.push_back(sizeTy); 269 types.push_back(sizeTy);
270 types.push_back(sizeTy); 270 types.push_back(sizeTy);
271 types.push_back(voidPtrTy); 271 types.push_back(voidPtrTy);
272 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); 272 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false);
273 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 273 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
274 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); 274 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M);
275 } 275 }
276 276
277 // Object _d_newclass(ClassInfo ci) 277 // Object _d_newclass(ClassInfo ci)
278 { 278 {
279 std::string fname("_d_newclass"); 279 std::string fname("_d_newclass");
280 std::vector<const llvm::Type*> types; 280 std::vector<const llvm::Type*> types;
281 types.push_back(classInfoTy); 281 types.push_back(classInfoTy);
282 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); 282 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false);
283 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 283 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
284 } 284 }
285 285
286 ///////////////////////////////////////////////////////////////////////////////////// 286 /////////////////////////////////////////////////////////////////////////////////////
287 ///////////////////////////////////////////////////////////////////////////////////// 287 /////////////////////////////////////////////////////////////////////////////////////
288 ///////////////////////////////////////////////////////////////////////////////////// 288 /////////////////////////////////////////////////////////////////////////////////////
294 std::vector<const llvm::Type*> types; \ 294 std::vector<const llvm::Type*> types; \
295 types.push_back(rt_ptr(TY)); \ 295 types.push_back(rt_ptr(TY)); \
296 types.push_back(sizeTy); \ 296 types.push_back(sizeTy); \
297 types.push_back(TY); \ 297 types.push_back(TY); \
298 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); \ 298 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); \
299 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \ 299 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \
300 } 300 }
301 301
302 ARRAY_INIT(boolTy,"i1") 302 ARRAY_INIT(boolTy,"i1")
303 ARRAY_INIT(byteTy,"i8") 303 ARRAY_INIT(byteTy,"i8")
304 ARRAY_INIT(shortTy,"i16") 304 ARRAY_INIT(shortTy,"i16")
318 types.push_back(voidPtrTy); 318 types.push_back(voidPtrTy);
319 types.push_back(sizeTy); 319 types.push_back(sizeTy);
320 types.push_back(voidPtrTy); 320 types.push_back(voidPtrTy);
321 types.push_back(sizeTy); 321 types.push_back(sizeTy);
322 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); 322 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
323 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 323 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
324 } 324 }
325 325
326 ///////////////////////////////////////////////////////////////////////////////////// 326 /////////////////////////////////////////////////////////////////////////////////////
327 ///////////////////////////////////////////////////////////////////////////////////// 327 /////////////////////////////////////////////////////////////////////////////////////
328 ///////////////////////////////////////////////////////////////////////////////////// 328 /////////////////////////////////////////////////////////////////////////////////////
333 std::string fname2(b); \ 333 std::string fname2(b); \
334 std::vector<const llvm::Type*> types; \ 334 std::vector<const llvm::Type*> types; \
335 types.push_back(TY); \ 335 types.push_back(TY); \
336 types.push_back(rt_dg1()); \ 336 types.push_back(rt_dg1()); \
337 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ 337 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \
338 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \ 338 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \
339 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); \ 339 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); \
340 } 340 }
341 STR_APPLY1(stringTy, "_aApplycw1", "_aApplycd1") 341 STR_APPLY1(stringTy, "_aApplycw1", "_aApplycd1")
342 STR_APPLY1(wstringTy, "_aApplywc1", "_aApplywd1") 342 STR_APPLY1(wstringTy, "_aApplywc1", "_aApplywd1")
343 STR_APPLY1(dstringTy, "_aApplydc1", "_aApplydw1") 343 STR_APPLY1(dstringTy, "_aApplydc1", "_aApplydw1")
344 #undef STR_APPLY 344 #undef STR_APPLY
349 std::string fname2(b); \ 349 std::string fname2(b); \
350 std::vector<const llvm::Type*> types; \ 350 std::vector<const llvm::Type*> types; \
351 types.push_back(TY); \ 351 types.push_back(TY); \
352 types.push_back(rt_dg2()); \ 352 types.push_back(rt_dg2()); \
353 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ 353 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \
354 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \ 354 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \
355 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); \ 355 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); \
356 } 356 }
357 STR_APPLY2(stringTy, "_aApplycw2", "_aApplycd2") 357 STR_APPLY2(stringTy, "_aApplycw2", "_aApplycd2")
358 STR_APPLY2(wstringTy, "_aApplywc2", "_aApplywd2") 358 STR_APPLY2(wstringTy, "_aApplywc2", "_aApplywd2")
359 STR_APPLY2(dstringTy, "_aApplydc2", "_aApplydw2") 359 STR_APPLY2(dstringTy, "_aApplydc2", "_aApplydw2")
360 #undef STR_APPLY2 360 #undef STR_APPLY2
365 std::string fname2(b); \ 365 std::string fname2(b); \
366 std::vector<const llvm::Type*> types; \ 366 std::vector<const llvm::Type*> types; \
367 types.push_back(TY); \ 367 types.push_back(TY); \
368 types.push_back(rt_dg1()); \ 368 types.push_back(rt_dg1()); \
369 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ 369 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \
370 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \ 370 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \
371 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); \ 371 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); \
372 } 372 }
373 STR_APPLY_R1(stringTy, "_aApplyRcw1", "_aApplyRcd1") 373 STR_APPLY_R1(stringTy, "_aApplyRcw1", "_aApplyRcd1")
374 STR_APPLY_R1(wstringTy, "_aApplyRwc1", "_aApplyRwd1") 374 STR_APPLY_R1(wstringTy, "_aApplyRwc1", "_aApplyRwd1")
375 STR_APPLY_R1(dstringTy, "_aApplyRdc1", "_aApplyRdw1") 375 STR_APPLY_R1(dstringTy, "_aApplyRdc1", "_aApplyRdw1")
376 #undef STR_APPLY 376 #undef STR_APPLY
381 std::string fname2(b); \ 381 std::string fname2(b); \
382 std::vector<const llvm::Type*> types; \ 382 std::vector<const llvm::Type*> types; \
383 types.push_back(TY); \ 383 types.push_back(TY); \
384 types.push_back(rt_dg2()); \ 384 types.push_back(rt_dg2()); \
385 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ 385 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \
386 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \ 386 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \
387 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); \ 387 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); \
388 } 388 }
389 STR_APPLY_R2(stringTy, "_aApplyRcw2", "_aApplyRcd2") 389 STR_APPLY_R2(stringTy, "_aApplyRcw2", "_aApplyRcd2")
390 STR_APPLY_R2(wstringTy, "_aApplyRwc2", "_aApplyRwd2") 390 STR_APPLY_R2(wstringTy, "_aApplyRwc2", "_aApplyRwd2")
391 STR_APPLY_R2(dstringTy, "_aApplyRdc2", "_aApplyRdw2") 391 STR_APPLY_R2(dstringTy, "_aApplyRdc2", "_aApplyRdw2")
392 #undef STR_APPLY2 392 #undef STR_APPLY2
402 std::vector<const llvm::Type*> types; 402 std::vector<const llvm::Type*> types;
403 types.push_back(sizeTy); 403 types.push_back(sizeTy);
404 types.push_back(sizeTy); 404 types.push_back(sizeTy);
405 types.push_back(sizeTy); 405 types.push_back(sizeTy);
406 const llvm::FunctionType* fty = llvm::FunctionType::get(sizeTy, types, false); 406 const llvm::FunctionType* fty = llvm::FunctionType::get(sizeTy, types, false);
407 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 407 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
408 } 408 }
409 409
410 ///////////////////////////////////////////////////////////////////////////////////// 410 /////////////////////////////////////////////////////////////////////////////////////
411 ///////////////////////////////////////////////////////////////////////////////////// 411 /////////////////////////////////////////////////////////////////////////////////////
412 ///////////////////////////////////////////////////////////////////////////////////// 412 /////////////////////////////////////////////////////////////////////////////////////
418 std::vector<const llvm::Type*> types; 418 std::vector<const llvm::Type*> types;
419 types.push_back(intTy); 419 types.push_back(intTy);
420 types.push_back(rt_ptr(rt_ptr(byteTy))); 420 types.push_back(rt_ptr(rt_ptr(byteTy)));
421 types.push_back(rt_array(stringTy->getContainedType(0))); 421 types.push_back(rt_array(stringTy->getContainedType(0)));
422 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); 422 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
423 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 423 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
424 } 424 }
425 425
426 ///////////////////////////////////////////////////////////////////////////////////// 426 /////////////////////////////////////////////////////////////////////////////////////
427 ///////////////////////////////////////////////////////////////////////////////////// 427 /////////////////////////////////////////////////////////////////////////////////////
428 ///////////////////////////////////////////////////////////////////////////////////// 428 /////////////////////////////////////////////////////////////////////////////////////
432 { 432 {
433 std::string fname("_d_toObject"); 433 std::string fname("_d_toObject");
434 std::vector<const llvm::Type*> types; 434 std::vector<const llvm::Type*> types;
435 types.push_back(voidPtrTy); 435 types.push_back(voidPtrTy);
436 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); 436 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false);
437 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 437 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
438 } 438 }
439 439
440 // cast interface 440 // cast interface
441 // Object _d_interface_cast(void* p, ClassInfo c) 441 // Object _d_interface_cast(void* p, ClassInfo c)
442 { 442 {
443 std::string fname("_d_interface_cast"); 443 std::string fname("_d_interface_cast");
444 std::vector<const llvm::Type*> types; 444 std::vector<const llvm::Type*> types;
445 types.push_back(voidPtrTy); 445 types.push_back(voidPtrTy);
446 types.push_back(classInfoTy); 446 types.push_back(classInfoTy);
447 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); 447 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false);
448 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 448 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
449 } 449 }
450 450
451 // dynamic cast 451 // dynamic cast
452 // Object _d_dynamic_cast(Object o, ClassInfo c) 452 // Object _d_dynamic_cast(Object o, ClassInfo c)
453 { 453 {
454 std::string fname("_d_dynamic_cast"); 454 std::string fname("_d_dynamic_cast");
455 std::vector<const llvm::Type*> types; 455 std::vector<const llvm::Type*> types;
456 types.push_back(objectTy); 456 types.push_back(objectTy);
457 types.push_back(classInfoTy); 457 types.push_back(classInfoTy);
458 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); 458 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false);
459 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 459 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
460 } 460 }
461 461
462 ///////////////////////////////////////////////////////////////////////////////////// 462 /////////////////////////////////////////////////////////////////////////////////////
463 ///////////////////////////////////////////////////////////////////////////////////// 463 /////////////////////////////////////////////////////////////////////////////////////
464 ///////////////////////////////////////////////////////////////////////////////////// 464 /////////////////////////////////////////////////////////////////////////////////////
470 std::string fname2("_adSortChar"); 470 std::string fname2("_adSortChar");
471 std::vector<const llvm::Type*> types; 471 std::vector<const llvm::Type*> types;
472 types.push_back(stringTy); 472 types.push_back(stringTy);
473 types.push_back(stringTy); 473 types.push_back(stringTy);
474 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); 474 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
475 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 475 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
476 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); 476 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M);
477 } 477 }
478 478
479 // wchar[] _adReverseWchar(wchar[] a) 479 // wchar[] _adReverseWchar(wchar[] a)
480 // wchar[] _adSortWchar(wchar[] a) 480 // wchar[] _adSortWchar(wchar[] a)
481 { 481 {
483 std::string fname2("_adSortWchar"); 483 std::string fname2("_adSortWchar");
484 std::vector<const llvm::Type*> types; 484 std::vector<const llvm::Type*> types;
485 types.push_back(wstringTy); 485 types.push_back(wstringTy);
486 types.push_back(wstringTy); 486 types.push_back(wstringTy);
487 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); 487 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
488 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 488 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
489 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); 489 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M);
490 } 490 }
491 491
492 // Array _adReverse(Array a, size_t szelem) 492 // Array _adReverse(Array a, size_t szelem)
493 { 493 {
494 std::string fname("_adReverse"); 494 std::string fname("_adReverse");
495 std::vector<const llvm::Type*> types; 495 std::vector<const llvm::Type*> types;
496 types.push_back(rt_array(byteTy)); 496 types.push_back(rt_array(byteTy));
497 types.push_back(rt_array(byteTy)); 497 types.push_back(rt_array(byteTy));
498 types.push_back(sizeTy); 498 types.push_back(sizeTy);
499 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); 499 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
500 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 500 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
501 } 501 }
502 502
503 // Array _adDupT(TypeInfo ti, Array a) 503 // Array _adDupT(TypeInfo ti, Array a)
504 { 504 {
505 std::string fname("_adDupT"); 505 std::string fname("_adDupT");
506 std::vector<const llvm::Type*> types; 506 std::vector<const llvm::Type*> types;
507 types.push_back(rt_array(byteTy)); 507 types.push_back(rt_array(byteTy));
508 types.push_back(typeInfoTy); 508 types.push_back(typeInfoTy);
509 types.push_back(rt_array(byteTy)); 509 types.push_back(rt_array(byteTy));
510 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); 510 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
511 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 511 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
512 } 512 }
513 513
514 // int _adEq(Array a1, Array a2, TypeInfo ti) 514 // int _adEq(Array a1, Array a2, TypeInfo ti)
515 // int _adCmp(Array a1, Array a2, TypeInfo ti) 515 // int _adCmp(Array a1, Array a2, TypeInfo ti)
516 { 516 {
519 std::vector<const llvm::Type*> types; 519 std::vector<const llvm::Type*> types;
520 types.push_back(rt_array(byteTy)); 520 types.push_back(rt_array(byteTy));
521 types.push_back(rt_array(byteTy)); 521 types.push_back(rt_array(byteTy));
522 types.push_back(typeInfoTy); 522 types.push_back(typeInfoTy);
523 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); 523 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false);
524 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 524 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
525 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); 525 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M);
526 } 526 }
527 527
528 // int _adCmpChar(Array a1, Array a2) 528 // int _adCmpChar(Array a1, Array a2)
529 { 529 {
530 std::string fname("_adCmpChar"); 530 std::string fname("_adCmpChar");
531 std::vector<const llvm::Type*> types; 531 std::vector<const llvm::Type*> types;
532 types.push_back(rt_array(byteTy)); 532 types.push_back(rt_array(byteTy));
533 types.push_back(rt_array(byteTy)); 533 types.push_back(rt_array(byteTy));
534 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); 534 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false);
535 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 535 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
536 } 536 }
537 537
538 // Array _adSort(Array a, TypeInfo ti) 538 // Array _adSort(Array a, TypeInfo ti)
539 { 539 {
540 std::string fname("_adSort"); 540 std::string fname("_adSort");
541 std::vector<const llvm::Type*> types; 541 std::vector<const llvm::Type*> types;
542 types.push_back(rt_array(byteTy)); 542 types.push_back(rt_array(byteTy));
543 types.push_back(rt_array(byteTy)); 543 types.push_back(rt_array(byteTy));
544 types.push_back(typeInfoTy); 544 types.push_back(typeInfoTy);
545 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); 545 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
546 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 546 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
547 } 547 }
548 548
549 ///////////////////////////////////////////////////////////////////////////////////// 549 /////////////////////////////////////////////////////////////////////////////////////
550 ///////////////////////////////////////////////////////////////////////////////////// 550 /////////////////////////////////////////////////////////////////////////////////////
551 ///////////////////////////////////////////////////////////////////////////////////// 551 /////////////////////////////////////////////////////////////////////////////////////
554 { 554 {
555 std::string fname("_aaLen"); 555 std::string fname("_aaLen");
556 std::vector<const llvm::Type*> types; 556 std::vector<const llvm::Type*> types;
557 types.push_back(aaTy); 557 types.push_back(aaTy);
558 const llvm::FunctionType* fty = llvm::FunctionType::get(sizeTy, types, false); 558 const llvm::FunctionType* fty = llvm::FunctionType::get(sizeTy, types, false);
559 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 559 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
560 } 560 }
561 561
562 // void* _aaGet(AA* aa, TypeInfo keyti, size_t valuesize, void* pkey) 562 // void* _aaGet(AA* aa, TypeInfo keyti, size_t valuesize, void* pkey)
563 { 563 {
564 std::string fname("_aaGet"); 564 std::string fname("_aaGet");
566 types.push_back(aaTy); 566 types.push_back(aaTy);
567 types.push_back(typeInfoTy); 567 types.push_back(typeInfoTy);
568 types.push_back(sizeTy); 568 types.push_back(sizeTy);
569 types.push_back(voidPtrTy); 569 types.push_back(voidPtrTy);
570 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); 570 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false);
571 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 571 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
572 } 572 }
573 573
574 // void* _aaGetRvalue(AA aa, TypeInfo keyti, size_t valuesize, void* pkey) 574 // void* _aaGetRvalue(AA aa, TypeInfo keyti, size_t valuesize, void* pkey)
575 { 575 {
576 std::string fname("_aaGetRvalue"); 576 std::string fname("_aaGetRvalue");
578 types.push_back(aaTy); 578 types.push_back(aaTy);
579 types.push_back(typeInfoTy); 579 types.push_back(typeInfoTy);
580 types.push_back(sizeTy); 580 types.push_back(sizeTy);
581 types.push_back(voidPtrTy); 581 types.push_back(voidPtrTy);
582 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); 582 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false);
583 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 583 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
584 } 584 }
585 585
586 // void* _aaIn(AA aa, TypeInfo keyti, void* pkey) 586 // void* _aaIn(AA aa, TypeInfo keyti, void* pkey)
587 { 587 {
588 std::string fname("_aaIn"); 588 std::string fname("_aaIn");
589 std::vector<const llvm::Type*> types; 589 std::vector<const llvm::Type*> types;
590 types.push_back(aaTy); 590 types.push_back(aaTy);
591 types.push_back(typeInfoTy); 591 types.push_back(typeInfoTy);
592 types.push_back(voidPtrTy); 592 types.push_back(voidPtrTy);
593 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); 593 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false);
594 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 594 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
595 } 595 }
596 596
597 // void _aaDel(AA aa, TypeInfo keyti, void* pkey) 597 // void _aaDel(AA aa, TypeInfo keyti, void* pkey)
598 { 598 {
599 std::string fname("_aaDel"); 599 std::string fname("_aaDel");
600 std::vector<const llvm::Type*> types; 600 std::vector<const llvm::Type*> types;
601 types.push_back(aaTy); 601 types.push_back(aaTy);
602 types.push_back(typeInfoTy); 602 types.push_back(typeInfoTy);
603 types.push_back(voidPtrTy); 603 types.push_back(voidPtrTy);
604 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); 604 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
605 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 605 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
606 } 606 }
607 607
608 // ArrayRet_t _aaValues(AA aa, size_t keysize, size_t valuesize) 608 // ArrayRet_t _aaValues(AA aa, size_t keysize, size_t valuesize)
609 { 609 {
610 std::string fname("_aaValues"); 610 std::string fname("_aaValues");
612 types.push_back(rt_array(byteTy)); 612 types.push_back(rt_array(byteTy));
613 types.push_back(aaTy); 613 types.push_back(aaTy);
614 types.push_back(sizeTy); 614 types.push_back(sizeTy);
615 types.push_back(sizeTy); 615 types.push_back(sizeTy);
616 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); 616 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
617 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 617 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
618 } 618 }
619 619
620 // void* _aaRehash(AA* paa, TypeInfo keyti) 620 // void* _aaRehash(AA* paa, TypeInfo keyti)
621 { 621 {
622 std::string fname("_aaRehash"); 622 std::string fname("_aaRehash");
623 std::vector<const llvm::Type*> types; 623 std::vector<const llvm::Type*> types;
624 types.push_back(aaTy); 624 types.push_back(aaTy);
625 types.push_back(typeInfoTy); 625 types.push_back(typeInfoTy);
626 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); 626 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false);
627 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 627 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
628 } 628 }
629 629
630 // ArrayRet_t _aaKeys(AA aa, size_t keysize) 630 // ArrayRet_t _aaKeys(AA aa, size_t keysize)
631 { 631 {
632 std::string fname("_aaKeys"); 632 std::string fname("_aaKeys");
633 std::vector<const llvm::Type*> types; 633 std::vector<const llvm::Type*> types;
634 types.push_back(rt_array(byteTy)); 634 types.push_back(rt_array(byteTy));
635 types.push_back(aaTy); 635 types.push_back(aaTy);
636 types.push_back(sizeTy); 636 types.push_back(sizeTy);
637 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); 637 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
638 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 638 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
639 } 639 }
640 640
641 // int _aaApply(AA aa, size_t keysize, dg_t dg) 641 // int _aaApply(AA aa, size_t keysize, dg_t dg)
642 { 642 {
643 std::string fname("_aaApply"); 643 std::string fname("_aaApply");
644 std::vector<const llvm::Type*> types; 644 std::vector<const llvm::Type*> types;
645 types.push_back(aaTy); 645 types.push_back(aaTy);
646 types.push_back(sizeTy); 646 types.push_back(sizeTy);
647 types.push_back(rt_dg1()); 647 types.push_back(rt_dg1());
648 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); 648 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false);
649 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 649 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
650 } 650 }
651 651
652 // int _aaApply2(AA aa, size_t keysize, dg2_t dg) 652 // int _aaApply2(AA aa, size_t keysize, dg2_t dg)
653 { 653 {
654 std::string fname("_aaApply2"); 654 std::string fname("_aaApply2");
655 std::vector<const llvm::Type*> types; 655 std::vector<const llvm::Type*> types;
656 types.push_back(aaTy); 656 types.push_back(aaTy);
657 types.push_back(sizeTy); 657 types.push_back(sizeTy);
658 types.push_back(rt_dg1()); 658 types.push_back(rt_dg1());
659 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); 659 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false);
660 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 660 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
661 } 661 }
662 662
663 ///////////////////////////////////////////////////////////////////////////////////// 663 /////////////////////////////////////////////////////////////////////////////////////
664 ///////////////////////////////////////////////////////////////////////////////////// 664 /////////////////////////////////////////////////////////////////////////////////////
665 ///////////////////////////////////////////////////////////////////////////////////// 665 /////////////////////////////////////////////////////////////////////////////////////
669 { 669 {
670 std::string fname("_moduleCtor"); 670 std::string fname("_moduleCtor");
671 std::string fname2("_moduleDtor"); 671 std::string fname2("_moduleDtor");
672 std::vector<const llvm::Type*> types; 672 std::vector<const llvm::Type*> types;
673 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); 673 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
674 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 674 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
675 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); 675 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M);
676 } 676 }
677 677
678 ///////////////////////////////////////////////////////////////////////////////////// 678 /////////////////////////////////////////////////////////////////////////////////////
679 ///////////////////////////////////////////////////////////////////////////////////// 679 /////////////////////////////////////////////////////////////////////////////////////
680 ///////////////////////////////////////////////////////////////////////////////////// 680 /////////////////////////////////////////////////////////////////////////////////////
683 { 683 {
684 std::string fname("_d_toObject"); 684 std::string fname("_d_toObject");
685 std::vector<const llvm::Type*> types; 685 std::vector<const llvm::Type*> types;
686 types.push_back(voidPtrTy); 686 types.push_back(voidPtrTy);
687 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); 687 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false);
688 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 688 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
689 } 689 }
690 690
691 // Object _d_dynamic_cast(Object o, ClassInfo c) 691 // Object _d_dynamic_cast(Object o, ClassInfo c)
692 { 692 {
693 std::string fname("_d_dynamic_cast"); 693 std::string fname("_d_dynamic_cast");
694 std::vector<const llvm::Type*> types; 694 std::vector<const llvm::Type*> types;
695 types.push_back(objectTy); 695 types.push_back(objectTy);
696 types.push_back(classInfoTy); 696 types.push_back(classInfoTy);
697 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); 697 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false);
698 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 698 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
699 } 699 }
700 700
701 // Object _d_interface_cast(void* p, ClassInfo c) 701 // Object _d_interface_cast(void* p, ClassInfo c)
702 { 702 {
703 std::string fname("_d_interface_cast"); 703 std::string fname("_d_interface_cast");
704 std::vector<const llvm::Type*> types; 704 std::vector<const llvm::Type*> types;
705 types.push_back(voidPtrTy); 705 types.push_back(voidPtrTy);
706 types.push_back(classInfoTy); 706 types.push_back(classInfoTy);
707 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); 707 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false);
708 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 708 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
709 } 709 }
710 710
711 ///////////////////////////////////////////////////////////////////////////////////// 711 /////////////////////////////////////////////////////////////////////////////////////
712 ///////////////////////////////////////////////////////////////////////////////////// 712 /////////////////////////////////////////////////////////////////////////////////////
713 ///////////////////////////////////////////////////////////////////////////////////// 713 /////////////////////////////////////////////////////////////////////////////////////
716 { 716 {
717 std::string fname("_d_throw_exception"); 717 std::string fname("_d_throw_exception");
718 std::vector<const llvm::Type*> types; 718 std::vector<const llvm::Type*> types;
719 types.push_back(objectTy); 719 types.push_back(objectTy);
720 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); 720 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
721 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 721 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
722 } 722 }
723 723
724 ///////////////////////////////////////////////////////////////////////////////////// 724 /////////////////////////////////////////////////////////////////////////////////////
725 ///////////////////////////////////////////////////////////////////////////////////// 725 /////////////////////////////////////////////////////////////////////////////////////
726 ///////////////////////////////////////////////////////////////////////////////////// 726 /////////////////////////////////////////////////////////////////////////////////////
730 std::string fname("_d_switch_string"); 730 std::string fname("_d_switch_string");
731 std::vector<const llvm::Type*> types; 731 std::vector<const llvm::Type*> types;
732 types.push_back(rt_array(rt_array2(byteTy))); 732 types.push_back(rt_array(rt_array2(byteTy)));
733 types.push_back(stringTy); 733 types.push_back(stringTy);
734 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); 734 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false);
735 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 735 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
736 } 736 }
737 737
738 // int _d_switch_ustring(wchar[][] table, wchar[] ca) 738 // int _d_switch_ustring(wchar[][] table, wchar[] ca)
739 { 739 {
740 std::string fname("_d_switch_ustring"); 740 std::string fname("_d_switch_ustring");
741 std::vector<const llvm::Type*> types; 741 std::vector<const llvm::Type*> types;
742 types.push_back(rt_array(rt_array2(shortTy))); 742 types.push_back(rt_array(rt_array2(shortTy)));
743 types.push_back(wstringTy); 743 types.push_back(wstringTy);
744 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); 744 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false);
745 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 745 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
746 } 746 }
747 747
748 // int _d_switch_dstring(dchar[][] table, dchar[] ca) 748 // int _d_switch_dstring(dchar[][] table, dchar[] ca)
749 { 749 {
750 std::string fname("_d_switch_dstring"); 750 std::string fname("_d_switch_dstring");
751 std::vector<const llvm::Type*> types; 751 std::vector<const llvm::Type*> types;
752 types.push_back(rt_array(rt_array2(intTy))); 752 types.push_back(rt_array(rt_array2(intTy)));
753 types.push_back(dstringTy); 753 types.push_back(dstringTy);
754 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); 754 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false);
755 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 755 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
756 } 756 }
757 } 757 }
758 758
759 759
760 760
761 761
762 762
763 763