Fix ABI on Win32.

We can't simply use the C calling convention, as the D(MD)
ABI is callee-pop, and this is hardcoded in naked functions
with stack parameters.

The \1 "trick" is normally used to avoid prefixes added by
LLVM; on the 3.2 release, a patch is needed to make it work
for the @<n> stdcall suffixes as well.
This commit is contained in:
David Nadlinger 2013-02-20 19:39:01 +01:00
parent e05a5c6f22
commit 2d3de4a3d4
4 changed files with 65 additions and 28 deletions

View file

@ -36,8 +36,6 @@ struct X86TargetABI : TargetABI
return llvm::CallingConv::C;
case LINKd:
case LINKdefault:
return global.params.targetTriple.isOSWindows() ?
llvm::CallingConv::C : llvm::CallingConv::X86_StdCall;
case LINKpascal:
case LINKwindows:
return llvm::CallingConv::X86_StdCall;
@ -46,6 +44,30 @@ struct X86TargetABI : TargetABI
}
}
std::string mangleForLLVM(llvm::StringRef name, LINK l)
{
switch (l)
{
case LINKc:
case LINKcpp:
case LINKintrinsic:
case LINKpascal:
case LINKwindows:
return name;
case LINKd:
case LINKdefault:
if (global.params.targetTriple.isOSWindows())
{
// Prepend a 0x1 byte to keep LLVM from adding the usual
// "@<paramsize>" stdcall suffix.
return ("\1_" + name).str();
}
return name;
default:
llvm_unreachable("Unhandled D linkage type.");
}
}
bool returnInArg(TypeFunction* tf)
{
#if DMDV2