Added initial support for raw LLVM inline asm.

This commit is contained in:
Tomas Lindquist Olsen
2009-03-28 06:32:06 +01:00
parent 36f6ebc77f
commit 99b863e2b1
9 changed files with 163 additions and 6 deletions

View File

@@ -987,6 +987,17 @@ void PragmaDeclaration::semantic(Scope *sc)
}
}
// pragma(llvm_inline_asm) { templdecl(s) }
else if (ident == Id::llvm_inline_asm)
{
if (args && args->dim > 0)
{
error("takes no parameters");
fatal();
}
llvm_internal = LLVMinline_asm;
}
#endif // LDC
else if (ignoreUnsupportedPragmas)
@@ -1116,6 +1127,33 @@ void PragmaDeclaration::semantic(Scope *sc)
}
break;
case LLVMinline_asm:
if (TemplateDeclaration* td = s->isTemplateDeclaration())
{
if (td->parameters->dim != 0)
{
error("the '%s' pragma template must have exactly zero template parameters", ident->toChars());
fatal();
}
else if (!td->onemember)
{
error("the '%s' pragma template must have exactly one member", ident->toChars());
fatal();
}
else if (td->overnext || td->overroot)
{
error("the '%s' pragma template must not be overloaded", ident->toChars());
fatal();
}
td->llvmInternal = llvm_internal;
}
else
{
error("the '%s' pragma is only allowed on template declarations", ident->toChars());
fatal();
}
break;
default:
warning("the LDC specific pragma '%s' is not yet implemented, ignoring", ident->toChars());
}

View File

@@ -1863,12 +1863,8 @@ struct GEPExp : UnaExp
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
Expression *toLvalue(Scope *sc, Expression *e);
#if IN_DMD
elem *toElem(IRState *irs);
#elif IN_LLVM
DValue* toElem(IRState* irs);
llvm::Constant *toConstElem(IRState *irs);
#endif
};
#endif

View File

@@ -225,6 +225,7 @@ Msgtable msgtable[] =
{ "vaarg", "va_arg" },
{ "ldc" },
{ "allow_inline" },
{ "llvm_inline_asm" },
// For special functions
{ "tohash", "toHash" },