diff tests/mini/asm8.d @ 945:03d7c4aac654

SWITCHED TO LLVM 2.5 ! Applied patch from ticket #129 to compile against latest LLVM. Thanks Frits van Bommel. Fixed implicit return by asm block at the end of a function on x86-32. Other architectures will produce an error at the moment. Adding support for new targets is fairly simple. Fixed return calling convention for complex numbers, ST and ST(1) were switched around. Added some testcases. I've run a dstress test and there are no regressions. However, the runtime does not seem to compile with symbolic debug information. -O3 -release -inline works well and is what I used for the dstress run. Tango does not compile, a small workaround is needed in tango.io.digest.Digest.Digest.hexDigest. See ticket #206 .
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sun, 08 Feb 2009 05:26:54 +0100
parents
children b2d27ddf8f45
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/mini/asm8.d	Sun Feb 08 05:26:54 2009 +0100
@@ -0,0 +1,119 @@
+int foo()
+{
+    version(X86)
+    asm { mov EAX, 42; }
+    else static assert(0, "todo");
+}
+
+ulong bar()
+{
+    version(X86)
+    asm { mov EDX, 0xAA; mov EAX, 0xFF; }
+    else static assert(0, "todo");
+}
+
+float onef()
+{
+    version(X86)
+    asm { fld1; }
+    else static assert(0, "todo");
+}
+
+double oned()
+{
+    version(X86)
+    asm { fld1; }
+    else static assert(0, "todo");
+}
+
+real oner()
+{
+    version(X86)
+    asm { fld1; }
+    else static assert(0, "todo");
+}
+
+real two = 2.0;
+
+creal cr()
+{
+    version(X86)
+    asm { fld1; fld two; }
+    else static assert(0, "todo");
+}
+
+creal cr2()
+{
+    version(X86)
+    asm
+    {
+        naked;
+        fld1;
+        fld two;
+        ret;
+    }
+    else static assert(0, "todo");
+}
+
+void* vp()
+{
+    version(X86)
+    asm { mov EAX, 0x80; }
+    else static assert(0, "todo");
+}
+
+int[int] gaa;
+
+int[int] aa()
+{
+    version(X86)
+    asm { mov EAX, gaa; }
+    else static assert(0, "todo");
+}
+
+Object gobj;
+
+Object ob()
+{
+    version(X86)
+    asm { mov EAX, gobj; }
+    else static assert(0, "todo");
+}
+
+char[] ghello = "hello world";
+
+char[] str()
+{
+    version(X86)
+    asm { lea ECX, ghello; mov EAX, [ECX]; mov EDX, [ECX+4]; }
+    else static assert(0, "todo");
+}
+
+char[] delegate() dg()
+{
+    version(X86)
+    asm { mov EAX, gobj; lea EDX, Object.toString; }
+    else static assert(0, "todo");
+}
+
+void main()
+{
+    gaa[4] = 5;
+    gobj = new Object;
+    auto adg = &gobj.toString;
+
+    assert(foo() == 42);
+    assert(bar() == 0x000000AA000000FF);
+    assert(onef() == 1);
+    assert(oned() == 1);
+    assert(oner() == 1);
+    assert(cr() == 1+2i);
+    assert(cr2() == 1+2i);
+    assert(vp() == cast(void*)0x80);
+    assert(aa() is gaa);
+    assert(ob() is gobj);
+    assert(str() == "hello world");
+    assert(dg()() == "object.Object");
+}
+
+extern(C) int printf(char*, ...);