This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
preliminary support for new Xtensa ABI
- From: Bob Wilson <bwilson at tensilica dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 18 Aug 2003 17:15:32 -0700
- Subject: preliminary support for new Xtensa ABI
- Organization: Tensilica, Inc.
Tensilica is in the process of developing support for an alternate ABI that
does not use register windows. Not all of the pieces are ready yet, but this
patch fixes up the assembly sources to include code for both the standard
Xtensa ABI and the new "call0" ABI. Tested and committed on the mainline.
2003-08-18 Bob Wilson <bob.wilson@acm.org>
* config/xtensa/crti.asm (_init, _fini): Add alternate code for new
call0 ABI.
* config/xtensa/crtn.asm (_init, _fini): Likewise.
* config/xtensa/lib1funcs.asm (__mulsi3, __udivsi3, __divsi3,
__umodsi3, __modsi3): Likewise.
* config/xtensa/t-xtensa (crti.o, crtn.o): Add $(GCC_CFLAGS) and
$(INCLUDES).
Index: crti.asm
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/xtensa/crti.asm,v
retrieving revision 1.2
diff -u -r1.2 crti.asm
--- crti.asm 23 Jul 2003 19:56:30 -0000 1.2
+++ crti.asm 18 Aug 2003 23:59:09 -0000
@@ -29,16 +29,28 @@
# .init sections. Users may put any desired instructions in those
# sections.
+#include "xtensa-config.h"
+
.section .init
.globl _init
.type _init,@function
.align 4
_init:
+#if XCHAL_HAVE_WINDOWED && !__XTENSA_CALL0_ABI__
entry sp, 64
+#else
+ addi sp, sp, -32
+ s32i a0, sp, 0
+#endif
.section .fini
.globl _fini
.type _fini,@function
.align 4
_fini:
+#if XCHAL_HAVE_WINDOWED && !__XTENSA_CALL0_ABI__
entry sp, 64
+#else
+ addi sp, sp, -32
+ s32i a0, sp, 0
+#endif
Index: crtn.asm
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/xtensa/crtn.asm,v
retrieving revision 1.1
diff -u -r1.1 crtn.asm
--- crtn.asm 24 Jan 2003 21:51:03 -0000 1.1
+++ crtn.asm 18 Aug 2003 23:59:09 -0000
@@ -29,8 +29,22 @@
# fact return. Users may put any desired instructions in those sections.
# This file is the last thing linked into any executable.
+#include "xtensa-config.h"
+
.section .init
+#if XCHAL_HAVE_WINDOWED && !__XTENSA_CALL0_ABI__
retw
+#else
+ l32i a0, sp, 0
+ addi sp, sp, 32
+ ret
+#endif
.section .fini
+#if XCHAL_HAVE_WINDOWED && !__XTENSA_CALL0_ABI__
retw
+#else
+ l32i a0, sp, 0
+ addi sp, sp, 32
+ ret
+#endif
Index: lib1funcs.asm
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/xtensa/lib1funcs.asm,v
retrieving revision 1.5
diff -u -r1.5 lib1funcs.asm
--- lib1funcs.asm 23 Jul 2003 19:56:30 -0000 1.5
+++ lib1funcs.asm 18 Aug 2003 23:59:09 -0000
@@ -75,19 +75,41 @@
#endif
.endm
+# Define macros for function entry and return, supporting either the
+# standard register windowed ABI or the non-windowed call0 ABI. These
+# macros do not allocate any extra stack space, so they only work for
+# leaf functions that do not need to spill anything to the stack.
+
+ .macro abi_entry reg, size
+#if XCHAL_HAVE_WINDOWED && !__XTENSA_CALL0_ABI__
+ entry \reg, \size
+#else
+ /* do nothing */
+#endif
+ .endm
+
+ .macro abi_return
+#if XCHAL_HAVE_WINDOWED && !__XTENSA_CALL0_ABI__
+ retw
+#else
+ ret
+#endif
+ .endm
+
+
#ifdef L_mulsi3
.align 4
.global __mulsi3
.type __mulsi3,@function
__mulsi3:
- entry sp, 32
+ abi_entry sp, 32
#if XCHAL_HAVE_MUL16
or a4, a2, a3
srai a4, a4, 16
bnez a4, .LMUL16
mul16u a2, a2, a3
- retw
+ abi_return
.LMUL16:
srai a4, a2, 16
srai a5, a3, 16
@@ -143,7 +165,7 @@
bgeui a3, 16, .Lmult_main_loop
neg a3, a2
movltz a2, a3, a5
- retw
+ abi_return
.align 4
.Lmult_main_loop:
@@ -173,7 +195,7 @@
#endif /* !XCHAL_HAVE_MUL16 && !XCHAL_HAVE_MAC16 */
- retw
+ abi_return
.size __mulsi3,.-__mulsi3
#endif /* L_mulsi3 */
@@ -242,7 +264,7 @@
.global __udivsi3
.type __udivsi3,@function
__udivsi3:
- entry sp, 32
+ abi_entry sp, 32
bltui a3, 2, .Lle_one # check if the divisor <= 1
mov a6, a2 # keep dividend in a6
@@ -275,7 +297,7 @@
bltu a6, a3, .Lreturn
addi a2, a2, 1 # increment quotient if dividend >= divisor
.Lreturn:
- retw
+ abi_return
.Lspecial:
# return dividend >= divisor
@@ -283,14 +305,14 @@
bltu a6, a3, .Lreturn2
movi a2, 1
.Lreturn2:
- retw
+ abi_return
.Lle_one:
beqz a3, .Lerror # if divisor == 1, return the dividend
- retw
+ abi_return
.Lerror:
movi a2, 0 # just return 0; could throw an exception
- retw
+ abi_return
.size __udivsi3,.-__udivsi3
#endif /* L_udivsi3 */
@@ -301,7 +323,7 @@
.global __divsi3
.type __divsi3,@function
__divsi3:
- entry sp, 32
+ abi_entry sp, 32
xor a7, a2, a3 # sign = dividend ^ divisor
do_abs a6, a2, a4 # udividend = abs(dividend)
do_abs a3, a3, a4 # udivisor = abs(divisor)
@@ -337,7 +359,7 @@
.Lreturn:
neg a5, a2
movltz a2, a5, a7 # return (sign < 0) ? -quotient : quotient
- retw
+ abi_return
.Lspecial:
movi a2, 0
@@ -346,16 +368,16 @@
movi a4, -1
movltz a2, a4, a7 # else return (sign < 0) ? -1 : 1
.Lreturn2:
- retw
+ abi_return
.Lle_one:
beqz a3, .Lerror
neg a2, a6 # if udivisor == 1, then return...
movgez a2, a6, a7 # (sign < 0) ? -udividend : udividend
- retw
+ abi_return
.Lerror:
movi a2, 0 # just return 0; could throw an exception
- retw
+ abi_return
.size __divsi3,.-__divsi3
#endif /* L_divsi3 */
@@ -366,7 +388,7 @@
.global __umodsi3
.type __umodsi3,@function
__umodsi3:
- entry sp, 32
+ abi_entry sp, 32
bltui a3, 2, .Lle_one # check if the divisor is <= 1
do_nsau a5, a2, a6, a7 # dividend_shift = nsau(dividend)
@@ -395,19 +417,19 @@
bltu a2, a3, .Lreturn
sub a2, a2, a3 # subtract once more if dividend >= divisor
.Lreturn:
- retw
+ abi_return
.Lspecial:
bltu a2, a3, .Lreturn2
sub a2, a2, a3 # subtract once if dividend >= divisor
.Lreturn2:
- retw
+ abi_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.
movi a2, 0
- retw
+ abi_return
.size __umodsi3,.-__umodsi3
#endif /* L_umodsi3 */
@@ -418,7 +440,7 @@
.global __modsi3
.type __modsi3,@function
__modsi3:
- entry sp, 32
+ abi_entry sp, 32
mov a7, a2 # save original (signed) dividend
do_abs a2, a2, a4 # udividend = abs(dividend)
do_abs a3, a3, a4 # udivisor = abs(divisor)
@@ -452,7 +474,7 @@
bgez a7, .Lpositive
neg a2, a2 # if (dividend < 0), return -udividend
.Lpositive:
- retw
+ abi_return
.Lspecial:
bltu a2, a3, .Lreturn2
@@ -461,13 +483,13 @@
bgez a7, .Lpositive2
neg a2, a2 # if (dividend < 0), return -udividend
.Lpositive2:
- retw
+ abi_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.
movi a2, 0
- retw
+ abi_return
.size __modsi3,.-__modsi3
#endif /* L_modsi3 */
Index: t-xtensa
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/xtensa/t-xtensa,v
retrieving revision 1.5
diff -u -r1.5 t-xtensa
--- t-xtensa 24 Jan 2003 21:51:03 -0000 1.5
+++ t-xtensa 18 Aug 2003 23:59:09 -0000
@@ -17,11 +17,11 @@
LIB2FUNCS_EXTRA += $(srcdir)/config/xtensa/lib2funcs.S
$(T)crti.o: $(srcdir)/config/xtensa/crti.asm $(GCC_PASSES)
- $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crti.o \
- -x assembler-with-cpp $(srcdir)/config/xtensa/crti.asm
+ $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
+ -c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/xtensa/crti.asm
$(T)crtn.o: $(srcdir)/config/xtensa/crtn.asm $(GCC_PASSES)
- $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crtn.o \
- -x assembler-with-cpp $(srcdir)/config/xtensa/crtn.asm
+ $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
+ -c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/xtensa/crtn.asm
$(out_object_file): gt-xtensa.h
gt-xtensa.h : s-gtype ; @true