Mercurial > projects > ldc
annotate tests/mini/dotproduct.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 | 1bb99290e03a |
children |
rev | line source |
---|---|
270
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
66
diff
changeset
|
1 extern(C) int printf(char*, ...); |
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
66
diff
changeset
|
2 |
1 | 3 struct vec3 |
4 { | |
5 float x,y,z; | |
6 | |
7 float dot(ref vec3 v) | |
8 { | |
9 return x*v.x + y*v.y + z*v.z; | |
10 } | |
11 | |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
12 void print(char[] n) |
1 | 13 { |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
14 printf("%.*s = vec3(%.4f, %.4f, %.4f)\n", n.length, n.ptr, x,y,z); |
1 | 15 } |
16 } | |
17 | |
18 int main() | |
19 { | |
20 printf("Dot Product test\n"); | |
21 | |
66
0c5f410d973c
[svn r70] Fixed bug where correct calling convention was not set on calling aggregate methods
lindquist
parents:
4
diff
changeset
|
22 const f = 0.7071067811865474617; |
1 | 23 vec3 v = vec3(f,f,0); |
24 vec3 w = vec3(f,0,f); | |
25 | |
26 v.print("v"); | |
66
0c5f410d973c
[svn r70] Fixed bug where correct calling convention was not set on calling aggregate methods
lindquist
parents:
4
diff
changeset
|
27 w.print("w"); |
1 | 28 |
29 auto dp = v.dot(w); | |
30 printf("v ยท w = %f\n", dp); | |
31 assert(dp > 0.4999 && dp < 0.5001); | |
32 | |
33 printf(" SUCCESS\n"); | |
34 return 0; | |
35 } | |
36 |