Mercurial > projects > ldc
annotate tests/mini/naked_asm5.d @ 1651:cb960b882ca3 default tip
bindings were moved to dsource.org/projects/bindings/
author | Moritz Warning <moritzwarning@web.de> |
---|---|
date | Thu, 20 May 2010 20:05:03 +0200 |
parents | e92e14690a4f |
children |
rev | line source |
---|---|
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
1 int foo(int op)(int a, int b) |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
2 { |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
3 version(X86) |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
4 { |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
5 const OP = (op == '+') ? "add" : "sub"; |
1448
e92e14690a4f
change mingw32 versioning to version(Windows)
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1447
diff
changeset
|
6 version (Windows) |
1447
a400b1dd657f
fix assembly code for mingw32 in minitests
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
928
diff
changeset
|
7 { |
a400b1dd657f
fix assembly code for mingw32 in minitests
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
928
diff
changeset
|
8 asm { naked; } |
a400b1dd657f
fix assembly code for mingw32 in minitests
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
928
diff
changeset
|
9 mixin("asm{push EBP;mov EBP,ESP;sub ESP,8;mov ECX,[EBP+8];"~OP~" EAX, ECX;add ESP,8;pop EBP;}"); |
a400b1dd657f
fix assembly code for mingw32 in minitests
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
928
diff
changeset
|
10 asm { ret; } |
a400b1dd657f
fix assembly code for mingw32 in minitests
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
928
diff
changeset
|
11 } else |
a400b1dd657f
fix assembly code for mingw32 in minitests
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
928
diff
changeset
|
12 { |
a400b1dd657f
fix assembly code for mingw32 in minitests
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
928
diff
changeset
|
13 asm { naked; } |
a400b1dd657f
fix assembly code for mingw32 in minitests
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
928
diff
changeset
|
14 mixin("asm{"~OP~" EAX, [ESP+4];}"); |
a400b1dd657f
fix assembly code for mingw32 in minitests
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
928
diff
changeset
|
15 asm { ret 4; } |
a400b1dd657f
fix assembly code for mingw32 in minitests
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
928
diff
changeset
|
16 } |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
17 } |
928
1b10a9c6e3e8
Added X86-64 version. Needed significant changes.
wilsonk@ubuntu
parents:
920
diff
changeset
|
18 else version(X86_64) |
1b10a9c6e3e8
Added X86-64 version. Needed significant changes.
wilsonk@ubuntu
parents:
920
diff
changeset
|
19 { |
1b10a9c6e3e8
Added X86-64 version. Needed significant changes.
wilsonk@ubuntu
parents:
920
diff
changeset
|
20 const OP = (op == '+') ? "add" : "sub"; |
1b10a9c6e3e8
Added X86-64 version. Needed significant changes.
wilsonk@ubuntu
parents:
920
diff
changeset
|
21 asm { naked; } |
1b10a9c6e3e8
Added X86-64 version. Needed significant changes.
wilsonk@ubuntu
parents:
920
diff
changeset
|
22 mixin("asm{"~OP~" ESI,EDI; mov EAX, ESI;}"); |
1b10a9c6e3e8
Added X86-64 version. Needed significant changes.
wilsonk@ubuntu
parents:
920
diff
changeset
|
23 asm { ret; } |
1b10a9c6e3e8
Added X86-64 version. Needed significant changes.
wilsonk@ubuntu
parents:
920
diff
changeset
|
24 } |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
25 else static assert(0, "todo"); |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
26 } |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
27 |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
28 void main() |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
29 { |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
30 int i = foo!('+')(2, 4); |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
31 assert(i == 6); |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
32 i = foo!('-')(2, 4); |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
33 assert(i == 2); |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
34 } |