mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-09-17 19:07:05 +02:00
Fixes in X86_64 ABI
This commit is contained in:
+11
-7
@@ -553,11 +553,16 @@ bool X86_64TargetABI::returnInArg(TypeFunction* tf) {
|
|||||||
Type* rt = tf->next->toBasetype();
|
Type* rt = tf->next->toBasetype();
|
||||||
|
|
||||||
if (tf->linkage == LINKd) {
|
if (tf->linkage == LINKd) {
|
||||||
|
#if DMDV2
|
||||||
|
if (tf->isref)
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
// All non-structs can be returned in registers.
|
// All non-structs can be returned in registers.
|
||||||
// FIXME: Update calling convention for static array returns
|
// FIXME: Update calling convention for static array returns
|
||||||
if (rt->ty != Tstruct)
|
if (rt->ty != Tstruct)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Try to figure out whether the struct fits in return registers
|
// Try to figure out whether the struct fits in return registers
|
||||||
// and whether it's a good idea to put it there.
|
// and whether it's a good idea to put it there.
|
||||||
return !x86_64_D_cc::retStructInRegs((TypeStruct*) rt);
|
return !x86_64_D_cc::retStructInRegs((TypeStruct*) rt);
|
||||||
@@ -671,17 +676,17 @@ void X86_64TargetABI::fixup(IrFuncTyArg& arg) {
|
|||||||
|
|
||||||
void X86_64TargetABI::rewriteFunctionType(TypeFunction* tf) {
|
void X86_64TargetABI::rewriteFunctionType(TypeFunction* tf) {
|
||||||
IrFuncTy& fty = tf->fty;
|
IrFuncTy& fty = tf->fty;
|
||||||
|
|
||||||
if (tf->linkage == LINKd) {
|
if (tf->linkage == LINKd) {
|
||||||
if (!fty.arg_sret) {
|
if (!fty.arg_sret) {
|
||||||
Type* rt = fty.ret->type->toBasetype();
|
Type* rt = fty.ret->type->toBasetype();
|
||||||
if (rt->ty == Tstruct) {
|
if (rt->ty == Tstruct && !fty.ret->byref) {
|
||||||
Logger::println("x86-64 D ABI: Transforming return type");
|
Logger::println("x86-64 D ABI: Transforming return type");
|
||||||
fixup_D(*fty.ret);
|
fixup_D(*fty.ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if DMDV1
|
||||||
if (fty.arg_this) {
|
if (fty.arg_this) {
|
||||||
fty.arg_this->attrs |= llvm::Attribute::Nest;
|
fty.arg_this->attrs |= llvm::Attribute::Nest;
|
||||||
}
|
}
|
||||||
@@ -689,7 +694,7 @@ void X86_64TargetABI::rewriteFunctionType(TypeFunction* tf) {
|
|||||||
fty.arg_nest->attrs |= llvm::Attribute::Nest;
|
fty.arg_nest->attrs |= llvm::Attribute::Nest;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Logger::println("x86-64 D ABI: Transforming arguments");
|
Logger::println("x86-64 D ABI: Transforming arguments");
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
||||||
@@ -702,7 +707,7 @@ void X86_64TargetABI::rewriteFunctionType(TypeFunction* tf) {
|
|||||||
// Arguments that are in memory are of no interest to us.
|
// Arguments that are in memory are of no interest to us.
|
||||||
if (arg.byref)
|
if (arg.byref)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Type* ty = arg.type->toBasetype();
|
Type* ty = arg.type->toBasetype();
|
||||||
if (ty->ty == Tstruct)
|
if (ty->ty == Tstruct)
|
||||||
fixup_D(arg);
|
fixup_D(arg);
|
||||||
@@ -710,7 +715,6 @@ void X86_64TargetABI::rewriteFunctionType(TypeFunction* tf) {
|
|||||||
if (Logger::enabled())
|
if (Logger::enabled())
|
||||||
Logger::cout() << "New arg type: " << *arg.ltype << '\n';
|
Logger::cout() << "New arg type: " << *arg.ltype << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// TODO: See if this is correct for more than just extern(C).
|
// TODO: See if this is correct for more than just extern(C).
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user