Commit 1d2d9def by Stephane Carrez Committed by Stephane Carrez

larith.asm (___adddi3): Optimize saving of result.

	* config/m68hc11/larith.asm (___adddi3): Optimize saving of result.
	(___subdi3): Likewise.
	(__mulsi3, __mulhi32): Avoid using _.tmp scratch location.
	(__map_data_section): Optimize 68hc11 case.

From-SVN: r50835
parent a0ccf503
2002-03-15 Stephane Carrez <Stephane.Carrez@worldnet.fr> 2002-03-15 Stephane Carrez <Stephane.Carrez@worldnet.fr>
* config/m68hc11/larith.asm (___adddi3): Optimize saving of result.
(___subdi3): Likewise.
(__mulsi3, __mulhi32): Avoid using _.tmp scratch location.
(__map_data_section): Optimize 68hc11 case.
2002-03-15 Stephane Carrez <Stephane.Carrez@worldnet.fr>
* config/m68hc11/m68hc11.c (m6812_cost): Make cost of add higher * config/m68hc11/m68hc11.c (m6812_cost): Make cost of add higher
than a shift to avoid adding a register with itself. than a shift to avoid adding a register with itself.
(m68hc11_memory_move_cost): Take into account NO_REGS. (m68hc11_memory_move_cost): Take into account NO_REGS.
......
/* libgcc routines for M68HC11 & M68HC12. /* libgcc routines for M68HC11 & M68HC12.
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU CC. This file is part of GNU CC.
...@@ -352,39 +352,27 @@ End: ...@@ -352,39 +352,27 @@ End:
___adddi3: ___adddi3:
tsx tsx
pshb xgdy
psha ldd 8,x ; Add LSB
ldd 8,x
addd 16,x addd 16,x
pshb std 6,y ; Save (carry preserved)
psha
ldd 6,x ldd 6,x
adcb 15,x adcb 15,x
adca 14,x adca 14,x
pshb std 4,y
psha
ldd 4,x ldd 4,x
adcb 13,x adcb 13,x
adca 12,x adca 12,x
pshb std 2,y
psha
ldd 2,x ldd 2,x
adcb 11,x adcb 11,x ; Add MSB
adca 10,x adca 10,x
tsx
ldy 6,x
std 0,y std 0,y
pulx
stx 2,y xgdy
pulx
stx 4,y
pulx
stx 6,y
pulx
rts rts
#endif #endif
...@@ -394,40 +382,27 @@ ___adddi3: ...@@ -394,40 +382,27 @@ ___adddi3:
___subdi3: ___subdi3:
tsx tsx
pshb xgdy
psha ldd 8,x ; Subtract LSB
ldd 8,x
subd 16,x subd 16,x
pshb std 6,y ; Save, borrow preserved
psha
ldd 6,x ldd 6,x
sbcb 15,x sbcb 15,x
sbca 14,x sbca 14,x
pshb std 4,y
psha
ldd 4,x ldd 4,x
sbcb 13,x sbcb 13,x
sbca 12,x sbca 12,x
pshb std 2,y
psha
ldd 2,x ldd 2,x ; Subtract MSB
sbcb 11,x sbcb 11,x
sbca 10,x sbca 10,x
tsx
ldy 6,x
std 0,y std 0,y
pulx
stx 2,y xgdy ;
pulx
stx 4,y
pulx
stx 6,y
pulx
rts rts
#endif #endif
...@@ -457,6 +432,7 @@ ___notdi2: ...@@ -457,6 +432,7 @@ ___notdi2:
coma coma
comb comb
std 0,x std 0,x
xgdx
rts rts
#endif #endif
...@@ -798,24 +774,73 @@ ___mulhi3: ...@@ -798,24 +774,73 @@ ___mulhi3:
emul emul
exg x,y exg x,y
pulx pulx
rts
#else #else
stx *_.tmp #ifdef NO_TMP
pshb ;
ldab *_.tmp+1 ; 16 bit multiplication without temp memory location.
mul ; A.high * B.low ; (smaller but slower)
ldaa *_.tmp ;
stab *_.tmp pshx ; (4)
pulb ins ; (3)
pshb pshb ; (3)
mul ; A.low * B.high psha ; (3)
addb *_.tmp pshx ; (4)
stab *_.tmp pula ; (4)
ldaa *_.tmp+1 pulx ; (5)
pulb mul ; (10) B.high * A.low
mul ; A.low * B.low xgdx ; (3)
adda *_.tmp mul ; (10) B.low * A.high
abx ; (3)
pula ; (4)
pulb ; (4)
mul ; (10) B.low * A.low
pshx ; (4)
tsx ; (3)
adda 1,x ; (4)
pulx ; (5)
rts ; (5) 20 bytes
; ---
; 91 cycles
#else
stx _.tmp ; (4/5)
pshb ; (3)
ldab _.tmp+1 ; (3/4)
mul ; (10) B.high * A.low
xgdx ; (3)
pulb ; (4)
stab _.tmp ; (3/4)
mul ; (10) B.low * A.high
abx ; (3)
ldd _.tmp ; (4/5)
mul ; (10) B.low * A.low
stx _.tmp ; (4)
adda _.tmp+1 ; (4/5)
rts ; (5) 20/26 bytes
; ---
; 70/76 cycles
#ifdef OLD_MUL
stx *_.tmp ; (4)
pshb ; (3)
ldab *_.tmp+1 ; (3)
mul ; (10) A.high * B.low
ldaa *_.tmp ; (3)
stab *_.tmp ; (3)
pulb ; (4)
pshb ; (4)
mul ; (10) A.low * B.high
addb *_.tmp ; (4)
stab *_.tmp ; (3)
ldaa *_.tmp+1 ; (3)
pulb ; (4)
mul ; (10) A.low * B.low
adda *_.tmp ; (4)
rts ; (5) 24/32 bytes
; 77/85 cycles
#endif
#endif
#endif #endif
rts
#endif #endif
#ifdef L_mulhi32 #ifdef L_mulhi32
...@@ -830,14 +855,18 @@ ___mulhi3: ...@@ -830,14 +855,18 @@ ___mulhi3:
; b = value on stack ; b = value on stack
; ;
; +---------------+ ; +---------------+
; | B low | <- 5,x ; | B low | <- 7,x
; +---------------+ ; +---------------+
; | B high | <- 4,x ; | B high | <- 6,x
; +---------------+ ; +---------------+
; | PC low | ; | PC low |
; +---------------+ ; +---------------+
; | PC high | ; | PC high |
; +---------------+ ; +---------------+
; | Tmp low |
; +---------------+
; | Tmp high |
; +---------------+
; | A low | ; | A low |
; +---------------+ ; +---------------+
; | A high | ; | A high |
...@@ -855,22 +884,24 @@ __mulhi32: ...@@ -855,22 +884,24 @@ __mulhi32:
ldy 2,sp ldy 2,sp
emul emul
exg x,y exg x,y
rts
#else #else
pshx ; Room for temp value
pshb pshb
psha psha
tsx tsx
ldab 4,x ldab 6,x
mul mul
xgdy ; A.high * B.high xgdy ; A.high * B.high
ldab 5,x ldab 7,x
pula pula
mul ; A.high * B.low mul ; A.high * B.low
std *_.tmp std 2,x
ldaa 1,x ldaa 1,x
ldab 4,x ldab 6,x
mul ; A.low * B.high mul ; A.low * B.high
addd *_.tmp addd 2,x
stab *_.tmp stab 2,x
tab tab
aby aby
bcc N bcc N
...@@ -878,18 +909,18 @@ __mulhi32: ...@@ -878,18 +909,18 @@ __mulhi32:
aby aby
iny iny
N: N:
ldab 5,x ldab 7,x
pula pula
mul ; A.low * B.low mul ; A.low * B.low
adda *_.tmp adda 2,x
pulx ; Drop temp location
pshy ; Put high part in X
pulx
bcc Ret bcc Ret
iny inx
Ret: Ret:
pshy
pulx
#endif
rts rts
#endif
#endif #endif
#ifdef L_mulsi3 #ifdef L_mulsi3
...@@ -946,7 +977,7 @@ A_high = 2 ...@@ -946,7 +977,7 @@ A_high = 2
; ;
; If A.high is 0, optimize into: (A.low * B.high) << 16 + (A.low * B.low) ; If A.high is 0, optimize into: (A.low * B.high) << 16 + (A.low * B.low)
; ;
stx *_.tmp cpx #0
beq A_high_zero beq A_high_zero
bsr ___mulhi3 ; A.high * B.low bsr ___mulhi3 ; A.high * B.low
; ;
...@@ -1050,7 +1081,8 @@ A_low_B_low: ...@@ -1050,7 +1081,8 @@ A_low_B_low:
.sect .install2,"ax",@progbits .sect .install2,"ax",@progbits
.globl __map_data_section .globl __map_data_section
.globl __data_image
.globl __data_section_size
__map_data_section: __map_data_section:
ldd #__data_section_size ldd #__data_section_size
beq Done beq Done
...@@ -1061,14 +1093,12 @@ Loop: ...@@ -1061,14 +1093,12 @@ Loop:
movb 1,x+,1,y+ movb 1,x+,1,y+
dbne d,Loop dbne d,Loop
#else #else
psha
ldaa 0,x ldaa 0,x
staa 0,y staa 0,y
pula
inx inx
iny iny
subd #1 cpx #__data_image_end
bne Loop blt Loop
#endif #endif
Done: Done:
......
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