comparison gen/tollvm.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 5a2983f97498
children 7261ff0f95ff
comparison
equal deleted inserted replaced
714:1e98c99a87cb 715:30b42a283c8e
23 23
24 bool DtoIsPassedByRef(Type* type) 24 bool DtoIsPassedByRef(Type* type)
25 { 25 {
26 Type* typ = type->toBasetype(); 26 Type* typ = type->toBasetype();
27 TY t = typ->ty; 27 TY t = typ->ty;
28 return (t == Tstruct || t == Tarray || t == Tdelegate || t == Tsarray); 28 return (t == Tstruct || t == Tdelegate || t == Tsarray);
29 } 29 }
30 30
31 bool DtoIsReturnedInArg(Type* type) 31 bool DtoIsReturnedInArg(Type* type)
32 { 32 {
33 Type* typ = type->toBasetype(); 33 Type* typ = type->toBasetype();
34 TY t = typ->ty; 34 TY t = typ->ty;
35 return (t == Tstruct || t == Tarray || t == Tdelegate || t == Tsarray); 35 return (t == Tstruct || t == Tdelegate || t == Tsarray);
36 } 36 }
37 37
38 unsigned DtoShouldExtend(Type* type) 38 unsigned DtoShouldExtend(Type* type)
39 { 39 {
40 type = type->toBasetype(); 40 type = type->toBasetype();
177 { 177 {
178 TypeTuple* ttupl = (TypeTuple*)t; 178 TypeTuple* ttupl = (TypeTuple*)t;
179 return DtoStructTypeFromArguments(ttupl->arguments); 179 return DtoStructTypeFromArguments(ttupl->arguments);
180 } 180 }
181 */ 181 */
182 // opaque type
183 case Topaque:
184 return llvm::OpaqueType::get();
185 182
186 default: 183 default:
187 printf("trying to convert unknown type '%s' with value %d\n", t->toChars(), t->ty); 184 printf("trying to convert unknown type '%s' with value %d\n", t->toChars(), t->ty);
188 assert(0); 185 assert(0);
189 } 186 }
558 555
559 ////////////////////////////////////////////////////////////////////////////////////////// 556 //////////////////////////////////////////////////////////////////////////////////////////
560 557
561 LLValue* DtoLoad(LLValue* src, const char* name) 558 LLValue* DtoLoad(LLValue* src, const char* name)
562 { 559 {
560 if (Logger::enabled())
561 Logger::cout() << "loading " << *src << '\n';
563 LLValue* ld = gIR->ir->CreateLoad(src, name ? name : "tmp"); 562 LLValue* ld = gIR->ir->CreateLoad(src, name ? name : "tmp");
564 //ld->setVolatile(gIR->func()->inVolatile); 563 //ld->setVolatile(gIR->func()->inVolatile);
565 return ld; 564 return ld;
566 } 565 }
567 566
568 void DtoStore(LLValue* src, LLValue* dst) 567 void DtoStore(LLValue* src, LLValue* dst)
569 { 568 {
569 if (Logger::enabled())
570 Logger::cout() << "storing " << *src << " into " << *dst << '\n';
570 LLValue* st = gIR->ir->CreateStore(src,dst); 571 LLValue* st = gIR->ir->CreateStore(src,dst);
571 //st->setVolatile(gIR->func()->inVolatile); 572 //st->setVolatile(gIR->func()->inVolatile);
572 } 573 }
573 574
574 ////////////////////////////////////////////////////////////////////////////////////////// 575 //////////////////////////////////////////////////////////////////////////////////////////
575 576
576 LLValue* DtoBitCast(LLValue* v, const LLType* t, const char* name) 577 LLValue* DtoBitCast(LLValue* v, const LLType* t, const char* name)
577 { 578 {
578 if (v->getType() == t) 579 if (v->getType() == t)
579 return v; 580 return v;
581 assert(!(isaStruct(t) || isaStruct(v->getType())));
580 return gIR->ir->CreateBitCast(v, t, name ? name : "tmp"); 582 return gIR->ir->CreateBitCast(v, t, name ? name : "tmp");
581 } 583 }
582 584
583 ////////////////////////////////////////////////////////////////////////////////////////// 585 //////////////////////////////////////////////////////////////////////////////////////////
584 586
804 { 806 {
805 LLValue* res = llvm::UndefValue::get(type); 807 LLValue* res = llvm::UndefValue::get(type);
806 res = gIR->ir->CreateInsertValue(res, V1, 0, "tmp"); 808 res = gIR->ir->CreateInsertValue(res, V1, 0, "tmp");
807 return gIR->ir->CreateInsertValue(res, V2, 1, name?name:"tmp"); 809 return gIR->ir->CreateInsertValue(res, V2, 1, name?name:"tmp");
808 } 810 }
811
812 LLValue* DtoAggrPair(LLValue* V1, LLValue* V2, const char* name)
813 {
814 const LLType* t = LLStructType::get(V1->getType(), V2->getType(), 0);
815 return DtoAggrPair(t, V1, V2, name);
816 }
817
818 LLValue* DtoAggrPaint(LLValue* aggr, const LLType* as)
819 {
820 if (aggr->getType() == as)
821 return aggr;
822
823 LLValue* res = llvm::UndefValue::get(as);
824
825 LLValue* V = gIR->ir->CreateExtractValue(aggr, 0, "tmp");;
826 V = DtoBitCast(V, as->getContainedType(0));
827 res = gIR->ir->CreateInsertValue(res, V, 0, "tmp");
828
829 V = gIR->ir->CreateExtractValue(aggr, 1, "tmp");;
830 V = DtoBitCast(V, as->getContainedType(1));
831 return gIR->ir->CreateInsertValue(res, V, 1, "tmp");
832 }