summaryrefslogtreecommitdiff
path: root/sysdeps/powerpc/powerpc64
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/powerpc/powerpc64')
-rw-r--r--sysdeps/powerpc/powerpc64/dl-machine.h16
-rw-r--r--sysdeps/powerpc/powerpc64/fpu/s_llround.S57
-rw-r--r--sysdeps/powerpc/powerpc64/fpu/s_llroundf.S53
-rw-r--r--sysdeps/powerpc/powerpc64/fpu/s_lrint.S1
-rw-r--r--sysdeps/powerpc/powerpc64/fpu/s_lround.S1
-rw-r--r--sysdeps/powerpc/powerpc64/fpu/s_lroundf.S1
6 files changed, 86 insertions, 43 deletions
diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h
index c837393d79..b674dbef43 100644
--- a/sysdeps/powerpc/powerpc64/dl-machine.h
+++ b/sysdeps/powerpc/powerpc64/dl-machine.h
@@ -1,6 +1,6 @@
/* Machine-dependent ELF dynamic relocation inline functions.
PowerPC64 version.
- Copyright 1995-2005, 2006 Free Software Foundation, Inc.
+ Copyright 1995-2005, 2006, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -287,6 +287,8 @@ BODY_PREFIX "_dl_start_user:\n" \
#define GLINK_INITIAL_ENTRY_WORDS 8
#define PPC_DCBST(where) asm volatile ("dcbst 0,%0" : : "r"(where) : "memory")
+#define PPC_DCBT(where) asm volatile ("dcbt 0,%0" : : "r"(where) : "memory")
+#define PPC_DCBF(where) asm volatile ("dcbf 0,%0" : : "r"(where) : "memory")
#define PPC_SYNC asm volatile ("sync" : : : "memory")
#define PPC_ISYNC asm volatile ("sync; isync" : : : "memory")
#define PPC_ICBI(where) asm volatile ("icbi 0,%0" : : "r"(where) : "memory")
@@ -408,6 +410,11 @@ elf_machine_fixup_plt (struct link_map *map, lookup_t sym_map,
Elf64_FuncDesc *rel = (Elf64_FuncDesc *) finaladdr;
Elf64_Addr offset = 0;
+ PPC_DCBT (&plt->fd_aux);
+ PPC_DCBT (&plt->fd_func);
+ PPC_DCBT (&rel->fd_aux);
+ PPC_DCBT (&rel->fd_func);
+
/* If sym_map is NULL, it's a weak undefined sym; Leave the plt zero. */
if (sym_map == NULL)
return 0;
@@ -430,13 +437,12 @@ elf_machine_fixup_plt (struct link_map *map, lookup_t sym_map,
plt->fd_aux = rel->fd_aux + offset;
plt->fd_toc = rel->fd_toc + offset;
- PPC_DCBST (&plt->fd_aux);
- PPC_DCBST (&plt->fd_toc);
- PPC_SYNC;
+ PPC_DCBF (&plt->fd_toc);
+ PPC_ISYNC;
plt->fd_func = rel->fd_func + offset;
PPC_DCBST (&plt->fd_func);
- PPC_SYNC;
+ PPC_ISYNC;
return finaladdr;
}
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llround.S b/sysdeps/powerpc/powerpc64/fpu/s_llround.S
index d023b8f2c0..4134847536 100644
--- a/sysdeps/powerpc/powerpc64/fpu/s_llround.S
+++ b/sysdeps/powerpc/powerpc64/fpu/s_llround.S
@@ -1,5 +1,5 @@
/* llround function. PowerPC64 version.
- Copyright (C) 2004, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,13 +21,13 @@
#include <math_ldbl_opt.h>
.section ".toc","aw"
-.LC0: /* -0.0 */
- .tc FD_00000000_0[TC],0x0000000000000000
+.LC0: /* 2^52 */
+ .tc FD_43300000_0[TC],0x4330000000000000
.LC1: /* 0.5 */
.tc FD_3fe00000_0[TC],0x3fe0000000000000
.section ".text"
-/* long long [r3] llround (float x [fp1])
+/* long long [r3] llround (double x [fp1])
IEEE 1003.1 llround function. IEEE specifies "round to the nearest
integer value, rounding halfway cases away from zero, regardless of
the current rounding mode." However PowerPC Architecture defines
@@ -35,26 +35,45 @@
tie, choose the one that is even (least significant bit o).".
So we can't use the PowerPC "round to Nearest" mode. Instead we set
"round toward Zero" mode and round by adding +-0.5 before rounding
- to the integer value. */
+ to the integer value.
+
+ It is necessary to detect when x is (+-)0x1.fffffffffffffp-2
+ because adding +-0.5 in this case will cause an erroneous shift,
+ carry and round. We simply return 0 if 0.5 > x > -0.5. Likewise
+ if x is and odd number between +-(2^52 and 2^53-1) a shift and
+ carry will erroneously round if biased with +-0.5. Therefore if x
+ is greater/less than +-2^52 we don't need to bias the number with
+ +-0.5. */
ENTRY (__llround)
CALL_MCOUNT 0
- lfd fp12,.LC0@toc(2)
- lfd fp10,.LC1@toc(2)
- fcmpu cr6,fp1,fp12 /* if (x > 0.0) */
- ble- cr6,.L4
- fadd fp1,fp1,fp10 /* x+= 0.5; */
-.L9:
- fctidz fp2,fp1 /* Convert To Integer DW llround toward 0. */
- stfd fp2,-16(r1)
- nop /* Insure the following load is in a different dispatch group */
- nop /* to avoid pipe stall on POWER4&5. */
+ lfd fp9,.LC0@toc(2) /* Load 2^52 into fpr9. */
+ lfd fp10,.LC1@toc(2)/* Load 0.5 into fpr10. */
+ fabs fp2,fp1 /* Get the absolute value of x. */
+ fsub fp12,fp10,fp10 /* Compute 0.0 into fp12. */
+ fcmpu cr6,fp2,fp10 /* if |x| < 0.5 */
+ fcmpu cr4,fp2,fp9 /* if |x| >= 2^52 */
+ fcmpu cr3,fp1,fp12 /* x is negative? x < 0.0 */
+ blt- cr6,.Lretzero /* 0.5 > x < -0.5 so just return 0. */
+ bge- cr4,.Lnobias /* 2^52 > x < -2^52 just convert with no bias. */
+ fadd fp3,fp2,fp10 /* |x|+=0.5 bias to prepare to round. */
+ bge cr3,.Lconvert /* x is positive so don't negate x. */
+ fnabs fp3,fp3 /* -(|x|+=0.5) */
+.Lconvert:
+ fctidz fp4,fp3 /* Convert to Integer double word round toward 0. */
+ stfd fp4,-16(r1)
+ nop
+ nop
nop
- ld r3,-16(r1)
+ ld r3,-16(r1) /* Load return as integer. */
+.Lout:
blr
-.L4:
- fsub fp1,fp1,fp10 /* x-= 0.5; */
- b .L9
+.Lretzero: /* 0.5 > x > -0.5 */
+ li r3,0 /* return 0. */
+ b .Lout
+.Lnobias:
+ fmr fp3,fp1
+ b .Lconvert
END (__llround)
strong_alias (__llround, __lround)
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llroundf.S b/sysdeps/powerpc/powerpc64/fpu/s_llroundf.S
index bbbd05492e..a211879393 100644
--- a/sysdeps/powerpc/powerpc64/fpu/s_llroundf.S
+++ b/sysdeps/powerpc/powerpc64/fpu/s_llroundf.S
@@ -1,5 +1,5 @@
/* llroundf function. PowerPC64 version.
- Copyright (C) 2004, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,8 +20,8 @@
#include <sysdep.h>
.section ".toc","aw"
-.LC0: /* -0.0 */
- .tc FD_00000000_0[TC],0x0000000000000000
+.LC0: /* 2^23 */
+ .tc FD_41600000_0[TC],0x4160000000000000
.LC1: /* 0.5 */
.tc FD_3fe00000_0[TC],0x3fe0000000000000
.section ".text"
@@ -34,24 +34,45 @@
tie, choose the one that is even (least significant bit o).".
So we can't use the PowerPC "round to Nearest" mode. Instead we set
"round toward Zero" mode and round by adding +-0.5 before rounding
- to the integer value. */
+ to the integer value.
+
+ It is necessary to detect when x is (+-)0x1.fffffffffffffp-2
+ because adding +-0.5 in this case will cause an erroneous shift,
+ carry and round. We simply return 0 if 0.5 > x > -0.5. Likewise
+ if x is and odd number between +-(2^23 and 2^24-1) a shift and
+ carry will erroneously round if biased with +-0.5. Therefore if x
+ is greater/less than +-2^23 we don't need to bias the number with
+ +-0.5. */
ENTRY (__llroundf)
CALL_MCOUNT 0
- lfd fp12,.LC0@toc(2)
- lfd fp10,.LC1@toc(2)
- fcmpu cr6,fp1,fp12 /* if (x < 0.0) */
- fsubs fp3,fp1,fp10 /* x-= 0.5; */
- ble- cr6,.L9
- fadds fp3,fp1,fp10 /* x+= 0.5; */
-.L9:
- fctidz fp2,fp3 /* Convert To Integer DW round toward 0. */
- stfd fp2,-16(r1)
- nop /* Insure the following load is in a different dispatch group */
- nop /* to avoid pipe stall on POWER4&5. */
+ lfd fp9,.LC0@toc(2) /* Load 2^23 into fpr9. */
+ lfd fp10,.LC1@toc(2)/* Load 0.5 into fpr10. */
+ fabs fp2,fp1 /* Get the absolute value of x. */
+ fsub fp12,fp10,fp10 /* Compute 0.0 into fp12. */
+ fcmpu cr6,fp2,fp10 /* if |x| < 0.5 */
+ fcmpu cr4,fp2,fp9 /* if |x| >= 2^23 */
+ fcmpu cr3,fp1,fp12 /* x is negative? x < 0.0 */
+ blt- cr6,.Lretzero /* 0.5 > x < -0.5 so just return 0. */
+ bge- cr4,.Lnobias /* 2^23 > x < -2^23 just convert with no bias. */
+ fadd fp3,fp2,fp10 /* |x|+=0.5 bias to prepare to round. */
+ bge cr3,.Lconvert /* x is positive so don't negate x. */
+ fnabs fp3,fp3 /* -(|x|+=0.5) */
+.Lconvert:
+ fctidz fp4,fp3 /* Convert to Integer double word round toward 0. */
+ stfd fp4,-16(r1)
+ nop
+ nop
nop
- ld r3,-16(r1)
+ ld r3,-16(r1) /* Load return as integer. */
+.Lout:
blr
+.Lretzero: /* 0.5 > x > -0.5 */
+ li r3,0 /* return 0. */
+ b .Lout
+.Lnobias:
+ fmr fp3,fp1
+ b .Lconvert
END (__llroundf)
strong_alias (__llroundf, __lroundf)
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_lrint.S b/sysdeps/powerpc/powerpc64/fpu/s_lrint.S
index fe774693b7..d3c2fff581 100644
--- a/sysdeps/powerpc/powerpc64/fpu/s_lrint.S
+++ b/sysdeps/powerpc/powerpc64/fpu/s_lrint.S
@@ -1,2 +1 @@
/* __lrint is in s_llrint.c */
-/* __lrint is in s_llrint.c */
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_lround.S b/sysdeps/powerpc/powerpc64/fpu/s_lround.S
index 883bba1c5d..4306c405c4 100644
--- a/sysdeps/powerpc/powerpc64/fpu/s_lround.S
+++ b/sysdeps/powerpc/powerpc64/fpu/s_lround.S
@@ -1,2 +1 @@
/* __lround is in s_llround.S */
-/* __lround is in s_llround.S */
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_lroundf.S b/sysdeps/powerpc/powerpc64/fpu/s_lroundf.S
index 15506f6801..6b2a4e37a6 100644
--- a/sysdeps/powerpc/powerpc64/fpu/s_lroundf.S
+++ b/sysdeps/powerpc/powerpc64/fpu/s_lroundf.S
@@ -1,2 +1 @@
/* __lroundf is in s_llroundf.S */
-/* __lroundf is in s_llroundf.S */