Commit 084de18d by Stephane Carrez

t-m68hc11-gas (LIB1ASMFUNCS): Build __far_trampoline.

	* config/m68hc11/t-m68hc11-gas (LIB1ASMFUNCS): Build __far_trampoline.
	(MULTILIB_OPTIONS): Must also generate for -mlong-calls.

	* config/m68hc11/larith.asm: Put a mode for ELF ABI flags.
	(ret, declare, farsym): New gas macros.
	(__premain, exit, abort, _cleanup, memcpy, memset, ___adddi3,
	___subdi3, ___notdi2, __mulhi32, __mulsi3): Use them to use 'rtc'
	and declare the symbol far when compiled with -mlong-calls.
	(__far_trampoline): New for 68HC12 trampoline code to invoke a
	far handler using jsr/bsr.

	* config/m68hc11/m68hc11-crt0.S: Put a mode for ELF ABI flags.
	(jsr): New macro to transform a 'jsr' into a 'call'.

From-SVN: r56282
parent f8a3bda2
...@@ -35,23 +35,63 @@ Boston, MA 02111-1307, USA. */ ...@@ -35,23 +35,63 @@ Boston, MA 02111-1307, USA. */
.file "larith.asm" .file "larith.asm"
#ifdef __HAVE_SHORT_INT__
.mode mshort
#else
.mode mlong
#endif
#if defined(__USE_RTC__) && defined(mc68hc12)
# define ARG(N) N+1
.macro ret
rtc
.endm
.macro declare name
.globl \name
.type \name,@function
.size \name,.Lend-\name
.far \name
\name:
.endm
.macro farsym name
.far NAME
.endm
#else
# define ARG(N) N
.macro ret
rts
.endm
.macro farsym name
.endm
.macro declare name
.globl \name
.type \name,@function
.size \name,.Lend-\name
\name:
.endm
#endif
.sect .text .sect .text
#define REG(NAME) \ #define REG(NAME) \
NAME: .word 0; \ NAME: .dc.w 1; \
.type NAME,@object ; \ .type NAME,@object ; \
.size NAME,2 .size NAME,2
#ifdef L_regs_min #ifdef L_regs_min
/* Pseudo hard registers used by gcc. /* Pseudo hard registers used by gcc.
They must be located in page0. They should be located in page0. */
They will normally appear at the end of .page0 section. */
#ifdef mc68hc12 .sect .softregs
.sect .bss
#else
.sect .page0
#endif
.globl _.tmp .globl _.tmp
.globl _.z,_.xy .globl _.z,_.xy
REG(_.tmp) REG(_.tmp)
...@@ -61,54 +101,34 @@ REG(_.xy) ...@@ -61,54 +101,34 @@ REG(_.xy)
#endif #endif
#ifdef L_regs_frame #ifdef L_regs_frame
#ifdef mc68hc12 .sect .softregs
.sect .bss
#else
.sect .page0
#endif
.globl _.frame .globl _.frame
REG(_.frame) REG(_.frame)
#endif #endif
#ifdef L_regs_d1_2 #ifdef L_regs_d1_2
#ifdef mc68hc12 .sect .softregs
.sect .bss
#else
.sect .page0
#endif
.globl _.d1,_.d2 .globl _.d1,_.d2
REG(_.d1) REG(_.d1)
REG(_.d2) REG(_.d2)
#endif #endif
#ifdef L_regs_d3_4 #ifdef L_regs_d3_4
#ifdef mc68hc12 .sect .softregs
.sect .bss
#else
.sect .page0
#endif
.globl _.d3,_.d4 .globl _.d3,_.d4
REG(_.d3) REG(_.d3)
REG(_.d4) REG(_.d4)
#endif #endif
#ifdef L_regs_d5_6 #ifdef L_regs_d5_6
#ifdef mc68hc12 .sect .softregs
.sect .bss
#else
.sect .page0
#endif
.globl _.d5,_.d6 .globl _.d5,_.d6
REG(_.d5) REG(_.d5)
REG(_.d6) REG(_.d6)
#endif #endif
#ifdef L_regs_d7_8 #ifdef L_regs_d7_8
#ifdef mc68hc12 .sect .softregs
.sect .bss
#else
.sect .page0
#endif
.globl _.d7,_.d8 .globl _.d7,_.d8
REG(_.d7) REG(_.d7)
REG(_.d8) REG(_.d8)
...@@ -116,9 +136,8 @@ REG(_.d8) ...@@ -116,9 +136,8 @@ REG(_.d8)
#ifdef L_regs_d9_16 #ifdef L_regs_d9_16
/* Pseudo hard registers used by gcc. /* Pseudo hard registers used by gcc.
They must be located in page0. They should be located in page0. */
They will normally appear at the end of .page0 section. */ .sect .softregs
.sect .page0
.globl _.d9,_.d10,_.d11,_.d12,_.d13,_.d14 .globl _.d9,_.d10,_.d11,_.d12,_.d13,_.d14
.globl _.d15,_.d16 .globl _.d15,_.d16
REG(_.d9) REG(_.d9)
...@@ -134,13 +153,8 @@ REG(_.d16) ...@@ -134,13 +153,8 @@ REG(_.d16)
#ifdef L_regs_d17_32 #ifdef L_regs_d17_32
/* Pseudo hard registers used by gcc. /* Pseudo hard registers used by gcc.
They must be located in page0. They should be located in page0. */
They will normally appear at the end of .page0 section. */ .sect .softregs
#ifdef mc68hc12
.sect .bss
#else
.sect .page0
#endif
.globl _.d17,_.d18,_.d19,_.d20,_.d21,_.d22 .globl _.d17,_.d18,_.d19,_.d20,_.d21,_.d22
.globl _.d23,_.d24,_.d25,_.d26,_.d27,_.d28 .globl _.d23,_.d24,_.d25,_.d26,_.d27,_.d28
.globl _.d29,_.d30,_.d31,_.d32 .globl _.d29,_.d30,_.d31,_.d32
...@@ -167,12 +181,10 @@ REG(_.d32) ...@@ -167,12 +181,10 @@ REG(_.d32)
;; Specific initialization for 68hc11 before the main. ;; Specific initialization for 68hc11 before the main.
;; Nothing special for a generic routine; Just enable interrupts. ;; Nothing special for a generic routine; Just enable interrupts.
;; ;;
.sect .text declare __premain
.globl __premain
__premain:
clra clra
tap ; Clear both I and X. tap ; Clear both I and X.
rts ret
#endif #endif
#ifdef L__exit #ifdef L__exit
...@@ -195,6 +207,8 @@ __premain: ...@@ -195,6 +207,8 @@ __premain:
.globl _exit .globl _exit
.globl exit .globl exit
.weak exit .weak exit
farsym exit
farsym _exit
exit: exit:
_exit: _exit:
...@@ -209,9 +223,8 @@ fatal: ...@@ -209,9 +223,8 @@ fatal:
;; ;;
;; Abort operation. This is defined for the GCC testsuite. ;; Abort operation. This is defined for the GCC testsuite.
;; ;;
.sect .text declare abort
.globl abort
abort:
ldd #255 ; ldd #255 ;
#ifdef mc68hc12 #ifdef mc68hc12
trap #0x30 trap #0x30
...@@ -226,20 +239,19 @@ abort: ...@@ -226,20 +239,19 @@ abort:
;; ;;
;; Cleanup operation used by exit(). ;; Cleanup operation used by exit().
;; ;;
.sect .text declare _cleanup
.globl _cleanup
_cleanup: ret
rts
#endif #endif
;----------------------------------------- ;-----------------------------------------
; required gcclib code ; required gcclib code
;----------------------------------------- ;-----------------------------------------
#ifdef L_memcpy #ifdef L_memcpy
.sect .text declare memcpy
declare __memcpy
.weak memcpy .weak memcpy
.globl memcpy
.globl __memcpy
;;; ;;;
;;; void* memcpy(void*, const void*, size_t) ;;; void* memcpy(void*, const void*, size_t)
;;; ;;;
...@@ -247,11 +259,9 @@ _cleanup: ...@@ -247,11 +259,9 @@ _cleanup:
;;; 2,sp = src Pmode ;;; 2,sp = src Pmode
;;; 4,sp = size HImode (size_t) ;;; 4,sp = size HImode (size_t)
;;; ;;;
__memcpy:
memcpy:
#ifdef mc68hc12 #ifdef mc68hc12
ldx 2,sp ldx ARG(2),sp
ldy 4,sp ldy ARG(4),sp
pshd pshd
xgdy xgdy
lsrd lsrd
...@@ -264,7 +274,7 @@ Loop: ...@@ -264,7 +274,7 @@ Loop:
dbne d,Loop dbne d,Loop
Done: Done:
puld puld
rts ret
#else #else
xgdy xgdy
tsx tsx
...@@ -294,9 +304,8 @@ End: ...@@ -294,9 +304,8 @@ End:
#endif #endif
#ifdef L_memset #ifdef L_memset
.sect .text declare memset
.globl memset declare __memset
.globl __memset
;;; ;;;
;;; void* memset(void*, int value, size_t) ;;; void* memset(void*, int value, size_t)
;;; ;;;
...@@ -304,17 +313,15 @@ End: ...@@ -304,17 +313,15 @@ End:
;;; D = dst Pmode ;;; D = dst Pmode
;;; 2,sp = src SImode ;;; 2,sp = src SImode
;;; 6,sp = size HImode (size_t) ;;; 6,sp = size HImode (size_t)
val = 5 val = ARG(5)
size = 6 size = ARG(6)
#else #else
;;; D = dst Pmode ;;; D = dst Pmode
;;; 2,sp = src SImode ;;; 2,sp = src SImode
;;; 6,sp = size HImode (size_t) ;;; 6,sp = size HImode (size_t)
val = 3 val = ARG(3)
size = 4 size = ARG(4)
#endif #endif
__memset:
memset:
#ifdef mc68hc12 #ifdef mc68hc12
xgdx xgdx
ldab val,sp ldab val,sp
...@@ -326,7 +333,7 @@ Loop: ...@@ -326,7 +333,7 @@ Loop:
dbne y,Loop dbne y,Loop
End: End:
puld puld
rts ret
#else #else
xgdx xgdx
tsy tsy
...@@ -345,95 +352,89 @@ End: ...@@ -345,95 +352,89 @@ End:
rts rts
#endif #endif
#endif #endif
#ifdef L_adddi3 #ifdef L_adddi3
.sect .text declare ___adddi3
.globl ___adddi3
___adddi3:
tsx tsx
xgdy xgdy
ldd 8,x ; Add LSB ldd ARG(8),x ; Add LSB
addd 16,x addd ARG(16),x
std 6,y ; Save (carry preserved) std ARG(6),y ; Save (carry preserved)
ldd 6,x ldd ARG(6),x
adcb 15,x adcb ARG(15),x
adca 14,x adca ARG(14),x
std 4,y std ARG(4),y
ldd 4,x ldd ARG(4),x
adcb 13,x adcb ARG(13),x
adca 12,x adca ARG(12),x
std 2,y std ARG(2),y
ldd 2,x ldd ARG(2),x
adcb 11,x ; Add MSB adcb ARG(11),x ; Add MSB
adca 10,x adca ARG(10),x
std 0,y std ARG(0),y
xgdy xgdy
rts ret
#endif #endif
#ifdef L_subdi3 #ifdef L_subdi3
.sect .text declare ___subdi3
.globl ___subdi3
___subdi3:
tsx tsx
xgdy xgdy
ldd 8,x ; Subtract LSB ldd ARG(8),x ; Subtract LSB
subd 16,x subd ARG(16),x
std 6,y ; Save, borrow preserved std ARG(6),y ; Save, borrow preserved
ldd 6,x ldd ARG(6),x
sbcb 15,x sbcb ARG(15),x
sbca 14,x sbca ARG(14),x
std 4,y std ARG(4),y
ldd 4,x ldd ARG(4),x
sbcb 13,x sbcb ARG(13),x
sbca 12,x sbca ARG(12),x
std 2,y std ARG(2),y
ldd 2,x ; Subtract MSB ldd ARG(2),x ; Subtract MSB
sbcb 11,x sbcb ARG(11),x
sbca 10,x sbca ARG(10),x
std 0,y std ARG(0),y
xgdy ; xgdy ;
rts ret
#endif #endif
#ifdef L_notdi2 #ifdef L_notdi2
.sect .text declare ___notdi2
.globl ___notdi2
___notdi2:
tsy tsy
xgdx xgdx
ldd 8,y ldd ARG(8),y
coma coma
comb comb
std 6,x std ARG(6),x
ldd 6,y ldd ARG(6),y
coma coma
comb comb
std 4,x std ARG(4),x
ldd 4,y ldd ARG(4),y
coma coma
comb comb
std 2,x std ARG(2),x
ldd 2,y ldd ARG(2),y
coma coma
comb comb
std 0,x std ARG(0),x
xgdx xgdx
rts ret
#endif #endif
#ifdef L_negsi2 #ifdef L_negsi2
...@@ -845,8 +846,6 @@ ___mulhi3: ...@@ -845,8 +846,6 @@ ___mulhi3:
#endif #endif
#ifdef L_mulhi32 #ifdef L_mulhi32
.sect .text
.globl __mulhi32
; ;
; ;
...@@ -880,12 +879,13 @@ ___mulhi3: ...@@ -880,12 +879,13 @@ ___mulhi3:
; <A-low> 1,x ; <A-low> 1,x
; <A-high> 0,x ; <A-high> 0,x
; ;
__mulhi32: declare __mulhi32
#ifdef mc68hc12 #ifdef mc68hc12
ldy 2,sp ldy ARG(2),sp
emul emul
exg x,y exg x,y
rts ret
#else #else
pshx ; Room for temp value pshx ; Room for temp value
pshb pshb
...@@ -925,8 +925,6 @@ Ret: ...@@ -925,8 +925,6 @@ Ret:
#endif #endif
#ifdef L_mulsi3 #ifdef L_mulsi3
.sect .text
.globl __mulsi3
; ;
; <B-low> 8,y ; <B-low> 8,y
...@@ -945,22 +943,23 @@ Ret: ...@@ -945,22 +943,23 @@ Ret:
; ;
; ;
__mulsi3: declare __mulsi3
#ifdef mc68hc12 #ifdef mc68hc12
pshd ; Save A.low pshd ; Save A.low
ldy 4,sp ldy ARG(4),sp
emul ; A.low * B.high emul ; A.low * B.high
ldy 6,sp ldy ARG(6),sp
exg x,d exg x,d
emul ; A.high * B.low emul ; A.high * B.low
leax d,x leax d,x
ldy 6,sp ldy ARG(6),sp
puld puld
emul ; A.low * B.low emul ; A.low * B.low
exg d,y exg d,y
leax d,x leax d,x
exg d,y exg d,y
rts ret
#else #else
B_low = 8 B_low = 8
B_high = 6 B_high = 6
...@@ -1186,6 +1185,39 @@ dtors_done: ...@@ -1186,6 +1185,39 @@ dtors_done:
#endif #endif
#ifdef L_far_tramp
#ifdef mc68hc12
.sect .text
.globl __far_trampoline
;; This is a trampoline used by the linker to invoke a function
;; using rtc to return and being called with jsr/bsr.
;; The trampoline generated is:
;;
;; foo_tramp:
;; ldy #foo
;; call __far_trampoline,page(foo)
;;
;; The linker transforms:
;;
;; jsr foo
;;
;; into
;; jsr foo_tramp
;;
;; The linker generated trampoline and _far_trampoline must be in
;; non-banked memory.
;;
__far_trampoline:
movb 0,sp, 2,sp ; Copy page register below the caller's return
leas 2,sp ; address.
jmp 0,y ; We have a 'call/rtc' stack layout now
; and can jump to the far handler
; (whose memory bank is mapped due to the
; call to the trampoline).
#endif
#endif
.Lend:
;----------------------------------------- ;-----------------------------------------
; end required gcclib code ; end required gcclib code
;----------------------------------------- ;-----------------------------------------
/* Startup code for M68HC11. /* Startup code for M68HC11.
Copyright (C) 1999, 2000 Free Software Foundation, Inc. Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
This file is free software; you can redistribute it and/or modify it 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 under the terms of the GNU General Public License as published by the
...@@ -36,6 +36,17 @@ Boston, MA 02111-1307, USA. */ ...@@ -36,6 +36,17 @@ Boston, MA 02111-1307, USA. */
;----------------------------------------- ;-----------------------------------------
.file "crt0.s" .file "crt0.s"
#ifdef __HAVE_SHORT_INT__
.mode mshort
#else
.mode mlong
#endif
#if defined(__USE_RTC__) && defined(mc68hc12)
.macro jsr name
call \name
.endm
#endif
;; ;;
;; ;;
;; The linker concatenate the .install* sections in the following order: ;; The linker concatenate the .install* sections in the following order:
......
...@@ -25,7 +25,7 @@ LIB1ASMFUNCS = _mulsi3 \ ...@@ -25,7 +25,7 @@ LIB1ASMFUNCS = _mulsi3 \
_premain __exit _abort _cleanup \ _premain __exit _abort _cleanup \
_adddi3 _subdi3 _notdi2 \ _adddi3 _subdi3 _notdi2 \
_ashrhi3 _lshrhi3 _lshlhi3 _ashrqi3 _lshlqi3 _map_data _init_bss \ _ashrhi3 _lshrhi3 _lshlhi3 _ashrqi3 _lshlqi3 _map_data _init_bss \
_ctor _dtor _ctor _dtor __far_trampoline
TARGET_LIBGCC2_CFLAGS = -DUSE_GAS -DIN_GCC TARGET_LIBGCC2_CFLAGS = -DUSE_GAS -DIN_GCC
...@@ -37,10 +37,10 @@ LIB2FUNCS_EXTRA = $(srcdir)/config/udivmodsi4.c \ ...@@ -37,10 +37,10 @@ LIB2FUNCS_EXTRA = $(srcdir)/config/udivmodsi4.c \
LIBGCC2_DEBUG_CFLAGS = LIBGCC2_DEBUG_CFLAGS =
LIBGCC2_CFLAGS = -Os $(LIBGCC2_INCLUDES) $(TARGET_LIBGCC2_CFLAGS) $(LIBGCC2_DEBUG_CFLAGS) $(GTHREAD_FLAGS) -DIN_LIBGCC2 LIBGCC2_CFLAGS = -Os $(LIBGCC2_INCLUDES) $(TARGET_LIBGCC2_CFLAGS) $(LIBGCC2_DEBUG_CFLAGS) $(GTHREAD_FLAGS) -DIN_LIBGCC2
MULTILIB_OPTIONS = m68hc11/m68hc12 mshort fshort-double MULTILIB_OPTIONS = m68hc11/m68hc12 mshort fshort-double mlong-calls
MULTILIB_DIRNAMES = MULTILIB_DIRNAMES =
MULTILIB_MATCHES = m68hc11=m6811 m68hc12=m6812 MULTILIB_MATCHES = m68hc11=m6811 m68hc12=m6812
MULTILIB_EXCEPTIONS = -mnoshort -mno68hc11 MULTILIB_EXCEPTIONS = -mnoshort -mno68hc11 -mnolong-calls
LIBGCC = stmp-multilib LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib INSTALL_LIBGCC = install-multilib
......
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