comparison gen/dvalue.cpp @ 585:fbb1a366cfbc

Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Tue, 09 Sep 2008 16:49:47 -0700
parents 45a67b6f1310
children 03a5e609eef3
comparison
equal deleted inserted replaced
584:c7d7e2282ba3 585:fbb1a366cfbc
2 2
3 #include "gen/tollvm.h" 3 #include "gen/tollvm.h"
4 #include "gen/irstate.h" 4 #include "gen/irstate.h"
5 #include "gen/logger.h" 5 #include "gen/logger.h"
6 #include "gen/dvalue.h" 6 #include "gen/dvalue.h"
7 #include "gen/llvmhelpers.h"
7 8
8 #include "declaration.h" 9 #include "declaration.h"
9 10
10 ///////////////////////////////////////////////////////////////////////////////////////////////// 11 /////////////////////////////////////////////////////////////////////////////////////////////////
11 ///////////////////////////////////////////////////////////////////////////////////////////////// 12 /////////////////////////////////////////////////////////////////////////////////////////////////
12 13
13 DVarValue::DVarValue(Type* t, VarDeclaration* vd, LLValue* llvmValue, bool lvalue) 14 DVarValue::DVarValue(Type* t, VarDeclaration* vd, LLValue* llvmValue)
14 { 15 {
15 var = vd; 16 var = vd;
16 val = llvmValue; 17 val = llvmValue;
17 rval = 0;
18 lval = lvalue;
19 type = t; 18 type = t;
20 } 19 }
21 20
22 DVarValue::DVarValue(Type* t, LLValue* lv, LLValue* rv) 21 DVarValue::DVarValue(Type* t, LLValue* llvmValue)
23 {
24 var = 0;
25 val = lv;
26 rval = rv;
27 lval = true;
28 type = t;
29 }
30
31 DVarValue::DVarValue(Type* t, LLValue* llvmValue, bool lvalue)
32 { 22 {
33 var = 0; 23 var = 0;
34 val = llvmValue; 24 val = llvmValue;
35 rval = 0;
36 lval = lvalue;
37 type = t; 25 type = t;
38 } 26 }
39 27
40 LLValue* DVarValue::getLVal() 28 LLValue* DVarValue::getLVal()
41 { 29 {
42 assert(val && lval); 30 assert(val);
43 return val; 31 return val;
44 } 32 }
45 33
46 LLValue* DVarValue::getRVal() 34 LLValue* DVarValue::getRVal()
47 { 35 {
48 assert(rval || val); 36 assert(val);
49 if (DtoIsPassedByRef(type)) { 37 Type* bt = type->toBasetype();
50 if (rval) return rval; 38 if (DtoIsPassedByRef(bt))
51 return val; 39 return val;
52 } 40 return DtoLoad(val);
53 else {
54 if (rval) return rval;
55 //Logger::cout() << "val: " << *val << '\n';
56 if (!isField() && DtoCanLoad(val)) {
57 return DtoLoad(val);
58 }
59 return val;
60 }
61 } 41 }
62 42
63 ///////////////////////////////////////////////////////////////////////////////////////////////// 43 /////////////////////////////////////////////////////////////////////////////////////////////////
64 ///////////////////////////////////////////////////////////////////////////////////////////////// 44 /////////////////////////////////////////////////////////////////////////////////////////////////
65 45