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]

Patch to implement x86 HImode FP -> integer patterns


This adds patterns for HImode FP -> integer conversions.

ChangeLog:

Sun Apr 25 20:02:41 EDT 1999  John Wehle  (john@feith.com)

	* i386.md (fix_truncsfhi2, fix_truncdfhi2,
	fix_truncxfhi2): New patterns.
	* i386.c (output_fix_trunc): Handle converting to HImode.

Enjoy!

-- John Wehle
------------------8<------------------------8<------------------------
*** gcc/config/i386/i386.md.ORIGINAL	Sun Apr 25 19:57:38 1999
--- gcc/config/i386/i386.md	Sun Apr 25 19:34:04 1999
***************
*** 2721,2726 ****
--- 2721,2751 ----
    "* return output_fix_trunc (insn, operands);"
    [(set_attr "type" "fpop")])
  
+ (define_expand "fix_truncsfhi2"
+   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
+ 		   (fix:HI (fix:SF (match_operand:SF 1 "register_operand" ""))))
+ 	      (clobber (match_dup 2))
+ 	      (clobber (match_dup 3))
+ 	      (clobber (match_dup 4))
+ 	      (clobber (match_scratch:HI 5 ""))])]
+   "TARGET_80387"
+   "
+ {
+   operands[2] = (rtx) assign_386_stack_local (HImode, 0);
+   operands[4] = operands[3] = (rtx) assign_386_stack_local (HImode, 1);
+ }")
+ 
+ (define_insn ""
+   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,!r")
+ 	(fix:HI (fix:SF (match_operand:SF 1 "register_operand" "f,f"))))
+    (clobber (match_operand:HI 2 "memory_operand" "m,m"))
+    (clobber (match_operand:HI 3 "memory_operand" "m,m"))
+    (clobber (match_operand:HI 4 "memory_operand" "m,m"))
+    (clobber (match_scratch:HI 5 "=&r,r"))]
+   "TARGET_80387"
+   "* return output_fix_trunc (insn, operands);"
+   [(set_attr "type" "fpop")])
+ 
  (define_expand "fix_truncsfdi2"
    [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
  		   (fix:DI (fix:SF (match_operand:SF 1 "register_operand" ""))))
***************
*** 2776,2781 ****
--- 2801,2831 ----
    "* return output_fix_trunc (insn, operands);"
    [(set_attr "type" "fpop")])
  
+ (define_expand "fix_truncdfhi2"
+   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
+ 		   (fix:HI (fix:DF (match_operand:DF 1 "register_operand" ""))))
+ 	      (clobber (match_dup 2))
+ 	      (clobber (match_dup 3))
+ 	      (clobber (match_dup 4))
+ 	      (clobber (match_scratch:HI 5 ""))])]
+   "TARGET_80387"
+   "
+ {
+   operands[2] = (rtx) assign_386_stack_local (HImode, 0);
+   operands[4] = operands[3] = (rtx) assign_386_stack_local (HImode, 1);
+ }")
+ 
+ (define_insn ""
+   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,!r")
+ 	(fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f,f"))))
+    (clobber (match_operand:HI 2 "memory_operand" "m,m"))
+    (clobber (match_operand:HI 3 "memory_operand" "m,m"))
+    (clobber (match_operand:HI 4 "memory_operand" "m,m"))
+    (clobber (match_scratch:HI 5 "=&r,r"))]
+   "TARGET_80387"
+   "* return output_fix_trunc (insn, operands);"
+   [(set_attr "type" "fpop")])
+ 
  (define_expand "fix_truncdfdi2"
    [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
  		   (fix:DI (fix:DF (match_operand:DF 1 "register_operand" ""))))
***************
*** 2826,2831 ****
--- 2876,2906 ----
     (clobber (match_operand:HI 2 "memory_operand" "m,m"))
     (clobber (match_operand:HI 3 "memory_operand" "m,m"))
     (clobber (match_operand:SI 4 "memory_operand" "m,m"))
+    (clobber (match_scratch:HI 5 "=&r,r"))]
+   "TARGET_80387"
+   "* return output_fix_trunc (insn, operands);"
+   [(set_attr "type" "fpop")])
+ 
+ (define_expand "fix_truncxfhi2"
+   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
+ 		   (fix:HI (fix:XF (match_operand:XF 1 "register_operand" ""))))
+ 	      (clobber (match_dup 2))
+ 	      (clobber (match_dup 3))
+ 	      (clobber (match_dup 4))
+ 	      (clobber (match_scratch:HI 5 ""))])]
+   "TARGET_80387"
+   "
+ {
+   operands[2] = (rtx) assign_386_stack_local (HImode, 0);
+   operands[4] = operands[3] = (rtx) assign_386_stack_local (HImode, 1);
+ }")
+ 
+ (define_insn ""
+   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,!r")
+ 	(fix:HI (fix:XF (match_operand:XF 1 "register_operand" "f,f"))))
+    (clobber (match_operand:HI 2 "memory_operand" "m,m"))
+    (clobber (match_operand:HI 3 "memory_operand" "m,m"))
+    (clobber (match_operand:HI 4 "memory_operand" "m,m"))
     (clobber (match_scratch:HI 5 "=&r,r"))]
    "TARGET_80387"
    "* return output_fix_trunc (insn, operands);"
*** gcc/config/i386/i386.c.ORIGINAL	Sun Apr 25 17:53:21 1999
--- gcc/config/i386/i386.c	Sun Apr 25 17:49:36 1999
*************** output_387_binary_op (insn, operands)
*** 3997,4005 ****
  
  /* Output code for INSN to convert a float to a signed int.  OPERANDS
     are the insn operands.  The input may be SFmode, DFmode, or XFmode
!    and the output operand may be SImode or DImode.  As a special case,
!    make sure that the 387 stack top dies if the output mode is DImode,
!    because the hardware requires this.  */
  
  char *
  output_fix_trunc (insn, operands)
--- 3997,4005 ----
  
  /* Output code for INSN to convert a float to a signed int.  OPERANDS
     are the insn operands.  The input may be SFmode, DFmode, or XFmode
!    and the output operand may be HImode, SImode, or DImode.  As a
!    special case, make sure that the 387 stack top dies if the output
!    mode is DImode, because the hardware requires this.  */
  
  char *
  output_fix_trunc (insn, operands)
*************** output_fix_trunc (insn, operands)
*** 4035,4040 ****
--- 4035,4042 ----
      {
        if (GET_MODE (operands[0]) == SImode)
  	output_asm_insn (AS2 (mov%L0,%4,%0), operands);
+       else if (GET_MODE (operands[0]) == HImode)
+ 	output_asm_insn (AS2 (mov%W0,%4,%0), operands);
        else
  	{
  	  xops[0] = operands[0];
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------



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