mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-23 08:13:13 +01:00
Made is and !is use the same numeric comparison as == and !=, fixes #328
Factored out common code from EqualExp and IdentityExp into DtoBinNumericEquals in binexp.cpp.
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#include "gen/irstate.h"
|
||||
#include "gen/tollvm.h"
|
||||
#include "gen/dvalue.h"
|
||||
#include "gen/logger.h"
|
||||
#include "gen/complex.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -65,3 +67,34 @@ DValue* DtoBinRem(Type* targettype, DValue* lhs, DValue* rhs)
|
||||
res = gIR->ir->CreateURem(l, r, "tmp");
|
||||
return new DImValue( targettype, res );
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LLValue* DtoBinNumericEquals(Loc loc, DValue* lhs, DValue* rhs, TOK op)
|
||||
{
|
||||
assert(op == TOKequal || op == TOKnotequal ||
|
||||
op == TOKidentity || op == TOKnotidentity);
|
||||
Type* t = lhs->getType()->toBasetype();
|
||||
assert(t->isfloating());
|
||||
Logger::println("numeric equality");
|
||||
|
||||
LLValue* lv = lhs->getRVal();
|
||||
LLValue* rv = rhs->getRVal();
|
||||
LLValue* res = 0;
|
||||
|
||||
if (t->iscomplex())
|
||||
{
|
||||
Logger::println("complex");
|
||||
res = DtoComplexEquals(loc, op, lhs, rhs);
|
||||
}
|
||||
else if (t->isfloating())
|
||||
{
|
||||
Logger::println("floating");
|
||||
res = (op == TOKidentity || op == TOKequal)
|
||||
? gIR->ir->CreateFCmpOEQ(lv,rv,"tmp")
|
||||
: gIR->ir->CreateFCmpUNE(lv,rv,"tmp");
|
||||
}
|
||||
|
||||
assert(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user