mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-09 16:33:14 +01:00
Added support for single D type register return from __asm.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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, ...);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user