[llvm-commits] [compiler-rt] r128282 - in /compiler-rt/trunk: lib/comparedf2.c lib/comparesf2.c lib/eqdf2.c lib/eqsf2.c lib/fp_lib.h lib/gedf2.c lib/gesf2.c lib/gtdf2.c lib/gtsf2.c lib/ledf2.c lib/lesf2.c lib/ltdf2.c lib/ltsf2.c lib/nedf2.c lib/nesf2.c lib/unorddf2.c lib/unordsf2.c make/platform/clang_darwin.mk

Daniel Dunbar daniel at zuster.org
Fri Mar 25 08:52:51 PDT 2011


Author: ddunbar
Date: Fri Mar 25 10:52:51 2011
New Revision: 128282

URL: http://llvm.org/viewvc/llvm-project?rev=128282&view=rev
Log:
Split single & double comparison routines into separate implementation files,
for consistency.

Added:
    compiler-rt/trunk/lib/eqdf2.c
    compiler-rt/trunk/lib/eqsf2.c
    compiler-rt/trunk/lib/gedf2.c
    compiler-rt/trunk/lib/gesf2.c
    compiler-rt/trunk/lib/gtdf2.c
    compiler-rt/trunk/lib/gtsf2.c
    compiler-rt/trunk/lib/ledf2.c
    compiler-rt/trunk/lib/lesf2.c
    compiler-rt/trunk/lib/ltdf2.c
    compiler-rt/trunk/lib/ltsf2.c
    compiler-rt/trunk/lib/nedf2.c
    compiler-rt/trunk/lib/nesf2.c
    compiler-rt/trunk/lib/unorddf2.c
    compiler-rt/trunk/lib/unordsf2.c
Removed:
    compiler-rt/trunk/lib/comparedf2.c
    compiler-rt/trunk/lib/comparesf2.c
Modified:
    compiler-rt/trunk/lib/fp_lib.h
    compiler-rt/trunk/make/platform/clang_darwin.mk

