This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Implement divmod on h8300 port.


Hi,

Attached is a patch to implement divmod on h8300 port.

Tested and committed.

Kazu Hirata

2001-12-14  Kazu Hirata  <kazu@hxi.com>

	* config/h8300/h8300.md (udivqi3): Remove.
	(divqi3): Likewise.
	(udivhi3): Likewise.
	(divhi3): Likewise.
	(umodqi3): Likewise.
	(modqi3): Likewise.
	(umodhi3): Likewise.
	(modhi3): Likewise.
	(udivmodqi3): New.
	(divmodqi3): Likewise.
	(udivmodhi3): Likewise.
	(divmodhi3): Likewise.

Index: h8300.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.md,v
retrieving revision 1.43
diff -c -r1.43 h8300.md
*** h8300.md	2001/11/15 20:49:01	1.43
--- h8300.md	2001/12/15 01:10:47
***************
*** 921,1020 ****
     (set_attr "cc" "none_0hit")])
  
  ;; ----------------------------------------------------------------------
! ;; DIVIDE INSTRUCTIONS
  ;; ----------------------------------------------------------------------
  
! (define_insn "udivqi3"
    [(set (match_operand:QI 0 "register_operand" "=r")
  	(truncate:QI
  	  (udiv:HI
  	    (match_operand:HI 1 "general_operand" "0")
! 	    (zero_extend:HI (match_operand:QI 2 "register_operand" "r")))))]
!   ""
!   "divxu	%X2,%T0"
!   [(set_attr "length" "2")
!    (set_attr "cc" "clobber")])
! 
! ;; ??? Will divxu always work here?
! 
! (define_insn "divqi3"
!   [(set (match_operand:QI 0 "register_operand" "=r")
  	(truncate:QI
! 	  (div:HI
! 	    (match_operand:HI 1 "general_operand" "0")
! 	    (sign_extend:HI (match_operand:QI 2 "register_operand" "r")))))]
!   ""
!   "divxu	%X2,%T0"
!   [(set_attr "length" "2")
!    (set_attr "cc" "clobber")])
! 
! (define_insn "udivhi3"
!   [(set (match_operand:HI 0 "register_operand" "=r")
! 	(truncate:HI
! 	  (udiv:SI
! 	    (match_operand:SI 1 "general_operand" "0")
! 	    (zero_extend:SI (match_operand:HI 2 "register_operand" "r")))))]
!   "TARGET_H8300H || TARGET_H8300S"
!   "divxu.w	%T2,%S0"
!   [(set_attr "length" "2")
!    (set_attr "cc" "clobber")])
! 
! (define_insn "divhi3"
!   [(set (match_operand:HI 0 "register_operand" "=r")
! 	(truncate:HI
! 	  (div:SI
! 	    (match_operand:SI 1 "general_operand" "0")
! 	    (sign_extend:SI (match_operand:HI 2 "register_operand" "r")))))]
    "TARGET_H8300H || TARGET_H8300S"
!   "divxs.w	%T2,%S0"
    [(set_attr "length" "4")
     (set_attr "cc" "clobber")])
  
! ;; ----------------------------------------------------------------------
! ;; MOD INSTRUCTIONS
! ;; ----------------------------------------------------------------------
! 
! (define_insn "umodqi3"
    [(set (match_operand:QI 0 "register_operand" "=r")
  	(truncate:QI
! 	  (umod:HI
  	    (match_operand:HI 1 "general_operand" "0")
! 	    (zero_extend:HI (match_operand:QI 2 "register_operand" "r")))))]
!   ""
!   "divxu	%X2,%T0\;mov	%t0,%s0"
!   [(set_attr "length" "4")
!    (set_attr "cc" "clobber")])
! 
! (define_insn "modqi3"
!   [(set (match_operand:QI 0 "register_operand" "=r")
  	(truncate:QI
  	  (mod:HI
! 	    (match_operand:HI 1 "general_operand" "0")
! 	    (sign_extend:HI (match_operand:QI 2 "register_operand" "r")))))]
    "TARGET_H8300H || TARGET_H8300S"
!   "divxs.b	%X2,%T0\;mov	%t0,%s0"
    [(set_attr "length" "6")
     (set_attr "cc" "clobber")])
  
! (define_insn "umodhi3"
    [(set (match_operand:HI 0 "register_operand" "=r")
  	(truncate:HI
! 	  (umod:SI
  	    (match_operand:SI 1 "general_operand" "0")
! 	    (zero_extend:SI (match_operand:HI 2 "register_operand" "r")))))]
    "TARGET_H8300H || TARGET_H8300S"
!   "divxu.w	%T2,%S0\;mov	%e0,%f0"
    [(set_attr "length" "4")
     (set_attr "cc" "clobber")])
  
