* config/moxie/moxie.md (*movsi, *movhi, *movqi): Use xor to load
authorgreen <green@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 9 Sep 2009 22:29:13 +0000 (22:29 +0000)
committergreen <green@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 9 Sep 2009 22:29:13 +0000 (22:29 +0000)
the constant 0 when appropriate.
* config/moxie/constraints.md: Add constraint O.

* config/moxie/moxie.c (moxie_setup_incoming_varargs): Adjust
to pass up to 6 32-bit argument values in registers.
(moxie_function_arg): Ditto.
(moxie_arg_partial_bytes): Ditto.
* config/moxie/moxie.h (FUNCTION_ARG_ADVANCE): Ditto.
(REG_PARM_STACK_SPACE): Ditto.
(FUNCTION_ARG_REGNO_P): Ditto.

* config/moxie/moxie.c (moxie_expand_prologue): Use dec
instruction to allocate stack space.

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

gcc/ChangeLog
gcc/config/moxie/constraints.md
gcc/config/moxie/moxie.c
gcc/config/moxie/moxie.h
gcc/config/moxie/moxie.md

index 43f4870..f9cea3d 100644 (file)
@@ -1,3 +1,20 @@
+2009-09-09  Anthony Green  <green@moxielogic.com>
+
+       * config/moxie/moxie.md (*movsi, *movhi, *movqi): Use xor to load
+       the constant 0 when appropriate.
+       * config/moxie/constraints.md: Add constraint O.
+
+       * config/moxie/moxie.c (moxie_setup_incoming_varargs): Adjust
+       to pass up to 6 32-bit argument values in registers.
+       (moxie_function_arg): Ditto.
+       (moxie_arg_partial_bytes): Ditto.
+       * config/moxie/moxie.h (FUNCTION_ARG_ADVANCE): Ditto.
+       (REG_PARM_STACK_SPACE): Ditto.
+       (FUNCTION_ARG_REGNO_P): Ditto.
+
+       * config/moxie/moxie.c (moxie_expand_prologue): Use dec
+       instruction to allocate stack space.
+
 2009-09-09  Segher Boessenkool  <segher@kernel.crashing.org>
 
        * config/rs6000/rs6000.md (bswapdi2_64bit): Fix
index 038be5d..f767268 100644 (file)
        (match_test "REG_P (XEXP (op, 0))
                    && REGNO_OK_FOR_BASE_P (REGNO (XEXP (op, 0)))")))
 
+(define_constraint "O"
+  "The constant zero"
+  (and (match_code "const_int")
+       (match_test "ival == 0")))
+
 (define_constraint "I"
   "An 8-bit constant (0..255)"
   (and (match_code "const_int")
@@ -49,4 +54,3 @@
   "A constant -(0..255)"
   (and (match_code "const_int")
        (match_test "ival >= -255 && ival <= 0")))
-
index 39a5c10..8b2d8b2 100644 (file)
@@ -273,25 +273,22 @@ moxie_expand_prologue (void)
 
   if (cfun->machine->size_for_adjusting_sp > 0)
     {
-      if (cfun->machine->size_for_adjusting_sp <= 255)
+      int i = cfun->machine->size_for_adjusting_sp;
+      while (i > 255)
        {
          insn = emit_insn (gen_subsi3 (stack_pointer_rtx, 
                                        stack_pointer_rtx, 
-                                       GEN_INT (cfun->machine->size_for_adjusting_sp)));
+                                       GEN_INT (255)));
          RTX_FRAME_RELATED_P (insn) = 1;
+         i -= 255;
        }
-      else
+      if (i > 0)
        {
-         insn = 
-           emit_insn (gen_movsi 
-                      (gen_rtx_REG (Pmode, MOXIE_R5), 
-                       GEN_INT (-cfun->machine->size_for_adjusting_sp)));
-         RTX_FRAME_RELATED_P (insn) = 1;
-         insn = emit_insn (gen_addsi3 (stack_pointer_rtx, 
+         insn = emit_insn (gen_subsi3 (stack_pointer_rtx, 
                                        stack_pointer_rtx, 
-                                       gen_rtx_REG (Pmode, MOXIE_R5)));
+                                       GEN_INT (i)));
          RTX_FRAME_RELATED_P (insn) = 1;
-       }       
+       }
     }
 }
 