Removed: compiler-rt/trunk/lib/comparedf2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/comparedf2.c?rev=128281&view=auto
==============================================================================
--- compiler-rt/trunk/lib/comparedf2.c (original)
+++ compiler-rt/trunk/lib/comparedf2.c (removed)
@@ -1,132 +0,0 @@
-//===-- lib/comparedf2.c - Double-precision comparisons -----------*- C -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// // This file implements the following soft-float comparison routines:
-//
-//   __eqdf2   __gedf2   __unorddf2
-//   __ledf2   __gtdf2
-//   __ltdf2
-//   __nedf2
-//
-// The semantics of the routines grouped in each column are identical, so there
-// is a single implementation for each, and wrappers to provide the other names.
-//
-// The main routines behave as follows:
-//
-//   __ledf2(a,b) returns -1 if a < b
-//                         0 if a == b
-//                         1 if a > b
-//                         1 if either a or b is NaN
-//
-//   __gedf2(a,b) returns -1 if a < b
-//                         0 if a == b
-//                         1 if a > b
-//                        -1 if either a or b is NaN
-//
-//   __unorddf2(a,b) returns 0 if both a and b are numbers
-//                           1 if either a or b is NaN
-//
-// Note that __ledf2( ) and __gedf2( ) are identical except in their handling of
-// NaN values.
-//
-//===----------------------------------------------------------------------===//
-
-#define DOUBLE_PRECISION
-#include "fp_lib.h"
-
-enum LE_RESULT {
-    LE_LESS      = -1,
-    LE_EQUAL     =  0,
-    LE_GREATER   =  1,
-    LE_UNORDERED =  1
-};
-
-enum LE_RESULT __ledf2(fp_t a, fp_t b) {
-    
-    const srep_t aInt = toRep(a);
-    const srep_t bInt = toRep(b);
-    const rep_t aAbs = aInt & absMask;
-    const rep_t bAbs = bInt & absMask;
-    
-    // If either a or b is NaN, they are unordered.
-    if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED;
-    
-    // If a and b are both zeros, they are equal.
-    if ((aAbs | bAbs) == 0) return LE_EQUAL;
-    
-    // If at least one of a and b is positive, we get the same result comparing
-    // a and b as signed integers as we would with a floating-point compare.
-    if ((aInt & bInt) >= 0) {
-        if (aInt < bInt) return LE_LESS;
-        else if (aInt == bInt) return LE_EQUAL;
-        else return LE_GREATER;
-    }
-    
-    // Otherwise, both are negative, so we need to flip the sense of the
-    // comparison to get the correct result.  (This assumes a twos- or ones-
-    // complement integer representation; if integers are represented in a
-    // sign-magnitude representation, then this flip is incorrect).
-    else {
-        if (aInt > bInt) return LE_LESS;
-        else if (aInt == bInt) return LE_EQUAL;
-        else return LE_GREATER;
-    }
-}
-
-enum GE_RESULT {
-    GE_LESS      = -1,
-    GE_EQUAL     =  0,
-    GE_GREATER   =  1,
-    GE_UNORDERED = -1   // Note: different from LE_UNORDERED
-};
-
-enum GE_RESULT __gedf2(fp_t a, fp_t b) {
-    
-    const srep_t aInt = toRep(a);
-    const srep_t bInt = toRep(b);
-    const rep_t aAbs = aInt & absMask;
-    const rep_t bAbs = bInt & absMask;
-    
-    if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED;
-    if ((aAbs | bAbs) == 0) return GE_EQUAL;
-    if ((aInt & bInt) >= 0) {
-        if (aInt < bInt) return GE_LESS;
-        else if (aInt == bInt) return GE_EQUAL;
-        else return GE_GREATER;
-    } else {
-        if (aInt > bInt) return GE_LESS;
-        else if (aInt == bInt) return GE_EQUAL;
-        else return GE_GREATER;
-    }
-}
-
-int __unorddf2(fp_t a, fp_t b) {
-    const rep_t aAbs = toRep(a) & absMask;
-    const rep_t bAbs = toRep(b) & absMask;
-    return aAbs > infRep || bAbs > infRep;
-}
-
-// The following are alternative names for the preceeding routines.
-
-enum LE_RESULT __eqdf2(fp_t a, fp_t b) {
-    return __ledf2(a, b);
-}
-
-enum LE_RESULT __ltdf2(fp_t a, fp_t b) {
-    return __ledf2(a, b);
-}
-
-enum LE_RESULT __nedf2(fp_t a, fp_t b) {
-    return __ledf2(a, b);
-}
-
-enum GE_RESULT __gtdf2(fp_t a, fp_t b) {
-    return __gedf2(a, b);
-}
-

