aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/xtensa
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@acm.org>2007-04-25 21:40:42 +0000
committerBob Wilson <bwilson@gcc.gnu.org>2007-04-25 21:40:42 +0000
commita2c2290b622b0298330a8d3bc1de1ca1524e7762 (patch)
treef7df6afd9db14aa950c9c9b048ad71b53f89a3e5 /gcc/config/xtensa
parent9f8b807381bf3e75c0b5b59e706cecdd0c4481ce (diff)
downloadgcc-a2c2290b622b0298330a8d3bc1de1ca1524e7762.zip
gcc-a2c2290b622b0298330a8d3bc1de1ca1524e7762.tar.gz
gcc-a2c2290b622b0298330a8d3bc1de1ca1524e7762.tar.bz2
lib1funcs.asm (__udivsi3, __divsi3): Throw an exception for divide-by-zero.
* config/xtensa/lib1funcs.asm (__udivsi3, __divsi3): Throw an exception for divide-by-zero. (__umodsi3, __modsi3): Likewise. From-SVN: r124165
Diffstat (limited to 'gcc/config/xtensa')
-rw-r--r--gcc/config/xtensa/lib1funcs.asm35
1 files changed, 28 insertions, 7 deletions
diff --git a/gcc/config/xtensa/lib1funcs.asm b/gcc/config/xtensa/lib1funcs.asm
index 5b4f8c8..6db2a7d 100644
--- a/gcc/config/xtensa/lib1funcs.asm
+++ b/gcc/config/xtensa/lib1funcs.asm
@@ -1,5 +1,6 @@
/* Assembly functions for the Xtensa version of libgcc1.
- Copyright (C) 2001, 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007
+ Free Software Foundation, Inc.
Contributed by Bob Wilson (bwilson@tensilica.com) at Tensilica.
This file is part of GCC.
@@ -530,7 +531,11 @@ __udivsi3:
leaf_return
.Lerror:
- /* just return 0; could throw an exception */
+ /* Divide by zero: Use an illegal instruction to force an exception.
+ The subsequent "DIV0" string can be recognized by the exception
+ handler to identify the real cause of the exception. */
+ ill
+ .ascii "DIV0"
.Lreturn0:
movi a2, 0
@@ -597,7 +602,11 @@ __divsi3:
leaf_return
.Lerror:
- /* just return 0; could throw an exception */
+ /* Divide by zero: Use an illegal instruction to force an exception.
+ The subsequent "DIV0" string can be recognized by the exception
+ handler to identify the real cause of the exception. */
+ ill
+ .ascii "DIV0"
.Lreturn0:
movi a2, 0
@@ -645,10 +654,16 @@ __umodsi3:
leaf_return
.Lle_one:
- /* The divisor is either 0 or 1, so just return 0.
- Someday we may want to throw an exception if the divisor is 0. */
+ beqz a3, .Lerror
movi a2, 0
leaf_return
+
+.Lerror:
+ /* Divide by zero: Use an illegal instruction to force an exception.
+ The subsequent "DIV0" string can be recognized by the exception
+ handler to identify the real cause of the exception. */
+ ill
+ .ascii "DIV0"
.size __umodsi3,.-__umodsi3
#endif /* L_umodsi3 */
@@ -697,10 +712,16 @@ __modsi3:
leaf_return
.Lle_one:
- /* udivisor is either 0 or 1, so just return 0.
- Someday we may want to throw an exception if udivisor is 0. */
+ beqz a3, .Lerror
movi a2, 0
leaf_return
+
+.Lerror:
+ /* Divide by zero: Use an illegal instruction to force an exception.
+ The subsequent "DIV0" string can be recognized by the exception
+ handler to identify the real cause of the exception. */
+ ill
+ .ascii "DIV0"
.size __modsi3,.-__modsi3
#endif /* L_modsi3 */