Mercurial > projects > ldc
diff gen/functions.cpp @ 1359:34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
that removes it.
This unbreaks the `llvm_*_with_overflow` intrinsics.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Sat, 16 May 2009 13:06:49 +0200 |
parents | 15e9762bb620 |
children | 46f6365a50d7 |
line wrap: on
line diff
--- a/gen/functions.cpp Fri May 15 17:17:20 2009 +0200 +++ b/gen/functions.cpp Sat May 16 13:06:49 2009 +0200 @@ -40,10 +40,9 @@ assert(type->ty == Tfunction); TypeFunction* f = (TypeFunction*)type; - if (f->linkage != LINKintrinsic) { - // Tell the ABI we're resolving a new function type - gABI->newFunctionType(f); - } + TargetABI* abi = (f->linkage == LINKintrinsic ? TargetABI::getIntrinsic() : gABI); + // Tell the ABI we're resolving a new function type + abi->newFunctionType(f); // Do not modify f->fty yet; this function may be called recursively if any // of the argument types refer to this type. @@ -63,18 +62,17 @@ Type* rt = f->next; unsigned a = 0; // sret return - if (f->linkage != LINKintrinsic) - if (gABI->returnInArg(f)) - { - fty.arg_sret = new IrFuncTyArg(rt, true, StructRet | NoAlias | NoCapture); - rt = Type::tvoid; - lidx++; - } - // sext/zext return - else if (unsigned se = DtoShouldExtend(rt)) - { - a = se; - } + if (abi->returnInArg(f)) + { + fty.arg_sret = new IrFuncTyArg(rt, true, StructRet | NoAlias | NoCapture); + rt = Type::tvoid; + lidx++; + } + // sext/zext return + else if (unsigned se = DtoShouldExtend(rt)) + { + a = se; + } fty.ret = new IrFuncTyArg(rt, false, a); } lidx++; @@ -152,8 +150,7 @@ argtype = ltd; } // byval - else if (f->linkage != LINKintrinsic - && gABI->passByVal(argtype)) + else if (abi->passByVal(argtype)) { if (!byref) a |= llvm::Attribute::ByVal; byref = true; @@ -172,7 +169,7 @@ // it has now been set. if (f->ir.type) { // Notify ABI that we won't be needing it for this function type anymore. - gABI->doneWithFunctionType(); + abi->doneWithFunctionType(); // Some cleanup of memory we won't use delete fty.ret; @@ -192,13 +189,11 @@ // Now we can modify f->fty safely. f->fty = fty; - if (f->linkage != LINKintrinsic) { - // let the abi rewrite the types as necesary - gABI->rewriteFunctionType(f); + // let the abi rewrite the types as necesary + abi->rewriteFunctionType(f); - // Tell the ABI we're done with this function type - gABI->doneWithFunctionType(); - } + // Tell the ABI we're done with this function type + abi->doneWithFunctionType(); // build the function type std::vector<const LLType*> argtypes;