Removed: compiler-rt/trunk/lib/comparesf2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/comparesf2.c?rev=128281&view=auto
==============================================================================
--- compiler-rt/trunk/lib/comparesf2.c (original)
+++ compiler-rt/trunk/lib/comparesf2.c (removed)
@@ -1,131 +0,0 @@
-//===-- lib/comparesf2.c - Single-precision comparisons -----------*- C -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the following soft-fp_t comparison routines:
-//
-//   __eqsf2   __gesf2   __unordsf2
-//   __lesf2   __gtsf2
-//   __ltsf2
-//   __nesf2
-//
-// The semantics of the routines grouped in each column are identical, so there
-// is a single implementation for each, and wrappers to provide the other names.
-//
-// The main routines behave as follows:
-//
-//   __lesf2(a,b) returns -1 if a < b
-//                         0 if a == b
-//                         1 if a > b
-//                         1 if either a or b is NaN
-//
-//   __gesf2(a,b) returns -1 if a < b
-//                         0 if a == b
-//                         1 if a > b
-//                        -1 if either a or b is NaN
-//
-//   __unordsf2(a,b) returns 0 if both a and b are numbers
-//                           1 if either a or b is NaN
-//
-// Note that __lesf2( ) and __gesf2( ) are identical except in their handling of
-// NaN values.
-//
-//===----------------------------------------------------------------------===//
-
-#define SINGLE_PRECISION
-#include "fp_lib.h"
-
-enum LE_RESULT {
-    LE_LESS      = -1,
-    LE_EQUAL     =  0,
-    LE_GREATER   =  1,
-    LE_UNORDERED =  1
-};
-
-enum LE_RESULT __lesf2(fp_t a, fp_t b) {
-    
-    const srep_t aInt = toRep(a);
-    const srep_t bInt = toRep(b);
-    const rep_t aAbs = aInt & absMask;
-    const rep_t bAbs = bInt & absMask;
-    
-    // If either a or b is NaN, they are unordered.
-    if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED;
-    
-    // If a and b are both zeros, they are equal.
-    if ((aAbs | bAbs) == 0) return LE_EQUAL;
-    
-    // If at least one of a and b is positive, we get the same result comparing
-    // a and b as signed integers as we would with a fp_ting-point compare.
-    if ((aInt & bInt) >= 0) {
-        if (aInt < bInt) return LE_LESS;
-        else if (aInt == bInt) return LE_EQUAL;
-        else return LE_GREATER;
-    }
-    
-    // Otherwise, both are negative, so we need to flip the sense of the
-    // comparison to get the correct result.  (This assumes a twos- or ones-
-    // complement integer representation; if integers are represented in a
-    // sign-magnitude representation, then this flip is incorrect).
-    else {
-        if (aInt > bInt) return LE_LESS;
-        else if (aInt == bInt) return LE_EQUAL;
-        else return LE_GREATER;
-    }
-}
-
-enum GE_RESULT {
-    GE_LESS      = -1,
-    GE_EQUAL     =  0,
-    GE_GREATER   =  1,
-    GE_UNORDERED = -1   // Note: different from LE_UNORDERED
-};
-
-enum GE_RESULT __gesf2(fp_t a, fp_t b) {
-    
-    const srep_t aInt = toRep(a);
-    const srep_t bInt = toRep(b);
-    const rep_t aAbs = aInt & absMask;
-    const rep_t bAbs = bInt & absMask;
-    
-    if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED;
-    if ((aAbs | bAbs) == 0) return GE_EQUAL;
-    if ((aInt & bInt) >= 0) {
-        if (aInt < bInt) return GE_LESS;
-        else if (aInt == bInt) return GE_EQUAL;
-        else return GE_GREATER;
-    } else {
-        if (aInt > bInt) return GE_LESS;
-        else if (aInt == bInt) return GE_EQUAL;
-        else return GE_GREATER;
-    }
-}
-
-int __unordsf2(fp_t a, fp_t b) {
-    const rep_t aAbs = toRep(a) & absMask;
-    const rep_t bAbs = toRep(b) & absMask;
-    return aAbs > infRep || bAbs > infRep;
-}
-
-// The following are alternative names for the preceeding routines.
-
-enum LE_RESULT __eqsf2(fp_t a, fp_t b) {
-    return __lesf2(a, b);
-}
-
-enum LE_RESULT __ltsf2(fp_t a, fp_t b) {
-    return __lesf2(a, b);
-}
-
-enum LE_RESULT __nesf2(fp_t a, fp_t b) {
-    return __lesf2(a, b);
-}
-
-enum GE_RESULT __gtsf2(fp_t a, fp_t b) {
-    return __gesf2(a, b);
-}

Added: compiler-rt/trunk/lib/eqdf2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/eqdf2.c?rev=128282&view=auto
==============================================================================
--- compiler-rt/trunk/lib/eqdf2.c (added)
+++ compiler-rt/trunk/lib/eqdf2.c Fri Mar 25 10:52:51 2011
@@ -0,0 +1,16 @@
+//===-- lib/eqdf2.c - Double-precision comparisons -----------*- C -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+enum LE_RESULT __ledf2(fp_t a, fp_t b);
+enum LE_RESULT __eqdf2(fp_t a, fp_t b) {
+    return __ledf2(a, b);
+}

Added: compiler-rt/trunk/lib/eqsf2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/eqsf2.c?rev=128282&view=auto
==============================================================================
--- compiler-rt/trunk/lib/eqsf2.c (added)
+++ compiler-rt/trunk/lib/eqsf2.c Fri Mar 25 10:52:51 2011
@@ -0,0 +1,16 @@
+//===-- lib/comparesf2.c - Single-precision comparisons -----------*- C -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+enum LE_RESULT __lesf2(fp_t a, fp_t b);
+enum LE_RESULT __eqsf2(fp_t a, fp_t b) {
+    return __lesf2(a, b);
+}

Modified: compiler-rt/trunk/lib/fp_lib.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fp_lib.h?rev=128282&r1=128281&r2=128282&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fp_lib.h (original)
+++ compiler-rt/trunk/lib/fp_lib.h Fri Mar 25 10:52:51 2011
@@ -25,6 +25,20 @@
 #include <stdbool.h>
 #include <limits.h>
 
