mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 16:41:06 +03:00
Disabled parameter reversing by default, it broke mini/typeinfo10.d
Fixed 'inreg' property placement for functions with reversed parameters. Made parameter reversal and inreg passing of first arg configurable in premake.lua
This commit is contained in:
parent
3c3a5dda14
commit
80e29f86e4
2 changed files with 15 additions and 7 deletions
|
@ -108,14 +108,11 @@ const llvm::FunctionType* DtoFunctionType(Type* type, const LLType* thistype, co
|
||||||
paramvec.push_back(t1);
|
paramvec.push_back(t1);
|
||||||
paramvec.push_back(getPtrToType(LLType::Int8Ty));
|
paramvec.push_back(getPtrToType(LLType::Int8Ty));
|
||||||
}
|
}
|
||||||
else if (arrayVararg)
|
|
||||||
{
|
|
||||||
// do nothing?
|
|
||||||
}
|
|
||||||
|
|
||||||
// number of formal params
|
// number of formal params
|
||||||
size_t n = Argument::dim(f->parameters);
|
size_t n = Argument::dim(f->parameters);
|
||||||
|
|
||||||
|
#if X86_REVERSE_PARAMS
|
||||||
// on x86 we need to reverse the formal params in some cases to match the ABI
|
// on x86 we need to reverse the formal params in some cases to match the ABI
|
||||||
if (global.params.cpu == ARCHx86)
|
if (global.params.cpu == ARCHx86)
|
||||||
{
|
{
|
||||||
|
@ -128,6 +125,7 @@ const llvm::FunctionType* DtoFunctionType(Type* type, const LLType* thistype, co
|
||||||
f->reverseIndex = paramvec.size();
|
f->reverseIndex = paramvec.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // X86_REVERSE_PARAMS
|
||||||
|
|
||||||
|
|
||||||
for (int i=0; i < n; ++i) {
|
for (int i=0; i < n; ++i) {
|
||||||
|
@ -194,6 +192,7 @@ const llvm::FunctionType* DtoFunctionType(Type* type, const LLType* thistype, co
|
||||||
bool isvararg = !(typesafeVararg || arrayVararg) && f->varargs;
|
bool isvararg = !(typesafeVararg || arrayVararg) && f->varargs;
|
||||||
llvm::FunctionType* functype = llvm::FunctionType::get(actualRettype, paramvec, isvararg);
|
llvm::FunctionType* functype = llvm::FunctionType::get(actualRettype, paramvec, isvararg);
|
||||||
|
|
||||||
|
#if X86_PASS_IN_EAX
|
||||||
// tell first param to be passed in a register if we can
|
// tell first param to be passed in a register if we can
|
||||||
// ONLY extern(D) functions !
|
// ONLY extern(D) functions !
|
||||||
if ((n > 0 || usesthis || usesnest) && f->linkage == LINKd)
|
if ((n > 0 || usesthis || usesnest) && f->linkage == LINKd)
|
||||||
|
@ -213,12 +212,14 @@ const llvm::FunctionType* DtoFunctionType(Type* type, const LLType* thistype, co
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int inreg = f->reverseParams ? n - 1 : 0;
|
int inreg = f->reverseParams ? n - 1 : 0;
|
||||||
Argument* arg = Argument::getNth(f->parameters, 0);
|
Argument* arg = Argument::getNth(f->parameters, inreg);
|
||||||
Type* t = arg->type->toBasetype();
|
Type* t = arg->type->toBasetype();
|
||||||
|
|
||||||
// 32bit ints, pointers, classes and static arrays are candidate for being passed in EAX
|
// 32bit ints, pointers, classes, static arrays and AAs
|
||||||
|
// are candidate for being passed in EAX
|
||||||
if ((arg->storageClass & STCin) &&
|
if ((arg->storageClass & STCin) &&
|
||||||
((t->isscalar() && !t->isfloating()) || t->ty == Tclass || t->ty == Tsarray) &&
|
((t->isscalar() && !t->isfloating()) ||
|
||||||
|
t->ty == Tclass || t->ty == Tsarray || t->ty == Taarray) &&
|
||||||
(t->size() <= PTRSIZE))
|
(t->size() <= PTRSIZE))
|
||||||
{
|
{
|
||||||
arg->llvmAttrs |= llvm::Attribute::InReg;
|
arg->llvmAttrs |= llvm::Attribute::InReg;
|
||||||
|
@ -226,6 +227,7 @@ const llvm::FunctionType* DtoFunctionType(Type* type, const LLType* thistype, co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // X86_PASS_IN_EAX
|
||||||
|
|
||||||
// done
|
// done
|
||||||
f->retInPtr = retinptr;
|
f->retInPtr = retinptr;
|
||||||
|
|
|
@ -37,6 +37,10 @@ end
|
||||||
|
|
||||||
io.write("Default target: '"..TRIPLE.."'\n");
|
io.write("Default target: '"..TRIPLE.."'\n");
|
||||||
|
|
||||||
|
-- x86 ABI support
|
||||||
|
X86_REVERSE_PARAMS = 0 --disabled for now
|
||||||
|
X86_PASS_IN_EAX = 1
|
||||||
|
|
||||||
-- D version - don't change these !!!
|
-- D version - don't change these !!!
|
||||||
DMDV1 = "1"
|
DMDV1 = "1"
|
||||||
|
|
||||||
|
@ -82,6 +86,8 @@ package.defines = {
|
||||||
"DMDV1="..DMDV1,
|
"DMDV1="..DMDV1,
|
||||||
"POSIX="..POSIX,
|
"POSIX="..POSIX,
|
||||||
"DEFAULT_TARGET_TRIPLE=\\\""..TRIPLE.."\\\"",
|
"DEFAULT_TARGET_TRIPLE=\\\""..TRIPLE.."\\\"",
|
||||||
|
"X86_REVERSE_PARAMS="..X86_REVERSE_PARAMS,
|
||||||
|
"X86_PASS_IN_EAX="..X86_PASS_IN_EAX,
|
||||||
}
|
}
|
||||||
package.config.Release.defines = { "LLVMD_NO_LOGGER" }
|
package.config.Release.defines = { "LLVMD_NO_LOGGER" }
|
||||||
package.config.Debug.buildoptions = { "-g -O0" }
|
package.config.Debug.buildoptions = { "-g -O0" }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue