Commit 8410904a by Nick Clifton Committed by Nick Clifton

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
parent 506f03c3
2015-01-27 Nick Clifton <nickc@redhat.com>
* 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
2015-01-27 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* config.host (i[34567]86-*-solaris2*, x86_64-*-solaris2.1[0-9]*):
......
; Copyright (C) 2012-2014 Free Software Foundation, Inc.
; Contributed by Red Hat.
;
; This file 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.
;
; This file 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/>.
#include "vregs.h"
START_FUNC ___clzhi2
;; Argument is in [SP+4], return in R8.
movw ax, [SP+4]
.global __clzhi2_internal
__clzhi2_internal:
movw r8, #16
cmpw ax, #0
bz $clzhi2_is_zero
mov e, #0xff
1:
inc e
shlw ax, 1
bnc $1b
mov a, e
mov r8, a
clzhi2_is_zero:
ret
END_FUNC ___clzhi2
START_FUNC ___clzsi2
;; Argument is in [SP+6]:[SP+4], return in R8.
movw ax, [SP+6]
cmpw ax, #0
bnz $__clzhi2_internal
movw ax, [SP+4]
call !__clzhi2_internal
movw ax, r8
addw ax, #16
movw r8, ax
ret
END_FUNC ___clzsi2
START_FUNC ___ctzhi2
;; Argument is in [SP+4], return in R8.
movw ax, [SP+4]
.global __ctzhi2_internal
__ctzhi2_internal:
movw r8, #16
cmpw ax, #0
bz $ctzhi2_is_zero
mov e, #0xff
1:
inc e
shrw ax, 1
bnc $1b
mov a, e
mov r8, a
ctzhi2_is_zero:
ret
END_FUNC ___ctzhi2
START_FUNC ___ctzsi2
;; Argument is in [SP+6]:[SP+4], return in R8.
movw ax, [SP+4]
cmpw ax, #0
bnz $__ctzhi2_internal
movw ax, [SP+6]
call !__ctzhi2_internal
movw ax, r8
addw ax, #16
movw r8, ax
ret
END_FUNC ___ctzsi2
START_FUNC ___ffshi2
;; Argument is in [SP+4], return in R8.
movw ax, [SP+4]
.global __ffshi2_internal
__ffshi2_internal:
movw r8, #0
cmpw ax, #0
bz $ffshi2_is_zero
mov e, #0
1:
inc e
shrw ax, 1
bnc $1b
mov a, e
mov r8, a
ffshi2_is_zero:
ret
END_FUNC ___ffshi2
START_FUNC ___ffssi2
;; Argument is in [SP+6]:[SP+4], return in R8.
movw ax, [SP+4]
cmpw ax, #0
bnz $__ffshi2_internal
movw ax, [SP+6]
cmpw ax, #0
bz $1f
call !__ffshi2_internal
movw ax, r8
addw ax, #16
1:
movw r8, ax
ret
END_FUNC ___ffssi2
START_FUNC ___parityqi_internal
mov1 cy, a.0
xor1 cy, a.1
xor1 cy, a.2
xor1 cy, a.3
xor1 cy, a.4
xor1 cy, a.5
xor1 cy, a.6
xor1 cy, a.7
movw ax, #0
bnc $1f
incw ax
1:
movw r8, ax
ret
END_FUNC ___parityqi_internal
START_FUNC ___parityhi2
;; Argument is in [SP+4], return in R8.
movw ax, [SP+4]
xor a, x
br $___parityqi_internal
END_FUNC ___parityhi2
START_FUNC ___paritysi2
;; Argument is in [SP+6]:[SP+4], return in R8.
movw ax, [SP+4]
xor a, x
mov b, a
movw ax, [SP+6]
xor a, x
xor a, b
br $___parityqi_internal
END_FUNC ___paritysi2
START_FUNC ___popcounthi2
;; Argument is in [SP+4], return in R8.
mov d, #2
br $___popcountqi_internal
END_FUNC ___popcounthi2
START_FUNC ___popcountsi2
;; Argument is in [SP+6]:[SP+4], return in R8.
mov d, #4
br $___popcountqi_internal
END_FUNC ___popcountsi2
START_FUNC ___popcountqi_internal
;; There are D bytes starting at [HL]
;; store count in R8.
movw ax, sp
addw ax, #4
movw hl, ax
mov a, #0
1:
xch a, b
mov a, [hl]
xch a, b
mov e, #8
2:
shl b,1
addc a, #0
dec e
bnz $2b
incw hl
dec d
bnz $1b
mov x, a
mov a, #0
movw r8, ax
ret
END_FUNC ___popcountqi_internal
......@@ -31,9 +31,8 @@
;; If A is less than B it returns 0. If A is greater
;; than B it returns 2. If they are equal it returns 1.
.global ___cmpsi2
.type ___cmpsi2, @function
___cmpsi2:
START_FUNC ___cmpsi2
;; A is at [sp+4]
;; B is at [sp+8]
;; Result put in R8
......@@ -88,18 +87,18 @@ ___cmpsi2:
movw r8, ax
ret
.size ___cmpsi2, . - ___cmpsi2
END_FUNC ___cmpsi2
;; ------------------------------------------------------
;; int __ucmpsi2 (unsigned long A, unsigned long B)
;;
;; Performs an unsigned comparison of A and B.
;; If A is less than B it returns 0. If A is greater
;; than B it returns 2. If they are equal it returns 1.
.global ___ucmpsi2
.type ___ucmpsi2, @function
___ucmpsi2:
START_FUNC ___ucmpsi2
;; A is at [sp+4]
;; B is at [sp+8]
;; Result put in R8..R9
......@@ -117,5 +116,57 @@ ___ucmpsi2:
br !!.Lless_than_or_greater_than
br !!.Lcompare_bottom_words
.size ___ucmpsi2, . - ___ucmpsi2
\ No newline at end of file
END_FUNC ___ucmpsi2
;; ------------------------------------------------------
;; signed int __gcc_bcmp (const unsigned char *s1, const unsigned char *s2, size_t size)
;; Result is negative if S1 is less than S2,
;; positive if S1 is greater, 0 if S1 and S2 are equal.
START_FUNC __gcc_bcmp
;; S1 is at [sp+4]
;; S2 is at [sp+6]
;; SIZE is at [sp+8]
;; Result in r8/r9
movw r10, #0
1:
;; Compare R10 against the SIZE parameter
movw ax, [sp+8]
subw ax, r10
sknz
br !!1f
;; Load S2[r10] into R8
movw ax, [sp+6]
addw ax, r10
movw hl, ax
mov a, [hl]
mov r8, a
;; Load S1[r10] into A
movw ax, [sp+4]
addw ax, r10
movw hl, ax
mov a, [hl]
;; Increment offset
incw r10
;; Compare loaded bytes
cmp a, r8
sknz
br !!1b
;; They differ. Subtract *S2 from *S1 and return as the result.
mov x, a
mov a, #0
mov r9, #0
subw ax, r8
1:
movw r8, ax
ret
END_FUNC __gcc_bcmp
......@@ -22,11 +22,7 @@
#include "vregs.h"
.text
.global ___lshrsi3
.type ___lshrsi3, @function
___lshrsi3:
START_FUNC ___lshrsi3
;; input:
;;
;; [zero]
......@@ -46,7 +42,6 @@ ___lshrsi3:
;; B - count
mov a, [sp+8] ; A now contains the count
cmp a, #0x20
bc $.Lcount_is_normal
......@@ -113,4 +108,4 @@ ___lshrsi3:
br $.Lloop_top
.size ___lshrsi3, .-___lshrsi3
END_FUNC ___lshrsi3
......@@ -33,6 +33,18 @@
; DE count (resL-tmp)
; HL [sp+4]
; Register use (G10):
;
; AX op2L
; BC op2H
; DE count
; HL [sp+4]
; r8/r9 res32L
; r10/r11 (resH)
; r12/r13 (resL-tmp)
; r16/r17 res32H
; r18/r19 op1
START_FUNC ___mulsi3
;; A is at [sp+4]
;; B is at [sp+8]
......@@ -159,7 +171,7 @@ START_FUNC ___mulsi3
sknc
incw ax
addw ax, r_2
.Lmul_hisi_no_add:
.Lmul_hisi_no_add:
sel rb1
shlw bc, 1
sel rb0
......@@ -267,3 +279,45 @@ START_FUNC ___mulhi3
.Lmul_hi_done:
ret
END_FUNC ___mulhi3
;;; --------------------------------------
#ifdef __RL78_G10__
START_FUNC ___mulqi3
mov a, [sp+4]
mov r9, a
mov a, [sp+6]
mov r10, a
mov a, #9
mov r11, a
clrb a
mov r8, a
.L2:
cmp0 r10
skz
dec r11
sknz
ret
mov a, r10
and a, #1
mov r12, a
cmp0 r12
sknz
br !!.L3
mov a, r9
mov l, a
mov a, r8
add a, l
mov r8, a
.L3:
mov a, r9
add a, a
mov r9, a
mov a, r10
shr a, 1
mov r10, a
br !!.L2
END_FUNC ___mulqi3
#endif
......@@ -37,11 +37,9 @@
.text
.global _signbit
_signbit:
.global _signbitf
_signbitf:
;; X is at [sp+4]
START_FUNC _signbit
START_ANOTHER_FUNC _signbitf
;; X is at [sp+4]..[SP+7]
;; result is in R8..R9
movw r8, #0
......@@ -50,12 +48,12 @@ _signbitf:
sknc
movw r8, #1
ret
.size _signbit, . - _signbit
.size _signbitf, . - _signbitf
END_ANOTHER_FUNC _signbitf
END_FUNC _signbit
.global _signbitl
_signbitl:
;; X is at [sp+4]
START_FUNC _signbitl
;; X is at [sp+4]..[SP+7]
;; result is in R8..R9
movw r8, #0
......@@ -64,4 +62,4 @@ _signbitl:
sknc
movw r8, #1
ret
.size _signbitl, . - _signbitl
END_FUNC _signbitl
......@@ -20,8 +20,6 @@
LIB2ADD = \
$(srcdir)/config/rl78/trampoline.S \
$(srcdir)/config/rl78/lib2div.c \
$(srcdir)/config/rl78/lib2mul.c \
$(srcdir)/config/rl78/lib2shift.c \
$(srcdir)/config/rl78/lshrsi3.S \
$(srcdir)/config/rl78/mulsi3.S \
......@@ -29,6 +27,22 @@ LIB2ADD = \
$(srcdir)/config/rl78/divmodhi.S \
$(srcdir)/config/rl78/divmodqi.S \
$(srcdir)/config/rl78/signbit.S \
$(srcdir)/config/rl78/bit-count.S \
$(srcdir)/config/rl78/fpbit-sf.S \
$(srcdir)/config/rl78/fpmath-sf.S \
$(srcdir)/config/rl78/cmpsi2.S
LIB2FUNCS_EXCLUDE = _clzhi2 _clzsi2 _ctzhi2 _ctzsi2 \
_popcounthi2 _popcountsi2 \
_parityhi2 _paritysi2 _ffssi2 _ffshi2 \
_negate_sf _compare_sf _eq_sf _ne_sf _gt_sf _ge_sf \
_lt_sf _le_sf _unord_sf \
_si_to_sf _usi_to_sf \
_sf_to_si _sf_to_usi \
_fixunssfsi _fixsfsi \
_addsub_sf _mul_sf _div_sf
# Remove __gcc_bcmp from LIB2FUNCS_ST
LIB2FUNCS_ST = _eprintf
HOST_LIBGCC2_CFLAGS += -Os -ffunction-sections -fdata-sections
......@@ -80,14 +80,10 @@ trampoline_array_end:
pointer in R10, allocate a trampoline and return its address in
R8. */
.text
.global ___trampoline_init
.type ___trampoline_init, @function
___trampoline_init:
START_FUNC ___trampoline_init
movw hl, #trampoline_array
1:
movw ax, [hl + TO_ADDR]
1: movw ax, [hl + TO_ADDR]
cmpw ax, #0
bz $2f
......@@ -107,30 +103,27 @@ ___trampoline_init:
movw ax, [hl + TO_STUB]
movw r8, ax
ret
.size ___trampoline_init, . - ___trampoline_init
END_FUNC ___trampoline_init
.global ___trampoline_uninit
.type ___trampoline_uninit, @function
___trampoline_uninit:
START_FUNC ___trampoline_uninit
movw hl, #trampoline_array
movw ax, sp
movw bc, ax
1:
movw ax, [hl + TO_FRAME]
1: movw ax, [hl + TO_FRAME]
cmpw ax, bc
bc $2f
clrw ax
movw [hl + TO_ADDR], ax
2:
movw ax, hl
2: movw ax, hl
addw ax, #TO_SIZE
movw hl, ax
cmpw ax, #trampoline_array_end
bnz $1b
ret
.size ___trampoline_uninit, . - ___trampoline_uninit
END_FUNC ___trampoline_uninit
......@@ -55,17 +55,25 @@ r23 = 0xffeef
#endif
.macro START_ANOTHER_FUNC name
.global \name
.type \name , @function
\name:
.endm
/* Start a function in its own section, so that it
can be subject to linker garbage collection. */
.macro START_FUNC name
.pushsection .text.\name,"ax",@progbits
.global \name
.type \name , @function
\name:
START_ANOTHER_FUNC \name
.endm
.macro END_ANOTHER_FUNC name
.size \name , . - \name
.endm
/* End the function. Set the size. */
.macro END_FUNC name
.size \name , . - \name
END_ANOTHER_FUNC \name
.popsection
.endm
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment