comparison import/llvmdc/intrinsics.di @ 443:44f08170f4ef

Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn. Reworked the LLVMDC specific pragmas.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Fri, 01 Aug 2008 00:32:06 +0200
parents
children cc40db549aea
comparison
equal deleted inserted replaced
442:76078c8ab5b9 443:44f08170f4ef
1 /*
2 * This module holds declarations to LLVM intrinsics.
3 *
4 * See the LLVM language reference for more information:
5 *
6 * - http://llvm.org/docs/LangRef.html#intrinsics
7 *
8 */
9
10 module llvmdc.intrinsics;
11
12 // Check for the right compiler
13 version(LLVMDC)
14 {
15 // OK
16 }
17 else
18 {
19 static assert(false, "This module is only valid for LLVMDC");
20 }
21
22 //
23 // CODE GENERATOR INTRINSICS
24 //
25
26
27 // The 'llvm.returnaddress' intrinsic attempts to compute a target-specific value indicating the return address of the current function or one of its callers.
28
29 pragma(intrinsic, "llvm.returnaddress")
30 void* llvm_returnaddress(uint level);
31
32
33 // The 'llvm.frameaddress' intrinsic attempts to return the target-specific frame pointer value for the specified stack frame.
34
35 pragma(intrinsic, "llvm.frameaddress")
36 void* llvm_frameaddress(uint level);
37
38
39 // The 'llvm.stacksave' intrinsic is used to remember the current state of the function stack, for use with llvm.stackrestore. This is useful for implementing language features like scoped automatic variable sized arrays in C99.
40
41 pragma(intrinsic, "llvm.stacksave")
42 void* llvm_stacksave();
43
44
45 // The 'llvm.stackrestore' intrinsic is used to restore the state of the function stack to the state it was in when the corresponding llvm.stacksave intrinsic executed. This is useful for implementing language features like scoped automatic variable sized arrays in C99.
46
47 pragma(intrinsic, "llvm.stackrestore")
48 void llvm_stackrestore(void* ptr);
49
50
51 // The 'llvm.prefetch' intrinsic is a hint to the code generator to insert a prefetch instruction if supported; otherwise, it is a noop. Prefetches have no effect on the behavior of the program but can change its performance characteristics.
52
53 pragma(intrinsic, "llvm.prefetch")
54 void llvm_prefetch(void* ptr, uint rw, uint locality);
55
56
57 // The 'llvm.pcmarker' intrinsic is a method to export a Program Counter (PC) in a region of code to simulators and other tools. The method is target specific, but it is expected that the marker will use exported symbols to transmit the PC of the marker. The marker makes no guarantees that it will remain with any specific instruction after optimizations. It is possible that the presence of a marker will inhibit optimizations. The intended use is to be inserted after optimizations to allow correlations of simulation runs.
58
59 pragma(intrinsic, "llvm.pcmarker")
60 void llvm_pcmarker(uint id);
61
62
63 // The 'llvm.readcyclecounter' intrinsic provides access to the cycle counter register (or similar low latency, high accuracy clocks) on those targets that support it. On X86, it should map to RDTSC. On Alpha, it should map to RPCC. As the backing counters overflow quickly (on the order of 9 seconds on alpha), this should only be used for small timings.
64
65 pragma(intrinsic, "llvm.readcyclecounter")
66 ulong readcyclecounter();
67
68
69
70
71 //
72 // STANDARD C LIBRARY INTRINSICS
73 //
74
75
76 // The 'llvm.memcpy.*' intrinsics copy a block of memory from the source location to the destination location.
77 // Note that, unlike the standard libc function, the llvm.memcpy.* intrinsics do not return a value, and takes an extra alignment argument.
78
79 pragma(intrinsic, "llvm.memcpy.i32")
80 void llvm_memcpy_i32(void* dst, void* src, uint len, uint alignment);
81 pragma(intrinsic, "llvm.memcpy.i64")
82 void llvm_memcpy_i64(void* dst, void* src, ulong len, uint alignment);
83
84
85 // The 'llvm.memmove.*' intrinsics move a block of memory from the source location to the destination location. It is similar to the 'llvm.memcpy' intrinsic but allows the two memory locations to overlap.
86 // Note that, unlike the standard libc function, the llvm.memmove.* intrinsics do not return a value, and takes an extra alignment argument.
87
88 pragma(intrinsic, "llvm.memmove.i32")
89 void llvm_memmove_i32(void* dst, void* src, uint len, uint alignment);
90 pragma(intrinsic, "llvm.memmove.i64")
91 void llvm_memmove_i64(void* dst, void* src, ulong len, int alignment);
92
93
94 // The 'llvm.memset.*' intrinsics fill a block of memory with a particular byte value.
95 // Note that, unlike the standard libc function, the llvm.memset intrinsic does not return a value, and takes an extra alignment argument.
96
97 pragma(intrinsic, "llvm.memset.i32")
98 void llvm_memset_i32(void* dst, ubyte val, uint len, uint alignment);
99 pragma(intrinsic, "llvm.memset.i64")
100 void llvm_memset_i64(void* dst, ubyte val, ulong len, uint alignment);
101
102
103 // The 'llvm.sqrt' intrinsics return the sqrt of the specified operand, returning the same value as the libm 'sqrt' functions would. Unlike sqrt in libm, however, llvm.sqrt has undefined behavior for negative numbers other than -0.0 (which allows for better optimization, because there is no need to worry about errno being set). llvm.sqrt(-0.0) is defined to return -0.0 like IEEE sqrt.
104
105 pragma(intrinsic, "llvm.sqrt.f32")
106 float llvm_sqrt_f32(float val);
107 pragma(intrinsic, "llvm.sqrt.f64")
108 double llvm_sqrt_f64(double val);
109 version(LLVM_X86_FP80)
110 {
111 pragma(intrinsic, "llvm.sqrt.f80")
112 real llvm_sqrt_f80(real val);
113 }
114
115
116 // The 'llvm.sin.*' intrinsics return the sine of the operand.
117
118 pragma(intrinsic, "llvm.sin.f32")
119 float llvm_sin_f32(float val);
120 pragma(intrinsic, "llvm.sin.f64")
121 double llvm_sin_f64(double val);
122 version(LLVM_X86_FP80)
123 {
124 pragma(intrinsic, "llvm.sin.f80")
125 real llvm_sin_f80(real val);
126 }
127
128
129 // The 'llvm.cos.*' intrinsics return the cosine of the operand.
130
131 pragma(intrinsic, "llvm.cos.f32")
132 float llvm_cos_f32(float val);
133 pragma(intrinsic, "llvm.cos.f64")
134 double llvm_cos_f64(double val);
135 version(LLVM_X86_FP80)
136 {
137 pragma(intrinsic, "llvm.cos.f80")
138 real llvm_cos_f80(real val);
139 }
140
141
142 // The 'llvm.powi.*' intrinsics return the first operand raised to the specified (positive or negative) power. The order of evaluation of multiplications is not defined. When a vector of floating point type is used, the second argument remains a scalar integer value.
143
144 pragma(intrinsic, "llvm.powi.f32")
145 float llvm_powi_f32(float val, int power);
146
147 pragma(intrinsic, "llvm.powi.f64")
148 double llvm_powi_f64(double val, int power);
149 version(LLVM_X86_FP80)
150 {
151 pragma(intrinsic, "llvm.powi.f80")
152 real llvm_powi_f80(real val, int power);
153 }
154
155
156 // The 'llvm.pow.*' intrinsics return the first operand raised to the specified (positive or negative) power.
157
158 pragma(intrinsic, "llvm.pow.f32")
159 float llvm_pow_f32(float val, float power);
160
161 pragma(intrinsic, "llvm.pow.f64")
162 double llvm_pow_f64(double val, double power);
163 version(LLVM_X86_FP80)
164 {
165 pragma(intrinsic, "llvm.pow.f80")
166 real llvm_pow_f80(real val, real power);
167 }
168
169
170
171
172 //
173 // BIT MANIPULATION INTRINSICS
174 //
175
176 // The 'llvm.bswap' family of intrinsics is used to byte swap integer values with an even number of bytes (positive multiple of 16 bits). These are useful for performing operations on data that is not in the target's native byte order.
177
178 pragma(intrinsic, "llvm.bswap.i16.i16")
179 ushort llvm_bswap_i16(ushort val);
180
181 pragma(intrinsic, "llvm.bswap.i32.i32")
182 uint llvm_bswap_i32(uint val);
183
184 pragma(intrinsic, "llvm.bswap.i64.i64")
185 ulong llvm_bswap_i64(ulong val);
186
187
188 // The 'llvm.ctpop' family of intrinsics counts the number of bits set in a value.
189
190 pragma(intrinsic, "llvm.ctpop.i8")
191 ubyte llvm_ctpop_i8(ubyte src);
192
193 pragma(intrinsic, "llvm.ctpop.i16")
194 ushort llvm_ctpop_i16(ushort src);
195
196 pragma(intrinsic, "llvm.ctpop.i32")
197 uint llvm_ctpop_i32(uint src);
198
199 pragma(intrinsic, "llvm.ctpop.i64")
200 ulong llvm_ctpop_i64(ulong src);
201
202
203 // The 'llvm.ctlz' family of intrinsic functions counts the number of leading zeros in a variable.
204
205 pragma(intrinsic, "llvm.ctlz.i8")
206 ubyte llvm_ctlz_i8(ubyte src);
207
208 pragma(intrinsic, "llvm.ctlz.i16")
209 ushort llvm_ctlz_i16(ushort src);
210
211 pragma(intrinsic, "llvm.ctlz.i32")
212 uint llvm_ctlz_i32(uint src);
213
214 pragma(intrinsic, "llvm.ctlz.i64")
215 ulong llvm_ctlz_i64(ulong src);
216
217
218 // The 'llvm.cttz' family of intrinsic functions counts the number of trailing zeros.
219
220 pragma(intrinsic, "llvm.cttz.i8")
221 ubyte llvm_cttz_i8(ubyte src);
222
223 pragma(intrinsic, "llvm.cttz.i16")
224 ushort llvm_cttz_i16(ushort src);
225
226 pragma(intrinsic, "llvm.cttz.i32")
227 uint llvm_cttz_i32(uint src);
228
229 pragma(intrinsic, "llvm.cttz.i64")
230 ulong llvm_cttz_i64(ulong src);
231
232
233 // The 'llvm.part.select' family of intrinsic functions selects a range of bits from an integer value and returns them in the same bit width as the original value.
234
235 pragma(intrinsic, "llvm.part.select.i8")
236 ubyte llvm_part_select_i(ubyte val, uint loBit, uint hiBit);
237
238 pragma(intrinsic, "llvm.part.select.i16")
239 ushort llvm_part_select_i(ushort val, uint loBit, uint hiBit);
240
241 pragma(intrinsic, "llvm.part.select.i32")
242 uint llvm_part_select_i(uint val, uint loBit, uint hiBit);
243
244 pragma(intrinsic, "llvm.part.select.i64")
245 ulong llvm_part_select_i(ulong val, uint loBit, uint hiBit);
246
247
248
249
250 //
251 // ATOMIC OPERATIONS AND SYNCHRONIZATION INTRINSICS
252 //
253
254 // TODO
255
256
257
258
259 //
260 // GENERAL INTRINSICS
261 //
262
263
264 // This intrinsics is lowered to the target dependent trap instruction. If the target does not have a trap instruction, this intrinsic will be lowered to the call of the abort() function.
265
266 pragma(intrinsic, "llvm.trap")
267 void llvm_trap();