LLValue *DtoComplexEquals(Loc &loc, TOK op, DValue *lhs, DValue *rhs) { DValue *lhs_re, *lhs_im, *rhs_re, *rhs_im; // lhs values DtoGetComplexParts(loc, lhs->type, lhs, lhs_re, lhs_im); // rhs values DtoGetComplexParts(loc, lhs->type, rhs, rhs_re, rhs_im); // (l.re==r.re && l.im==r.im) or (l.re!=r.re || l.im!=r.im) LLValue *b1 = DtoBinFloatsEquals(loc, lhs_re, rhs_re, op); LLValue *b2 = DtoBinFloatsEquals(loc, lhs_im, rhs_im, op); if (op == TOKequal) { return gIR->ir->CreateAnd(b1, b2); } return gIR->ir->CreateOr(b1, b2); }
LLValue *DtoBinNumericEquals(Loc &loc, DValue *lhs, DValue *rhs, TOK op) { assert(op == TOKequal || op == TOKnotequal || op == TOKidentity || op == TOKnotidentity); Type *t = lhs->type->toBasetype(); assert(t->isfloating()); Logger::println("numeric equality"); LLValue *res = nullptr; if (t->iscomplex()) { Logger::println("complex"); res = DtoComplexEquals(loc, op, lhs, rhs); } else if (t->isfloating()) { Logger::println("floating"); res = DtoBinFloatsEquals(loc, lhs, rhs, op); } assert(res); return res; }