2011-11-29 22:36:43 +01:00
|
|
|
/* libgcc routines for RL78
|
2020-01-01 12:51:42 +01:00
|
|
|
Copyright (C) 2011-2020 Free Software Foundation, Inc.
|
2011-11-29 22:36:43 +01:00
|
|
|
Contributed by Red Hat.
|
|
|
|
|
|
|
|
This file is part of GCC.
|
|
|
|
|
|
|
|
GCC is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU General Public License as published
|
|
|
|
by the Free Software Foundation; either version 3, or (at your
|
|
|
|
option) any later version.
|
|
|
|
|
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
|
|
License for more details.
|
|
|
|
|
|
|
|
Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
permissions described in the GCC Runtime Library Exception, version
|
|
|
|
3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License and
|
|
|
|
a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
/* RL78 Trampoline support
|
|
|
|
|
|
|
|
Since the RL78's RAM is not in the first 64k, we cannot "just" use a
|
|
|
|
function pointer to point to a trampoline on the stack. So, we
|
|
|
|
create N fixed trampolines that read from an array, and allocate
|
|
|
|
them as needed.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2013-09-16 23:15:46 +02:00
|
|
|
#include "vregs.h"
|
2011-11-29 22:36:43 +01:00
|
|
|
|
|
|
|
.data
|
|
|
|
.p2align 1
|
|
|
|
trampoline_array:
|
|
|
|
|
|
|
|
.macro stub n
|
|
|
|
|
|
|
|
.text
|
|
|
|
trampoline_\n:
|
|
|
|
.type trampoline_\n, @function
|
|
|
|
movw ax, !trampoline_chain_\n
|
|
|
|
movw r14, ax
|
|
|
|
movw ax, !trampoline_addr_\n
|
|
|
|
br ax
|
|
|
|
.size trampoline_\n, .-trampoline_\n
|
|
|
|
|
|
|
|
.data
|
|
|
|
trampoline_frame_\n:
|
|
|
|
.short 0
|
|
|
|
trampoline_stub_\n:
|
|
|
|
.short trampoline_\n
|
|
|
|
trampoline_chain_\n:
|
|
|
|
.short 0
|
|
|
|
trampoline_addr_\n:
|
|
|
|
.short 0
|
|
|
|
|
|
|
|
#define TO_FRAME 0
|
|
|
|
#define TO_STUB 2
|
|
|
|
#define TO_CHAIN 4
|
|
|
|
#define TO_ADDR 6
|
|
|
|
#define TO_SIZE 8
|
|
|
|
|
|
|
|
.endm
|
|
|
|
|
|
|
|
stub 0
|
|
|
|
stub 1
|
|
|
|
stub 2
|
|
|
|
stub 3
|
|
|
|
stub 4
|
|
|
|
stub 5
|
|
|
|
|
|
|
|
trampoline_array_end:
|
|
|
|
|
|
|
|
/* Given the function pointer in R8 and the static chain
|
|
|
|
pointer in R10, allocate a trampoline and return its address in
|
|
|
|
R8. */
|
|
|
|
|
cmpsi2.S: Use function start and end macros.
* config/rl78/cmpsi2.S: Use function start and end macros.
(__gcc_bcmp): New function.
* config/rl78/lshrsi3.S: Use function start and end macros.
* config/rl78/mulsi3.S: Add support for G10.
(__mulqi3): New function for G10.
* config/rl78/signbit.S: Use function start and end macros.
* config/rl78/t-rl78 (LIB2ADD): Add bit-count.S, fpbit-sf.S and
fpmath-sf.S.
(LIB2FUNCS_EXCLUDE): Define.
(LIB2FUNCS_ST): Define.
* config/rl78/trampoline.S: Use function start and end macros.
* config/rl78/vregs.h (START_FUNC): New macro.
(START_ANOTHER_FUNC): New macro.
(END_FUNC): New macro.
(END_ANOTHER_FUNC): New macro.
* config/rl78/bit-count.S: New file. Contains assembler
implementations of the bit counting functions: ___clzhi2,
__clzsi2, ctzhi2, ctzsi2, ffshi2, ffssi2, __partityhi2,
__paritysi2, __popcounthi2 and __popcountsi2.
* config/rl78/fpbit-sf.S: New file. Contains assembler
implementationas of the math functions: __negsf2, __cmpsf2,
__eqsf2, __nesf2, __lesf2, __ltsf2, __gesf2, gtsf2, __unordsf2,
__fixsfsi, __fixunssfsi, __floatsisf and __floatunssisf.
* config/rl78/fpmath-sf.S: New file. Contains assembler
implementations of the math functions: __subsf3, __addsf3,
__mulsf3 and __divsf3
From-SVN: r220162
2015-01-27 12:36:01 +01:00
|
|
|
START_FUNC ___trampoline_init
|
2011-11-29 22:36:43 +01:00
|
|
|
movw hl, #trampoline_array
|
cmpsi2.S: Use function start and end macros.
* config/rl78/cmpsi2.S: Use function start and end macros.
(__gcc_bcmp): New function.
* config/rl78/lshrsi3.S: Use function start and end macros.
* config/rl78/mulsi3.S: Add support for G10.
(__mulqi3): New function for G10.
* config/rl78/signbit.S: Use function start and end macros.
* config/rl78/t-rl78 (LIB2ADD): Add bit-count.S, fpbit-sf.S and
fpmath-sf.S.
(LIB2FUNCS_EXCLUDE): Define.
(LIB2FUNCS_ST): Define.
* config/rl78/trampoline.S: Use function start and end macros.
* config/rl78/vregs.h (START_FUNC): New macro.
(START_ANOTHER_FUNC): New macro.
(END_FUNC): New macro.
(END_ANOTHER_FUNC): New macro.
* config/rl78/bit-count.S: New file. Contains assembler
implementations of the bit counting functions: ___clzhi2,
__clzsi2, ctzhi2, ctzsi2, ffshi2, ffssi2, __partityhi2,
__paritysi2, __popcounthi2 and __popcountsi2.
* config/rl78/fpbit-sf.S: New file. Contains assembler
implementationas of the math functions: __negsf2, __cmpsf2,
__eqsf2, __nesf2, __lesf2, __ltsf2, __gesf2, gtsf2, __unordsf2,
__fixsfsi, __fixunssfsi, __floatsisf and __floatunssisf.
* config/rl78/fpmath-sf.S: New file. Contains assembler
implementations of the math functions: __subsf3, __addsf3,
__mulsf3 and __divsf3
From-SVN: r220162
2015-01-27 12:36:01 +01:00
|
|
|
|
|
|
|
1: movw ax, [hl + TO_ADDR]
|
2011-11-29 22:36:43 +01:00
|
|
|
cmpw ax, #0
|
|
|
|
bz $2f
|
|
|
|
|
|
|
|
movw ax, hl
|
|
|
|
addw ax, #TO_SIZE
|
|
|
|
movw hl, ax
|
|
|
|
cmpw ax, #trampoline_array_end
|
|
|
|
bnz $1b
|
|
|
|
brk ; no more slots?
|
|
|
|
|
|
|
|
2: movw ax, r8
|
|
|
|
movw [hl + TO_ADDR], ax
|
|
|
|
movw ax, r10
|
|
|
|
movw [hl + TO_CHAIN], ax
|
|
|
|
movw ax, sp
|
|
|
|
movw [hl + TO_FRAME], ax
|
|
|
|
|
|
|
|
movw ax, [hl + TO_STUB]
|
|
|
|
movw r8, ax
|
|
|
|
ret
|
cmpsi2.S: Use function start and end macros.
* config/rl78/cmpsi2.S: Use function start and end macros.
(__gcc_bcmp): New function.
* config/rl78/lshrsi3.S: Use function start and end macros.
* config/rl78/mulsi3.S: Add support for G10.
(__mulqi3): New function for G10.
* config/rl78/signbit.S: Use function start and end macros.
* config/rl78/t-rl78 (LIB2ADD): Add bit-count.S, fpbit-sf.S and
fpmath-sf.S.
(LIB2FUNCS_EXCLUDE): Define.
(LIB2FUNCS_ST): Define.
* config/rl78/trampoline.S: Use function start and end macros.
* config/rl78/vregs.h (START_FUNC): New macro.
(START_ANOTHER_FUNC): New macro.
(END_FUNC): New macro.
(END_ANOTHER_FUNC): New macro.
* config/rl78/bit-count.S: New file. Contains assembler
implementations of the bit counting functions: ___clzhi2,
__clzsi2, ctzhi2, ctzsi2, ffshi2, ffssi2, __partityhi2,
__paritysi2, __popcounthi2 and __popcountsi2.
* config/rl78/fpbit-sf.S: New file. Contains assembler
implementationas of the math functions: __negsf2, __cmpsf2,
__eqsf2, __nesf2, __lesf2, __ltsf2, __gesf2, gtsf2, __unordsf2,
__fixsfsi, __fixunssfsi, __floatsisf and __floatunssisf.
* config/rl78/fpmath-sf.S: New file. Contains assembler
implementations of the math functions: __subsf3, __addsf3,
__mulsf3 and __divsf3
From-SVN: r220162
2015-01-27 12:36:01 +01:00
|
|
|
END_FUNC ___trampoline_init
|
2011-11-29 22:36:43 +01:00
|
|
|
|
cmpsi2.S: Use function start and end macros.
* config/rl78/cmpsi2.S: Use function start and end macros.
(__gcc_bcmp): New function.
* config/rl78/lshrsi3.S: Use function start and end macros.
* config/rl78/mulsi3.S: Add support for G10.
(__mulqi3): New function for G10.
* config/rl78/signbit.S: Use function start and end macros.
* config/rl78/t-rl78 (LIB2ADD): Add bit-count.S, fpbit-sf.S and
fpmath-sf.S.
(LIB2FUNCS_EXCLUDE): Define.
(LIB2FUNCS_ST): Define.
* config/rl78/trampoline.S: Use function start and end macros.
* config/rl78/vregs.h (START_FUNC): New macro.
(START_ANOTHER_FUNC): New macro.
(END_FUNC): New macro.
(END_ANOTHER_FUNC): New macro.
* config/rl78/bit-count.S: New file. Contains assembler
implementations of the bit counting functions: ___clzhi2,
__clzsi2, ctzhi2, ctzsi2, ffshi2, ffssi2, __partityhi2,
__paritysi2, __popcounthi2 and __popcountsi2.
* config/rl78/fpbit-sf.S: New file. Contains assembler
implementationas of the math functions: __negsf2, __cmpsf2,
__eqsf2, __nesf2, __lesf2, __ltsf2, __gesf2, gtsf2, __unordsf2,
__fixsfsi, __fixunssfsi, __floatsisf and __floatunssisf.
* config/rl78/fpmath-sf.S: New file. Contains assembler
implementations of the math functions: __subsf3, __addsf3,
__mulsf3 and __divsf3
From-SVN: r220162
2015-01-27 12:36:01 +01:00
|
|
|
|
|
|
|
START_FUNC ___trampoline_uninit
|
2011-11-29 22:36:43 +01:00
|
|
|
movw hl, #trampoline_array
|
|
|
|
movw ax, sp
|
|
|
|
movw bc, ax
|
cmpsi2.S: Use function start and end macros.
* config/rl78/cmpsi2.S: Use function start and end macros.
(__gcc_bcmp): New function.
* config/rl78/lshrsi3.S: Use function start and end macros.
* config/rl78/mulsi3.S: Add support for G10.
(__mulqi3): New function for G10.
* config/rl78/signbit.S: Use function start and end macros.
* config/rl78/t-rl78 (LIB2ADD): Add bit-count.S, fpbit-sf.S and
fpmath-sf.S.
(LIB2FUNCS_EXCLUDE): Define.
(LIB2FUNCS_ST): Define.
* config/rl78/trampoline.S: Use function start and end macros.
* config/rl78/vregs.h (START_FUNC): New macro.
(START_ANOTHER_FUNC): New macro.
(END_FUNC): New macro.
(END_ANOTHER_FUNC): New macro.
* config/rl78/bit-count.S: New file. Contains assembler
implementations of the bit counting functions: ___clzhi2,
__clzsi2, ctzhi2, ctzsi2, ffshi2, ffssi2, __partityhi2,
__paritysi2, __popcounthi2 and __popcountsi2.
* config/rl78/fpbit-sf.S: New file. Contains assembler
implementationas of the math functions: __negsf2, __cmpsf2,
__eqsf2, __nesf2, __lesf2, __ltsf2, __gesf2, gtsf2, __unordsf2,
__fixsfsi, __fixunssfsi, __floatsisf and __floatunssisf.
* config/rl78/fpmath-sf.S: New file. Contains assembler
implementations of the math functions: __subsf3, __addsf3,
__mulsf3 and __divsf3
From-SVN: r220162
2015-01-27 12:36:01 +01:00
|
|
|
|
|
|
|
1: movw ax, [hl + TO_FRAME]
|
2011-11-29 22:36:43 +01:00
|
|
|
cmpw ax, bc
|
|
|
|
bc $2f
|
|
|
|
|
|
|
|
clrw ax
|
|
|
|
movw [hl + TO_ADDR], ax
|
|
|
|
|
cmpsi2.S: Use function start and end macros.
* config/rl78/cmpsi2.S: Use function start and end macros.
(__gcc_bcmp): New function.
* config/rl78/lshrsi3.S: Use function start and end macros.
* config/rl78/mulsi3.S: Add support for G10.
(__mulqi3): New function for G10.
* config/rl78/signbit.S: Use function start and end macros.
* config/rl78/t-rl78 (LIB2ADD): Add bit-count.S, fpbit-sf.S and
fpmath-sf.S.
(LIB2FUNCS_EXCLUDE): Define.
(LIB2FUNCS_ST): Define.
* config/rl78/trampoline.S: Use function start and end macros.
* config/rl78/vregs.h (START_FUNC): New macro.
(START_ANOTHER_FUNC): New macro.
(END_FUNC): New macro.
(END_ANOTHER_FUNC): New macro.
* config/rl78/bit-count.S: New file. Contains assembler
implementations of the bit counting functions: ___clzhi2,
__clzsi2, ctzhi2, ctzsi2, ffshi2, ffssi2, __partityhi2,
__paritysi2, __popcounthi2 and __popcountsi2.
* config/rl78/fpbit-sf.S: New file. Contains assembler
implementationas of the math functions: __negsf2, __cmpsf2,
__eqsf2, __nesf2, __lesf2, __ltsf2, __gesf2, gtsf2, __unordsf2,
__fixsfsi, __fixunssfsi, __floatsisf and __floatunssisf.
* config/rl78/fpmath-sf.S: New file. Contains assembler
implementations of the math functions: __subsf3, __addsf3,
__mulsf3 and __divsf3
From-SVN: r220162
2015-01-27 12:36:01 +01:00
|
|
|
2: movw ax, hl
|
2011-11-29 22:36:43 +01:00
|
|
|
addw ax, #TO_SIZE
|
|
|
|
movw hl, ax
|
|
|
|
cmpw ax, #trampoline_array_end
|
|
|
|
bnz $1b
|
|
|
|
|
|
|
|
ret
|
cmpsi2.S: Use function start and end macros.
* config/rl78/cmpsi2.S: Use function start and end macros.
(__gcc_bcmp): New function.
* config/rl78/lshrsi3.S: Use function start and end macros.
* config/rl78/mulsi3.S: Add support for G10.
(__mulqi3): New function for G10.
* config/rl78/signbit.S: Use function start and end macros.
* config/rl78/t-rl78 (LIB2ADD): Add bit-count.S, fpbit-sf.S and
fpmath-sf.S.
(LIB2FUNCS_EXCLUDE): Define.
(LIB2FUNCS_ST): Define.
* config/rl78/trampoline.S: Use function start and end macros.
* config/rl78/vregs.h (START_FUNC): New macro.
(START_ANOTHER_FUNC): New macro.
(END_FUNC): New macro.
(END_ANOTHER_FUNC): New macro.
* config/rl78/bit-count.S: New file. Contains assembler
implementations of the bit counting functions: ___clzhi2,
__clzsi2, ctzhi2, ctzsi2, ffshi2, ffssi2, __partityhi2,
__paritysi2, __popcounthi2 and __popcountsi2.
* config/rl78/fpbit-sf.S: New file. Contains assembler
implementationas of the math functions: __negsf2, __cmpsf2,
__eqsf2, __nesf2, __lesf2, __ltsf2, __gesf2, gtsf2, __unordsf2,
__fixsfsi, __fixunssfsi, __floatsisf and __floatunssisf.
* config/rl78/fpmath-sf.S: New file. Contains assembler
implementations of the math functions: __subsf3, __addsf3,
__mulsf3 and __divsf3
From-SVN: r220162
2015-01-27 12:36:01 +01:00
|
|
|
END_FUNC ___trampoline_uninit
|