summaryrefslogtreecommitdiffstats
path: root/compiler-rt
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-03-25 15:52:51 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-03-25 15:52:51 +0000
commit1102c9ae58ecafa26dc088d75abee3591dede94e (patch)
treedd3b6de4045d81106ef70149f1adf5efc39fb983 /compiler-rt
parent69f1f9391bf11589ad1704d586309a96ee132903 (diff)
downloadbcm5719-llvm-1102c9ae58ecafa26dc088d75abee3591dede94e.tar.gz
bcm5719-llvm-1102c9ae58ecafa26dc088d75abee3591dede94e.zip
Split single & double comparison routines into separate implementation files,
for consistency. llvm-svn: 128282
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/lib/eqdf2.c16
-rw-r--r--compiler-rt/lib/eqsf2.c16
-rw-r--r--compiler-rt/lib/fp_lib.h14
-rw-r--r--compiler-rt/lib/gedf2.c61
-rw-r--r--compiler-rt/lib/gesf2.c61
-rw-r--r--compiler-rt/lib/gtdf2.c17
-rw-r--r--compiler-rt/lib/gtsf2.c16
-rw-r--r--compiler-rt/lib/ledf2.c (renamed from compiler-rt/lib/comparedf2.c)61
-rw-r--r--compiler-rt/lib/lesf2.c (renamed from compiler-rt/lib/comparesf2.c)60
-rw-r--r--compiler-rt/lib/ltdf2.c16
-rw-r--r--compiler-rt/lib/ltsf2.c16
-rw-r--r--compiler-rt/lib/nedf2.c17
-rw-r--r--compiler-rt/lib/nesf2.c16
-rw-r--r--compiler-rt/lib/unorddf2.c47
-rw-r--r--compiler-rt/lib/unordsf2.c17
-rw-r--r--compiler-rt/make/platform/clang_darwin.mk3
16 files changed, 333 insertions, 121 deletions
diff --git a/compiler-rt/lib/eqdf2.c b/compiler-rt/lib/eqdf2.c
new file mode 100644
index 00000000000..4ca544edea2
--- /dev/null
+++ b/compiler-rt/lib/eqdf2.c
@@ -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);
+}
diff --git a/compiler-rt/lib/eqsf2.c b/compiler-rt/lib/eqsf2.c
new file mode 100644
index 00000000000..8d1cf97f6f4
--- /dev/null
+++ b/compiler-rt/lib/eqsf2.c
@@ -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);
+}
diff --git a/compiler-rt/lib/fp_lib.h b/compiler-rt/lib/fp_lib.h
index 6c9455ace0e..2333c8aec60 100644
--- a/compiler-rt/lib/fp_lib.h
+++ b/compiler-rt/lib/fp_lib.h
@@ -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;
diff --git a/compiler-rt/lib/gedf2.c b/compiler-rt/lib/gedf2.c
new file mode 100644
index 00000000000..c6ce2137b21
--- /dev/null
+++ b/compiler-rt/lib/gedf2.c
@@ -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;
+ }
+}
diff --git a/compiler-rt/lib/gesf2.c b/compiler-rt/lib/gesf2.c
new file mode 100644
index 00000000000..fb8a291dfa1
--- /dev/null
+++ b/compiler-rt/lib/gesf2.c
@@ -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;
+ }
+}
diff --git a/compiler-rt/lib/gtdf2.c b/compiler-rt/lib/gtdf2.c
new file mode 100644
index 00000000000..4af83d5334d
--- /dev/null
+++ b/compiler-rt/lib/gtdf2.c
@@ -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);
+}
+
diff --git a/compiler-rt/lib/gtsf2.c b/compiler-rt/lib/gtsf2.c
new file mode 100644
index 00000000000..3c32d7f414c
--- /dev/null
+++ b/compiler-rt/lib/gtsf2.c
@@ -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);
+}
diff --git a/compiler-rt/lib/comparedf2.c b/compiler-rt/lib/ledf2.c
index fe35fd80aad..f730ee003a3 100644
--- a/compiler-rt/lib/comparedf2.c
+++ b/compiler-rt/lib/ledf2.c
@@ -1,4 +1,4 @@
-//===-- lib/comparedf2.c - Double-precision comparisons -----------*- C -*-===//
+//===-- lib/ledf2.c - Double-precision comparisons ----------------*- C -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -40,13 +40,6 @@
#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);
@@ -78,55 +71,3 @@ enum LE_RESULT __ledf2(fp_t a, fp_t b) {
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);
-}
-
diff --git a/compiler-rt/lib/comparesf2.c b/compiler-rt/lib/lesf2.c
index 3f2e358addb..371dc148f2b 100644
--- a/compiler-rt/lib/comparesf2.c
+++ b/compiler-rt/lib/lesf2.c
@@ -1,4 +1,4 @@
-//===-- lib/comparesf2.c - Single-precision comparisons -----------*- C -*-===//
+//===-- lib/lesf2.c - Single-precision comparisons ----------------*- C -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -40,13 +40,6 @@
#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);
@@ -78,54 +71,3 @@ enum LE_RESULT __lesf2(fp_t a, fp_t b) {
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);
-}
diff --git a/compiler-rt/lib/ltdf2.c b/compiler-rt/lib/ltdf2.c
new file mode 100644
index 00000000000..07e2a396c6a
--- /dev/null
+++ b/compiler-rt/lib/ltdf2.c
@@ -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);
+}
diff --git a/compiler-rt/lib/ltsf2.c b/compiler-rt/lib/ltsf2.c
new file mode 100644
index 00000000000..85415fd3d5c
--- /dev/null
+++ b/compiler-rt/lib/ltsf2.c
@@ -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);
+}
diff --git a/compiler-rt/lib/nedf2.c b/compiler-rt/lib/nedf2.c
new file mode 100644
index 00000000000..db069460274
--- /dev/null
+++ b/compiler-rt/lib/nedf2.c
@@ -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);
+}
+
diff --git a/compiler-rt/lib/nesf2.c b/compiler-rt/lib/nesf2.c
new file mode 100644
index 00000000000..465cd1a0571
--- /dev/null
+++ b/compiler-rt/lib/nesf2.c
@@ -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);
+}
diff --git a/compiler-rt/lib/unorddf2.c b/compiler-rt/lib/unorddf2.c
new file mode 100644
index 00000000000..0327f103c74
--- /dev/null
+++ b/compiler-rt/lib/unorddf2.c
@@ -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;
+}
diff --git a/compiler-rt/lib/unordsf2.c b/compiler-rt/lib/unordsf2.c
new file mode 100644
index 00000000000..0ef7c11d181
--- /dev/null
+++ b/compiler-rt/lib/unordsf2.c
@@ -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;
+}
diff --git a/compiler-rt/make/platform/clang_darwin.mk b/compiler-rt/make/platform/clang_darwin.mk
index e27c92c8781..dc377c41688 100644
--- a/compiler-rt/make/platform/clang_darwin.mk
+++ b/compiler-rt/make/platform/clang_darwin.mk
@@ -223,8 +223,7 @@ FUNCTIONS.cc_kext.x86_64 := $(CCKEXT_X86_FUNCTIONS) \
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 \
OpenPOWER on IntegriCloud