annotate gen/dvalue.h @ 1638:0de4525a9ed6

Apply workaround for #395 by klickverbot.
author Christian Kamm <kamm incasoftware de>
date Mon, 08 Mar 2010 20:06:08 +0100
parents a5bfed1f6775
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
664
eef8ac26c66c Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents: 601
diff changeset
1 #ifndef LDC_GEN_DVALUE_H
eef8ac26c66c Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents: 601
diff changeset
2 #define LDC_GEN_DVALUE_H
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
3
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
4 /*
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
5 These classes are used for generating the IR. They encapsulate D values and
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
6 provide a common interface to the most common operations. When more specialized
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
7 handling is necessary, they hold enough information to do-the-right-thing (TM)
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
8 */
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
9
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
10 #include <cassert>
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
11 #include "root.h"
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
12
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
13 struct Type;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
14 struct Dsymbol;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
15 struct VarDeclaration;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
16 struct FuncDeclaration;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
17
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
18 namespace llvm
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
19 {
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
20 class Value;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
21 class Type;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
22 class Constant;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
23 }
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
24
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
25 struct DImValue;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
26 struct DConstValue;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
27 struct DNullValue;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
28 struct DVarValue;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
29 struct DFieldValue;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
30 struct DFuncValue;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
31 struct DSliceValue;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
32
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
33 // base class for d-values
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
34 struct DValue : Object
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
35 {
1180
f5729209a1d4 Remove some redundancy from the DValue hierarchy: all subclasses had a 'type'
Frits van Bommel <fvbommel wxs.nl>
parents: 1151
diff changeset
36 Type* type;
f5729209a1d4 Remove some redundancy from the DValue hierarchy: all subclasses had a 'type'
Frits van Bommel <fvbommel wxs.nl>
parents: 1151
diff changeset
37 DValue(Type* ty) : type(ty) {}
f5729209a1d4 Remove some redundancy from the DValue hierarchy: all subclasses had a 'type'
Frits van Bommel <fvbommel wxs.nl>
parents: 1151
diff changeset
38
f5729209a1d4 Remove some redundancy from the DValue hierarchy: all subclasses had a 'type'
Frits van Bommel <fvbommel wxs.nl>
parents: 1151
diff changeset
39 Type*& getType() { assert(type); return type; }
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
40
1206
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
41 virtual llvm::Value* getLVal() { assert(0); return 0; }
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
42 virtual llvm::Value* getRVal() { assert(0); return 0; }
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
43
334
20446d22f832 [svn r355] Get rid of IRState::exps and topexp.
ChristianK
parents: 213
diff changeset
44 virtual bool isLVal() { return false; }
20446d22f832 [svn r355] Get rid of IRState::exps and topexp.
ChristianK
parents: 213
diff changeset
45
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
46 virtual DImValue* isIm() { return NULL; }
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
47 virtual DConstValue* isConst() { return NULL; }
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
48 virtual DNullValue* isNull() { return NULL; }
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
49 virtual DVarValue* isVar() { return NULL; }
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
50 virtual DFieldValue* isField() { return NULL; }
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
51 virtual DSliceValue* isSlice() { return NULL; }
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
52 virtual DFuncValue* isFunc() { return NULL; }
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
53
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
54 protected:
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
55 DValue() {}
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
56 DValue(const DValue&) { }
1180
f5729209a1d4 Remove some redundancy from the DValue hierarchy: all subclasses had a 'type'
Frits van Bommel <fvbommel wxs.nl>
parents: 1151
diff changeset
57 DValue& operator=(const DValue& other) { type = other.type; return *this; }
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
58 };
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
59
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
60 // immediate d-value
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
61 struct DImValue : DValue
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
62 {
1206
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
63 llvm::Value* val;
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
64
1206
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
65 DImValue(Type* t, llvm::Value* v) : DValue(t), val(v) { }
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
66
1206
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
67 virtual llvm::Value* getRVal() { assert(val); return val; }
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
68
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
69 virtual DImValue* isIm() { return this; }
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
70 };
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
71
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
72 // constant d-value
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
73 struct DConstValue : DValue
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
74 {
1206
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
75 llvm::Constant* c;
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
76
1206
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
77 DConstValue(Type* t, llvm::Constant* con) : DValue(t), c(con) {}
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
78
1206
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
79 virtual llvm::Value* getRVal();
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
80
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
81 virtual DConstValue* isConst() { return this; }
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
82 };
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
83
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
84 // null d-value
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
85 struct DNullValue : DConstValue
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
86 {
1206
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
87 DNullValue(Type* t, llvm::Constant* con) : DConstValue(t,con) {}
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
88 virtual DNullValue* isNull() { return this; }
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
89 };
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
90
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
91 // variable d-value
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
92 struct DVarValue : DValue
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
93 {
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
94 VarDeclaration* var;
1206
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
95 llvm::Value* val;
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
96
1206
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
97 DVarValue(Type* t, VarDeclaration* vd, llvm::Value* llvmValue);
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
98 DVarValue(Type* t, llvm::Value* llvmValue);
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
99
585
fbb1a366cfbc Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
100 virtual bool isLVal() { return true; }
1206
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
101 virtual llvm::Value* getLVal();
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
102 virtual llvm::Value* getRVal();
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
103
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
104 virtual DVarValue* isVar() { return this; }
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
105 };
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
106
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
107 // field d-value
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
108 struct DFieldValue : DVarValue
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
109 {
1206
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
110 DFieldValue(Type* t, llvm::Value* llvmValue) : DVarValue(t, llvmValue) {}
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
111 virtual DFieldValue* isField() { return this; }
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
112 };
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
113
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
114 // slice d-value
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
115 struct DSliceValue : DValue
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
116 {
1206
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
117 llvm::Value* len;
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
118 llvm::Value* ptr;
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
119
1206
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
120 DSliceValue(Type* t, llvm::Value* l, llvm::Value* p) : DValue(t), len(l), ptr(p) {}
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
121
1206
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
122 virtual llvm::Value* getRVal();
715
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 664
diff changeset
123
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
124 virtual DSliceValue* isSlice() { return this; }
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
125 };
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
126
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
127 // function d-value
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
128 struct DFuncValue : DValue
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
129 {
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
130 FuncDeclaration* func;
1206
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
131 llvm::Value* val;
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
132 llvm::Value* vthis;
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
133
1206
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
134 DFuncValue(FuncDeclaration* fd, llvm::Value* v, llvm::Value* vt = 0);
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
135
1206
a5bfed1f6775 Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents: 1180
diff changeset
136 virtual llvm::Value* getRVal();
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
137
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
138 virtual DFuncValue* isFunc() { return this; }
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
139 };
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
140
664
eef8ac26c66c Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents: 601
diff changeset
141 #endif // LDC_GEN_DVALUE_H