Mercurial > projects > ldc
view tests/mini/naked_asm5.d @ 951:e71c61befd6d
Now that we're using LLVM 2.5, we can stop always running the
CFGSimplification pass.
The pass was originally added as a workaround for a LLVM 2.4 bug where debug
info would reference labels that have been optimized away.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Thu, 12 Feb 2009 18:39:03 +0100 |
parents | 1b10a9c6e3e8 |
children | a400b1dd657f |
line wrap: on
line source
int foo(int op)(int a, int b) { version(X86) { const OP = (op == '+') ? "add" : "sub"; asm { naked; } mixin("asm{"~OP~" EAX, [ESP+4];}"); asm { ret 4; } } else version(X86_64) { const OP = (op == '+') ? "add" : "sub"; asm { naked; } mixin("asm{"~OP~" ESI,EDI; mov EAX, ESI;}"); asm { ret; } } else static assert(0, "todo"); } void main() { int i = foo!('+')(2, 4); assert(i == 6); i = foo!('-')(2, 4); assert(i == 2); }