annotate tests/mini/asm8.d @ 979:523bf4f166bc

Fix some assembler issues: The assembler was miscompiling "add" (specifically, the "add reg/mem, imm" variations). The change that caused this seems to have been made because without it, some "add"s didn't compile at all. This patch reverts the previous change, and makes sure assembler operands are remapped correctly even though the input operands auto-generated due to updating operations aren't explicitly used.
author Frits van Bommel <fvbommel wxs.nl>
date Wed, 18 Feb 2009 21:46:14 +0100
parents 926c1d06c7ec
children 855889b7b268
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
959
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
1 const float one_f = 1;
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
2 const double one_d = 1;
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
3 const real one_r = 1;
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
4
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
5 int foo()
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
6 {
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
7 version(X86)
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
8 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
9 asm { mov EAX, 42; }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
10 }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
11 else version (X86_64)
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
12 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
13 asm { mov EAX, 42; }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
14 }
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
15 else static assert(0, "todo");
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
16 }
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
17
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
18 ulong bar()
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
19 {
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
20 version(X86)
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
21 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
22 asm { mov EDX, 0xAA; mov EAX, 0xFF; }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
23 }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
24 else version (X86_64)
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
25 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
26 asm { movq RAX, 0xFF; }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
27 }
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
28 else static assert(0, "todo");
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
29 }
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
30
959
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
31
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
32 float onef()
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
33 {
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
34 version(X86)
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
35 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
36 asm { fld1; }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
37 }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
38 else version (X86_64)
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
39 {
959
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
40 asm { movss XMM0, [one_f]; }
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
41 }
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
42 else static assert(0, "todo");
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
43 }
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
44
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
45 double oned()
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
46 {
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
47 version(X86)
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
48 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
49 asm { fld1; }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
50 }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
51 else version (X86_64)
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
52 {
959
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
53 asm { movsd XMM0, [one_d]; }
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
54 }
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
55 else static assert(0, "todo");
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
56 }
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
57
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
58 real oner()
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
59 {
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
60 version(X86)
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
61 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
62 asm { fld1; }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
63 }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
64 else version (X86_64)
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
65 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
66 asm { fld1; }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
67 }
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
68 else static assert(0, "todo");
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
69 }
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
70
959
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
71 ifloat oneif()
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
72 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
73 version(X86)
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
74 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
75 asm { fld1; }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
76 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
77 else version (X86_64)
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
78 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
79 asm { movss XMM0, [one_f]; }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
80 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
81 else static assert(0, "todo");
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
82 }
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
83
959
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
84 idouble oneid()
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
85 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
86 version(X86)
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
87 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
88 asm { fld1; }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
89 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
90 else version (X86_64)
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
91 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
92 asm { movsd XMM0, [one_d]; }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
93 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
94 else static assert(0, "todo");
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
95 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
96
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
97 ireal oneir()
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
98 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
99 version(X86)
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
100 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
101 asm { fld1; }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
102 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
103 else version (X86_64)
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
104 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
105 asm { fld1; }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
106 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
107 else static assert(0, "todo");
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
108 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
109
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
110
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
111 const float two_f = 2;
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
112
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
113 cfloat cf()
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
114 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
115 version(X86)
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
116 {
967
926c1d06c7ec Fix test on x86-32.
Christian Kamm <kamm incasoftware de>
parents: 964
diff changeset
117 asm { fld1; fld two_f; }
959
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
118 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
119 else version (X86_64)
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
120 {
964
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
121 version(all) {
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
122 asm
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
123 {
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
124 movss XMM0, [one_f];
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
125 movss XMM1, [two_f];
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
126 }
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
127 } else {
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
128 // Code for when LDC becomes ABI-compatible with GCC
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
129 // regarding cfloat returns.
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
130 asm {
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
131 movd EAX, [one_f];
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
132 movd ECX, [two_f];
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
133
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
134 // invalid operand size :(
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
135 //shl RCX, 32;
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
136 //or RAX, RCX;
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
137
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
138 pushq RAX;
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
139 mov [RSP + 4], EAX;
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
140 popq RAX;
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
141
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
142 movd XMM0, RAX;
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
143 }
959
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
144 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
145 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
146 else static assert(0, "todo");
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
147 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
148
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
149 cfloat cf2()
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
150 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
151 version(X86)
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
152 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
153 asm
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
154 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
155 naked;
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
156 fld1;
967
926c1d06c7ec Fix test on x86-32.
Christian Kamm <kamm incasoftware de>
parents: 964
diff changeset
157 fld two_f;
959
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
158 ret;
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
159 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
160 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
161 else version (X86_64)
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
162 {
964
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
163 version(all) {
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
164 asm
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
165 {
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
166 naked;
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
167 movss XMM0, [one_f];
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
168 movss XMM1, [two_f];
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
169 ret;
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
170 }
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
171 } else {
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
172 // Code for when LDC becomes ABI-compatible with GCC
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
173 // regarding cfloat returns.
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
174 asm {
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
175 naked;
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
176 mov EAX, [one_f];
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
177 mov ECX, [two_f];
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
178
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
179 // invalid operand size :(
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
180 //shl RCX, 32;
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
181 //or RAX, RCX;
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
182
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
183 pushq RAX;
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
184 mov [RSP + 4], EAX;
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
185 popq RAX;
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
186
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
187 movd RAX, XMM0;
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
188 ret;
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
189 }
959
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
190 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
191 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
192 else static assert(0, "todo");
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
193 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
194
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
195
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
196 const double two_d = 2;
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
197
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
198 cdouble cd()
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
199 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
200 version(X86)
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
201 {
964
aa2e3a6c3410 Some changes I missed in my last commit (wound up in wrong patch file)
Frits van Bommel <fvbommel wxs.nl>
parents: 959
diff changeset
202 asm { fld1; fld two_d; }
959
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
203 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
204 else version (X86_64)
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
205 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
206 asm
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
207 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
208 leaq RAX, [one_d];
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
209 leaq RCX, [two_d];
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
210 movsd XMM0, [RAX];
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
211 movsd XMM1, [RCX];
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
212 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
213 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
214 else static assert(0, "todo");
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
215 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
216
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
217 cdouble cd2()
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
218 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
219 version(X86)
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
220 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
221 asm
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
222 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
223 naked;
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
224 fld1;
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
225 fld two_d;
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
226 ret;
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
227 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
228 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
229 else version (X86_64)
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
230 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
231 asm
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
232 {
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
233 naked;
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
234 movsd XMM0, [one_d];
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
235 movsd XMM1, [two_d];
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
236 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
237 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
238 else static assert(0, "todo");
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
239 }
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
240
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
241
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
242 const real two_r = 2.0;
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
243
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
244 creal cr()
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
245 {
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
246 version(X86)
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
247 {
959
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
248 asm { fld1; fld two_r; }
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
249 }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
250 else version (X86_64)
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
251 {
959
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
252 asm { fld two_r; fld1; }
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
253 }
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
254 else static assert(0, "todo");
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
255 }
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
256
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
257 creal cr2()
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
258 {
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
259 version(X86)
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
260 {
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
261 asm
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
262 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
263 naked;
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
264 fld1;
959
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
265 fld two_r;
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
266 ret;
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
267 }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
268 }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
269 else version (X86_64)
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
270 {
959
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
271 asm
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
272 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
273 naked;
959
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
274 fld two_r;
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
275 fld1;
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
276 ret;
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
277 }
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
278 }
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
279 else static assert(0, "todo");
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
280 }
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
281
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
282 void* vp()
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
283 {
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
284 version(X86)
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
285 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
286 asm { mov EAX, 0x80; }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
287 }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
288 else version (X86_64)
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
289 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
290 asm { movq RAX, 0x80; }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
291 }
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
292 else static assert(0, "todo");
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
293 }
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
294
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
295 int[int] gaa;
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
296
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
297 int[int] aa()
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
298 {
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
299 version(X86)
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
300 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
301 asm { mov EAX, gaa; }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
302 }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
303 else version (X86_64)
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
304 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
305 asm { movq RAX, gaa; }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
306 }
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
307 else static assert(0, "todo");
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
308 }
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
309
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
310 Object gobj;
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
311
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
312 Object ob()
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
313 {
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
314 version(X86)
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
315 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
316 asm { mov EAX, gobj; }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
317 }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
318 else version (X86_64)
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
319 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
320 asm { movq RAX, gobj; }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
321 }
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
322 else static assert(0, "todo");
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
323 }
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
324
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
325 char[] ghello = "hello world";
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
326
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
327 char[] str()
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
328 {
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
329 version(X86)
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
330 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
331 asm { lea ECX, ghello; mov EAX, [ECX]; mov EDX, [ECX+4]; }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
332 }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
333 else version (X86_64)
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
334 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
335 asm { movq RAX, [ghello]; movq RDX, [ghello]+8; }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
336 }
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
337 else static assert(0, "todo");
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
338 }
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
339
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
340 char[] delegate() dg()
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
341 {
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
342 version(X86)
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
343 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
344 asm { mov EAX, gobj; lea EDX, Object.toString; }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
345 }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
346 else version (X86_64)
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
347 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
348 asm { movq RAX, [gobj]; leaq RDX, Object.toString; }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
349 }
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
350 else static assert(0, "todo");
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
351 }
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
352
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
353 void main()
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
354 {
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
355 gaa[4] = 5;
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
356 gobj = new Object;
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
357 auto adg = &gobj.toString;
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
358
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
359 assert(foo() == 42);
949
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
360 version(X86)
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
361 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
362 assert(bar() == 0x000000AA000000FF);
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
363 }
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
364 else version (X86_64)
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
365 {
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
366 assert(bar() == 0x00000000000000FF);
b2d27ddf8f45 changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents: 945
diff changeset
367 }
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
368 assert(onef() == 1);
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
369 assert(oned() == 1);
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
370 assert(oner() == 1);
959
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
371
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
372 assert(oneif() == 1i);
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
373 assert(oneid() == 1i);
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
374 assert(oneir() == 1i);
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
375
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
376 assert(cf() == 1+2i);
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
377 assert(cf2() == 1+2i);
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
378
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
379 assert(cd() == 1+2i);
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
380 assert(cd2() == 1+2i);
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
381
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
382 assert(cr() == 1+2i);
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
383 assert(cr2() == 1+2i);
959
7e669954db7d Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents: 949
diff changeset
384
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
385 assert(vp() == cast(void*)0x80);
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
386 assert(aa() is gaa);
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
387 assert(ob() is gobj);
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
388 assert(str() == "hello world");
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
389 assert(dg()() == "object.Object");
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
390 }
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
391
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
392 extern(C) int printf(char*, ...);