+// Result enumerations used in comparison routines.
+enum LE_RESULT {
+    LE_LESS      = -1,
+    LE_EQUAL     =  0,
+    LE_GREATER   =  1,
+    LE_UNORDERED =  1
+};
+enum GE_RESULT {
+    GE_LESS      = -1,
+    GE_EQUAL     =  0,
+    GE_GREATER   =  1,
+    GE_UNORDERED = -1   // Note: different from LE_UNORDERED
+};
+
 #if defined SINGLE_PRECISION
 
 typedef uint32_t rep_t;

Added: compiler-rt/trunk/lib/gedf2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/gedf2.c?rev=128282&view=auto
==============================================================================
--- compiler-rt/trunk/lib/gedf2.c (added)
+++ compiler-rt/trunk/lib/gedf2.c Fri Mar 25 10:52:51 2011
@@ -0,0 +1,61 @@
+//===-- lib/gedf2.c - Double-precision comparisons ----------------*- C -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the following soft-float comparison routines:
+//
+//   __eqdf2   __gedf2   __unorddf2
+//   __ledf2   __gtdf2
+//   __ltdf2
+//   __nedf2
+//
+// The semantics of the routines grouped in each column are identical, so there
+// is a single implementation for each, and wrappers to provide the other names.
+//
+// The main routines behave as follows:
+//
+//   __ledf2(a,b) returns -1 if a < b
+//                         0 if a == b
+//                         1 if a > b
+//                         1 if either a or b is NaN
+//
+//   __gedf2(a,b) returns -1 if a < b
+//                         0 if a == b
+//                         1 if a > b
+//                        -1 if either a or b is NaN
+//
+//   __unorddf2(a,b) returns 0 if both a and b are numbers
+//                           1 if either a or b is NaN
+//
+// Note that __ledf2( ) and __gedf2( ) are identical except in their handling of
+// NaN values.
+//
+//===----------------------------------------------------------------------===//
+
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+enum GE_RESULT __gedf2(fp_t a, fp_t b) {
+    
+    const srep_t aInt = toRep(a);
+    const srep_t bInt = toRep(b);
+    const rep_t aAbs = aInt & absMask;
+    const rep_t bAbs = bInt & absMask;
+    
+    if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED;
+    if ((aAbs | bAbs) == 0) return GE_EQUAL;
+    if ((aInt & bInt) >= 0) {
+        if (aInt < bInt) return GE_LESS;
+        else if (aInt == bInt) return GE_EQUAL;
+        else return GE_GREATER;
+    } else {
+        if (aInt > bInt) return GE_LESS;
+        else if (aInt == bInt) return GE_EQUAL;
+        else return GE_GREATER;
+    }
+}

Added: compiler-rt/trunk/lib/gesf2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/gesf2.c?rev=128282&view=auto
==============================================================================
--- compiler-rt/trunk/lib/gesf2.c (added)
+++ compiler-rt/trunk/lib/gesf2.c Fri Mar 25 10:52:51 2011
@@ -0,0 +1,61 @@
+//===-- lib/gesf2.c - Single-precision comparisons ----------------*- C -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the following soft-fp_t comparison routines:
+//
+//   __eqsf2   __gesf2   __unordsf2
+//   __lesf2   __gtsf2
+//   __ltsf2
+//   __nesf2
+//
+// The semantics of the routines grouped in each column are identical, so there
+// is a single implementation for each, and wrappers to provide the other names.
+//
+// The main routines behave as follows:
+//
+//   __lesf2(a,b) returns -1 if a < b
+//                         0 if a == b
+//                         1 if a > b
+//                         1 if either a or b is NaN
+//
+//   __gesf2(a,b) returns -1 if a < b
+//                         0 if a == b
+//                         1 if a > b
+//                        -1 if either a or b is NaN
+//
+//   __unordsf2(a,b) returns 0 if both a and b are numbers
+//                           1 if either a or b is NaN
+//
+// Note that __lesf2( ) and __gesf2( ) are identical except in their handling of
+// NaN values.
+//
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+enum GE_RESULT __gesf2(fp_t a, fp_t b) {
+    
+    const srep_t aInt = toRep(a);
+    const srep_t bInt = toRep(b);
+    const rep_t aAbs = aInt & absMask;
+    const rep_t bAbs = bInt & absMask;
+    
+    if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED;
+    if ((aAbs | bAbs) == 0) return GE_EQUAL;
+    if ((aInt & bInt) >= 0) {
+        if (aInt < bInt) return GE_LESS;
+        else if (aInt == bInt) return GE_EQUAL;
+        else return GE_GREATER;
+    } else {
+        if (aInt > bInt) return GE_LESS;
+        else if (aInt == bInt) return GE_EQUAL;
+        else return GE_GREATER;
+    }
+}

