comparison runtime/ldc.diff @ 665:d8a1481eaa0c

Renames.
author Christian Kamm <kamm incasoftware de>
date Mon, 06 Oct 2008 22:56:54 +0200
parents runtime/llvmdc.diff@6aaa3d3c1183
children 8d7e58801c82
comparison
equal deleted inserted replaced
664:eef8ac26c66c 665:d8a1481eaa0c
1 Index: object.di
2 ===================================================================
3 --- object.di (revision 3954)
4 +++ object.di (working copy)
5 @@ -150,6 +150,9 @@
6 void function() dtor;
7 void function() unitTest;
8
9 + void* xgetMembers;
10 + void function() ictor;
11 +
12 static int opApply( int delegate( inout ModuleInfo ) );
13 }
14
15 Index: lib/common/tango/core/BitManip.d
16 ===================================================================
17 --- lib/common/tango/core/BitManip.d (revision 3954)
18 +++ lib/common/tango/core/BitManip.d (working copy)
19 @@ -171,6 +171,10 @@
20 */
21 uint outpl( uint port_address, uint value );
22 }
23 +else version( LDC )
24 +{
25 + public import ldc.bitmanip;
26 +}
27 else
28 {
29 public import std.intrinsic;
30 Index: lib/common/tango/core/Thread.d
31 ===================================================================
32 --- lib/common/tango/core/Thread.d (revision 3954)
33 +++ lib/common/tango/core/Thread.d (working copy)
34 @@ -244,8 +244,29 @@
35 }
36 body
37 {
38 - version( D_InlineAsm_X86 )
39 + version( LDC)
40 {
41 + version(X86)
42 + {
43 + uint eax,ecx,edx,ebx,ebp,esi,edi;
44 + asm
45 + {
46 + mov eax[EBP], EAX ;
47 + mov ecx[EBP], ECX ;
48 + mov edx[EBP], EDX ;
49 + mov ebx[EBP], EBX ;
50 + mov ebp[EBP], EBP ;
51 + mov esi[EBP], ESI ;
52 + mov edi[EBP], EDI ;
53 + }
54 + }
55 + else
56 + {
57 + static assert( false, "Architecture not supported." );
58 + }
59 + }
60 + else version( D_InlineAsm_X86 )
61 + {
62 asm
63 {
64 pushad;
65 @@ -297,8 +318,12 @@
66 }
67 }
68
69 - version( D_InlineAsm_X86 )
70 + version( LDC)
71 {
72 + // nothing to pop
73 + }
74 + else version( D_InlineAsm_X86 )
75 + {
76 asm
77 {
78 popad;
79 @@ -2286,6 +2311,13 @@
80 version = AsmPPC_Posix;
81 }
82
83 + version( LLVM_InlineAsm_X86 )
84 + {
85 + version( Win32 )
86 + version = LLVM_AsmX86_Win32;
87 + else version( Posix )
88 + version = LLVM_AsmX86_Posix;
89 + }
90
91 version( Posix )
92 {
93 @@ -2296,6 +2328,8 @@
94 version( AsmX86_Win32 ) {} else
95 version( AsmX86_Posix ) {} else
96 version( AsmPPC_Posix ) {} else
97 + version( LLVM_AsmX86_Win32 ) {} else
98 + version( LLVM_AsmX86_Posix ) {} else
99 {
100 // NOTE: The ucontext implementation requires architecture specific
101 // data definitions to operate so testing for it must be done
102 @@ -2306,10 +2340,10 @@
103 import tango.stdc.posix.ucontext;
104 }
105 }
106 -
107 - const size_t PAGESIZE;
108 }
109
110 +// this can't be private since it's used as default argument to a public function
111 +const size_t PAGESIZE;
112
113 static this()
114 {
115 @@ -2336,7 +2370,7 @@
116 }
117 }
118
119 -
120 +extern(C) int printf(char*, ...);
121 ////////////////////////////////////////////////////////////////////////////////
122 // Fiber Entry Point and Context Switch
123 ////////////////////////////////////////////////////////////////////////////////
124 @@ -2450,6 +2484,22 @@
125 ret;
126 }
127 }
128 + else version( LLVM_AsmX86_Posix )
129 + {
130 + asm
131 + {
132 + // clobber registers to save
133 + inc EBX;
134 + inc ESI;
135 + inc EDI;
136 +
137 + // store oldp again with more accurate address
138 + mov EAX, oldp;
139 + mov [EAX], ESP;
140 + // load newp to begin context switch
141 + mov ESP, newp;
142 + }
143 + }
144 else static if( is( ucontext_t ) )
145 {
146 Fiber cfib = Fiber.getThis();
147 @@ -3115,6 +3165,16 @@
148 push( 0x00000000 ); // ESI
149 push( 0x00000000 ); // EDI
150 }
151 + else version( LLVM_AsmX86_Posix )
152 + {
153 + push( cast(size_t) &fiber_entryPoint ); // EIP
154 + push( 0x00000000 ); // newp
155 + push( 0x00000000 ); // oldp
156 + push( 0x00000000 ); // EBP
157 + push( 0x00000000 ); // EBX
158 + push( 0x00000000 ); // ESI
159 + push( 0x00000000 ); // EDI
160 + }
161 else version( AsmPPC_Posix )
162 {
163 version( StackGrowsDown )
164 Index: lib/unittest.sh
165 ===================================================================
166 --- lib/unittest.sh (revision 3954)
167 +++ lib/unittest.sh (working copy)
168 @@ -18,8 +18,9 @@
169 --help: This message
170 --run-all: Reports result instead of breaking. Do not use this if you want to
171 run unittest runner through a debugger.
172 - dmd: Builds unittests for dmd
173 - gdc: Builds unittests for gdc
174 + dmd: Builds unittests for dmd
175 + gdc: Builds unittests for gdc
176 + ldc: Builds unittests for ldc
177
178 <none>: Builds unittests for all known compilers.'
179 exit 0
180 @@ -86,7 +87,7 @@
181 void main() {}
182 EOF
183
184 - rebuild -w -d -g -L-ldl -L-lz -L-lbz2 -debug=UnitTest -debug -full -clean -unittest \
185 + rebuild -w -d -L-ldl -L-lz -L-lbz2 -debug=UnitTest -debug -full -clean -unittest \
186 -version=UnitTest $EXE.d tango/core/*.d tango/core/sync/*.d tango/io/digest/*.d \
187 tango/io/model/*.d tango/io/protocol/*.d tango/io/selector/*.d tango/io/*.d \
188 tango/io/vfs/*.d tango/io/vfs/model/*.d \
189 @@ -125,6 +126,9 @@
190 gdc)
191 GDC=1
192 ;;
193 + ldc)
194 + LDC=1
195 + ;;
196 *)
197 usage
198 ;;
199 @@ -132,10 +136,11 @@
200 shift
201 done
202
203 -if [ ! "$DMD" -a ! "$GDC" ]
204 +if [ ! "$DMD" -a ! "$GDC" -a ! "$LDC" ]
205 then
206 DMD=1
207 GDC=1
208 + LDC=1
209 fi
210
211 if [ "$DMD" = "1" ]
212 @@ -146,4 +151,7 @@
213 then
214 compile gdc runUnitTest_gdc
215 fi
216 -
217 +if [ "$LDC" = "1" ]
218 +then
219 + compile ldc runUnitTest_ldc
220 +fi
221 Index: lib/gc/basic/gcx.d
222 ===================================================================
223 --- lib/gc/basic/gcx.d (revision 3954)
224 +++ lib/gc/basic/gcx.d (working copy)
225 @@ -65,6 +65,13 @@
226 }
227
228
229 +struct BlkInfo
230 +{
231 + void* base;
232 + size_t size;
233 + uint attr;
234 +}
235 +
236 private
237 {
238 enum BlkAttr : uint
239 @@ -75,13 +82,6 @@
240 ALL_BITS = 0b1111_1111
241 }
242
243 - struct BlkInfo
244 - {
245 - void* base;
246 - size_t size;
247 - uint attr;
248 - }
249 -
250 extern (C) void* rt_stackBottom();
251 extern (C) void* rt_stackTop();
252
253 @@ -2178,6 +2178,28 @@
254 __builtin_unwind_init();
255 sp = & sp;
256 }
257 + else version(LDC)
258 + {
259 + version(X86)
260 + {
261 + uint eax,ecx,edx,ebx,ebp,esi,edi;
262 + asm
263 + {
264 + mov eax[EBP], EAX ;
265 + mov ecx[EBP], ECX ;
266 + mov edx[EBP], EDX ;
267 + mov ebx[EBP], EBX ;
268 + mov ebp[EBP], EBP ;
269 + mov esi[EBP], ESI ;
270 + mov edi[EBP], EDI ;
271 + mov sp[EBP],ESP ;
272 + }
273 + }
274 + else
275 + {
276 + static assert( false, "Architecture not supported." );
277 + }
278 + }
279 else
280 {
281 asm
282 @@ -2191,6 +2213,10 @@
283 {
284 // nothing to do
285 }
286 + else version(LDC)
287 + {
288 + // nothing to do
289 + }
290 else
291 {
292 asm
293 Index: lib/gc/basic/gcbits.d
294 ===================================================================
295 --- lib/gc/basic/gcbits.d (revision 3954)
296 +++ lib/gc/basic/gcbits.d (working copy)
297 @@ -39,6 +39,10 @@
298 {
299 // use the unoptimized version
300 }
301 +else version(LDC)
302 +{
303 + // ditto
304 +}
305 else version (D_InlineAsm_X86)
306 {
307 version = Asm86;
308 Index: tango/text/convert/Layout.d
309 ===================================================================
310 --- tango/text/convert/Layout.d (revision 3954)
311 +++ tango/text/convert/Layout.d (working copy)
312 @@ -47,6 +47,12 @@
313 alias void* Arg;
314 alias va_list ArgList;
315 }
316 +else version(LDC)
317 + {
318 + private import tango.core.Vararg;
319 + alias void* Arg;
320 + alias va_list ArgList;
321 + }
322 else
323 {
324 alias void* Arg;
325 @@ -197,9 +203,18 @@
326 assert (formatStr, "null format specifier");
327 assert (arguments.length < 64, "too many args in Layout.convert");
328
329 - version (GNU)
330 + version (LDC)
331 {
332 Arg[64] arglist = void;
333 + foreach (i, arg; arguments)
334 + {
335 + arglist[i] = args;
336 + args += (arg.tsize + size_t.sizeof - 1) & ~ (size_t.sizeof - 1);
337 + }
338 + }
339 + else version (GNU)
340 + {
341 + Arg[64] arglist = void;
342 int[64] intargs = void;
343 byte[64] byteargs = void;
344 long[64] longargs = void;
345 Index: tango/core/Vararg.d
346 ===================================================================
347 --- tango/core/Vararg.d (revision 3954)
348 +++ tango/core/Vararg.d (working copy)
349 @@ -15,6 +15,10 @@
350 {
351 public import std.stdarg;
352 }
353 +else version( LDC )
354 +{
355 + public import ldc.vararg;
356 +}
357 else
358 {
359 /**
360 Index: tango/core/Atomic.d
361 ===================================================================
362 --- tango/core/Atomic.d (revision 3954)
363 +++ tango/core/Atomic.d (working copy)
364 @@ -270,6 +270,167 @@
365
366
367 ////////////////////////////////////////////////////////////////////////////////
368 +// LDC Atomics Implementation
369 +////////////////////////////////////////////////////////////////////////////////
370 +
371 +
372 +else version( LDC )
373 +{
374 + import ldc.intrinsics;
375 +
376 +
377 + ////////////////////////////////////////////////////////////////////////////
378 + // Atomic Load
379 + ////////////////////////////////////////////////////////////////////////////
380 +
381 +
382 + template atomicLoad( msync ms = msync.seq, T )
383 + {
384 + T atomicLoad(ref T val)
385 + {
386 + llvm_memory_barrier(
387 + ms == msync.hlb || ms == msync.acq || ms == msync.seq,
388 + ms == msync.hsb || ms == msync.acq || ms == msync.seq,
389 + ms == msync.slb || ms == msync.rel || ms == msync.seq,
390 + ms == msync.ssb || ms == msync.rel || ms == msync.seq,
391 + false);
392 + static if (isPointerType!(T))
393 + {
394 + return cast(T)llvm_atomic_load_add!(size_t)(cast(size_t*)&val, 0);
395 + }
396 + else static if (is(T == bool))
397 + {
398 + return llvm_atomic_load_add!(ubyte)(cast(ubyte*)&val, cast(ubyte)0) ? 1 : 0;
399 + }
400 + else
401 + {
402 + return llvm_atomic_load_add!(T)(&val, cast(T)0);
403 + }
404 + }
405 + }
406 +
407 +
408 + ////////////////////////////////////////////////////////////////////////////
409 + // Atomic Store
410 + ////////////////////////////////////////////////////////////////////////////
411 +
412 +
413 + template atomicStore( msync ms = msync.seq, T )
414 + {
415 + void atomicStore( ref T val, T newval )
416 + {
417 + llvm_memory_barrier(
418 + ms == msync.hlb || ms == msync.acq || ms == msync.seq,
419 + ms == msync.hsb || ms == msync.acq || ms == msync.seq,
420 + ms == msync.slb || ms == msync.rel || ms == msync.seq,
421 + ms == msync.ssb || ms == msync.rel || ms == msync.seq,
422 + false);
423 + static if (isPointerType!(T))
424 + {
425 + llvm_atomic_swap!(size_t)(cast(size_t*)&val, cast(size_t)newval);
426 + }
427 + else static if (is(T == bool))
428 + {
429 + llvm_atomic_swap!(ubyte)(cast(ubyte*)&val, newval?1:0);
430 + }
431 + else
432 + {
433 + llvm_atomic_swap!(T)(&val, newval);
434 + }
435 + }
436 + }
437 +
438 +
439 + ////////////////////////////////////////////////////////////////////////////
440 + // Atomic Store If
441 + ////////////////////////////////////////////////////////////////////////////
442 +
443 +
444 + template atomicStoreIf( msync ms = msync.seq, T )
445 + {
446 + bool atomicStoreIf( ref T val, T newval, T equalTo )
447 + {
448 + llvm_memory_barrier(
449 + ms == msync.hlb || ms == msync.acq || ms == msync.seq,
450 + ms == msync.hsb || ms == msync.acq || ms == msync.seq,
451 + ms == msync.slb || ms == msync.rel || ms == msync.seq,
452 + ms == msync.ssb || ms == msync.rel || ms == msync.seq,
453 + false);
454 + T oldval = void;
455 + static if (isPointerType!(T))
456 + {
457 + oldval = cast(T)llvm_atomic_cmp_swap!(size_t)(cast(size_t*)&val, cast(size_t)equalTo, cast(size_t)newval);
458 + }
459 + else static if (is(T == bool))
460 + {
461 + oldval = llvm_atomic_cmp_swap!(ubyte)(cast(ubyte*)&val, equalTo?1:0, newval?1:0)?0:1;
462 + }
463 + else
464 + {
465 + oldval = llvm_atomic_cmp_swap!(T)(&val, equalTo, newval);
466 + }
467 + return oldval == equalTo;
468 + }
469 + }
470 +
471 +
472 + ////////////////////////////////////////////////////////////////////////////
473 + // Atomic Increment
474 + ////////////////////////////////////////////////////////////////////////////
475 +
476 +
477 + template atomicIncrement( msync ms = msync.seq, T )
478 + {
479 + //
480 + // NOTE: This operation is only valid for integer or pointer types
481 + //
482 + static assert( isValidNumericType!(T) );
483 +
484 +
485 + T atomicIncrement( ref T val )
486 + {
487 + static if (isPointerType!(T))
488 + {
489 + llvm_atomic_load_add!(size_t)(cast(size_t*)&val, 1);
490 + }
491 + else
492 + {
493 + llvm_atomic_load_add!(T)(&val, cast(T)1);
494 + }
495 + return val;
496 + }
497 + }
498 +
499 +
500 + ////////////////////////////////////////////////////////////////////////////
501 + // Atomic Decrement
502 + ////////////////////////////////////////////////////////////////////////////
503 +
504 +
505 + template atomicDecrement( msync ms = msync.seq, T )
506 + {
507 + //
508 + // NOTE: This operation is only valid for integer or pointer types
509 + //
510 + static assert( isValidNumericType!(T) );
511 +
512 +
513 + T atomicDecrement( ref T val )
514 + {
515 + static if (isPointerType!(T))
516 + {
517 + llvm_atomic_load_sub!(size_t)(cast(size_t*)&val, 1);
518 + }
519 + else
520 + {
521 + llvm_atomic_load_sub!(T)(&val, cast(T)1);
522 + }
523 + return val;
524 + }
525 + }
526 +}
527 +
528 +////////////////////////////////////////////////////////////////////////////////
529 // x86 Atomic Function Implementation
530 ////////////////////////////////////////////////////////////////////////////////
531
532 Index: tango/math/Math.d
533 ===================================================================
534 --- tango/math/Math.d (revision 3954)
535 +++ tango/math/Math.d (working copy)
536 @@ -76,6 +76,14 @@
537 version = DigitalMars_D_InlineAsm_X86;
538 }
539 }
540 +else version(LDC)
541 +{
542 + import ldc.intrinsics;
543 + version(X86)
544 + {
545 + version = LDC_X86;
546 + }
547 +}
548
549 /*
550 * Constants
551 @@ -298,6 +306,24 @@
552 * Bugs:
553 * Results are undefined if |x| >= $(POWER 2,64).
554 */
555 +version(LDC)
556 +{
557 + alias llvm_cos_f32 cos;
558 + alias llvm_cos_f64 cos;
559 + version(X86)
560 + {
561 + alias llvm_cos_f80 cos;
562 + }
563 + else
564 + {
565 + real cos(real x)
566 + {
567 + return tango.stdc.math.cosl(x);
568 + }
569 + }
570 +}
571 +else
572 +{
573 real cos(real x) /* intrinsic */
574 {
575 version(D_InlineAsm_X86)
576 @@ -313,6 +339,7 @@
577 return tango.stdc.math.cosl(x);
578 }
579 }
580 +}
581
582 debug(UnitTest) {
583 unittest {
584 @@ -333,6 +360,24 @@
585 * Bugs:
586 * Results are undefined if |x| >= $(POWER 2,64).
587 */
588 +version(LDC)
589 +{
590 + alias llvm_sin_f32 sin;
591 + alias llvm_sin_f64 sin;
592 + version(X86)
593 + {
594 + alias llvm_sin_f80 sin;
595 + }
596 + else
597 + {
598 + real sin(real x)
599 + {
600 + return tango.stdc.math.sinl(x);
601 + }
602 + }
603 +}
604 +else
605 +{
606 real sin(real x) /* intrinsic */
607 {
608 version(D_InlineAsm_X86)
609 @@ -348,6 +393,7 @@
610 return tango.stdc.math.sinl(x);
611 }
612 }
613 +}
614
615 debug(UnitTest) {
616 unittest {
617 @@ -374,7 +420,11 @@
618 {
619 version (GNU) {
620 return tanl(x);
621 - } else {
622 + }
623 + else version(LDC) {
624 + return tango.stdc.math.tanl(x);
625 + }
626 + else {
627 asm
628 {
629 fld x[EBP] ; // load theta
630 @@ -947,6 +997,25 @@
631 * <tr> <td> +&infin; <td> +&infin; <td> no
632 * )
633 */
634 +version(LDC)
635 +{
636 + alias llvm_sqrt_f32 sqrt;
637 + alias llvm_sqrt_f64 sqrt;
638 + version(X86)
639 + {
640 + alias llvm_sqrt_f80 sqrt;
641 + }
642 + else
643 + {
644 + real sqrt(real x)
645 + {
646 + return tango.stdc.math.sqrtl(x);
647 + }
648 + }
649 +}
650 +else
651 +{
652 +
653 float sqrt(float x) /* intrinsic */
654 {
655 version(D_InlineAsm_X86)
656 @@ -995,6 +1064,8 @@
657 }
658 }
659
660 +}
661 +
662 /** ditto */
663 creal sqrt(creal z)
664 {
665 @@ -1477,7 +1548,14 @@
666 }
667 }
668 }
669 - return tango.stdc.math.powl(x, y);
670 + version(LDC_X86)
671 + {
672 + return llvm_pow_f80(x, y);
673 + }
674 + else
675 + {
676 + return tango.stdc.math.powl(x, y);
677 + }
678 }
679
680 debug(UnitTest) {
681 Index: tango/stdc/stdlib.d
682 ===================================================================
683 --- tango/stdc/stdlib.d (revision 3954)
684 +++ tango/stdc/stdlib.d (working copy)
685 @@ -94,6 +94,11 @@
686 {
687 void* alloca(size_t size);
688 }
689 +else version( LDC )
690 +{
691 + pragma(alloca)
692 + void* alloca(size_t size);
693 +}
694 else version( GNU )
695 {
696 private import gcc.builtins;
697 Index: tango/stdc/stdarg.d
698 ===================================================================
699 --- tango/stdc/stdarg.d (revision 3954)
700 +++ tango/stdc/stdarg.d (working copy)
701 @@ -13,6 +13,10 @@
702 {
703 public import std.c.stdarg;
704 }
705 +else version( LDC )
706 +{
707 + public import ldc.cstdarg;
708 +}
709 else
710 {
711 alias void* va_list;