OSDN Git Service

Apply https://gcc.gnu.org/bugzilla/attachment.cgi?id=28797 for lm32-elf.
[pf3gnuchains/gcc-fork.git] / gcc / config / lm32 / lm32.c
index 18a4b44..fbd823b 100644 (file)
@@ -1,7 +1,7 @@
 /* Subroutines used for code generation on the Lattice Mico32 architecture.
    Contributed by Jon Beniston <jon@beniston.com>
 
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
 
    This file is part of GCC.
 
@@ -41,7 +41,6 @@
 #include "tm_p.h"
 #include "function.h"
 #include "diagnostic-core.h"
-#include "toplev.h"
 #include "optabs.h"
 #include "libfuncs.h"
 #include "ggc.h"
@@ -66,34 +65,25 @@ static rtx emit_add (rtx dest, rtx src0, rtx src1);
 static void expand_save_restore (struct lm32_frame_info *info, int op);
 static void stack_adjust (HOST_WIDE_INT amount);
 static bool lm32_in_small_data_p (const_tree);
-static void lm32_setup_incoming_varargs (CUMULATIVE_ARGS * cum,
+static void lm32_setup_incoming_varargs (cumulative_args_t cum,
                                         enum machine_mode mode, tree type,
                                         int *pretend_size, int no_rtl);
-static bool lm32_rtx_costs (rtx x, int code, int outer_code, int *total,
-                           bool speed);
+static bool lm32_rtx_costs (rtx x, int code, int outer_code, int opno,
+                           int *total, bool speed);
 static bool lm32_can_eliminate (const int, const int);
 static bool
 lm32_legitimate_address_p (enum machine_mode mode, rtx x, bool strict);
 static HOST_WIDE_INT lm32_compute_frame_size (int size);
 static void lm32_option_override (void);
-static rtx lm32_function_arg (CUMULATIVE_ARGS * cum,
+static rtx lm32_function_arg (cumulative_args_t cum,
                              enum machine_mode mode, const_tree type,
                              bool named);
-static void lm32_function_arg_advance (CUMULATIVE_ARGS * cum,
+static void lm32_function_arg_advance (cumulative_args_t cum,
                                       enum machine_mode mode,
                                       const_tree type, bool named);
 
-/* Implement TARGET_OPTION_OPTIMIZATION_TABLE.  */
-static const struct default_options lm32_option_optimization_table[] =
-  {
-    { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },
-    { OPT_LEVELS_NONE, 0, NULL, 0 }
-  };
-
 #undef TARGET_OPTION_OVERRIDE
 #define TARGET_OPTION_OVERRIDE lm32_option_override
-#undef TARGET_OPTION_OPTIMIZATION_TABLE
-#define TARGET_OPTION_OPTIMIZATION_TABLE lm32_option_optimization_table
 #undef TARGET_ADDRESS_COST
 #define TARGET_ADDRESS_COST hook_int_rtx_bool_0
 #undef TARGET_RTX_COSTS
