Mercurial > projects > ldc
comparison tango.patch @ 1079:4e388d9d0e25
Intrinsics overhaul:
- More error checking for pragma(intrinsic)
- Properly handle templating for real (use actual nr of bits, not .sizeof * 8)
- Template all .i* and .f* intrinsics
- The old names are deprecated aliases now
I also added a preliminary patch to make tango.math.Math use the new versions.
(I think it looks a lot nicer now)
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Tue, 10 Mar 2009 04:45:32 +0100 |
parents | |
children | 5710440ea420 |
comparison
equal
deleted
inserted
replaced
1077:bb57632d27ea | 1079:4e388d9d0e25 |
---|---|
1 Index: tango/tango/math/Math.d | |
2 =================================================================== | |
3 --- tango/tango/math/Math.d (revision 4388) | |
4 +++ tango/tango/math/Math.d (working copy) | |
5 @@ -80,13 +80,9 @@ | |
6 } else version(D_InlineAsm_X86) { | |
7 version = Naked_D_InlineAsm_X86; | |
8 } | |
9 -else version(LDC) | |
10 +version(LDC) | |
11 { | |
12 import ldc.intrinsics; | |
13 - version(X86) | |
14 - { | |
15 - version = LDC_X86; | |
16 - } | |
17 } | |
18 | |
19 /* | |
20 @@ -312,26 +308,12 @@ | |
21 * Results are undefined if |x| >= $(POWER 2,64). | |
22 */ | |
23 | |
24 -version(LDC) | |
25 +real cos(real x) /* intrinsic */ | |
26 { | |
27 - alias llvm_cos_f32 cos; | |
28 - alias llvm_cos_f64 cos; | |
29 - version(X86) | |
30 + version(LDC) | |
31 { | |
32 - alias llvm_cos_f80 cos; | |
33 + return llvm_cos(x); | |
34 } | |
35 - else | |
36 - { | |
37 - real cos(real x) | |
38 - { | |
39 - return tango.stdc.math.cosl(x); | |
40 - } | |
41 - } | |
42 -} | |
43 -else | |
44 -{ | |
45 -real cos(real x) /* intrinsic */ | |
46 -{ | |
47 version(D_InlineAsm_X86) | |
48 { | |
49 asm | |
50 @@ -345,7 +327,6 @@ | |
51 return tango.stdc.math.cosl(x); | |
52 } | |
53 } | |
54 -} | |
55 | |
56 debug(UnitTest) { | |
57 unittest { | |
58 @@ -366,26 +347,12 @@ | |
59 * Bugs: | |
60 * Results are undefined if |x| >= $(POWER 2,64). | |
61 */ | |
62 -version(LDC) | |
63 +real sin(real x) /* intrinsic */ | |
64 { | |
65 - alias llvm_sin_f32 sin; | |
66 - alias llvm_sin_f64 sin; | |
67 - version(X86) | |
68 + version(LDC) | |
69 { | |
70 - alias llvm_sin_f80 sin; | |
71 + return llvm_sin(x); | |
72 } | |
73 - else | |
74 - { | |
75 - real sin(real x) | |
76 - { | |
77 - return tango.stdc.math.sinl(x); | |
78 - } | |
79 - } | |
80 -} | |
81 -else | |
82 -{ | |
83 -real sin(real x) /* intrinsic */ | |
84 -{ | |
85 version(D_InlineAsm_X86) | |
86 { | |
87 asm | |
88 @@ -399,7 +366,6 @@ | |
89 return tango.stdc.math.sinl(x); | |
90 } | |
91 } | |
92 -} | |
93 | |
94 debug(UnitTest) { | |
95 unittest { | |
96 @@ -999,29 +965,14 @@ | |
97 * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) $(TD no)) | |
98 * ) | |
99 */ | |
100 -version(LDC) | |
101 +float sqrt(float x) /* intrinsic */ | |
102 { | |
103 - alias llvm_sqrt_f32 sqrt; | |
104 - alias llvm_sqrt_f64 sqrt; | |
105 - version(X86) | |
106 + version(LDC) | |
107 { | |
108 - alias llvm_sqrt_f80 sqrt; | |
109 + return llvm_sqrt(x); | |
110 } | |
111 - else | |
112 + else version(D_InlineAsm_X86) | |
113 { | |
114 - real sqrt(real x) | |
115 - { | |
116 - return tango.stdc.math.sqrtl(x); | |
117 - } | |
118 - } | |
119 -} | |
120 -else | |
121 -{ | |
122 - | |
123 -float sqrt(float x) /* intrinsic */ | |
124 -{ | |
125 - version(D_InlineAsm_X86) | |
126 - { | |
127 asm | |
128 { | |
129 fld x; | |
130 @@ -1036,8 +987,12 @@ | |
131 | |
132 double sqrt(double x) /* intrinsic */ /// ditto | |
133 { | |
134 - version(D_InlineAsm_X86) | |
135 + version(LDC) | |
136 { | |
137 + return llvm_sqrt(x); | |
138 + } | |
139 + else version(D_InlineAsm_X86) | |
140 + { | |
141 asm | |
142 { | |
143 fld x; | |
144 @@ -1052,8 +1007,12 @@ | |
145 | |
146 real sqrt(real x) /* intrinsic */ /// ditto | |
147 { | |
148 - version(D_InlineAsm_X86) | |
149 + version(LDC) | |
150 { | |
151 + return llvm_sqrt(x); | |
152 + } | |
153 + else version(D_InlineAsm_X86) | |
154 + { | |
155 asm | |
156 { | |
157 fld x; | |
158 @@ -1066,8 +1025,6 @@ | |
159 } | |
160 } | |
161 | |
162 -} | |
163 - | |
164 /** ditto */ | |
165 creal sqrt(creal z) | |
166 { | |
167 @@ -1714,9 +1671,9 @@ | |
168 } | |
169 } | |
170 } | |
171 - version(LDC_X86) | |
172 + version(LDC) | |
173 { | |
174 - return llvm_pow_f80(x, y); | |
175 + return llvm_pow(x, y); | |
176 } | |
177 else | |
178 { |