OSDN Git Service

* i386.c (ix86_force_to_memory, ix86_free_from_memory): New.
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 27 Nov 2000 16:23:27 +0000 (16:23 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 27 Nov 2000 16:23:27 +0000 (16:23 +0000)
* i386-protos.h (ix86_force_to_memory, ix86_free_from_memory): Declare
* i386.md (float?i?f, int/fp operations): Rewrite spliters to use
ix86_force_to_memory and ix86_free_from_memory.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37797 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/i386/i386-protos.h
gcc/config/i386/i386.c
gcc/config/i386/i386.md

index a1970f7..816a0bb 100644 (file)
@@ -1,3 +1,10 @@
+Mon Nov 27 17:22:56 MET 2000  Jan Hubicka  <jh@suse.cz>
+
+       * i386.c (ix86_force_to_memory, ix86_free_from_memory): New.
+       * i386-protos.h (ix86_force_to_memory, ix86_free_from_memory): Declare
+       * i386.md (float?i?f, int/fp operations): Rewrite spliters to use
+       ix86_force_to_memory and ix86_free_from_memory.
+
 2000-11-27  Richard Earnshaw  <rearnsha@arm.com>
 
        * arm.md (arm_adddi3, adddi_sesidi_di, adddi_zesidi_di, arm_addsi3,
index 2651f4b..e000dca 100644 (file)
@@ -128,6 +128,9 @@ extern int ix86_sched_reorder PARAMS ((FILE *, int, rtx *, int, int));
 extern int ix86_variable_issue PARAMS ((FILE *, int, rtx, int));
 extern enum machine_mode ix86_fp_compare_mode PARAMS ((enum rtx_code));
 
+extern rtx ix86_force_to_memory PARAMS ((enum machine_mode, rtx));
+extern void ix86_free_from_memory PARAMS ((enum machine_mode));
+
 #ifdef TREE_CODE
 extern void init_cumulative_args PARAMS ((CUMULATIVE_ARGS *, tree, rtx));
 extern rtx function_arg PARAMS ((CUMULATIVE_ARGS *, enum machine_mode, tree, int));
index ca3881f..9a80d00 100644 (file)
@@ -8299,3 +8299,67 @@ ix86_expand_builtin (exp, target, subtarget, mode, ignore)
   /* @@@ Should really do something sensible here.  */
   return 0;
 }
+
+/* Store OPERAND to the memory after reload is completed.  This means
+   that we can't easilly use assign_stack_local.  */
+rtx
+ix86_force_to_memory (mode, operand)
+     enum machine_mode mode;
+     rtx operand;
+{
+  if (!reload_completed)
+    abort ();
+  switch (mode)
+    {
+      case DImode:
+       {
+         rtx operands[2];
+         split_di (&operand, 1, operands, operands+1);
+         emit_insn (
+           gen_rtx_SET (VOIDmode,
+                        gen_rtx_MEM (SImode,
+                                     gen_rtx_PRE_DEC (Pmode,
+                                                      stack_pointer_rtx)),
+                        operands[1]));
+         emit_insn (
+           gen_rtx_SET (VOIDmode,
+                        gen_rtx_MEM (SImode,
+                                     gen_rtx_PRE_DEC (Pmode,
+                                                      stack_pointer_rtx)),
+                        operands[0]));
+       }
+       break;
+      case HImode:
+       /* It is better to store HImodes as SImodes.  */
+       if (!TARGET_PARTIAL_REG_STALL)
+         operand = gen_lowpart (SImode, operand);
+       /* FALLTHRU */
+      case SImode:
+       emit_insn (
+         gen_rtx_SET (VOIDmode,
+                      gen_rtx_MEM (GET_MODE (operand),
+                                   gen_rtx_PRE_DEC (SImode,
+                                                    stack_pointer_rtx)),
+                      operand));
+       break;
+      default:
+       abort();
+    }
+  return gen_rtx_MEM (mode, stack_pointer_rtx);
+}
+
+/* Free operand from the memory.  */
+void
+ix86_free_from_memory (mode)
+     enum machine_mode mode;
+{
+  /* Use LEA to deallocate stack space.  In peephole2 it will be converted
+     to pop or add instruction if registers are available.  */
+  emit_insn (gen_rtx_SET (VOIDmode, stack_pointer_rtx,
+                         gen_rtx_PLUS (Pmode, stack_pointer_rtx,
+                                       GEN_INT (mode == DImode
+                                                ? 8
+                                                : mode == HImode && TARGET_PARTIAL_REG_STALL
+                                                ? 2
+                                                : 4))));
+}
index 20c6dbd..2b5d3b8 100644 (file)
 ;; %%% Kill these when reload knows how to do it.
 (define_split
   [(set (match_operand 0 "register_operand" "")
-       (float (match_operand:HI 1 "register_operand" "")))]
+       (float (match_operand 1 "register_operand" "")))]
   "reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
