comparison 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
comparison
equal deleted inserted replaced
944:eb310635d80e 945:03d7c4aac654
1 int foo()
2 {
3 version(X86)
4 asm { mov EAX, 42; }
5 else static assert(0, "todo");
6 }
7
8 ulong bar()
9 {
10 version(X86)
11 asm { mov EDX, 0xAA; mov EAX, 0xFF; }
12 else static assert(0, "todo");
13 }
14
15 float onef()
16 {
17 version(X86)
18 asm { fld1; }
19 else static assert(0, "todo");
20 }
21
22 double oned()
23 {
24 version(X86)
25 asm { fld1; }
26 else static assert(0, "todo");
27 }
28
29 real oner()
30 {
31 version(X86)
32 asm { fld1; }
33 else static assert(0, "todo");
34 }
35
36 real two = 2.0;
37
38 creal cr()
39 {
40 version(X86)
41 asm { fld1; fld two; }
42 else static assert(0, "todo");
43 }
44
45 creal cr2()
46 {
47 version(X86)
48 asm
49 {
50 naked;
51 fld1;
52 fld two;
53 ret;
54 }
55 else static assert(0, "todo");
56 }
57
58 void* vp()
59 {
60 version(X86)
61 asm { mov EAX, 0x80; }
62 else static assert(0, "todo");
63 }
64
65 int[int] gaa;
66
67 int[int] aa()
68 {
69 version(X86)
70 asm { mov EAX, gaa; }
71 else static assert(0, "todo");
72 }
73
74 Object gobj;
75
76 Object ob()
77 {
78 version(X86)
79 asm { mov EAX, gobj; }
80 else static assert(0, "todo");
81 }
82
83 char[] ghello = "hello world";
84
85 char[] str()
86 {
87 version(X86)
88 asm { lea ECX, ghello; mov EAX, [ECX]; mov EDX, [ECX+4]; }
89 else static assert(0, "todo");
90 }
91
92 char[] delegate() dg()
93 {
94 version(X86)
95 asm { mov EAX, gobj; lea EDX, Object.toString; }
96 else static assert(0, "todo");
97 }
98
99 void main()
100 {
101 gaa[4] = 5;
102 gobj = new Object;
103 auto adg = &gobj.toString;
104
105 assert(foo() == 42);
106 assert(bar() == 0x000000AA000000FF);
107 assert(onef() == 1);
108 assert(oned() == 1);
109 assert(oner() == 1);
110 assert(cr() == 1+2i);
111 assert(cr2() == 1+2i);
112 assert(vp() == cast(void*)0x80);
113 assert(aa() is gaa);
114 assert(ob() is gobj);
115 assert(str() == "hello world");
116 assert(dg()() == "object.Object");
117 }
118
119 extern(C) int printf(char*, ...);