! (define_insn "modhi3"
    [(set (match_operand:HI 0 "register_operand" "=r")
  	(truncate:HI
! 	  (mod:SI
  	    (match_operand:SI 1 "general_operand" "0")
! 	    (sign_extend:SI (match_operand:HI 2 "register_operand" "r")))))]
    "TARGET_H8300H || TARGET_H8300S"
!   "divxs.w	%T2,%S0\;mov	%e0,%f0"
    [(set_attr "length" "6")
     (set_attr "cc" "clobber")])
  
--- 921,1014 ----
     (set_attr "cc" "none_0hit")])
  
  ;; ----------------------------------------------------------------------
! ;; DIVIDE/MOD INSTRUCTIONS
  ;; ----------------------------------------------------------------------
  
! (define_insn "udivmodqi4"
    [(set (match_operand:QI 0 "register_operand" "=r")
  	(truncate:QI
  	  (udiv:HI
  	    (match_operand:HI 1 "general_operand" "0")
! 	    (zero_extend:HI (match_operand:QI 2 "register_operand" "r")))))
!    (set (match_operand:QI 3 "register_operand" "=r")
  	(truncate:QI
! 	  (umod:HI
! 	    (match_dup 1)
! 	    (zero_extend:HI (match_dup 2)))))]
    "TARGET_H8300H || TARGET_H8300S"
!   "*
! {
!   if (find_reg_note (insn, REG_UNUSED, operands[3]))
!     return \"divxu.b\\t%X2,%T0\";
!   else
!     return \"divxu.b\\t%X2,%T0\;mov.b\\t%t0,%s3\";
! }"
    [(set_attr "length" "4")
     (set_attr "cc" "clobber")])
  
! (define_insn "divmodqi4"
    [(set (match_operand:QI 0 "register_operand" "=r")
  	(truncate:QI
! 	  (div:HI
  	    (match_operand:HI 1 "general_operand" "0")
! 	    (sign_extend:HI (match_operand:QI 2 "register_operand" "r")))))
!    (set (match_operand:QI 3 "register_operand" "=r")
  	(truncate:QI
  	  (mod:HI
! 	    (match_dup 1)
! 	    (sign_extend:HI (match_dup 2)))))]
    "TARGET_H8300H || TARGET_H8300S"
!   "*
! {
!   if (find_reg_note (insn, REG_UNUSED, operands[3]))
!     return \"divxs.b\\t%X2,%T0\";
!   else
!     return \"divxs.b\\t%X2,%T0\;mov.b\\t%t0,%s3\";
! }"
    [(set_attr "length" "6")
     (set_attr "cc" "clobber")])
  
! (define_insn "udivmodhi4"
    [(set (match_operand:HI 0 "register_operand" "=r")
  	(truncate:HI
! 	  (udiv:SI
  	    (match_operand:SI 1 "general_operand" "0")
! 	    (zero_extend:SI (match_operand:HI 2 "register_operand" "r")))))
!    (set (match_operand:HI 3 "register_operand" "=r")
! 	(truncate:HI
! 	  (umod:SI
! 	    (match_dup 1)
! 	    (zero_extend:SI (match_dup 2)))))]
    "TARGET_H8300H || TARGET_H8300S"
!   "*
! {
!   if (find_reg_note (insn, REG_UNUSED, operands[3]))
!     return \"divxu.w\\t%T2,%S0\";
!   else
!     return \"divxu.w\\t%T2,%S0\;mov.w\\t%e0,%f3\";
! }"
    [(set_attr "length" "4")
     (set_attr "cc" "clobber")])
  
! (define_insn "divmodhi4"
    [(set (match_operand:HI 0 "register_operand" "=r")
  	(truncate:HI
! 	  (div:SI
  	    (match_operand:SI 1 "general_operand" "0")
! 	    (sign_extend:SI (match_operand:HI 2 "register_operand" "r")))))
!    (set (match_operand:HI 3 "register_operand" "=r")
! 	(truncate:HI
! 	  (mod:SI
! 	    (match_dup 1)
! 	    (sign_extend:SI (match_dup 2)))))]
    "TARGET_H8300H || TARGET_H8300S"
!   "*
! {
!   if (find_reg_note (insn, REG_UNUSED, operands[3]))
!     return \"divxs.w\\t%T2,%S0\";
!   else
!     return \"divxs.w\\t%T2,%S0\;mov.w\\t%e0,%f3\";
! }"
    [(set_attr "length" "6")
     (set_attr "cc" "clobber")])
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]