@@ -359,14 +356,14 @@ moxie_setup_incoming_varargs (CUMULATIVE_ARGS *cum,
                              int *pretend_size, int no_rtl)
 {
   int regno;
-  int regs = 7 - *cum;
+  int regs = 8 - *cum;
   
   *pretend_size = regs < 0 ? 0 : GET_MODE_SIZE (SImode) * regs;
   
   if (no_rtl)
     return;
   
-  for (regno = *cum; regno < 7; regno++)
+  for (regno = *cum; regno < 8; regno++)
     {
       rtx reg = gen_rtx_REG (SImode, regno);
       rtx slot = gen_rtx_PLUS (Pmode,
@@ -395,7 +392,7 @@ rtx
 moxie_function_arg (CUMULATIVE_ARGS cum, enum machine_mode mode,
                    tree type ATTRIBUTE_UNUSED, int named ATTRIBUTE_UNUSED)
 {
-  if (cum < 7)
+  if (cum < 8)
     return gen_rtx_REG (mode, cum);
   else 
     return NULL_RTX;
@@ -420,7 +417,7 @@ moxie_pass_by_reference (CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED,
   else
     size = GET_MODE_SIZE (mode);
 
-  return size > 4*5;
+  return size > 4*6;
 }
 
 /* Some function arguments will only partially fit in the registers
@@ -434,7 +431,7 @@ moxie_arg_partial_bytes (CUMULATIVE_ARGS *cum,
 {
   int bytes_left, size;
 
-  if (*cum >= 7)
+  if (*cum >= 8)
     return 0;
 
   if (moxie_pass_by_reference (cum, mode, type, named))
@@ -448,7 +445,7 @@ moxie_arg_partial_bytes (CUMULATIVE_ARGS *cum,
   else
     size = GET_MODE_SIZE (mode);
 
-  bytes_left = (4 * 5) - ((*cum - 2) * 4);
+  bytes_left = (4 * 6) - ((*cum - 2) * 4);
 
   if (size > bytes_left)
     return bytes_left;
index f50a6b2..21792da 100644 (file)
@@ -182,7 +182,7 @@ enum reg_class
 
 /* A C expression whose value is a register class containing hard
    register REGNO.  */
-#define REGNO_REG_CLASS(R) ((R < MOXIE_PC) ? GENERAL_REGS : \
+#define REGNO_REG_CLASS(R) ((R < MOXIE_PC) ? GENERAL_REGS :            \
                             (R == MOXIE_CC ? CC_REGS : SPECIAL_REGS))
 
 /* A C expression for the number of consecutive hard registers,
@@ -263,7 +263,7 @@ enum reg_class
    : (unsigned) int_size_in_bytes (TYPE))
 
 #define FUNCTION_ARG_ADVANCE(CUM,MODE,TYPE,NAMED) \
-  (CUM = (CUM < MOXIE_R5 ?                        \
+  (CUM = (CUM < MOXIE_R6 ?                        \
           CUM + ((3 + MOXIE_FUNCTION_ARG_SIZE(MODE,TYPE))/4) : CUM ))
 
 /* How Scalar Function Values Are Returned */
@@ -299,7 +299,7 @@ enum reg_class
 
 /* Define this if it is the responsibility of the caller to allocate
    the area reserved for arguments passed in registers.  */
-#define REG_PARM_STACK_SPACE(FNDECL) (5 * UNITS_PER_WORD)
+#define REG_PARM_STACK_SPACE(FNDECL) (6 * UNITS_PER_WORD)
 
 /* Offset from the argument pointer register to the first argument's
    address.  On some machines it may depend on the data type of the
@@ -463,7 +463,7 @@ do                                                                        \
 
 /* A C expression that is nonzero if REGNO is the number of a hard
    register in which function arguments are sometimes passed.  */
-#define FUNCTION_ARG_REGNO_P(r) (r >= MOXIE_R0 && r <= MOXIE_R4)
+#define FUNCTION_ARG_REGNO_P(r) (r >= MOXIE_R0 && r <= MOXIE_R5)
 
 /* A C expression that is nonzero if REGNO is the number of a hard
    register in which the values of called function may come back.  */
index 02072f4..a8e6887 100644 (file)
 }")
 
 (define_insn "*movsi"
-  [(set (match_operand:SI 0 "general_operand" "=r,r,W,A,r,r,B,r")
-       (match_operand:SI 1 "moxie_general_movsrc_operand" "r,i,r,r,W,A,r,B"))]
+  [(set (match_operand:SI 0 "general_operand" "=r,r,r,W,A,r,r,B,r")
+       (match_operand:SI 1 "moxie_general_movsrc_operand" "O,r,i,r,r,W,A,r,B"))]
   "register_operand (operands[0], SImode)
    || register_operand (operands[1], SImode)"
   "@
+   xor    %0, %0
    mov    %0, %1
    ldi.l  %0, %1
    st.l   %0, %1
    lda.l  %0, %1
    sto.l  %0, %1
    ldo.l  %0, %1"
-  [(set_attr "length"  "2,6,2,6,2,6,6,6")])
+  [(set_attr "length"  "2,2,6,2,6,2,6,6,6")])
 
 (define_expand "movqi"
   [(set (match_operand:QI 0 "general_operand" "")
 }")
 
 (define_insn "*movqi"
-  [(set (match_operand:QI 0 "general_operand" "=r,r,W,A,r,r,B,r")
-       (match_operand:QI 1 "moxie_general_movsrc_operand" "r,i,r,r,W,A,r,B"))]
+  [(set (match_operand:QI 0 "general_operand" "=r,r,r,W,A,r,r,B,r")
+       (match_operand:QI 1 "moxie_general_movsrc_operand" "O,r,i,r,r,W,A,r,B"))]
   "register_operand (operands[0], QImode)
    || register_operand (operands[1], QImode)"
   "@
+   xor    %0, %0
    mov    %0, %1
    ldi.b  %0, %1
    st.b   %0, %1
    lda.b  %0, %1
    sto.b  %0, %1
    ldo.b  %0, %1"
-  [(set_attr "length"  "2,6,2,6,2,6,6,6")])
+  [(set_attr "length"  "2,2,6,2,6,2,6,6,6")])
 
 (define_expand "movhi"
   [(set (match_operand:HI 0 "general_operand" "")
 }")
 
 (define_insn "*movhi"
-  [(set (match_operand:HI 0 "general_operand" "=r,r,W,A,r,r,B,r")
-       (match_operand:HI 1 "moxie_general_movsrc_operand" "r,i,r,r,W,A,r,B"))]
+  [(set (match_operand:HI 0 "general_operand" "=r,r,r,W,A,r,r,B,r")
+       (match_operand:HI 1 "moxie_general_movsrc_operand" "O,r,i,r,r,W,A,r,B"))]
   "(register_operand (operands[0], HImode)
     || register_operand (operands[1], HImode))"
   "@
+   xor    %0, %0
    mov    %0, %1
    ldi.s  %0, %1
    st.s   %0, %1
    lda.s  %0, %1
    sto.s  %0, %1
    ldo.s  %0, %1"
-  [(set_attr "length"  "2,6,2,6,2,6,6,6")])
+  [(set_attr "length"  "2,2,6,2,6,2,6,6,6")])
 
 ;; -------------------------------------------------------------------------
 ;; Compare instructions