comparison gen/toir.cpp @ 704:43165a082535

Fixed issue with accessing a WithStatement context from inside a nested function. see mini/with2.d Renamed some LLVM uses of ::create statics to ::Create , lower case ones will be deprecated soon.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Tue, 14 Oct 2008 13:21:14 +0200
parents 06576ece1a1b
children 5a2983f97498
comparison
equal deleted inserted replaced
703:06576ece1a1b 704:43165a082535
618 DValue* res; 618 DValue* res;
619 if (e1->type->toBasetype()->ty == Tpointer) { 619 if (e1->type->toBasetype()->ty == Tpointer) {
620 Logger::println("ptr"); 620 Logger::println("ptr");
621 LLValue* tmp = r->getRVal(); 621 LLValue* tmp = r->getRVal();
622 LLValue* zero = llvm::ConstantInt::get(tmp->getType(),0,false); 622 LLValue* zero = llvm::ConstantInt::get(tmp->getType(),0,false);
623 tmp = llvm::BinaryOperator::createSub(zero,tmp,"tmp",p->scopebb()); 623 tmp = llvm::BinaryOperator::CreateSub(zero,tmp,"tmp",p->scopebb());
624 tmp = llvm::GetElementPtrInst::Create(l->getRVal(),tmp,"tmp",p->scopebb()); 624 tmp = llvm::GetElementPtrInst::Create(l->getRVal(),tmp,"tmp",p->scopebb());
625 res = new DImValue(type, tmp); 625 res = new DImValue(type, tmp);
626 } 626 }
627 else if (t->iscomplex()) { 627 else if (t->iscomplex()) {
628 Logger::println("complex"); 628 Logger::println("complex");
1410 if (e1type->isintegral()) 1410 if (e1type->isintegral())
1411 { 1411 {
1412 assert(e2type->isintegral()); 1412 assert(e2type->isintegral());
1413 LLValue* one = llvm::ConstantInt::get(val->getType(), 1, !e2type->isunsigned()); 1413 LLValue* one = llvm::ConstantInt::get(val->getType(), 1, !e2type->isunsigned());
1414 if (op == TOKplusplus) { 1414 if (op == TOKplusplus) {
1415 post = llvm::BinaryOperator::createAdd(val,one,"tmp",p->scopebb()); 1415 post = llvm::BinaryOperator::CreateAdd(val,one,"tmp",p->scopebb());
1416 } 1416 }
1417 else if (op == TOKminusminus) { 1417 else if (op == TOKminusminus) {
1418 post = llvm::BinaryOperator::createSub(val,one,"tmp",p->scopebb()); 1418 post = llvm::BinaryOperator::CreateSub(val,one,"tmp",p->scopebb());
1419 } 1419 }
1420 } 1420 }
1421 else if (e1type->ty == Tpointer) 1421 else if (e1type->ty == Tpointer)
1422 { 1422 {
1423 assert(e2type->isintegral()); 1423 assert(e2type->isintegral());
1429 else if (e1type->isfloating()) 1429 else if (e1type->isfloating())
1430 { 1430 {
1431 assert(e2type->isfloating()); 1431 assert(e2type->isfloating());
1432 LLValue* one = DtoConstFP(e1type, 1.0); 1432 LLValue* one = DtoConstFP(e1type, 1.0);
1433 if (op == TOKplusplus) { 1433 if (op == TOKplusplus) {
1434 post = llvm::BinaryOperator::createAdd(val,one,"tmp",p->scopebb()); 1434 post = llvm::BinaryOperator::CreateAdd(val,one,"tmp",p->scopebb());
1435 } 1435 }
1436 else if (op == TOKminusminus) { 1436 else if (op == TOKminusminus) {
1437 post = llvm::BinaryOperator::createSub(val,one,"tmp",p->scopebb()); 1437 post = llvm::BinaryOperator::CreateSub(val,one,"tmp",p->scopebb());
1438 } 1438 }
1439 } 1439 }
1440 else 1440 else
1441 assert(post); 1441 assert(post);
1442 1442
1698 1698
1699 p->scope() = IRScope(andand, andandend); 1699 p->scope() = IRScope(andand, andandend);
1700 DValue* v = e2->toElem(p); 1700 DValue* v = e2->toElem(p);
1701 1701
1702 LLValue* vbool = DtoBoolean(loc, v); 1702 LLValue* vbool = DtoBoolean(loc, v);
1703 LLValue* uandvbool = llvm::BinaryOperator::create(llvm::BinaryOperator::And, ubool, vbool,"tmp",p->scopebb()); 1703 LLValue* uandvbool = llvm::BinaryOperator::Create(llvm::BinaryOperator::And, ubool, vbool,"tmp",p->scopebb());
1704 DtoStore(uandvbool,resval); 1704 DtoStore(uandvbool,resval);
1705 llvm::BranchInst::Create(andandend,p->scopebb()); 1705 llvm::BranchInst::Create(andandend,p->scopebb());
1706 1706
1707 p->scope() = IRScope(andandend, oldend); 1707 p->scope() = IRScope(andandend, oldend);
1708 1708
1752 { \ 1752 { \
1753 Logger::print("%sExp::toElem: %s | %s\n", #X, toChars(), type->toChars()); \ 1753 Logger::print("%sExp::toElem: %s | %s\n", #X, toChars(), type->toChars()); \
1754 LOG_SCOPE; \ 1754 LOG_SCOPE; \
1755 DValue* u = e1->toElem(p); \ 1755 DValue* u = e1->toElem(p); \
1756 DValue* v = e2->toElem(p); \ 1756 DValue* v = e2->toElem(p); \
1757 LLValue* x = llvm::BinaryOperator::create(llvm::Instruction::Y, u->getRVal(), v->getRVal(), "tmp", p->scopebb()); \ 1757 LLValue* x = llvm::BinaryOperator::Create(llvm::Instruction::Y, u->getRVal(), v->getRVal(), "tmp", p->scopebb()); \
1758 return new DImValue(type, x); \ 1758 return new DImValue(type, x); \
1759 } \ 1759 } \
1760 \ 1760 \
1761 DValue* X##AssignExp::toElem(IRState* p) \ 1761 DValue* X##AssignExp::toElem(IRState* p) \
1762 { \ 1762 { \
1764 LOG_SCOPE; \ 1764 LOG_SCOPE; \
1765 DValue* u = e1->toElem(p); \ 1765 DValue* u = e1->toElem(p); \
1766 DValue* v = e2->toElem(p); \ 1766 DValue* v = e2->toElem(p); \
1767 LLValue* uval = u->getRVal(); \ 1767 LLValue* uval = u->getRVal(); \
1768 LLValue* vval = v->getRVal(); \ 1768 LLValue* vval = v->getRVal(); \
1769 LLValue* tmp = llvm::BinaryOperator::create(llvm::Instruction::Y, uval, vval, "tmp", p->scopebb()); \ 1769 LLValue* tmp = llvm::BinaryOperator::Create(llvm::Instruction::Y, uval, vval, "tmp", p->scopebb()); \
1770 DtoStore(DtoPointedType(u->getLVal(), tmp), u->getLVal()); \ 1770 DtoStore(DtoPointedType(u->getLVal(), tmp), u->getLVal()); \
1771 return u; \ 1771 return u; \
1772 } 1772 }
1773 1773
1774 BinBitExp(And,And); 1774 BinBitExp(And,And);
2020 2020
2021 DValue* u = e1->toElem(p); 2021 DValue* u = e1->toElem(p);
2022 2022
2023 LLValue* value = u->getRVal(); 2023 LLValue* value = u->getRVal();
2024 LLValue* minusone = llvm::ConstantInt::get(value->getType(), -1, true); 2024 LLValue* minusone = llvm::ConstantInt::get(value->getType(), -1, true);
2025 value = llvm::BinaryOperator::create(llvm::Instruction::Xor, value, minusone, "tmp", p->scopebb()); 2025 value = llvm::BinaryOperator::Create(llvm::Instruction::Xor, value, minusone, "tmp", p->scopebb());
2026 2026
2027 return new DImValue(type, value); 2027 return new DImValue(type, value);
2028 } 2028 }
2029 2029
2030 ////////////////////////////////////////////////////////////////////////////////////////// 2030 //////////////////////////////////////////////////////////////////////////////////////////