annotate gen/binops.cpp @ 270:d9d5d59873d8 trunk

[svn r291] Fixed a bunch of the old Phobos tests to work with Tango. Branch statements now emit a new block after it. Fixed the _adSort runtime function had a bad signature. Added a missing dot prefix on compiler generated string tables for string switch. Fixed, PTRSIZE seems like it was wrong on 64bit, now it definitely gets set properly.
author lindquist
date Mon, 16 Jun 2008 16:01:19 +0200
parents a95056b3c996
children ca2dfe98036c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
1 #include "gen/llvm.h"
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
2
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
3 #include "declaration.h"
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
4
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
5 #include "gen/irstate.h"
104
4d1e9eb001e0 [svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents: 86
diff changeset
6 #include "gen/tollvm.h"
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
7 #include "gen/dvalue.h"
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
8
104
4d1e9eb001e0 [svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents: 86
diff changeset
9 //////////////////////////////////////////////////////////////////////////////
4d1e9eb001e0 [svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents: 86
diff changeset
10
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
11 DValue* DtoBinAdd(DValue* lhs, DValue* rhs)
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
12 {
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 104
diff changeset
13 LLValue* v = gIR->ir->CreateAdd(lhs->getRVal(), rhs->getRVal(), "tmp");
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
14 return new DImValue( lhs->getType(), v );
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
15 }
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
16
104
4d1e9eb001e0 [svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents: 86
diff changeset
17 //////////////////////////////////////////////////////////////////////////////
4d1e9eb001e0 [svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents: 86
diff changeset
18
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
19 DValue* DtoBinSub(DValue* lhs, DValue* rhs)
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
20 {
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 104
diff changeset
21 LLValue* v = gIR->ir->CreateSub(lhs->getRVal(), rhs->getRVal(), "tmp");
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
22 return new DImValue( lhs->getType(), v );
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
23 }
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
24
104
4d1e9eb001e0 [svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents: 86
diff changeset
25 //////////////////////////////////////////////////////////////////////////////
4d1e9eb001e0 [svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents: 86
diff changeset
26
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
27 DValue* DtoBinMul(DValue* lhs, DValue* rhs)
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
28 {
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 104
diff changeset
29 LLValue* v = gIR->ir->CreateMul(lhs->getRVal(), rhs->getRVal(), "tmp");
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
30 return new DImValue( lhs->getType(), v );
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
31 }
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
32
104
4d1e9eb001e0 [svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents: 86
diff changeset
33 //////////////////////////////////////////////////////////////////////////////
4d1e9eb001e0 [svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents: 86
diff changeset
34
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
35 DValue* DtoBinDiv(DValue* lhs, DValue* rhs)
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
36 {
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
37 Type* t = lhs->getType();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 213
diff changeset
38 LLValue *l, *r;
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
39 l = lhs->getRVal();
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
40 r = rhs->getRVal();
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 104
diff changeset
41 LLValue* res;
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
42 if (t->isfloating())
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
43 res = gIR->ir->CreateFDiv(l, r, "tmp");
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
44 else if (!t->isunsigned())
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
45 res = gIR->ir->CreateSDiv(l, r, "tmp");
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
46 else
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
47 res = gIR->ir->CreateUDiv(l, r, "tmp");
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
48 return new DImValue( lhs->getType(), res );
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
49 }
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
50
104
4d1e9eb001e0 [svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents: 86
diff changeset
51 //////////////////////////////////////////////////////////////////////////////
4d1e9eb001e0 [svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents: 86
diff changeset
52
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
53 DValue* DtoBinRem(DValue* lhs, DValue* rhs)
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
54 {
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
55 Type* t = lhs->getType();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 213
diff changeset
56 LLValue *l, *r;
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
57 l = lhs->getRVal();
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
58 r = rhs->getRVal();
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 104
diff changeset
59 LLValue* res;
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
60 if (t->isfloating())
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
61 res = gIR->ir->CreateFRem(l, r, "tmp");
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
62 else if (!t->isunsigned())
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
63 res = gIR->ir->CreateSRem(l, r, "tmp");
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
64 else
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
65 res = gIR->ir->CreateURem(l, r, "tmp");
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
66 return new DImValue( lhs->getType(), res );
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
diff changeset
67 }