comparison gen/runtime.cpp @ 715:30b42a283c8e

Removed TypeOpaque from DMD. Changed runtime functions taking opaque[] to void[]. Implemented proper type painting, to avoid "resizing" array casts in runtime calls that previously took opaque[]. Implemented dynamic arrays as first class types, this implements proper ABI for these types on x86. Added dwarf region end after call to assert function, fixes some problems with llvm not allowing this to be missing. Reverted change to WithStatement from rev [704] it breaks MiniD, mini/with2.d needs to be fixed some other way... Fixed tango bug 1339 in runtime, problem with _adReverseChar on invalid UTF-8. Disabled .bc generation in the compiler runtime part, genobj.d triggers some llvm bug when using debug info. the .o seems to work fine.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Wed, 22 Oct 2008 14:55:33 +0200
parents 6aaa3d3c1183
children 7261ff0f95ff
comparison
equal deleted inserted replaced
714:1e98c99a87cb 715:30b42a283c8e
108 return getPtrToType(t); 108 return getPtrToType(t);
109 } 109 }
110 110
111 static const LLType* rt_array(const LLType* elemty) 111 static const LLType* rt_array(const LLType* elemty)
112 { 112 {
113 std::vector<const LLType*> t; 113 return llvm::StructType::get(DtoSize_t(), rt_ptr(elemty), 0);
114 t.push_back(DtoSize_t());
115 t.push_back(rt_ptr(elemty));
116 return rt_ptr(llvm::StructType::get(t));
117 }
118
119 static const LLType* rt_array2(const LLType* elemty)
120 {
121 std::vector<const LLType*> t;
122 t.push_back(DtoSize_t());
123 t.push_back(rt_ptr(elemty));
124 return llvm::StructType::get(t);
125 } 114 }
126 115
127 static const LLType* rt_dg1() 116 static const LLType* rt_dg1()
128 { 117 {
129 std::vector<const LLType*> types; 118 std::vector<const LLType*> types;
197 std::string fname3("_d_switch_error"); 186 std::string fname3("_d_switch_error");
198 std::vector<const LLType*> types; 187 std::vector<const LLType*> types;
199 types.push_back(stringTy); 188 types.push_back(stringTy);
200 types.push_back(intTy); 189 types.push_back(intTy);
201 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); 190 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
202 llvm::AttrListPtr palist; 191 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
203 palist = palist.addAttr(1, llvm::Attribute::ByVal); 192 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M);
204 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist); 193 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname3, M);
205 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setAttributes(palist);
206 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname3, M)->setAttributes(palist);
207 } 194 }
208 195
209 // void _d_assert_msg( char[] msg, char[] file, uint line ) 196 // void _d_assert_msg( char[] msg, char[] file, uint line )
210 { 197 {
211 std::string fname("_d_assert_msg"); 198 std::string fname("_d_assert_msg");
212 std::vector<const LLType*> types; 199 std::vector<const LLType*> types;
213 types.push_back(stringTy); 200 types.push_back(stringTy);
214 types.push_back(stringTy); 201 types.push_back(stringTy);
215 types.push_back(intTy); 202 types.push_back(intTy);
216 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); 203 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false);
217 llvm::AttrListPtr palist; 204 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
218 palist = palist.addAttr(1, llvm::Attribute::ByVal);
219 palist = palist.addAttr(2, llvm::Attribute::ByVal);
220 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist);
221 } 205 }
222 206
223 ///////////////////////////////////////////////////////////////////////////////////// 207 /////////////////////////////////////////////////////////////////////////////////////
224 ///////////////////////////////////////////////////////////////////////////////////// 208 /////////////////////////////////////////////////////////////////////////////////////
225 ///////////////////////////////////////////////////////////////////////////////////// 209 /////////////////////////////////////////////////////////////////////////////////////
380 std::vector<const LLType*> types; \ 364 std::vector<const LLType*> types; \
381 types.push_back(TY); \ 365 types.push_back(TY); \
382 types.push_back(rt_dg1()); \ 366 types.push_back(rt_dg1()); \
383 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ 367 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \
384 llvm::AttrListPtr palist; \ 368 llvm::AttrListPtr palist; \
385 palist = palist.addAttr(1, llvm::Attribute::ByVal); \
386 palist = palist.addAttr(2, llvm::Attribute::ByVal); \ 369 palist = palist.addAttr(2, llvm::Attribute::ByVal); \
387 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist); \ 370 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist); \
388 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setAttributes(palist); \ 371 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setAttributes(palist); \
389 } 372 }
390 STR_APPLY1(stringTy, "_aApplycw1", "_aApplycd1") 373 STR_APPLY1(stringTy, "_aApplycw1", "_aApplycd1")
400 std::vector<const LLType*> types; \ 383 std::vector<const LLType*> types; \
401 types.push_back(TY); \ 384 types.push_back(TY); \
402 types.push_back(rt_dg2()); \ 385 types.push_back(rt_dg2()); \
403 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ 386 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \
404 llvm::AttrListPtr palist; \ 387 llvm::AttrListPtr palist; \
405 palist = palist.addAttr(1, llvm::Attribute::ByVal); \
406 palist = palist.addAttr(2, llvm::Attribute::ByVal); \ 388 palist = palist.addAttr(2, llvm::Attribute::ByVal); \
407 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist); \ 389 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist); \
408 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setAttributes(palist); \ 390 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setAttributes(palist); \
409 } 391 }
410 STR_APPLY2(stringTy, "_aApplycw2", "_aApplycd2") 392 STR_APPLY2(stringTy, "_aApplycw2", "_aApplycd2")
419 std::vector<const LLType*> types; \ 401 std::vector<const LLType*> types; \
420 types.push_back(TY); \ 402 types.push_back(TY); \
421 types.push_back(rt_dg1()); \ 403 types.push_back(rt_dg1()); \
422 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ 404 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \
423 llvm::AttrListPtr palist; \ 405 llvm::AttrListPtr palist; \
424 palist = palist.addAttr(1, llvm::Attribute::ByVal); \
425 palist = palist.addAttr(2, llvm::Attribute::ByVal); \ 406 palist = palist.addAttr(2, llvm::Attribute::ByVal); \
426 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist); \ 407 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist); \
427 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setAttributes(palist); \ 408 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setAttributes(palist); \
428 } 409 }
429 STR_APPLY_R1(stringTy, "_aApplyRcw1", "_aApplyRcd1") 410 STR_APPLY_R1(stringTy, "_aApplyRcw1", "_aApplyRcd1")
438 std::vector<const LLType*> types; \ 419 std::vector<const LLType*> types; \
439 types.push_back(TY); \ 420 types.push_back(TY); \
440 types.push_back(rt_dg2()); \ 421 types.push_back(rt_dg2()); \
441 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ 422 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \
442 llvm::AttrListPtr palist; \ 423 llvm::AttrListPtr palist; \
443 palist = palist.addAttr(1, llvm::Attribute::ByVal); \
444 palist = palist.addAttr(2, llvm::Attribute::ByVal); \ 424 palist = palist.addAttr(2, llvm::Attribute::ByVal); \
445 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist); \ 425 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist); \
446 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setAttributes(palist); \ 426 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setAttributes(palist); \
447 } 427 }
448 STR_APPLY_R2(stringTy, "_aApplyRcw2", "_aApplyRcd2") 428 STR_APPLY_R2(stringTy, "_aApplyRcw2", "_aApplyRcd2")
468 448
469 ///////////////////////////////////////////////////////////////////////////////////// 449 /////////////////////////////////////////////////////////////////////////////////////
470 ///////////////////////////////////////////////////////////////////////////////////// 450 /////////////////////////////////////////////////////////////////////////////////////
471 ///////////////////////////////////////////////////////////////////////////////////// 451 /////////////////////////////////////////////////////////////////////////////////////
472 452
473 // builds the d string[] for the D main args from the C main args
474 // void _d_main_args(uint n, char** args, ref char[][] res)
475 {
476 std::string fname("_d_main_args");
477 std::vector<const LLType*> types;
478 types.push_back(intTy);
479 types.push_back(rt_ptr(rt_ptr(byteTy)));
480 types.push_back(rt_array(stringTy->getContainedType(0)));
481 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
482 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
483 }
484
485 /////////////////////////////////////////////////////////////////////////////////////
486 /////////////////////////////////////////////////////////////////////////////////////
487 /////////////////////////////////////////////////////////////////////////////////////
488
489 // cast to object 453 // cast to object
490 // Object _d_toObject(void* p) 454 // Object _d_toObject(void* p)
491 { 455 {
492 std::string fname("_d_toObject"); 456 std::string fname("_d_toObject");
493 std::vector<const LLType*> types; 457 std::vector<const LLType*> types;
527 { 491 {
528 std::string fname("_adReverseChar"); 492 std::string fname("_adReverseChar");
529 std::string fname2("_adSortChar"); 493 std::string fname2("_adSortChar");
530 std::vector<const LLType*> types; 494 std::vector<const LLType*> types;
531 types.push_back(stringTy); 495 types.push_back(stringTy);
532 types.push_back(stringTy); 496 const llvm::FunctionType* fty = llvm::FunctionType::get(stringTy, types, false);
533 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); 497 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
534 llvm::AttrListPtr palist; 498 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M);
535 palist = palist.addAttr(2, llvm::Attribute::ByVal);
536 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist);
537 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setAttributes(palist);
538 } 499 }
539 500
540 // wchar[] _adReverseWchar(wchar[] a) 501 // wchar[] _adReverseWchar(wchar[] a)
541 // wchar[] _adSortWchar(wchar[] a) 502 // wchar[] _adSortWchar(wchar[] a)
542 { 503 {
543 std::string fname("_adReverseWchar"); 504 std::string fname("_adReverseWchar");
544 std::string fname2("_adSortWchar"); 505 std::string fname2("_adSortWchar");
545 std::vector<const LLType*> types; 506 std::vector<const LLType*> types;
546 types.push_back(wstringTy); 507 types.push_back(wstringTy);
547 types.push_back(wstringTy); 508 const llvm::FunctionType* fty = llvm::FunctionType::get(wstringTy, types, false);
548 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); 509 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
549 llvm::AttrListPtr palist; 510 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M);
550 palist = palist.addAttr(2, llvm::Attribute::ByVal); 511 }
551 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist); 512
552 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setAttributes(palist); 513 // void[] _adReverse(void[] a, size_t szelem)
553 }
554
555 // Array _adReverse(Array a, size_t szelem)
556 { 514 {
557 std::string fname("_adReverse"); 515 std::string fname("_adReverse");
516 std::vector<const LLType*> types;
517 types.push_back(rt_array(byteTy));
518 types.push_back(sizeTy);
519 const llvm::FunctionType* fty = llvm::FunctionType::get(rt_array(byteTy), types, false);
520 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
521 }
522
523 // void[] _adDupT(TypeInfo ti, void[] a)
524 {
525 std::string fname("_adDupT");
526 std::vector<const LLType*> types;
527 types.push_back(typeInfoTy);
528 types.push_back(rt_array(byteTy));
529 const llvm::FunctionType* fty = llvm::FunctionType::get(rt_array(byteTy), types, false);
530 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
531 }
532
533 // int _adEq(void[] a1, void[] a2, TypeInfo ti)
534 // int _adCmp(void[] a1, void[] a2, TypeInfo ti)
535 {
536 std::string fname("_adEq");
537 std::string fname2("_adCmp");
558 std::vector<const LLType*> types; 538 std::vector<const LLType*> types;
559 types.push_back(rt_array(byteTy)); 539 types.push_back(rt_array(byteTy));
560 types.push_back(rt_array(byteTy)); 540 types.push_back(rt_array(byteTy));
561 types.push_back(sizeTy);
562 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
563 llvm::AttrListPtr palist;
564 palist = palist.addAttr(2, llvm::Attribute::ByVal);
565 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist);
566 }
567
568 // Array _adDupT(TypeInfo ti, Array a)
569 {
570 std::string fname("_adDupT");
571 std::vector<const LLType*> types;
572 types.push_back(rt_array(byteTy));
573 types.push_back(typeInfoTy);
574 types.push_back(rt_array(byteTy));
575 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
576 llvm::AttrListPtr palist;
577 palist = palist.addAttr(3, llvm::Attribute::ByVal);
578 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist);
579 }
580
581 // int _adEq(Array a1, Array a2, TypeInfo ti)
582 // int _adCmp(Array a1, Array a2, TypeInfo ti)
583 {
584 std::string fname("_adEq");
585 std::string fname2("_adCmp");
586 std::vector<const LLType*> types;
587 types.push_back(rt_array(byteTy));
588 types.push_back(rt_array(byteTy));
589 types.push_back(typeInfoTy); 541 types.push_back(typeInfoTy);
590 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); 542 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false);
591 llvm::AttrListPtr palist; 543 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
592 palist = palist.addAttr(1, llvm::Attribute::ByVal); 544 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M);
593 palist = palist.addAttr(2, llvm::Attribute::ByVal); 545 }
594 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist); 546
595 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setAttributes(palist); 547 // int _adCmpChar(void[] a1, void[] a2)
596 }
597
598 // int _adCmpChar(Array a1, Array a2)
599 { 548 {
600 std::string fname("_adCmpChar"); 549 std::string fname("_adCmpChar");
601 std::vector<const LLType*> types; 550 std::vector<const LLType*> types;
602 types.push_back(rt_array(byteTy)); 551 types.push_back(rt_array(byteTy));
603 types.push_back(rt_array(byteTy)); 552 types.push_back(rt_array(byteTy));
604 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); 553 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false);
605 llvm::AttrListPtr palist; 554 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
606 palist = palist.addAttr(1, llvm::Attribute::ByVal); 555 }
607 palist = palist.addAttr(2, llvm::Attribute::ByVal); 556
608 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist); 557 // void[] _adSort(void[] a, TypeInfo ti)
609 }
610
611 // Array _adSort(Array a, TypeInfo ti)
612 { 558 {
613 std::string fname("_adSort"); 559 std::string fname("_adSort");
614 std::vector<const LLType*> types; 560 std::vector<const LLType*> types;
615 types.push_back(rt_array(byteTy)); 561 types.push_back(rt_array(byteTy));
616 types.push_back(rt_array(byteTy)); 562 types.push_back(typeInfoTy);
617 types.push_back(typeInfoTy); 563 const llvm::FunctionType* fty = llvm::FunctionType::get(rt_array(byteTy), types, false);
618 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); 564 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
619 llvm::AttrListPtr palist;
620 palist = palist.addAttr(2, llvm::Attribute::ByVal);
621 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist);
622 } 565 }
623 566
624 ///////////////////////////////////////////////////////////////////////////////////// 567 /////////////////////////////////////////////////////////////////////////////////////
625 ///////////////////////////////////////////////////////////////////////////////////// 568 /////////////////////////////////////////////////////////////////////////////////////
626 ///////////////////////////////////////////////////////////////////////////////////// 569 /////////////////////////////////////////////////////////////////////////////////////
678 types.push_back(voidPtrTy); 621 types.push_back(voidPtrTy);
679 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); 622 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
680 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 623 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
681 } 624 }
682 625
683 // ArrayRet_t _aaValues(AA aa, size_t keysize, size_t valuesize) 626 // void[] _aaValues(AA aa, size_t keysize, size_t valuesize)
684 { 627 {
685 std::string fname("_aaValues"); 628 std::string fname("_aaValues");
686 std::vector<const LLType*> types; 629 std::vector<const LLType*> types;
687 types.push_back(rt_array(byteTy)); 630 types.push_back(aaTy);
688 types.push_back(aaTy); 631 types.push_back(sizeTy);
689 types.push_back(sizeTy); 632 types.push_back(sizeTy);
690 types.push_back(sizeTy); 633 const llvm::FunctionType* fty = llvm::FunctionType::get(rt_array(byteTy), types, false);
691 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
692 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 634 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
693 } 635 }
694 636
695 // void* _aaRehash(AA* paa, TypeInfo keyti) 637 // void* _aaRehash(AA* paa, TypeInfo keyti)
696 { 638 {
700 types.push_back(typeInfoTy); 642 types.push_back(typeInfoTy);
701 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); 643 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false);
702 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 644 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
703 } 645 }
704 646
705 // ArrayRet_t _aaKeys(AA aa, size_t keysize) 647 // void[] _aaKeys(AA aa, size_t keysize)
706 { 648 {
707 std::string fname("_aaKeys"); 649 std::string fname("_aaKeys");
708 std::vector<const LLType*> types; 650 std::vector<const LLType*> types;
709 types.push_back(rt_array(byteTy)); 651 types.push_back(aaTy);
710 types.push_back(aaTy); 652 types.push_back(sizeTy);
711 types.push_back(sizeTy); 653 const llvm::FunctionType* fty = llvm::FunctionType::get(rt_array(byteTy), types, false);
712 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
713 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 654 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
714 } 655 }
715 656
716 // int _aaApply(AA aa, size_t keysize, dg_t dg) 657 // int _aaApply(AA aa, size_t keysize, dg_t dg)
717 { 658 {
730 { 671 {
731 std::string fname("_aaApply2"); 672 std::string fname("_aaApply2");
732 std::vector<const LLType*> types; 673 std::vector<const LLType*> types;
733 types.push_back(aaTy); 674 types.push_back(aaTy);
734 types.push_back(sizeTy); 675 types.push_back(sizeTy);
735 types.push_back(rt_dg1()); 676 types.push_back(rt_dg2());
736 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); 677 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false);
737 llvm::AttrListPtr palist; 678 llvm::AttrListPtr palist;
738 palist = palist.addAttr(3, llvm::Attribute::ByVal); 679 palist = palist.addAttr(3, llvm::Attribute::ByVal);
739 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist); 680 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist);
740 } 681 }
806 747
807 // int _d_switch_string(char[][] table, char[] ca) 748 // int _d_switch_string(char[][] table, char[] ca)
808 { 749 {
809 std::string fname("_d_switch_string"); 750 std::string fname("_d_switch_string");
810 std::vector<const LLType*> types; 751 std::vector<const LLType*> types;
811 types.push_back(rt_array(rt_array2(byteTy))); 752 types.push_back(rt_array(stringTy));
812 types.push_back(stringTy); 753 types.push_back(stringTy);
813 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); 754 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false);
814 llvm::AttrListPtr palist; 755 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
815 palist = palist.addAttr(1, llvm::Attribute::ByVal);
816 palist = palist.addAttr(2, llvm::Attribute::ByVal);
817 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist);
818 } 756 }
819 757
820 // int _d_switch_ustring(wchar[][] table, wchar[] ca) 758 // int _d_switch_ustring(wchar[][] table, wchar[] ca)
821 { 759 {
822 std::string fname("_d_switch_ustring"); 760 std::string fname("_d_switch_ustring");
823 std::vector<const LLType*> types; 761 std::vector<const LLType*> types;
824 types.push_back(rt_array(rt_array2(shortTy))); 762 types.push_back(rt_array(wstringTy));
825 types.push_back(wstringTy); 763 types.push_back(wstringTy);
826 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); 764 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false);
827 llvm::AttrListPtr palist; 765 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
828 palist = palist.addAttr(1, llvm::Attribute::ByVal);
829 palist = palist.addAttr(2, llvm::Attribute::ByVal);
830 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist);
831 } 766 }
832 767
833 // int _d_switch_dstring(dchar[][] table, dchar[] ca) 768 // int _d_switch_dstring(dchar[][] table, dchar[] ca)
834 { 769 {
835 std::string fname("_d_switch_dstring"); 770 std::string fname("_d_switch_dstring");
836 std::vector<const LLType*> types; 771 std::vector<const LLType*> types;
837 types.push_back(rt_array(rt_array2(intTy))); 772 types.push_back(rt_array(dstringTy));
838 types.push_back(dstringTy); 773 types.push_back(dstringTy);
839 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); 774 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false);
840 llvm::AttrListPtr palist; 775 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
841 palist = palist.addAttr(1, llvm::Attribute::ByVal);
842 palist = palist.addAttr(2, llvm::Attribute::ByVal);
843 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setAttributes(palist);
844 } 776 }
845 777
846 ///////////////////////////////////////////////////////////////////////////////////// 778 /////////////////////////////////////////////////////////////////////////////////////
847 ///////////////////////////////////////////////////////////////////////////////////// 779 /////////////////////////////////////////////////////////////////////////////////////
848 ///////////////////////////////////////////////////////////////////////////////////// 780 /////////////////////////////////////////////////////////////////////////////////////