changeset 608:52ab8f3130d9

Removed dmdintrinsic.d from the runtime, we already have llvmdc.bitmanip. Updated tango patch to import tango.core.BitManip instead of std.intrinsic.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Thu, 18 Sep 2008 21:14:37 +0200
parents 9526b29ae342
children 2cf4359d344f
files runtime/internal/dmdintrinsic.d runtime/internal/llvmdc.mak runtime/llvmdc.diff
diffstat 3 files changed, 25 insertions(+), 260 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/internal/dmdintrinsic.d	Thu Sep 18 21:07:35 2008 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,231 +0,0 @@
-
-
-// written by Walter Bright
-// www.digitalmars.com
-// Placed into the public domain
-
-/* NOTE: This file has been patched from the original DMD distribution to
-   work with the GDC compiler.
-
-   Modified by David Friedman, May 2006
-   Modified by Christian Kamm, Sep 2008
-*/
-
-/** These functions are built-in intrinsics to the compiler.
- *
-	Intrinsic functions are functions built in to the compiler,
-	usually to take advantage of specific CPU features that
-	are inefficient to handle via external functions.
-	The compiler's optimizer and code generator are fully
-	integrated in with intrinsic functions, bringing to bear
-	their full power on them.
-	This can result in some surprising speedups.
- * Macros:
- *	WIKI=Phobos/StdIntrinsic
- */
-
-module std.intrinsic;
-
-/**
- * Scans the bits in v starting with bit 0, looking
- * for the first set bit.
- * Returns:
- *	The bit number of the first bit set.
- *	The return value is undefined if v is zero.
- */
-int bsf(uint v)
-{
-    uint m = 1;
-    uint i;
-    for (i = 0; i < 32; i++,m<<=1) {
-	if (v&m)
-	    return i;
-    }
-    return i; // supposed to be undefined
-}
-
-/**
- * Scans the bits in v from the most significant bit
- * to the least significant bit, looking
- * for the first set bit.
- * Returns:
- *	The bit number of the first bit set.
- *	The return value is undefined if v is zero.
- * Example:
- * ---
- * import std.intrinsic;
- *
- * int main()
- * {   
- *     uint v;
- *     int x;
- *
- *     v = 0x21;
- *     x = bsf(v);
- *     printf("bsf(x%x) = %d\n", v, x);
- *     x = bsr(v);
- *     printf("bsr(x%x) = %d\n", v, x);
- *     return 0;
- * } 
- * ---
- * Output:
- *  bsf(x21) = 0<br>
- *  bsr(x21) = 5
- */
-int bsr(uint v)
-{
-    uint m = 0x80000000;
-    uint i;
-    for (i = 32; i ; i--,m>>>=1) {
-	if (v&m)
-	    return i-1;
-    }
-    return i; // supposed to be undefined
-}
-
-/**
- * Tests the bit.
- */
-int bt(uint *p, uint bitnum)
-{
-    return (p[bitnum / (uint.sizeof*8)] & (1<<(bitnum & ((uint.sizeof*8)-1)))) ? -1 : 0 ;
-}
-
-/**
- * Tests and complements the bit.
- */
-int btc(uint *p, uint bitnum)
-{
-    uint * q = p + (bitnum / (uint.sizeof*8));
-    uint mask = 1 << (bitnum & ((uint.sizeof*8) - 1));
-    int result = *q & mask;
-    *q ^= mask;
-    return result ? -1 : 0;
-}
-
-/**
- * Tests and resets (sets to 0) the bit.
- */
-int btr(uint *p, uint bitnum)
-{
-    uint * q = p + (bitnum / (uint.sizeof*8));
-    uint mask = 1 << (bitnum & ((uint.sizeof*8) - 1));
-    int result = *q & mask;
-    *q &= ~mask;
-    return result ? -1 : 0;
-}
-
-/**
- * Tests and sets the bit.
- * Params:
- * p = a non-NULL pointer to an array of uints.
- * index = a bit number, starting with bit 0 of p[0],
- * and progressing. It addresses bits like the expression:
----
-p[index / (uint.sizeof*8)] & (1 << (index & ((uint.sizeof*8) - 1)))
----
- * Returns:
- * 	A non-zero value if the bit was set, and a zero
- *	if it was clear.
- *
- * Example: 
- * ---
-import std.intrinsic;
-
-int main()
-{   
-    uint array[2];
-
-    array[0] = 2;
-    array[1] = 0x100;
-
-    printf("btc(array, 35) = %d\n", <b>btc</b>(array, 35));
-    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
-
-    printf("btc(array, 35) = %d\n", <b>btc</b>(array, 35));
-    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
-
-    printf("bts(array, 35) = %d\n", <b>bts</b>(array, 35));
-    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
-
-    printf("btr(array, 35) = %d\n", <b>btr</b>(array, 35));
-    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
-
-    printf("bt(array, 1) = %d\n", <b>bt</b>(array, 1));
-    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
-
-    return 0;
-} 
- * ---
- * Output:
-<pre>
-btc(array, 35) = 0
-array = [0]:x2, [1]:x108
-btc(array, 35) = -1
-array = [0]:x2, [1]:x100
-bts(array, 35) = 0
-array = [0]:x2, [1]:x108
-btr(array, 35) = -1
-array = [0]:x2, [1]:x100
-bt(array, 1) = -1
-array = [0]:x2, [1]:x100
-</pre>
- */
-int bts(uint *p, uint bitnum)
-{
-    uint * q = p + (bitnum / (uint.sizeof*8));
-    uint mask = 1 << (bitnum & ((uint.sizeof*8) - 1));
-    int result = *q & mask;
-    *q |= mask;
-    return result ? -1 : 0;
-}
-
-
-/**
- * Swaps bytes in a 4 byte uint end-to-end, i.e. byte 0 becomes
-	byte 3, byte 1 becomes byte 2, byte 2 becomes byte 1, byte 3
-	becomes byte 0.
- */
-uint bswap(uint v)
-{
-    return ((v&0xFF)<<24)|((v&0xFF00)<<8)|((v&0xFF0000)>>>8)|((v&0xFF000000)>>>24);
-}
-
-
-//
-// Unimplemented functions
-//
-/+
-
-/**
- * Reads I/O port at port_address.
- */
-ubyte  inp(uint port_address);
-
-/**
- * ditto
- */
-ushort inpw(uint port_address);
-
-/**
- * ditto
- */
-uint   inpl(uint port_address);
-
-
-/**
- * Writes and returns value to I/O port at port_address.
- */
-ubyte  outp(uint port_address, ubyte value);
-
-/**
- * ditto
- */
-ushort outpw(uint port_address, ushort value);
-
-/**
- * ditto
- */
-uint   outpl(uint port_address, uint value);
-
-+/
\ No newline at end of file
--- a/runtime/internal/llvmdc.mak	Thu Sep 18 21:07:35 2008 +0200
+++ b/runtime/internal/llvmdc.mak	Thu Sep 18 21:14:37 2008 +0200
@@ -87,8 +87,7 @@
     memory.bc \
     qsort2.bc \
     switch.bc \
