Mercurial > projects > ldc
view tests/mini/asm7.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 | 4ac97ec7c18e |
children | 12b423e17860 |
line wrap: on
line source
module tangotests.asm7; // test massive label collisions (runtime uses Loverflow too) extern(C) int printf(char*, ...); void main() { int a = add(1,2); int s = sub(1,2); assert(a == 3); assert(s == -1); } int add(int a, int b) { int res; version (LLVM_InlineAsm_X86) { asm { mov EAX, a; add EAX, b; jo Loverflow; mov res, EAX; } } else version (LLVM_InlineAsm_X86_64) { asm { mov EAX, a; add EAX, b; jo Loverflow; mov res, EAX; } } printf("%d\n",res); return res; Loverflow: assert(0, "add overflow"); } int sub(int a, int b) { int res; version (LLVM_InlineAsm_X86) { asm { mov EAX, a; sub EAX, b; jo Loverflow; mov res, EAX; } } else version (LLVM_InlineAsm_X86_64) { asm { mov EAX, a; sub EAX, b; jo Loverflow; mov res, EAX; } } printf("%d\n",res); return res; Loverflow: assert(0, "sub overflow"); int x; }