public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* QImode truncate / extend patch applied to sh port
@ 2002-07-25 14:18 Joern Rennecke
  0 siblings, 0 replies; only message in thread
From: Joern Rennecke @ 2002-07-25 14:18 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 160 bytes --]

Tested on i686-pc-linux-gnu X sh64-elf and X sh-elf.

-- 
--------------------------
SuperH
2430 Aztec West / Almondsbury / BRISTOL / BS32 4AQ
T:+44 1454 462330

[-- Attachment #2: truncdiqi-fix --]
[-- Type: text/plain, Size: 3492 bytes --]

Thu Jul 25 20:34:50 2002  J"orn Rennecke <joern.rennecke@superh.com>

	* sh.h (LOAD_EXTEND_OP): QImode zero-extends on SHmedia.
	* sh.md (truncdiqi2, movqi_media): Likewise.

Index: config/sh/sh.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.h,v
retrieving revision 1.163
diff -p -r1.163 sh.h
*** config/sh/sh.h	18 Jul 2002 19:26:07 -0000	1.163
--- config/sh/sh.h	25 Jul 2002 19:34:44 -0000
*************** while (0)
*** 2623,2631 ****
     will either zero-extend or sign-extend.  The value of this macro should
     be the code that says which one of the two operations is implicitly
     done, NIL if none.  */
  /* FP registers can load SImode values, but don't implicitly sign-extend
     them to DImode.  */
! #define LOAD_EXTEND_OP(MODE) ((MODE) != SImode ? SIGN_EXTEND : NIL)
  
  /* Define if loading short immediate values into registers sign extends.  */
  #define SHORT_IMMEDIATES_SIGN_EXTEND
--- 2623,2634 ----
     will either zero-extend or sign-extend.  The value of this macro should
     be the code that says which one of the two operations is implicitly
     done, NIL if none.  */
+ /* For SHmedia, we can truncate to QImode easier using zero extension.  */
  /* FP registers can load SImode values, but don't implicitly sign-extend
     them to DImode.  */
! #define LOAD_EXTEND_OP(MODE) \
!  (((MODE) == QImode  && TARGET_SHMEDIA) ? ZERO_EXTEND \
!   : (MODE) != SImode ? SIGN_EXTEND : NIL)
  
  /* Define if loading short immediate values into registers sign extends.  */
  #define SHORT_IMMEDIATES_SIGN_EXTEND
Index: config/sh/sh.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.md,v
retrieving revision 1.116
diff -p -r1.116 sh.md
*** config/sh/sh.md	18 Jul 2002 19:26:07 -0000	1.116
--- config/sh/sh.md	25 Jul 2002 19:34:44 -0000
***************
*** 3382,3398 ****
    [(set_attr "type"   "arith_media,store_media")
     (set_attr "length" "8,4")])
  
! ; N.B. we want sign-extension here because
! ; - we need to be consistent with LOAD_EXTEND_OP and movqi
! ; - only sign extension allows us to do signed compares transparently.
! ;  unsigned compares don't care about the kind of extension as long as
! ;   it's consistent.
  (define_insn "truncdiqi2"
    [(set (match_operand:QI 0 "general_movdst_operand" "=r,m")
  	(truncate:QI (match_operand:DI 1 "register_operand" "r,r")))]
    "TARGET_SHMEDIA"
    "@
! 	ori	%1, -256, %0
  	st%M0.b	%m0, %1"
    [(set_attr "type"   "arith_media,store")])
  
--- 3382,3396 ----
    [(set_attr "type"   "arith_media,store_media")
     (set_attr "length" "8,4")])
  
! ; N.B. This should agree with LOAD_EXTEND_OP and movqi.
! ; Because we use zero extension, we can't provide signed QImode compares
! ; using a simple compare or conditional banch insn.
  (define_insn "truncdiqi2"
    [(set (match_operand:QI 0 "general_movdst_operand" "=r,m")
  	(truncate:QI (match_operand:DI 1 "register_operand" "r,r")))]
    "TARGET_SHMEDIA"
    "@
! 	and	%1, 255, %0
  	st%M0.b	%m0, %1"
    [(set_attr "type"   "arith_media,store")])
  
***************
*** 3741,3747 ****
    "@
  	add.l	%1, r63, %0
  	movi	%1, %0
! 	ld%M1.b	%m1, %0
  	st%M0.b	%m0, %1"
    [(set_attr "type" "arith_media,arith_media,load_media,store_media")])
  
--- 3739,3745 ----
    "@
  	add.l	%1, r63, %0
  	movi	%1, %0
! 	ld%M1.ub	%m1, %0
  	st%M0.b	%m0, %1"
    [(set_attr "type" "arith_media,arith_media,load_media,store_media")])
  

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-07-25 19:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-25 14:18 QImode truncate / extend patch applied to sh port Joern Rennecke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).