Added: compiler-rt/trunk/lib/gtdf2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/gtdf2.c?rev=128282&view=auto
==============================================================================
--- compiler-rt/trunk/lib/gtdf2.c (added)
+++ compiler-rt/trunk/lib/gtdf2.c Fri Mar 25 10:52:51 2011
@@ -0,0 +1,17 @@
+//===-- lib/gtdf2.c - Double-precision comparisons ----------------*- C -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+enum GE_RESULT __gedf2(fp_t a, fp_t b);
+enum GE_RESULT __gtdf2(fp_t a, fp_t b) {
+    return __gedf2(a, b);
+}
+

Added: compiler-rt/trunk/lib/gtsf2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/gtsf2.c?rev=128282&view=auto
==============================================================================
--- compiler-rt/trunk/lib/gtsf2.c (added)
+++ compiler-rt/trunk/lib/gtsf2.c Fri Mar 25 10:52:51 2011
@@ -0,0 +1,16 @@
+//===-- lib/gtsf2.c - Single-precision comparisons ----------------*- C -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+enum GE_RESULT __gesf2(fp_t a, fp_t b);
+enum GE_RESULT __gtsf2(fp_t a, fp_t b) {
+    return __gesf2(a, b);
+}

Added: compiler-rt/trunk/lib/ledf2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ledf2.c?rev=128282&view=auto
==============================================================================
--- compiler-rt/trunk/lib/ledf2.c (added)
+++ compiler-rt/trunk/lib/ledf2.c Fri Mar 25 10:52:51 2011
@@ -0,0 +1,73 @@
+//===-- lib/ledf2.c - Double-precision comparisons ----------------*- C -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// // This file implements the following soft-float comparison routines:
+//
+//   __eqdf2   __gedf2   __unorddf2
+//   __ledf2   __gtdf2
+//   __ltdf2
+//   __nedf2
+//
+// The semantics of the routines grouped in each column are identical, so there
+// is a single implementation for each, and wrappers to provide the other names.
+//
+// The main routines behave as follows:
+//
+//   __ledf2(a,b) returns -1 if a < b
+//                         0 if a == b
+//                         1 if a > b
+//                         1 if either a or b is NaN
+//
+//   __gedf2(a,b) returns -1 if a < b
+//                         0 if a == b
+//                         1 if a > b
+//                        -1 if either a or b is NaN
+//
+//   __unorddf2(a,b) returns 0 if both a and b are numbers
+//                           1 if either a or b is NaN
+//
+// Note that __ledf2( ) and __gedf2( ) are identical except in their handling of
+// NaN values.
+//
+//===----------------------------------------------------------------------===//
+
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+enum LE_RESULT __ledf2(fp_t a, fp_t b) {
+    
+    const srep_t aInt = toRep(a);
+    const srep_t bInt = toRep(b);
+    const rep_t aAbs = aInt & absMask;
+    const rep_t bAbs = bInt & absMask;
+    
+    // If either a or b is NaN, they are unordered.
+    if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED;
+    
+    // If a and b are both zeros, they are equal.
+    if ((aAbs | bAbs) == 0) return LE_EQUAL;
+    
+    // If at least one of a and b is positive, we get the same result comparing
+    // a and b as signed integers as we would with a floating-point compare.
+    if ((aInt & bInt) >= 0) {
+        if (aInt < bInt) return LE_LESS;
+        else if (aInt == bInt) return LE_EQUAL;
+        else return LE_GREATER;
+    }
+    
+    // Otherwise, both are negative, so we need to flip the sense of the
+    // comparison to get the correct result.  (This assumes a twos- or ones-
+    // complement integer representation; if integers are represented in a
+    // sign-magnitude representation, then this flip is incorrect).
+    else {
+        if (aInt > bInt) return LE_LESS;
+        else if (aInt == bInt) return LE_EQUAL;
+        else return LE_GREATER;
+    }
+}

