summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/sparc/sparcv9
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/linux/sparc/sparcv9')
-rw-r--r--libc/sysdeps/linux/sparc/sparcv9/rem.S20
-rw-r--r--libc/sysdeps/linux/sparc/sparcv9/sdiv.S18
-rw-r--r--libc/sysdeps/linux/sparc/sparcv9/udiv.S15
-rw-r--r--libc/sysdeps/linux/sparc/sparcv9/umul.S15
-rw-r--r--libc/sysdeps/linux/sparc/sparcv9/urem.S17
5 files changed, 85 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/sparc/sparcv9/rem.S b/libc/sysdeps/linux/sparc/sparcv9/rem.S
new file mode 100644
index 000000000..1474e32ae
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/sparcv9/rem.S
@@ -0,0 +1,20 @@
+/*
+ * Sparc v9 has divide.
+ * As divx takes 68 cycles and sdivcc only 36,
+ * we use sdivcc eventhough it is deprecated.
+ */
+
+ .text
+ .align 32
+ENTRY(.rem)
+
+ sra %o0, 31, %o2
+ wr %o2, 0, %y
+ sdivcc %o0, %o1, %o2
+ xnor %o2, %g0, %o3
+ movvs %icc, %o3, %o2
+ smul %o2, %o1, %o2
+ retl
+ sub %o0, %o2, %o0
+
+END(.rem)
diff --git a/libc/sysdeps/linux/sparc/sparcv9/sdiv.S b/libc/sysdeps/linux/sparc/sparcv9/sdiv.S
new file mode 100644
index 000000000..45535bb68
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/sparcv9/sdiv.S
@@ -0,0 +1,18 @@
+/*
+ * Sparc v9 has divide.
+ * As divx takes 68 cycles and sdivcc only 36,
+ * we use sdivcc eventhough it is deprecated.
+ */
+
+ .text
+ .align 32
+ENTRY(.div)
+
+ sra %o0, 31, %o2
+ wr %o2, 0, %y
+ sdivcc %o0, %o1, %o0
+ xnor %o0, %g0, %o2
+ retl
+ movvs %icc, %o2, %o0
+
+END(.div)
diff --git a/libc/sysdeps/linux/sparc/sparcv9/udiv.S b/libc/sysdeps/linux/sparc/sparcv9/udiv.S
new file mode 100644
index 000000000..303f29bdf
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/sparcv9/udiv.S
@@ -0,0 +1,15 @@
+/*
+ * Sparc v9 has divide.
+ * As divx takes 68 cycles and udiv only 37,
+ * we use udiv eventhough it is deprecated.
+ */
+
+ .text
+ .align 32
+ENTRY(.udiv)
+
+ wr %g0, 0, %y
+ retl
+ udiv %o0, %o1, %o0
+
+END(.udiv)
diff --git a/libc/sysdeps/linux/sparc/sparcv9/umul.S b/libc/sysdeps/linux/sparc/sparcv9/umul.S
new file mode 100644
index 000000000..e65e4b95f
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/sparcv9/umul.S
@@ -0,0 +1,15 @@
+/*
+ * Sparc v9 has multiply.
+ */
+
+ .text
+ .align 32
+ENTRY(.umul)
+
+ srl %o0, 0, %o0
+ srl %o1, 0, %o1
+ mulx %o0, %o1, %o0
+ retl
+ srlx %o0, 32, %o1
+
+END(.umul)
diff --git a/libc/sysdeps/linux/sparc/sparcv9/urem.S b/libc/sysdeps/linux/sparc/sparcv9/urem.S
new file mode 100644
index 000000000..93542698d
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/sparcv9/urem.S
@@ -0,0 +1,17 @@
+/*
+ * Sparc v9 has divide.
+ * As divx takes 68 cycles and udiv only 37,
+ * we use udiv eventhough it is deprecated.
+ */
+
+ .text
+ .align 32
+ENTRY(.urem)
+
+ wr %g0, 0, %y
+ udiv %o0, %o1, %o2
+ umul %o2, %o1, %o2
+ retl
+ sub %o0, %o2, %o0
+
+END(.urem)