Mercurial > projects > ldc
annotate tests/mini/asm5.d @ 974:815e1b8c6b00
Allow 'return exp;' for void main().
It's unfortunate that for main the llvm type and D type don't match up...
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Tue, 17 Feb 2009 18:53:15 +0100 |
parents | b2d27ddf8f45 |
children | 855889b7b268 |
rev | line source |
---|---|
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
1 int foo() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
2 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
3 version(X86) |
949
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
4 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
5 asm { mov EAX, 42; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
6 } else version(X86_64) |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
7 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
8 asm { movq RAX, 42; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
9 } |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
10 else static assert(0, "todo"); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
11 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
12 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
13 ulong bar() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
14 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
15 version(X86) |
949
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
16 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
17 asm { mov EAX, 0xFF; mov EDX, 0xAA; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
18 } else version(X86_64) |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
19 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
20 asm { movq RAX, 0xFF; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
21 } |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
22 else static assert(0, "todo"); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
23 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
24 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
25 void main() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
26 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
27 long l = 1; |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
28 l = 2; |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
29 l = 4; |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
30 l = 8; |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
31 assert(foo() == 42); |
949
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
32 version(X86) |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
33 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
34 assert(bar() == 0x000000AA000000FF); |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
35 } else version(X86_64) |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
36 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
37 assert(bar() == 0x00000000000000FF); |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
38 } |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
39 } |