Added: compiler-rt/trunk/lib/lesf2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lesf2.c?rev=128282&view=auto
==============================================================================
--- compiler-rt/trunk/lib/lesf2.c (added)
+++ compiler-rt/trunk/lib/lesf2.c Fri Mar 25 10:52:51 2011
@@ -0,0 +1,73 @@
+//===-- lib/lesf2.c - Single-precision comparisons ----------------*- C -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the following soft-fp_t comparison routines:
+//
+//   __eqsf2   __gesf2   __unordsf2
+//   __lesf2   __gtsf2
+//   __ltsf2
+//   __nesf2
+//
+// The semantics of the routines grouped in each column are identical, so there
+// is a single implementation for each, and wrappers to provide the other names.
+//
+// The main routines behave as follows:
+//
+//   __lesf2(a,b) returns -1 if a < b
+//                         0 if a == b
+//                         1 if a > b
+//                         1 if either a or b is NaN
+//
+//   __gesf2(a,b) returns -1 if a < b
+//                         0 if a == b
+//                         1 if a > b
+//                        -1 if either a or b is NaN
+//
+//   __unordsf2(a,b) returns 0 if both a and b are numbers
+//                           1 if either a or b is NaN
+//
+// Note that __lesf2( ) and __gesf2( ) are identical except in their handling of
+// NaN values.
+//
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+enum LE_RESULT __lesf2(fp_t a, fp_t b) {
+    
+    const srep_t aInt = toRep(a);
+    const srep_t bInt = toRep(b);
+    const rep_t aAbs = aInt & absMask;
+    const rep_t bAbs = bInt & absMask;
+    
+    // If either a or b is NaN, they are unordered.
+    if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED;
+    
+    // If a and b are both zeros, they are equal.
+    if ((aAbs | bAbs) == 0) return LE_EQUAL;
+    
+    // If at least one of a and b is positive, we get the same result comparing
+    // a and b as signed integers as we would with a fp_ting-point compare.
+    if ((aInt & bInt) >= 0) {
+        if (aInt < bInt) return LE_LESS;
+        else if (aInt == bInt) return LE_EQUAL;
+        else return LE_GREATER;
+    }
+    
+    // Otherwise, both are negative, so we need to flip the sense of the
+    // comparison to get the correct result.  (This assumes a twos- or ones-
+    // complement integer representation; if integers are represented in a
+    // sign-magnitude representation, then this flip is incorrect).
+    else {
+        if (aInt > bInt) return LE_LESS;
+        else if (aInt == bInt) return LE_EQUAL;
+        else return LE_GREATER;
+    }
+}

Added: compiler-rt/trunk/lib/ltdf2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ltdf2.c?rev=128282&view=auto
==============================================================================
--- compiler-rt/trunk/lib/ltdf2.c (added)
+++ compiler-rt/trunk/lib/ltdf2.c Fri Mar 25 10:52:51 2011
@@ -0,0 +1,16 @@
+//===-- lib/ltdf2.c - Double-precision comparisons ----------------*- C -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+enum LE_RESULT __ledf2(fp_t a, fp_t b);
+enum LE_RESULT __ltdf2(fp_t a, fp_t b) {
+    return __ledf2(a, b);
+}

Added: compiler-rt/trunk/lib/ltsf2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ltsf2.c?rev=128282&view=auto
==============================================================================
--- compiler-rt/trunk/lib/ltsf2.c (added)
+++ compiler-rt/trunk/lib/ltsf2.c Fri Mar 25 10:52:51 2011
@@ -0,0 +1,16 @@
+//===-- lib/comparesf2.c - Single-precision comparisons -----------*- C -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+enum LE_RESULT __lesf2(fp_t a, fp_t b);
+enum LE_RESULT __ltsf2(fp_t a, fp_t b) {
+    return __lesf2(a, b);
+}

