comparison gen/arrays.cpp @ 162:1856c62af24b trunk

[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
author lindquist
date Mon, 05 May 2008 00:56:53 +0200
parents 5c17f81fc1c1
children a8cd9bc1021a
comparison
equal deleted inserted replaced
161:3a891cfcd249 162:1856c62af24b
601 ////////////////////////////////////////////////////////////////////////////////////////// 601 //////////////////////////////////////////////////////////////////////////////////////////
602 void DtoCatArrayElement(llvm::Value* arr, Expression* exp1, Expression* exp2) 602 void DtoCatArrayElement(llvm::Value* arr, Expression* exp1, Expression* exp2)
603 { 603 {
604 Type* t1 = DtoDType(exp1->type); 604 Type* t1 = DtoDType(exp1->type);
605 Type* t2 = DtoDType(exp2->type); 605 Type* t2 = DtoDType(exp2->type);
606
607 // handle reverse case
608 if (t2->next && t1 == DtoDType(t2->next))
609 {
610 Type* tmp = t1;
611 t1 = t2;
612 t2 = tmp;
613 Expression* e = exp1;
614 exp1 = exp2;
615 exp2 = e;
616 }
606 617
607 assert(t1->ty == Tarray); 618 assert(t1->ty == Tarray);
608 assert(t2 == DtoDType(t1->next)); 619 assert(t2 == DtoDType(t1->next));
609 620
610 DValue* e1 = exp1->toElem(gIR); 621 DValue* e1 = exp1->toElem(gIR);
776 { 787 {
777 llvm::ICmpInst::Predicate pred = (op == TOKidentity) ? llvm::ICmpInst::ICMP_EQ : llvm::ICmpInst::ICMP_NE; 788 llvm::ICmpInst::Predicate pred = (op == TOKidentity) ? llvm::ICmpInst::ICMP_EQ : llvm::ICmpInst::ICMP_NE;
778 789
779 if (r == NULL) { 790 if (r == NULL) {
780 llvm::Value* ll = gIR->ir->CreateLoad(DtoGEPi(l, 0,0, "tmp"),"tmp"); 791 llvm::Value* ll = gIR->ir->CreateLoad(DtoGEPi(l, 0,0, "tmp"),"tmp");
781 llvm::Value* rl = DtoConstSize_t(0); 792 llvm::Value* rl = llvm::Constant::getNullValue(ll->getType());//DtoConstSize_t(0);
782 llvm::Value* b1 = gIR->ir->CreateICmp(pred,ll,rl,"tmp"); 793 llvm::Value* b1 = gIR->ir->CreateICmp(pred,ll,rl,"tmp");
783 794
784 llvm::Value* lp = gIR->ir->CreateLoad(DtoGEPi(l, 0,1, "tmp"),"tmp"); 795 llvm::Value* lp = gIR->ir->CreateLoad(DtoGEPi(l, 0,1, "tmp"),"tmp");
785 const llvm::PointerType* pty = isaPointer(lp->getType()); 796 const llvm::PointerType* pty = isaPointer(lp->getType());
786 llvm::Value* rp = llvm::ConstantPointerNull::get(pty); 797 llvm::Value* rp = llvm::ConstantPointerNull::get(pty);