Mercurial > projects > ldc
annotate gen/aa.cpp @ 715:30b42a283c8e
Removed TypeOpaque from DMD.
Changed runtime functions taking opaque[] to void[].
Implemented proper type painting, to avoid "resizing" array casts in runtime calls that previously took opaque[].
Implemented dynamic arrays as first class types, this implements proper ABI for these types on x86.
Added dwarf region end after call to assert function, fixes some problems with llvm not allowing this to be missing.
Reverted change to WithStatement from rev [704] it breaks MiniD, mini/with2.d needs to be fixed some other way...
Fixed tango bug 1339 in runtime, problem with _adReverseChar on invalid UTF-8.
Disabled .bc generation in the compiler runtime part, genobj.d triggers some llvm bug when using debug info. the .o seems to work fine.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Wed, 22 Oct 2008 14:55:33 +0200 |
parents | 26fce59fe80a |
children | 03d7c4aac654 |
rev | line source |
---|---|
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
1 #include "gen/llvm.h" |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
2 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
3 #include "mtype.h" |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
4 #include "declaration.h" |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
5 #include "aggregate.h" |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
6 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
7 #include "gen/aa.h" |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
8 #include "gen/runtime.h" |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
9 #include "gen/tollvm.h" |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
10 #include "gen/llvmhelpers.h" |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
11 #include "gen/logger.h" |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
12 #include "gen/irstate.h" |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
13 #include "gen/dvalue.h" |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
14 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
15 // makes sure the key value lives in memory so it can be passed to the runtime functions without problems |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
16 // returns the pointer |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
315
diff
changeset
|
17 static LLValue* to_pkey(Loc& loc, DValue* key) |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
18 { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
19 Type* keytype = key->getType(); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
20 bool needmem = !DtoIsPassedByRef(keytype); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
21 LLValue* pkey; |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
22 if (key->isIm()) { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
23 pkey = key->getRVal(); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
24 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
25 else if (DVarValue* var = key->isVar()) { |
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:
479
diff
changeset
|
26 pkey = key->getLVal(); |
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:
479
diff
changeset
|
27 needmem = false; |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
28 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
29 else if (key->isConst()) { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
30 needmem = true; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
31 pkey = key->getRVal(); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
32 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
33 else { |
479
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
34 LLValue* tmp = DtoAlloca(DtoType(keytype), "aatmpkeystorage"); |
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:
479
diff
changeset
|
35 DVarValue var(keytype, tmp); |
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:
479
diff
changeset
|
36 DtoAssign(loc, &var, key); |
168
08cfde5f70d3
[svn r184] fixed an AA helper for giving keys storage, which the runtime needs. tango.text.UnicodeData now compiles.
lindquist
parents:
163
diff
changeset
|
37 return tmp; |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
38 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
39 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
40 // give memory |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
41 if (needmem) { |
479
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
42 LLValue* tmp = DtoAlloca(DtoType(keytype), "aatmpkeystorage"); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
43 DtoStore(pkey, tmp); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
44 pkey = tmp; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
45 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
46 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
47 return pkey; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
48 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
49 |
127 | 50 // returns the keytype typeinfo |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
51 static LLValue* to_keyti(DValue* key) |
127 | 52 { |
53 // keyti param | |
54 Type* keytype = key->getType(); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
55 return DtoTypeInfoOf(keytype, false); |
127 | 56 } |
57 | |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
58 ///////////////////////////////////////////////////////////////////////////////////// |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
59 |
458
121624c14053
Fixed AA Rvalue-only access (like indexing an AA return value immediately).
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
455
diff
changeset
|
60 DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue) |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
61 { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
62 // call: |
458
121624c14053
Fixed AA Rvalue-only access (like indexing an AA return value immediately).
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
455
diff
changeset
|
63 // extern(C) void* _aaGet(AA* aa, TypeInfo keyti, size_t valuesize, void* pkey) |
121624c14053
Fixed AA Rvalue-only access (like indexing an AA return value immediately).
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
455
diff
changeset
|
64 // or |
121624c14053
Fixed AA Rvalue-only access (like indexing an AA return value immediately).
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
455
diff
changeset
|
65 // extern(C) void* _aaGetRvalue(AA aa, TypeInfo keyti, size_t valuesize, void* pkey) |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
66 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
67 // first get the runtime function |
458
121624c14053
Fixed AA Rvalue-only access (like indexing an AA return value immediately).
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
455
diff
changeset
|
68 llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, lvalue?"_aaGet":"_aaGetRvalue"); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
69 const llvm::FunctionType* funcTy = func->getFunctionType(); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
70 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
71 // aa param |
458
121624c14053
Fixed AA Rvalue-only access (like indexing an AA return value immediately).
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
455
diff
changeset
|
72 LLValue* aaval = lvalue ? aa->getLVal() : aa->getRVal(); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
73 aaval = DtoBitCast(aaval, funcTy->getParamType(0)); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
74 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
75 // keyti param |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
76 LLValue* keyti = to_keyti(key); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
77 keyti = DtoBitCast(keyti, funcTy->getParamType(1)); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
78 |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
156
diff
changeset
|
79 // valuesize param |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
80 LLValue* valsize = DtoConstSize_t(getABITypeSize(DtoType(type))); |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
156
diff
changeset
|
81 |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
82 // pkey param |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
315
diff
changeset
|
83 LLValue* pkey = to_pkey(loc, key); |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
156
diff
changeset
|
84 pkey = DtoBitCast(pkey, funcTy->getParamType(3)); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
85 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
86 // call runtime |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
275
diff
changeset
|
87 LLValue* ret = gIR->CreateCallOrInvoke4(func, aaval, keyti, valsize, pkey, "aa.index")->get(); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
88 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
89 // cast return value |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
90 const LLType* targettype = getPtrToType(DtoType(type)); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
91 if (ret->getType() != targettype) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
92 ret = DtoBitCast(ret, targettype); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
93 |
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:
479
diff
changeset
|
94 return new DVarValue(type, ret); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
95 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
96 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
97 ///////////////////////////////////////////////////////////////////////////////////// |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
98 |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
315
diff
changeset
|
99 DValue* DtoAAIn(Loc& loc, Type* type, DValue* aa, DValue* key) |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
100 { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
101 // call: |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
102 // extern(C) void* _aaIn(AA aa*, TypeInfo keyti, void* pkey) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
103 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
104 // first get the runtime function |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
105 llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaIn"); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
106 const llvm::FunctionType* funcTy = func->getFunctionType(); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
107 |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
108 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
109 Logger::cout() << "_aaIn = " << *func << '\n'; |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
110 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
111 // aa param |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
112 LLValue* aaval = aa->getRVal(); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
113 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
114 { |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
115 Logger::cout() << "aaval: " << *aaval << '\n'; |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
116 Logger::cout() << "totype: " << *funcTy->getParamType(0) << '\n'; |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
117 } |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
118 aaval = DtoBitCast(aaval, funcTy->getParamType(0)); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
119 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
120 // keyti param |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
121 LLValue* keyti = to_keyti(key); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
122 keyti = DtoBitCast(keyti, funcTy->getParamType(1)); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
123 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
124 // pkey param |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
315
diff
changeset
|
125 LLValue* pkey = to_pkey(loc, key); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
126 pkey = DtoBitCast(pkey, funcTy->getParamType(2)); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
127 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
128 // call runtime |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
275
diff
changeset
|
129 LLValue* ret = gIR->CreateCallOrInvoke3(func, aaval, keyti, pkey, "aa.in")->get(); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
130 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
131 // cast return value |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
132 const LLType* targettype = DtoType(type); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
133 if (ret->getType() != targettype) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
134 ret = DtoBitCast(ret, targettype); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
135 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
136 return new DImValue(type, ret); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
137 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
138 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
diff
changeset
|
139 ///////////////////////////////////////////////////////////////////////////////////// |
127 | 140 |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
315
diff
changeset
|
141 void DtoAARemove(Loc& loc, DValue* aa, DValue* key) |
127 | 142 { |
143 // call: | |
144 // extern(C) void _aaDel(AA aa, TypeInfo keyti, void* pkey) | |
145 | |
146 // first get the runtime function | |
147 llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaDel"); | |
148 const llvm::FunctionType* funcTy = func->getFunctionType(); | |
149 | |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
150 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
151 Logger::cout() << "_aaDel = " << *func << '\n'; |
127 | 152 |
153 // aa param | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
154 LLValue* aaval = aa->getRVal(); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
155 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
156 { |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
157 Logger::cout() << "aaval: " << *aaval << '\n'; |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
158 Logger::cout() << "totype: " << *funcTy->getParamType(0) << '\n'; |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
159 } |
127 | 160 aaval = DtoBitCast(aaval, funcTy->getParamType(0)); |
161 | |
162 // keyti param | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
163 LLValue* keyti = to_keyti(key); |
127 | 164 keyti = DtoBitCast(keyti, funcTy->getParamType(1)); |
165 | |
166 // pkey param | |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
315
diff
changeset
|
167 LLValue* pkey = to_pkey(loc, key); |
127 | 168 pkey = DtoBitCast(pkey, funcTy->getParamType(2)); |
169 | |
170 // build arg vector | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
171 LLSmallVector<LLValue*, 3> args; |
127 | 172 args.push_back(aaval); |
173 args.push_back(keyti); | |
174 args.push_back(pkey); | |
175 | |
176 // call runtime | |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
275
diff
changeset
|
177 gIR->CreateCallOrInvoke(func, args.begin(), args.end()); |
127 | 178 } |