-    invariant.bc \
-    dmdintrinsic.bc \
+    invariant.bc
 
 OBJ_UTIL= \
     util/console.bc \
--- a/runtime/llvmdc.diff	Thu Sep 18 21:07:35 2008 +0200
+++ b/runtime/llvmdc.diff	Thu Sep 18 21:14:37 2008 +0200
@@ -1,6 +1,6 @@
 Index: object.di
 ===================================================================
---- object.di	(revision 3899)
+--- object.di	(revision 3936)
 +++ object.di	(working copy)
 @@ -150,6 +150,9 @@
      void function() dtor;
@@ -14,7 +14,7 @@
  
 Index: lib/unittest.sh
 ===================================================================
---- lib/unittest.sh	(revision 3899)
+--- lib/unittest.sh	(revision 3936)
 +++ lib/unittest.sh	(working copy)
 @@ -18,8 +18,9 @@
    --help: This message
@@ -71,7 +71,7 @@
 +fi
 Index: lib/common/tango/core/BitManip.d
 ===================================================================
---- lib/common/tango/core/BitManip.d	(revision 3899)
+--- lib/common/tango/core/BitManip.d	(revision 3936)
 +++ lib/common/tango/core/BitManip.d	(working copy)
 @@ -171,6 +171,10 @@
       */
@@ -86,7 +86,7 @@
      public import std.intrinsic;
 Index: lib/common/tango/core/Thread.d
 ===================================================================
---- lib/common/tango/core/Thread.d	(revision 3899)
+--- lib/common/tango/core/Thread.d	(revision 3936)
 +++ lib/common/tango/core/Thread.d	(working copy)
 @@ -244,8 +244,29 @@
          }
