Added support for single D type register return from __asm.

This commit is contained in:
Tomas Lindquist Olsen
2009-03-28 07:24:53 +01:00
parent 99b863e2b1
commit 1809214995
3 changed files with 12 additions and 10 deletions

View File

@@ -1130,9 +1130,9 @@ void PragmaDeclaration::semantic(Scope *sc)
case LLVMinline_asm:
if (TemplateDeclaration* td = s->isTemplateDeclaration())
{
if (td->parameters->dim != 0)
if (td->parameters->dim > 1)
{
error("the '%s' pragma template must have exactly zero template parameters", ident->toChars());
error("the '%s' pragma template must have exactly zero or one template parameters", ident->toChars());
fatal();
}
else if (!td->onemember)
@@ -1140,11 +1140,6 @@ void PragmaDeclaration::semantic(Scope *sc)
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

View File

@@ -376,7 +376,8 @@ DValue * DtoInlineAsmExpr(Loc loc, FuncDeclaration * fd, Expressions * arguments
}
// build asm function type
llvm::FunctionType* FT = llvm::FunctionType::get(llvm::Type::VoidTy, argtypes, false);
const llvm::Type* ret_type = DtoType(fd->type->nextOf());
llvm::FunctionType* FT = llvm::FunctionType::get(ret_type, argtypes, false);
// build asm call
bool sideeffect = true;
@@ -384,8 +385,8 @@ DValue * DtoInlineAsmExpr(Loc loc, FuncDeclaration * fd, Expressions * arguments
llvm::Value* v = gIR->ir->CreateCall(ia, args.begin(), args.end(), "");
// return NULL for now
return NULL;
// return call as im value
return new DImValue(fd->type->nextOf(), v);
}

View File

@@ -5,3 +5,9 @@ template __asm()
{
void __asm(char[] asmcode, char[] constraints, ...);
}
pragma(llvm_inline_asm)
template __asm(T)
{
T __asm(char[] asmcode, char[] constraints, ...);
}