Mercurial > projects > ldc
comparison gen/toir.cpp @ 616:5ced42a55aa9
Fix NegExp not to use substraction.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sun, 21 Sep 2008 19:28:57 +0200 |
parents | 83ca663ecc20 |
children | 722630261d62 |
comparison
equal
deleted
inserted
replaced
615:c60e122f4ada | 616:5ced42a55aa9 |
---|---|
2022 if (type->iscomplex()) { | 2022 if (type->iscomplex()) { |
2023 return DtoComplexNeg(loc, type, l); | 2023 return DtoComplexNeg(loc, type, l); |
2024 } | 2024 } |
2025 | 2025 |
2026 LLValue* val = l->getRVal(); | 2026 LLValue* val = l->getRVal(); |
2027 Type* t = type->toBasetype(); | 2027 |
2028 | 2028 val = gIR->ir->CreateNeg(val,"negval"); |
2029 LLValue* zero = 0; | |
2030 if (t->isintegral()) | |
2031 zero = llvm::ConstantInt::get(val->getType(), 0, true); | |
2032 else if (t->isfloating()) { | |
2033 zero = DtoConstFP(type, 0.0); | |
2034 } | |
2035 else | |
2036 assert(0); | |
2037 | |
2038 val = llvm::BinaryOperator::createSub(zero,val,"tmp",p->scopebb()); | |
2039 return new DImValue(type, val); | 2029 return new DImValue(type, val); |
2040 } | 2030 } |
2041 | 2031 |
2042 ////////////////////////////////////////////////////////////////////////////////////////// | 2032 ////////////////////////////////////////////////////////////////////////////////////////// |
2043 | 2033 |