@@ -175,6 +165,9 @@ gen_int_relational (enum rtx_code code,
 {
   enum machine_mode mode;
   int branch_p;
+  rtx temp;
+  rtx cond;
+  rtx label;
 
   mode = GET_MODE (cmp0);
   if (mode == VOIDmode)
@@ -191,18 +184,22 @@ gen_int_relational (enum rtx_code code,
     case LT:
     case LEU:
     case LTU:
-      code = swap_condition (code);
-      rtx temp = cmp0;
-      cmp0 = cmp1;
-      cmp1 = temp;
-      break;
+      {
+       rtx temp;
+
+       code = swap_condition (code);
+       temp = cmp0;
+       cmp0 = cmp1;
+       cmp1 = temp;
+       break;
+      }
     default:
       break;
     }
 
   if (branch_p)
     {
-      rtx insn;
+      rtx insn, cond, label;
 
       /* Operands must be in registers.  */
       if (!register_operand (cmp0, mode))
@@ -211,8 +208,8 @@ gen_int_relational (enum rtx_code code,
        cmp1 = force_reg (mode, cmp1);
 
       /* Generate conditional branch instruction.  */
-      rtx cond = gen_rtx_fmt_ee (code, mode, cmp0, cmp1);
-      rtx label = gen_rtx_LABEL_REF (VOIDmode, destination);
+      cond = gen_rtx_fmt_ee (code, mode, cmp0, cmp1);
+      label = gen_rtx_LABEL_REF (VOIDmode, destination);
       insn = gen_rtx_SET (VOIDmode, pc_rtx,
                          gen_rtx_IF_THEN_ELSE (VOIDmode,
                                                cond, label, pc_rtx));
@@ -386,18 +383,17 @@ lm32_expand_prologue (void)
       /* Setup frame pointer if it's needed.  */
       if (frame_pointer_needed == 1)
        {
-         /* Load offset - Don't use total_size, as that includes pretend_size, 
-             which isn't part of this frame?  */
-         insn =
-           emit_move_insn (frame_pointer_rtx,
-                           GEN_INT (current_frame_info.args_size +
-                                    current_frame_info.callee_size +
-                                    current_frame_info.locals_size));
-         RTX_FRAME_RELATED_P (insn) = 1;
+         /* Move sp to fp.  */
+         insn = emit_move_insn (frame_pointer_rtx, stack_pointer_rtx);
+         RTX_FRAME_RELATED_P (insn) = 1; 
 
-         /* Add in sp.  */
-         insn = emit_add (frame_pointer_rtx,
-                          frame_pointer_rtx, stack_pointer_rtx);
+         /* Add offset - Don't use total_size, as that includes pretend_size, 
+             which isn't part of this frame?  */
+         insn = emit_add (frame_pointer_rtx, 
+                          frame_pointer_rtx,
+                          GEN_INT (current_frame_info.args_size +
+                                   current_frame_info.callee_size +
+                                   current_frame_info.locals_size));
          RTX_FRAME_RELATED_P (insn) = 1;
        }
 
@@ -519,7 +515,7 @@ lm32_print_operand (FILE * file, rtx op, int letter)
   else if (GET_CODE (op) == CONST_DOUBLE)
     {
       if ((CONST_DOUBLE_LOW (op) != 0) || (CONST_DOUBLE_HIGH (op) != 0))
-       output_operand_lossage ("Only 0.0 can be loaded as an immediate");
+       output_operand_lossage ("only 0.0 can be loaded as an immediate");
       else
        fprintf (file, "0");
     }
@@ -624,9 +620,11 @@ lm32_print_operand_address (FILE * file, rtx addr)
     (otherwise it is an extra parameter matching an ellipsis).  */
 
 static rtx
-lm32_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+lm32_function_arg (cumulative_args_t cum_v, enum machine_mode mode,
                   const_tree type, bool named)
 {
+  CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v);
+
   if (mode == VOIDmode)
     /* Compute operand 2 of the call insn.  */
     return GEN_INT (0);
@@ -641,10 +639,10 @@ lm32_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode,
 }
 
 static void
-lm32_function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+lm32_function_arg_advance (cumulative_args_t cum, enum machine_mode mode,
                           const_tree type, bool named ATTRIBUTE_UNUSED)
 {
-  *cum += LM32_NUM_REGS2 (mode, type);
+  *get_cumulative_args (cum) += LM32_NUM_REGS2 (mode, type);
 }
 
 HOST_WIDE_INT
@@ -677,9 +675,10 @@ lm32_compute_initial_elimination_offset (int from, int to)
 }
 
 static void
-lm32_setup_incoming_varargs (CUMULATIVE_ARGS * cum, enum machine_mode mode,
+lm32_setup_incoming_varargs (cumulative_args_t cum_v, enum machine_mode mode,
                             tree type, int *pretend_size, int no_rtl)
 {
+  CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v);
   int first_anon_arg;
   tree fntype;
 
@@ -841,7 +840,7 @@ lm32_block_move_inline (rtx dest, rtx src, HOST_WIDE_INT length,
   delta = bits / BITS_PER_UNIT;
 
   /* Allocate a buffer for the temporary registers.  */
-  regs = alloca (sizeof (rtx) * length / delta);
+  regs = XALLOCAVEC (rtx, length / delta);
 
   /* Load as many BITS-sized chunks as possible.  */
   for (offset = 0, i = 0; offset + delta <= length; offset += delta, i++)
@@ -926,7 +925,8 @@ nonpic_symbol_mentioned_p (rtx x)
    scanned.  In either case, *TOTAL contains the cost result.  */
 
 static bool
-lm32_rtx_costs (rtx x, int code, int outer_code, int *total, bool speed)
+lm32_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED,
+               int *total, bool speed)
 {
   enum machine_mode mode = GET_MODE (x);
   bool small_mode;
@@ -1227,15 +1227,3 @@ lm32_move_ok (enum machine_mode mode, rtx operands[2]) {
     return register_or_zero_operand (operands[1], mode);
   return true;
 }
-
-/* Implement LEGITIMATE_CONSTANT_P.  */
-
-bool
-lm32_legitimate_constant_p (rtx x)
-{
-  /* 32-bit addresses require multiple instructions.  */  
-  if (!flag_pic && reloc_operand (x, GET_MODE (x)))
-    return false; 
-  
-  return true;
-}