Mercurial > projects > ldc
comparison gen/abi.cpp @ 1050:32ead42679d1
Fix a bug in the X86 ABI. The size of a struct is different from the size of a
pointer to that struct...
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Fri, 06 Mar 2009 21:15:13 +0100 |
parents | 6bb04dbee21f |
children | dc608dc33081 |
comparison
equal
deleted
inserted
replaced
1049:afe271b0e271 | 1050:32ead42679d1 |
---|---|
131 assert(dv->isLVal()); | 131 assert(dv->isLVal()); |
132 LLValue* mem = dv->getLVal(); | 132 LLValue* mem = dv->getLVal(); |
133 const LLType* t = LLIntegerType::get(dty->size()*8); | 133 const LLType* t = LLIntegerType::get(dty->size()*8); |
134 DtoLoad(DtoBitCast(mem, getPtrToType(t))); | 134 DtoLoad(DtoBitCast(mem, getPtrToType(t))); |
135 } | 135 } |
136 const LLType* type(Type*, const LLType* t) | 136 const LLType* type(Type* t, const LLType*) |
137 { | 137 { |
138 size_t sz = getTypePaddedSize(t)*8; | 138 size_t sz = t->size()*8; |
139 return LLIntegerType::get(sz); | 139 return LLIntegerType::get(sz); |
140 } | 140 } |
141 }; | 141 }; |
142 | 142 |
143 ////////////////////////////////////////////////////////////////////////////// | 143 ////////////////////////////////////////////////////////////////////////////// |
176 // RETURN VALUE | 176 // RETURN VALUE |
177 | 177 |
178 // complex {re,im} -> {im,re} | 178 // complex {re,im} -> {im,re} |
179 if (rt->iscomplex()) | 179 if (rt->iscomplex()) |
180 { | 180 { |
181 Logger::println("Rewriting complex return value"); | |
181 fty->ret->rewrite = &swapComplex; | 182 fty->ret->rewrite = &swapComplex; |
182 } | 183 } |
183 | 184 |
184 // IMPLICIT PARAMETERS | 185 // IMPLICIT PARAMETERS |
185 | 186 |
186 // mark this/nested params inreg | 187 // mark this/nested params inreg |
187 if (fty->arg_this) | 188 if (fty->arg_this) |
188 { | 189 { |
190 Logger::println("Putting 'this' in register"); | |
189 fty->arg_this->attrs = llvm::Attribute::InReg; | 191 fty->arg_this->attrs = llvm::Attribute::InReg; |
190 } | 192 } |
191 else if (fty->arg_nest) | 193 else if (fty->arg_nest) |
192 { | 194 { |
195 Logger::println("Putting context ptr in register"); | |
193 fty->arg_nest->attrs = llvm::Attribute::InReg; | 196 fty->arg_nest->attrs = llvm::Attribute::InReg; |
194 } | 197 } |
195 // otherwise try to mark the last param inreg | 198 // otherwise try to mark the last param inreg |
196 else if (!fty->arg_sret && !fty->args.empty()) | 199 else if (!fty->arg_sret && !fty->args.empty()) |
197 { | 200 { |
204 Type* lastTy = last->type->toBasetype(); | 207 Type* lastTy = last->type->toBasetype(); |
205 unsigned sz = lastTy->size(); | 208 unsigned sz = lastTy->size(); |
206 | 209 |
207 if (last->byref && !last->isByVal()) | 210 if (last->byref && !last->isByVal()) |
208 { | 211 { |
212 Logger::println("Putting last (byref) parameter in register"); | |
209 last->attrs |= llvm::Attribute::InReg; | 213 last->attrs |= llvm::Attribute::InReg; |
210 } | 214 } |
211 else if (!lastTy->isfloating() && (sz == 1 || sz == 2 || sz == 4)) // right? | 215 else if (!lastTy->isfloating() && (sz == 1 || sz == 2 || sz == 4)) // right? |
212 { | 216 { |
213 // rewrite the struct into an integer to make inreg work | 217 // rewrite the struct into an integer to make inreg work |