Mercurial > projects > ldc
comparison gen/tollvm.cpp @ 516:eada571dc8ff
Fix delegate equality.
Fixes:
mini/delegate.d
run/d/delegate_17_A
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 16 Aug 2008 10:48:25 +0200 |
parents | a34078905d01 |
children | 7e2867ed70d9 |
comparison
equal
deleted
inserted
replaced
515:e739ef5dfff0 | 516:eada571dc8ff |
---|---|
203 ////////////////////////////////////////////////////////////////////////////////////////// | 203 ////////////////////////////////////////////////////////////////////////////////////////// |
204 | 204 |
205 LLValue* DtoDelegateEquals(TOK op, LLValue* lhs, LLValue* rhs) | 205 LLValue* DtoDelegateEquals(TOK op, LLValue* lhs, LLValue* rhs) |
206 { | 206 { |
207 Logger::println("Doing delegate equality"); | 207 Logger::println("Doing delegate equality"); |
208 llvm::ICmpInst::Predicate pred = (op == TOKequal || op == TOKidentity) ? llvm::ICmpInst::ICMP_EQ : llvm::ICmpInst::ICMP_NE; | |
209 llvm::Value *b1, *b2; | 208 llvm::Value *b1, *b2; |
210 if (rhs == NULL) | 209 if (rhs == NULL) |
211 { | 210 { |
212 LLValue* l = DtoLoad(DtoGEPi(lhs,0,0)); | 211 LLValue* l = DtoLoad(DtoGEPi(lhs,0,0)); |
213 LLValue* r = llvm::Constant::getNullValue(l->getType()); | 212 LLValue* r = llvm::Constant::getNullValue(l->getType()); |
214 b1 = gIR->ir->CreateICmp(pred,l,r,"tmp"); | 213 b1 = gIR->ir->CreateICmp(llvm::ICmpInst::ICMP_EQ,l,r,"tmp"); |
215 l = DtoLoad(DtoGEPi(lhs,0,1)); | 214 l = DtoLoad(DtoGEPi(lhs,0,1)); |
216 r = llvm::Constant::getNullValue(l->getType()); | 215 r = llvm::Constant::getNullValue(l->getType()); |
217 b2 = gIR->ir->CreateICmp(pred,l,r,"tmp"); | 216 b2 = gIR->ir->CreateICmp(llvm::ICmpInst::ICMP_EQ,l,r,"tmp"); |
218 } | 217 } |
219 else | 218 else |
220 { | 219 { |
221 LLValue* l = DtoLoad(DtoGEPi(lhs,0,0)); | 220 LLValue* l = DtoLoad(DtoGEPi(lhs,0,0)); |
222 LLValue* r = DtoLoad(DtoGEPi(rhs,0,0)); | 221 LLValue* r = DtoLoad(DtoGEPi(rhs,0,0)); |
223 b1 = gIR->ir->CreateICmp(pred,l,r,"tmp"); | 222 b1 = gIR->ir->CreateICmp(llvm::ICmpInst::ICMP_EQ,l,r,"tmp"); |
224 l = DtoLoad(DtoGEPi(lhs,0,1)); | 223 l = DtoLoad(DtoGEPi(lhs,0,1)); |
225 r = DtoLoad(DtoGEPi(rhs,0,1)); | 224 r = DtoLoad(DtoGEPi(rhs,0,1)); |
226 b2 = gIR->ir->CreateICmp(pred,l,r,"tmp"); | 225 b2 = gIR->ir->CreateICmp(llvm::ICmpInst::ICMP_EQ,l,r,"tmp"); |
227 } | 226 } |
228 LLValue* b = gIR->ir->CreateAnd(b1,b2,"tmp"); | 227 LLValue* b = gIR->ir->CreateAnd(b1,b2,"tmp"); |
229 if (op == TOKnotequal || op == TOKnotidentity) | 228 if (op == TOKnotequal || op == TOKnotidentity) |
230 return gIR->ir->CreateNot(b,"tmp"); | 229 return gIR->ir->CreateNot(b,"tmp"); |
231 return b; | 230 return b; |