27
27
using namespace dmd ;
28
28
29
29
// returns the keytype typeinfo
30
- static LLConstant *to_keyti (const Loc &loc, DValue *aa, LLType *targetType ) {
30
+ static LLConstant *to_keyti (const Loc &loc, DValue *aa) {
31
31
// keyti param
32
32
assert (aa->type ->toBasetype ()->ty == TY::Taarray);
33
33
TypeAArray *aatype = static_cast <TypeAArray *>(aa->type ->toBasetype ());
34
- LLConstant *ti = DtoTypeInfoOf (loc, aatype->index , /* base=*/ false );
35
- return DtoBitCast (ti, targetType);
34
+ return DtoTypeInfoOf (loc, aatype->index );
36
35
}
37
36
38
37
// //////////////////////////////////////////////////////////////////////////////
@@ -49,35 +48,28 @@ DLValue *DtoAAIndex(const Loc &loc, Type *type, DValue *aa, DValue *key,
49
48
// first get the runtime function
50
49
llvm::Function *func =
51
50
getRuntimeFunction (loc, gIR ->module , lvalue ? " _aaGetY" : " _aaInX" );
52
- LLFunctionType *funcTy = func->getFunctionType ();
53
51
54
52
// aa param
55
53
LLValue *aaval = lvalue ? DtoLVal (aa) : DtoRVal (aa);
56
- aaval = DtoBitCast (aaval, funcTy-> getParamType ( 0 ));
54
+ assert (aaval-> getType ()-> isPointerTy ( ));
57
55
58
56
// pkey param
59
57
LLValue *pkey = makeLValue (loc, key);
60
- pkey = DtoBitCast (pkey, funcTy->getParamType (lvalue ? 3 : 2 ));
61
58
62
59
// call runtime
63
60
LLValue *ret;
64
61
if (lvalue) {
65
62
auto t = mutableOf (unSharedOf (aa->type ));
66
- LLValue *rawAATI = DtoTypeInfoOf (loc, t, /* base=*/ false );
67
- LLValue *castedAATI = DtoBitCast (rawAATI, funcTy->getParamType (1 ));
63
+ LLValue *aati = DtoTypeInfoOf (loc, t);
68
64
LLValue *valsize = DtoConstSize_t (getTypeAllocSize (DtoType (type)));
69
- ret = gIR ->CreateCallOrInvoke (func, aaval, castedAATI , valsize, pkey,
65
+ ret = gIR ->CreateCallOrInvoke (func, aaval, aati , valsize, pkey,
70
66
" aa.index" );
71
67
} else {
72
- LLValue *keyti = to_keyti (loc, aa, funcTy-> getParamType ( 1 ) );
68
+ LLValue *keyti = to_keyti (loc, aa);
73
69
ret = gIR ->CreateCallOrInvoke (func, aaval, keyti, pkey, " aa.index" );
74
70
}
75
71
76
- // cast return value
77
- LLType *targettype = DtoPtrToType (type);
78
- if (ret->getType () != targettype) {
79
- ret = DtoBitCast (ret, targettype);
80
- }
72
+ assert (ret->getType ()->isPointerTy ());
81
73
82
74
// Only check bounds for rvalues ('aa[key]').
83
75
// Lvalue use ('aa[key] = value') auto-adds an element.
@@ -112,34 +104,25 @@ DValue *DtoAAIn(const Loc &loc, Type *type, DValue *aa, DValue *key) {
112
104
113
105
// first get the runtime function
114
106
llvm::Function *func = getRuntimeFunction (loc, gIR ->module , " _aaInX" );
115
- LLFunctionType *funcTy = func->getFunctionType ();
116
107
117
108
IF_LOG Logger::cout () << " _aaIn = " << *func << ' \n ' ;
118
109
119
110
// aa param
120
111
LLValue *aaval = DtoRVal (aa);
112
+ assert (aaval->getType ()->isPointerTy ());
121
113
IF_LOG {
122
114
Logger::cout () << " aaval: " << *aaval << ' \n ' ;
123
- Logger::cout () << " totype: " << *funcTy->getParamType (0 ) << ' \n ' ;
124
115
}
125
- aaval = DtoBitCast (aaval, funcTy->getParamType (0 ));
126
116
127
117
// keyti param
128
- LLValue *keyti = to_keyti (loc, aa, funcTy-> getParamType ( 1 ) );
118
+ LLValue *keyti = to_keyti (loc, aa);
129
119
130
120
// pkey param
131
121
LLValue *pkey = makeLValue (loc, key);
132
- pkey = DtoBitCast (pkey, getVoidPtrType ());
133
122
134
123
// call runtime
135
124
LLValue *ret = gIR ->CreateCallOrInvoke (func, aaval, keyti, pkey, " aa.in" );
136
125
137
- // cast return value
138
- LLType *targettype = DtoType (type);
139
- if (ret->getType () != targettype) {
140
- ret = DtoBitCast (ret, targettype);
141
- }
142
-
143
126
return new DImValue (type, ret);
144
127
}
145
128
@@ -156,24 +139,21 @@ DValue *DtoAARemove(const Loc &loc, DValue *aa, DValue *key) {
156
139
157
140
// first get the runtime function
158
141
llvm::Function *func = getRuntimeFunction (loc, gIR ->module , " _aaDelX" );
159
- LLFunctionType *funcTy = func->getFunctionType ();
160
142
161
143
IF_LOG Logger::cout () << " _aaDel = " << *func << ' \n ' ;
162
144
163
145
// aa param
164
146
LLValue *aaval = DtoRVal (aa);
147
+ assert (aaval->getType ()->isPointerTy ());
165
148
IF_LOG {
166
149
Logger::cout () << " aaval: " << *aaval << ' \n ' ;
167
- Logger::cout () << " totype: " << *funcTy->getParamType (0 ) << ' \n ' ;
168
150
}
169
- aaval = DtoBitCast (aaval, funcTy->getParamType (0 ));
170
151
171
152
// keyti param
172
- LLValue *keyti = to_keyti (loc, aa, funcTy-> getParamType ( 1 ) );
153
+ LLValue *keyti = to_keyti (loc, aa);
173
154
174
155
// pkey param
175
156
LLValue *pkey = makeLValue (loc, key);
176
- pkey = DtoBitCast (pkey, funcTy->getParamType (2 ));
177
157
178
158
// call runtime
179
159
LLValue *res = gIR ->CreateCallOrInvoke (func, aaval, keyti, pkey);
@@ -188,10 +168,11 @@ LLValue *DtoAAEquals(const Loc &loc, EXP op, DValue *l, DValue *r) {
188
168
assert (t == r->type ->toBasetype () &&
189
169
" aa equality is only defined for aas of same type" );
190
170
llvm::Function *func = getRuntimeFunction (loc, gIR ->module , " _aaEqual" );
191
- LLFunctionType *funcTy = func->getFunctionType ();
192
171
193
- LLValue *aaval = DtoBitCast (DtoRVal (l), funcTy->getParamType (1 ));
194
- LLValue *abval = DtoBitCast (DtoRVal (r), funcTy->getParamType (2 ));
172
+ LLValue *aaval = DtoRVal (l);
173
+ assert (aaval->getType ()->isPointerTy ());
174
+ LLValue *abval = DtoRVal (r);
175
+ assert (abval->getType ()->isPointerTy ());
195
176
LLValue *aaTypeInfo = DtoTypeInfoOf (loc, t);
196
177
LLValue *res =
197
178
gIR ->CreateCallOrInvoke (func, aaTypeInfo, aaval, abval, " aaEqRes" );
0 commit comments