-  [(set (mem:HI (pre_dec:SI (reg:SI 7))) (match_dup 1))
-   (set (match_dup 0) (match_dup 2))
-   (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 2)))]
-  "operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]),
-                               gen_rtx_MEM (HImode, stack_pointer_rtx));")
-
-(define_split
-  [(set (match_operand 0 "register_operand" "")
-       (float (match_operand:SI 1 "register_operand" "")))]
-  "reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
-  [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 1))
-   (set (match_dup 0) (match_dup 2))
-   (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
-             (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
-  "operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]),
-                               gen_rtx_MEM (SImode, stack_pointer_rtx));")
-
-(define_split
-  [(set (match_operand 0 "register_operand" "")
-       (float (match_operand:DI 1 "nonmemory_operand" "")))]
-  "reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
-  [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 2))
-   (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 1))
-   (set (match_dup 0) (match_dup 3))
-   (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
-             (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])
-   (parallel [(set (match_dup 2) (mem:SI (reg:SI 7)))
-             (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
-  "split_di (operands+1, 1, operands+1, operands+2);
-   operands[3] = gen_rtx_FLOAT (GET_MODE (operands[0]),
-                               gen_rtx_MEM (DImode, stack_pointer_rtx));")
+  [(const_int 0)]
+  "
+{
+  operands[2] = ix86_force_to_memory (GET_MODE (operands[1]), operands[1]);
+  operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[2]);
+  emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[2]));
+  ix86_free_from_memory (GET_MODE (operands[1]));
+  DONE;
+}")
 \f
 ;; Add instructions
 
            (match_operand 2 "register_operand" "")]))]
   "TARGET_80387 && reload_completed
    && FLOAT_MODE_P (GET_MODE (operands[0]))"
-  [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 1))
-   (set (match_dup 0)
-       (match_op_dup 3 [(match_dup 4) (match_dup 2)]))
-   (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
-              (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
-  "operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]),
-                               gen_rtx_MEM (SImode, stack_pointer_rtx));")
+  [(const_int 0)]
+  "
+{ 
+  operands[4] = ix86_force_to_memory (GET_MODE (operands[1]), operands[1]);
+  operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[4]);
+  emit_insn (gen_rtx_SET (VOIDmode, operands[0],
+                         gen_rtx_fmt_ee (GET_CODE (operands[3]),
+                                         GET_MODE (operands[3]),
+                                         operands[4],
+                                         operands[2])));
+  ix86_free_from_memory (GET_MODE (operands[1]));
+  DONE;
+}")
 
 (define_split
   [(set (match_operand 0 "register_operand" "")
            (float (match_operand:SI 2 "register_operand" ""))]))]
   "TARGET_80387 && reload_completed
    && FLOAT_MODE_P (GET_MODE (operands[0]))"
-  [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 2))
-   (set (match_dup 0)
-       (match_op_dup 3 [(match_dup 1) (match_dup 4)]))
-   (parallel [(set (match_dup 2) (mem:SI (reg:SI 7)))
-              (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
-  "operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]),
-                               gen_rtx_MEM (SImode, stack_pointer_rtx));")
+  [(const_int 0)]
+  "
+{
+  operands[4] = ix86_force_to_memory (GET_MODE (operands[2]), operands[2]);
+  operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[4]);
+  emit_insn (gen_rtx_SET (VOIDmode, operands[0],
+                         gen_rtx_fmt_ee (GET_CODE (operands[3]),
+                                         GET_MODE (operands[3]),
+                                         operands[1],
+                                         operands[4])));
+  ix86_free_from_memory (GET_MODE (operands[2]));
+  DONE;
+}")
 \f
 ;; FPU special functions.