Mercurial > projects > ldc
changeset 1153:4454126b4345
Added support for single D type register return from __asm.
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Sat, 28 Mar 2009 07:24:53 +0100 |
parents | 521dd1626d76 |
children | 9279a9dc6df3 |
files | dmd/attrib.c gen/naked.cpp runtime/import/ldc/llvmasm.di |
diffstat | 3 files changed, 12 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/dmd/attrib.c Sat Mar 28 06:32:06 2009 +0100 +++ b/dmd/attrib.c Sat Mar 28 07:24:53 2009 +0100 @@ -1130,9 +1130,9 @@ 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 @@ 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
--- a/gen/naked.cpp Sat Mar 28 06:32:06 2009 +0100 +++ b/gen/naked.cpp Sat Mar 28 07:24:53 2009 +0100 @@ -376,7 +376,8 @@ } // 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 @@ 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); }
--- a/runtime/import/ldc/llvmasm.di Sat Mar 28 06:32:06 2009 +0100 +++ b/runtime/import/ldc/llvmasm.di Sat Mar 28 07:24:53 2009 +0100 @@ -5,3 +5,9 @@ { void __asm(char[] asmcode, char[] constraints, ...); } + +pragma(llvm_inline_asm) +template __asm(T) +{ + T __asm(char[] asmcode, char[] constraints, ...); +}