Mercurial > projects > ldc
comparison gen/binops.cpp @ 524:ca2dfe98036c
Binary ops had the wrong result type for real op imaginary.
Fixes:
run/creal_03
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sun, 17 Aug 2008 12:21:53 +0200 |
parents | a95056b3c996 |
children | cc5fee7836dc |
comparison
equal
deleted
inserted
replaced
523:c9a606d6e641 | 524:ca2dfe98036c |
---|---|
22 return new DImValue( lhs->getType(), v ); | 22 return new DImValue( lhs->getType(), v ); |
23 } | 23 } |
24 | 24 |
25 ////////////////////////////////////////////////////////////////////////////// | 25 ////////////////////////////////////////////////////////////////////////////// |
26 | 26 |
27 DValue* DtoBinMul(DValue* lhs, DValue* rhs) | 27 DValue* DtoBinMul(Type* targettype, DValue* lhs, DValue* rhs) |
28 { | 28 { |
29 LLValue* v = gIR->ir->CreateMul(lhs->getRVal(), rhs->getRVal(), "tmp"); | 29 LLValue* v = gIR->ir->CreateMul(lhs->getRVal(), rhs->getRVal(), "tmp"); |
30 return new DImValue( lhs->getType(), v ); | 30 return new DImValue( targettype, v ); |
31 } | 31 } |
32 | 32 |
33 ////////////////////////////////////////////////////////////////////////////// | 33 ////////////////////////////////////////////////////////////////////////////// |
34 | 34 |
35 DValue* DtoBinDiv(DValue* lhs, DValue* rhs) | 35 DValue* DtoBinDiv(Type* targettype, DValue* lhs, DValue* rhs) |
36 { | 36 { |
37 Type* t = lhs->getType(); | 37 Type* t = lhs->getType(); |
38 LLValue *l, *r; | 38 LLValue *l, *r; |
39 l = lhs->getRVal(); | 39 l = lhs->getRVal(); |
40 r = rhs->getRVal(); | 40 r = rhs->getRVal(); |
43 res = gIR->ir->CreateFDiv(l, r, "tmp"); | 43 res = gIR->ir->CreateFDiv(l, r, "tmp"); |
44 else if (!t->isunsigned()) | 44 else if (!t->isunsigned()) |
45 res = gIR->ir->CreateSDiv(l, r, "tmp"); | 45 res = gIR->ir->CreateSDiv(l, r, "tmp"); |
46 else | 46 else |
47 res = gIR->ir->CreateUDiv(l, r, "tmp"); | 47 res = gIR->ir->CreateUDiv(l, r, "tmp"); |
48 return new DImValue( lhs->getType(), res ); | 48 return new DImValue( targettype, res ); |
49 } | 49 } |
50 | 50 |
51 ////////////////////////////////////////////////////////////////////////////// | 51 ////////////////////////////////////////////////////////////////////////////// |
52 | 52 |
53 DValue* DtoBinRem(DValue* lhs, DValue* rhs) | 53 DValue* DtoBinRem(Type* targettype, DValue* lhs, DValue* rhs) |
54 { | 54 { |
55 Type* t = lhs->getType(); | 55 Type* t = lhs->getType(); |
56 LLValue *l, *r; | 56 LLValue *l, *r; |
57 l = lhs->getRVal(); | 57 l = lhs->getRVal(); |
58 r = rhs->getRVal(); | 58 r = rhs->getRVal(); |
61 res = gIR->ir->CreateFRem(l, r, "tmp"); | 61 res = gIR->ir->CreateFRem(l, r, "tmp"); |
62 else if (!t->isunsigned()) | 62 else if (!t->isunsigned()) |
63 res = gIR->ir->CreateSRem(l, r, "tmp"); | 63 res = gIR->ir->CreateSRem(l, r, "tmp"); |
64 else | 64 else |
65 res = gIR->ir->CreateURem(l, r, "tmp"); | 65 res = gIR->ir->CreateURem(l, r, "tmp"); |
66 return new DImValue( lhs->getType(), res ); | 66 return new DImValue( targettype, res ); |
67 } | 67 } |