@@ -135,7 +135,7 @@
                      popad;
 Index: lib/gc/basic/gcx.d
 ===================================================================
---- lib/gc/basic/gcx.d	(revision 3899)
+--- lib/gc/basic/gcx.d	(revision 3936)
 +++ lib/gc/basic/gcx.d	(working copy)
 @@ -2178,6 +2178,28 @@
              __builtin_unwind_init();
@@ -179,7 +179,7 @@
          asm
 Index: lib/gc/basic/gcbits.d
 ===================================================================
---- lib/gc/basic/gcbits.d	(revision 3899)
+--- lib/gc/basic/gcbits.d	(revision 3936)
 +++ lib/gc/basic/gcbits.d	(working copy)
 @@ -39,6 +39,10 @@
  {
@@ -194,7 +194,7 @@
      version = Asm86;
 Index: tango/text/convert/Layout.d
 ===================================================================
---- tango/text/convert/Layout.d	(revision 3899)
+--- tango/text/convert/Layout.d	(revision 3936)
 +++ tango/text/convert/Layout.d	(working copy)
 @@ -47,6 +47,12 @@
          alias void* Arg;
@@ -231,7 +231,7 @@
                          long[64] longargs = void;
 Index: tango/core/Vararg.d
 ===================================================================
---- tango/core/Vararg.d	(revision 3899)
+--- tango/core/Vararg.d	(revision 3936)
 +++ tango/core/Vararg.d	(working copy)
 @@ -15,6 +15,10 @@
  {
@@ -246,7 +246,7 @@
      /**
 Index: tango/core/Atomic.d
 ===================================================================
---- tango/core/Atomic.d	(revision 3899)
+--- tango/core/Atomic.d	(revision 3936)
 +++ tango/core/Atomic.d	(working copy)
 @@ -270,6 +270,161 @@
  
@@ -412,7 +412,7 @@
  
 Index: tango/math/Math.d
 ===================================================================
---- tango/math/Math.d	(revision 3899)
+--- tango/math/Math.d	(revision 3936)
 +++ tango/math/Math.d	(working copy)
 @@ -76,6 +76,14 @@
          version = DigitalMars_D_InlineAsm_X86;
@@ -561,9 +561,9 @@
  debug(UnitTest) {
 Index: tango/math/internal/BignumX86.d
 ===================================================================
---- tango/math/internal/BignumX86.d	(revision 3899)
+--- tango/math/internal/BignumX86.d	(revision 3936)
 +++ tango/math/internal/BignumX86.d	(working copy)
-@@ -50,6 +50,8 @@
+@@ -49,6 +49,8 @@
  private:
  version(GNU) {
      // GDC is a filthy liar. It can't actually do inline asm.
@@ -574,23 +574,20 @@
   *
 Index: tango/math/internal/BiguintCore.d
 ===================================================================
---- tango/math/internal/BiguintCore.d	(revision 3899)
+--- tango/math/internal/BiguintCore.d	(revision 3936)
 +++ tango/math/internal/BiguintCore.d	(working copy)
-@@ -12,7 +12,10 @@
- } else version(GNU) {
-     // GDC lies about its X86 support
- private import tango.math.internal.BignumNoAsm;    
--} else version(D_InlineAsm_X86) { 
-+} else version(LLVMDC) {
-+    // I guess llvmdc does too :(
-+private import tango.math.internal.BignumNoAsm;    
-+} else version(D_InlineAsm_X86) {
- private import tango.math.internal.BignumX86;
- } else {
- private import tango.math.internal.BignumNoAsm;
+@@ -859,7 +859,7 @@
+     result[half..$].simpleAddAssign(mid);
+ }
+ 
+-import std.intrinsic;
++import tango.core.BitManip;
+ 
+ 
+ /* Knuth's Algorithm D, as presented in "Hacker's Delight"
 Index: tango/stdc/stdlib.d
 ===================================================================
---- tango/stdc/stdlib.d	(revision 3899)
+--- tango/stdc/stdlib.d	(revision 3936)
 +++ tango/stdc/stdlib.d	(working copy)
 @@ -94,6 +94,11 @@
  {
@@ -606,7 +603,7 @@
      private import gcc.builtins;
 Index: tango/stdc/stdarg.d
 ===================================================================
---- tango/stdc/stdarg.d	(revision 3899)
+--- tango/stdc/stdarg.d	(revision 3936)
 +++ tango/stdc/stdarg.d	(working copy)
 @@ -13,6 +13,10 @@
  {