diff gen/toir.cpp @ 1152:521dd1626d76

Added initial support for raw LLVM inline asm.
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Sat, 28 Mar 2009 06:32:06 +0100
parents 3cf0066e6faf
children f528e55fb32f
line wrap: on
line diff
--- a/gen/toir.cpp	Sat Mar 28 05:00:43 2009 +0100
+++ b/gen/toir.cpp	Sat Mar 28 06:32:06 2009 +0100
@@ -196,7 +196,11 @@
     {
         Logger::println("FuncDeclaration");
         LLValue* func = 0;
-        if (fdecl->llvmInternal != LLVMva_arg) {
+        if (fdecl->llvmInternal == LLVMinline_asm) {
+            error("special ldc inline asm is not a normal function");
+            fatal();
+        }
+        else if (fdecl->llvmInternal != LLVMva_arg) {
             fdecl->codegen(Type::sir);
             func = fdecl->ir.irFunc->func;
         }
@@ -723,6 +727,19 @@
     Logger::print("CallExp::toElem: %s @ %s\n", toChars(), type->toChars());
     LOG_SCOPE;
 
+    // handle magic inline asm
+    if (e1->op == TOKvar)
+    {
+        VarExp* ve = (VarExp*)e1;
+        if (FuncDeclaration* fd = ve->var->isFuncDeclaration())
+        {
+            if (fd->llvmInternal == LLVMinline_asm)
+            {
+                return DtoInlineAsmExpr(loc, fd, arguments);
+            }
+        }
+    }
+
     // get the callee value
     DValue* fnval = e1->toElem(p);