Added: compiler-rt/trunk/lib/nedf2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/nedf2.c?rev=128282&view=auto
==============================================================================
--- compiler-rt/trunk/lib/nedf2.c (added)
+++ compiler-rt/trunk/lib/nedf2.c Fri Mar 25 10:52:51 2011
@@ -0,0 +1,17 @@
+//===-- lib/nedf2.c - Double-precision comparisons ----------------*- C -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+enum LE_RESULT __ledf2(fp_t a, fp_t b);
+enum LE_RESULT __nedf2(fp_t a, fp_t b) {
+    return __ledf2(a, b);
+}
+

Added: compiler-rt/trunk/lib/nesf2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/nesf2.c?rev=128282&view=auto
==============================================================================
--- compiler-rt/trunk/lib/nesf2.c (added)
+++ compiler-rt/trunk/lib/nesf2.c Fri Mar 25 10:52:51 2011
@@ -0,0 +1,16 @@
+//===-- lib/nesf2.c - Single-precision comparisons ----------------*- C -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+enum LE_RESULT __lesf2(fp_t a, fp_t b);
+enum LE_RESULT __nesf2(fp_t a, fp_t b) {
+    return __lesf2(a, b);
+}

Added: compiler-rt/trunk/lib/unorddf2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/unorddf2.c?rev=128282&view=auto
==============================================================================
--- compiler-rt/trunk/lib/unorddf2.c (added)
+++ compiler-rt/trunk/lib/unorddf2.c Fri Mar 25 10:52:51 2011
@@ -0,0 +1,47 @@
+//===-- lib/unorddf2.c - Double-precision comparisons -------------*- C -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// // This file implements the following soft-float comparison routines:
+//
+//   __eqdf2   __gedf2   __unorddf2
+//   __ledf2   __gtdf2
+//   __ltdf2
+//   __nedf2
+//
+// The semantics of the routines grouped in each column are identical, so there
+// is a single implementation for each, and wrappers to provide the other names.
+//
+// The main routines behave as follows:
+//
+//   __ledf2(a,b) returns -1 if a < b
+//                         0 if a == b
+//                         1 if a > b
+//                         1 if either a or b is NaN
+//
+//   __gedf2(a,b) returns -1 if a < b
+//                         0 if a == b
+//                         1 if a > b
+//                        -1 if either a or b is NaN
+//
+//   __unorddf2(a,b) returns 0 if both a and b are numbers
+//                           1 if either a or b is NaN
+//
+// Note that __ledf2( ) and __gedf2( ) are identical except in their handling of
+// NaN values.
+//
+//===----------------------------------------------------------------------===//
+
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+int __unorddf2(fp_t a, fp_t b) {
+    const rep_t aAbs = toRep(a) & absMask;
+    const rep_t bAbs = toRep(b) & absMask;
+    return aAbs > infRep || bAbs > infRep;
+}

Added: compiler-rt/trunk/lib/unordsf2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/unordsf2.c?rev=128282&view=auto
==============================================================================
--- compiler-rt/trunk/lib/unordsf2.c (added)
+++ compiler-rt/trunk/lib/unordsf2.c Fri Mar 25 10:52:51 2011
@@ -0,0 +1,17 @@
+//===-- lib/unordsf2.c - Single-precision comparisons -------------*- C -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+int __unordsf2(fp_t a, fp_t b) {
+    const rep_t aAbs = toRep(a) & absMask;
+    const rep_t bAbs = toRep(b) & absMask;
+    return aAbs > infRep || bAbs > infRep;
+}

Modified: compiler-rt/trunk/make/platform/clang_darwin.mk
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/platform/clang_darwin.mk?rev=128282&r1=128281&r2=128282&view=diff
==============================================================================
--- compiler-rt/trunk/make/platform/clang_darwin.mk (original)
+++ compiler-rt/trunk/make/platform/clang_darwin.mk Fri Mar 25 10:52:51 2011
@@ -223,8 +223,7 @@
 CCKEXT_MISSING_FUNCTIONS := \
 	cmpdf2 cmpsf2 div0 \
 	ffssi2 \
-	gtdf2 gtsf2 ltdf2 ltsf2 \
-	udiv_w_sdiv unorddf2 unordsf2 bswapdi2 \
+	udiv_w_sdiv bswapdi2 \
 	bswapsi2 \
 	gcc_bcmp \
 	do_global_dtors \





More information about the llvm-commits mailing list