# HG changeset patch # User Tomas Lindquist Olsen # Date 1224951127 -7200 # Node ID 6de2ed4f0abe85b514d8974803255c4958698791 # Parent 55f6c2e454d7ca08ee9d7cfa4f5f0b0b0b082e62 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 diff -r 55f6c2e454d7 -r 6de2ed4f0abe gen/functions.cpp --- a/gen/functions.cpp Sat Oct 25 06:03:28 2008 +0200 +++ b/gen/functions.cpp Sat Oct 25 18:12:07 2008 +0200 @@ -108,14 +108,11 @@ paramvec.push_back(t1); paramvec.push_back(getPtrToType(LLType::Int8Ty)); } - else if (arrayVararg) - { - // do nothing? - } // number of formal params 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 if (global.params.cpu == ARCHx86) { @@ -128,6 +125,7 @@ f->reverseIndex = paramvec.size(); } } +#endif // X86_REVERSE_PARAMS for (int i=0; i < n; ++i) { @@ -194,6 +192,7 @@ bool isvararg = !(typesafeVararg || arrayVararg) && f->varargs; 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 // ONLY extern(D) functions ! if ((n > 0 || usesthis || usesnest) && f->linkage == LINKd) @@ -213,12 +212,14 @@ else { 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(); - // 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) && - ((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)) { arg->llvmAttrs |= llvm::Attribute::InReg; @@ -226,6 +227,7 @@ } } } +#endif // X86_PASS_IN_EAX // done f->retInPtr = retinptr; diff -r 55f6c2e454d7 -r 6de2ed4f0abe premake.lua --- a/premake.lua Sat Oct 25 06:03:28 2008 +0200 +++ b/premake.lua Sat Oct 25 18:12:07 2008 +0200 @@ -37,6 +37,10 @@ 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 !!! DMDV1 = "1" @@ -82,6 +86,8 @@ "DMDV1="..DMDV1, "POSIX="..POSIX, "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.Debug.buildoptions = { "-g -O0" }