mn10300.c (expand_prologue): Rework to avoid unnecessary "add" operations.
authorJeff Law <law@gcc.gnu.org>
Fri, 7 Mar 1997 16:42:33 +0000 (09:42 -0700)
committerJeff Law <law@gcc.gnu.org>
Fri, 7 Mar 1997 16:42:33 +0000 (09:42 -0700)
        * mn10300/mn10300.c (expand_prologue): Rework to avoid unnecessary
        "add" operations.
        (expand_epilogue): Likewise.
        * mn10300/mn10300.h (STARTING_FRAME_OFFSET): Is zero after the last
        round of prologue/epilogue changes.
        (FIRST_PARM_OFFSET): Is now 16 (-4 for REG_PARM_STACK_SPACE + 20 for
        register save area).
        (REG_PARM_STACK_SPACE): Define as 4 bytes.
        (OUTGOING_REG_PARM_STACK_SPACE): Define so caller allocates it.
        * mn10300/mn10300.md (call expander): Don't emit insns to adjust the
        stack here anymore.
        (call_value expander): Likewise.

        * mn10300/mn10300.md (bCC patterns): Just use "bCC target" now that
        the assembler handles relaxing.

From-SVN: r13696

gcc/config/mn10300/mn10300.c
gcc/config/mn10300/mn10300.h
gcc/config/mn10300/mn10300.md

index 673ddb2b7d3ea96f9dedb9f1cb989031a1f0db88..0d9e6fc5b04fd24f78726a4e97af398952b0e176 100644 (file)
@@ -219,12 +219,7 @@ expand_prologue ()
   emit_insn (gen_store_movm ());
 
   if (frame_pointer_needed)
-    {
-      emit_move_insn (frame_pointer_rtx, stack_pointer_rtx);
-      emit_insn (gen_addsi3 (frame_pointer_rtx,
-                            frame_pointer_rtx,
-                            GEN_INT (20)));
-    }
+    emit_move_insn (frame_pointer_rtx, stack_pointer_rtx);
 
   if (size)
     emit_insn (gen_addsi3 (stack_pointer_rtx,
@@ -240,9 +235,6 @@ expand_epilogue ()
   /* Cut back the stack.  */
   if (frame_pointer_needed)
     {
-      emit_insn (gen_addsi3 (frame_pointer_rtx,
-                            frame_pointer_rtx,
-                            GEN_INT (-20)));
       emit_move_insn (stack_pointer_rtx, frame_pointer_rtx);
       size = 0;
     }
index 64f0a629b3239e278120414b9159561f7509b6e4..0f1074cf645567f419b82ca11ae15b7e6f59595a 100644 (file)
@@ -337,13 +337,13 @@ enum reg_class {
    first local allocated.  Otherwise, it is the offset to the BEGINNING
    of the first local allocated.  */
 
-#define STARTING_FRAME_OFFSET -20
+#define STARTING_FRAME_OFFSET 0
 
 /* Offset of first parameter from the argument pointer register value.  */
 /* Is equal to the size of the saved fp + pc, even if an fp isn't
    saved since the value is used before we know.  */
 
-#define FIRST_PARM_OFFSET(FNDECL) 0
+#define FIRST_PARM_OFFSET(FNDECL) (-4 + 20)
 
 /* Specify the registers used for certain standard purposes.
    The values of these macros are register numbers.  */
@@ -374,7 +374,7 @@ enum reg_class {
    as of the start of the function body.  This depends on the layout
    of the fixed parts of the stack frame and on how registers are saved.  */
 
-#define INITIAL_FRAME_POINTER_OFFSET(DEPTH) (DEPTH) = 0
+#define INITIAL_FRAME_POINTER_OFFSET(DEPTH) (DEPTH) = 20
 
 /* A guess for the MN10300.  */
 #define PROMOTE_PROTOTYPES 1
@@ -388,6 +388,17 @@ enum reg_class {
 
 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
 
+/* On the mn10300, the caller is responsible for allocating and deallocating
+   a stack slot for the "call" and "calls" instructions to save their return
+   pointer.  We used to do this in the "call" and "call_value" expanders,
+   but that generated poor code.
+
+   Now we pretend that we have an outgoing register parameter space so that
+   the generic function calling code will allocate the slot.  */
+   
+#define REG_PARM_STACK_SPACE(FNDECL) 4
+#define OUTGOING_REG_PARM_STACK_SPACE
+
 /* 1 if N is a possible register number for function argument passing.
    On the MN10300, no registers are used in this way.  */
 
index ebf41e54279698bffca11be3b3ee658161036da3..52546c85a56a777d4755e76ac48fe8855991cd52 100644 (file)
@@ -1,5 +1,5 @@
 ;; GCC machine description for Matsushita MN10300
-;; Copyright (C) 1996 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
 
 ;;   Contributed by Jeff Law (law@cygnus.com).
 
          || GET_CODE (operands[1]) == LE
          || GET_CODE (operands[1]) == LT))
     return 0;
-  return \"b%B1 .+8\\n\\tjmp %0\\n\";
+  return \"b%b1 %0\";
 }"
  [(set_attr "cc" "none")])
 
          || GET_CODE (operands[1]) == LE
          || GET_CODE (operands[1]) == LT))
     return 0;
-  return \"b%b1 .+8\\n\\tjmp %0\\n\";
+  return \"b%B1 %0\";
 }"
  [(set_attr "cc" "none")])
 
   ""
   "
 {
-  emit_insn (gen_addsi3 (stack_pointer_rtx,
-                        stack_pointer_rtx,
-                        GEN_INT (-4)));
   if (! call_address_operand (XEXP (operands[0], 0)))
     XEXP (operands[0], 0) = force_reg (SImode, XEXP (operands[0], 0));
   emit_call_insn (gen_call_internal (XEXP (operands[0], 0), operands[1]));
-  emit_insn (gen_addsi3 (stack_pointer_rtx,
-                        stack_pointer_rtx,
-                        GEN_INT (4)));
   DONE;
 }")
 
   ""
   "
 {
-  emit_insn (gen_addsi3 (stack_pointer_rtx,
-                        stack_pointer_rtx,
-                        GEN_INT (-4)));
   if (! call_address_operand (XEXP (operands[1], 0)))
     XEXP (operands[1], 0) = force_reg (SImode, XEXP (operands[1], 0));
   emit_call_insn (gen_call_value_internal (operands[0],
                                           XEXP (operands[1], 0),
                                           operands[2]));
-  emit_insn (gen_addsi3 (stack_pointer_rtx,
-                        stack_pointer_rtx,
-                        GEN_INT (4)));
   DONE;
 }")