Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)

Fixed align N; in asm blocks.

Fixed inreg parameter passing on x86 for ref/out params.

Removed support for lazy initialization of function local static variables, I have no idea why I ever implemented this, it's not in the D spec, and DMD doesn't support it :P

Some of the global variable related changes might cause minor regressions, but they should be easily fixable.
This commit is contained in:
Tomas Lindquist Olsen 2009-02-03 08:54:57 +01:00
parent 8ab98dad49
commit dc5944df99
28 changed files with 491 additions and 153 deletions

View file

@ -209,12 +209,16 @@ const llvm::FunctionType* DtoFunctionType(Type* type, const LLType* thistype, co
{
Type* t = arg->type->toBasetype();
// 32bit ints, pointers, classes, static arrays and AAs
// 32bit ints, pointers, classes, static arrays, AAs, ref and out params
// are candidate for being passed in EAX
if ((arg->storageClass & STCin) &&
((t->isscalar() && !t->isfloating()) ||
if (
(arg->storageClass & (STCref|STCout))
||
((arg->storageClass & STCin) &&
((t->isscalar() && !t->isfloating()) ||
t->ty == Tclass || t->ty == Tsarray || t->ty == Taarray) &&
(t->size() <= PTRSIZE))
(t->size() <= PTRSIZE))
)
{
arg->llvmAttrs |= llvm::Attribute::InReg;
assert((f->thisAttrs & llvm::Attribute::InReg) == 0 && "can't have two inreg args!");
@ -618,7 +622,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
//////////////////////////////////////////////////////////////////////////////////////////
void DtoDefineFunc(FuncDeclaration* fd)
void DtoDefineFunction(FuncDeclaration* fd)
{
if (fd->ir.defined) return;
fd->ir.defined = true;
@ -628,6 +632,13 @@ void DtoDefineFunc(FuncDeclaration* fd)
Logger::println("DtoDefineFunc(%s): %s", fd->toPrettyChars(), fd->loc.toChars());
LOG_SCOPE;
// if this function is naked, we take over right away! no standard processing!
if (fd->naked)
{
DtoDefineNakedFunction(fd);
return;
}
// debug info
if (global.params.symdebug) {
Module* mo = fd->getModule();
@ -684,8 +695,7 @@ void DtoDefineFunc(FuncDeclaration* fd)
// this hack makes sure the frame pointer elimination optimization is disabled.
// this this eliminates a bunch of inline asm related issues.
// naked must always eliminate the framepointer however...
if (fd->inlineAsm && !fd->naked)
if (fd->inlineAsm)
{
// emit a call to llvm_eh_unwind_init
LLFunction* hack = GET_INTRINSIC_DECL(eh_unwind_init);