re PR target/44755 (picochip.md enum types mismatch)
[gcc.git] / gcc / config / picochip / picochip.c
index f494b957687e04a2e7b9baf48576a3f1e8ccd9a2..2e82247ad2eb6adbe8ef7a6f8603ebb57847f633 100644 (file)
@@ -198,6 +198,13 @@ static struct recog_data picochip_saved_recog_data;
 /* Determine which ALU to use for the instruction in
    picochip_current_prescan_insn. */
 static char picochip_get_vliw_alu_id (void);
+
+/* Implement TARGET_OPTION_OPTIMIZATION_TABLE.  */
+static const struct default_options picochip_option_optimization_table[] =
+  {
+    { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },
+    { OPT_LEVELS_NONE, 0, NULL, 0 }
+  };
 \f
 /* Initialize the GCC target structure.  */
 
@@ -326,6 +333,9 @@ static char picochip_get_vliw_alu_id (void);
 #undef TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE
 #define TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE picochip_option_override
 
+#undef TARGET_OPTION_OPTIMIZATION_TABLE
+#define TARGET_OPTION_OPTIMIZATION_TABLE picochip_option_optimization_table
+
 #undef TARGET_EXCEPT_UNWIND_INFO
 #define TARGET_EXCEPT_UNWIND_INFO sjlj_except_unwind_info
 
@@ -354,8 +364,12 @@ picochip_option_override (void)
      that could potentially increase stack size.*/
    if (flag_conserve_stack)
      {
-       maybe_set_param_value (PARAM_LARGE_STACK_FRAME, 0);
-       maybe_set_param_value (PARAM_STACK_FRAME_GROWTH, 0);
+       maybe_set_param_value (PARAM_LARGE_STACK_FRAME, 0,
+                             global_options.x_param_values,
+                             global_options_set.x_param_values);
+       maybe_set_param_value (PARAM_STACK_FRAME_GROWTH, 0,
+                             global_options.x_param_values,
+                             global_options_set.x_param_values);
      }
 
   /* Turn off the elimination of unused types. The elaborator
@@ -671,12 +685,10 @@ picochip_emit_stack_allocate (int adjustment)
      so that the correct Dwarf information is generated (see documention
      for RTX_FRAME_RELATED_P for more details). */
   RTX_FRAME_RELATED_P (insn) = 1;
-  REG_NOTES (insn) =
-    gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR,
-                      gen_rtx_SET (VOIDmode, stack_pointer_reg,
-                                   gen_rtx_PLUS (Pmode, stack_pointer_reg,
-                                                 GEN_INT (-adjustment))),
-                      REG_NOTES (insn));
+  add_reg_note (insn, REG_FRAME_RELATED_EXPR,
+               gen_rtx_SET (VOIDmode, stack_pointer_reg,
+                            gen_rtx_PLUS (Pmode, stack_pointer_reg,
+                                          GEN_INT (-adjustment))));
 
 }
 
@@ -729,10 +741,8 @@ picochip_emit_save_register (rtx reg, int offset)
                       gen_rtx_REG (HImode, REGNO (reg) + 1));
        RTX_FRAME_RELATED_P (RTVEC_ELT (p, 1)) = 1;
 
-       REG_NOTES (insn) =
-         gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR,
-                            gen_rtx_PARALLEL (VOIDmode, p),
-                            REG_NOTES (insn));
+       add_reg_note (insn, REG_FRAME_RELATED_EXPR,
+                     gen_rtx_PARALLEL (VOIDmode, p));
 
       }
       break;
@@ -751,7 +761,7 @@ picochip_emit_save_register (rtx reg, int offset)
 static void
 picochip_emit_restore_register (rtx reg, int offset)
 {
-  rtx stack_pointer, address, mem, insn;
+  rtx stack_pointer, address, mem;
 
   stack_pointer = gen_rtx_REG (Pmode, STACK_POINTER_REGNUM);
 
@@ -759,7 +769,7 @@ picochip_emit_restore_register (rtx reg, int offset)
 
   mem = gen_rtx_MEM (GET_MODE (reg), address);
 
-  insn = emit_move_insn (reg, mem);
+  emit_move_insn (reg, mem);
 
 }
 
@@ -1463,7 +1473,7 @@ picochip_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED,
     {
       int high_val, low_val, offset;
       offset = INTVAL (XEXP (x, 1));
-      // Ignore cases with negative offsets.
+      /* Ignore cases with negative offsets.  */
       if (offset < 0)
         return x;
       high_val = offset & mask_val;
@@ -1520,7 +1530,7 @@ picochip_legitimize_reload_address (rtx *x,
       return 1;
     }
 
-  // Depending on mode, the offsets allowed are either 16/32/64.
+  /* Depending on mode, the offsets allowed are either 16/32/64.  */
   switch (mode)
     {
       case QImode:
@@ -1542,7 +1552,7 @@ picochip_legitimize_reload_address (rtx *x,
     {
       int high_val, low_val, offset;
       offset = INTVAL (XEXP (*x, 1));
-      // Ignore cases with negative offsets.
+      /* Ignore cases with negative offsets.  */
       if (offset < 0)
         return 0;
       high_val = offset & mask_val;
@@ -2285,8 +2295,7 @@ picochip_is_short_branch (rtx insn)
   int isRealShortBranch = (get_attr_length(insn) == SHORT_BRANCH_LENGTH);
 
   return (isRealShortBranch ||
-         (!isRealShortBranch &&
-          picochip_current_vliw_state.num_insns_in_packet > 1));
+         picochip_current_vliw_state.num_insns_in_packet > 1);
 }
 
 /* Output a compare-and-branch instruction (matching the cbranch
@@ -3183,7 +3192,6 @@ reorder_var_tracking_notes (void)
   FOR_EACH_BB (bb)
     {
       rtx insn, next, last_insn = NULL_RTX;
-      rtx vliw_start = NULL_RTX;
       rtx queue = NULL_RTX;
 
       /* Iterate through the bb and find the last non-debug insn */
@@ -3349,7 +3357,9 @@ picochip_reorg (void)
 
       if (last_insn_in_packet != NULL)
        {
-          rtx tmp_note = emit_note_after (NOTE_KIND(prologue_end_note), last_insn_in_packet);
+          rtx tmp_note
+           = emit_note_after ((enum insn_note) NOTE_KIND (prologue_end_note),
+                              last_insn_in_packet);
           memcpy(&NOTE_DATA (tmp_note), &NOTE_DATA(prologue_end_note), sizeof(NOTE_DATA(prologue_end_note)));
          delete_insn (prologue_end_note);
        }
@@ -3924,7 +3934,7 @@ picochip_expand_builtin_2op (enum insn_code icode, tree call, rtx target)
 
   /* Grab the incoming argument and emit its RTL. */
   arg0 = CALL_EXPR_ARG (call, 0);
-  op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
+  op0 = expand_expr (arg0, NULL_RTX, VOIDmode, EXPAND_NORMAL);
 
   /* Determine the modes of the instruction operands. */
   tmode = insn_data[icode].operand[0].mode;
@@ -3965,8 +3975,8 @@ picochip_expand_builtin_3op (enum insn_code icode, tree call, rtx target)
   arg1 = CALL_EXPR_ARG (call, 1);
 
   /* Emit rtl sequences for the function arguments. */
-  op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
-  op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
+  op0 = expand_expr (arg0, NULL_RTX, VOIDmode, EXPAND_NORMAL);
+  op1 = expand_expr (arg1, NULL_RTX, VOIDmode, EXPAND_NORMAL);
 
   /* Get the mode's of each of the instruction operands. */
   tmode = insn_data[icode].operand[0].mode;
@@ -4009,8 +4019,8 @@ picochip_expand_builtin_2opvoid (enum insn_code icode, tree call)
   arg1 = CALL_EXPR_ARG (call, 1);
 
   /* Emit rtl sequences for the function arguments. */
-  op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
-  op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
+  op0 = expand_expr (arg0, NULL_RTX, VOIDmode, EXPAND_NORMAL);
+  op1 = expand_expr (arg1, NULL_RTX, VOIDmode, EXPAND_NORMAL);
 
   /* Get the mode's of each of the instruction operands. */
   mode0 = insn_data[icode].operand[0].mode;
@@ -4046,9 +4056,9 @@ picochip_expand_array_get (tree call, rtx target)
   arg2 = CALL_EXPR_ARG (call, 2) ;
 
   /* Emit rtl sequences for the function arguments. */
-  op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
-  op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
-  op2 = expand_expr (arg2, NULL_RTX, VOIDmode, 0);
+  op0 = expand_expr (arg0, NULL_RTX, VOIDmode, EXPAND_NORMAL);
+  op1 = expand_expr (arg1, NULL_RTX, VOIDmode, EXPAND_NORMAL);
+  op2 = expand_expr (arg2, NULL_RTX, VOIDmode, EXPAND_NORMAL);
 
   /* The second and third operands must be constant.  Nothing else will
      do. */
@@ -4091,10 +4101,10 @@ picochip_expand_array_put (tree call, rtx target)
   arg3 = CALL_EXPR_ARG (call, 3);
 
   /* Emit rtl sequences for the function arguments. */
-  op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
-  op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
-  op2 = expand_expr (arg2, NULL_RTX, VOIDmode, 0);
-  op3 = expand_expr (arg3, NULL_RTX, VOIDmode, 0);
+  op0 = expand_expr (arg0, NULL_RTX, VOIDmode, EXPAND_NORMAL);
+  op1 = expand_expr (arg1, NULL_RTX, VOIDmode, EXPAND_NORMAL);
+  op2 = expand_expr (arg2, NULL_RTX, VOIDmode, EXPAND_NORMAL);
+  op3 = expand_expr (arg3, NULL_RTX, VOIDmode, EXPAND_NORMAL);
 
   /* The first operand must be an SImode register. */
   if (GET_MODE (op0) != SImode || REG != GET_CODE (op0))
@@ -4134,9 +4144,9 @@ picochip_expand_array_testport (tree call, rtx target)
   arg2 = CALL_EXPR_ARG (call, 2);
 
   /* Emit rtl sequences for the function arguments. */
-  op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
-  op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
-  op2 = expand_expr (arg2, NULL_RTX, VOIDmode, 0);
+  op0 = expand_expr (arg0, NULL_RTX, VOIDmode, EXPAND_NORMAL);
+  op1 = expand_expr (arg1, NULL_RTX, VOIDmode, EXPAND_NORMAL);
+  op2 = expand_expr (arg2, NULL_RTX, VOIDmode, EXPAND_NORMAL);
 
   /* The first operand must be a HImode register, or a constant.  If it
      isn't, force it into a HImode register. */
@@ -4211,30 +4221,18 @@ picochip_init_builtins (void)
     tree_cons (NULL_TREE, integer_type_node, int_int_endlink);
   tree int_long_endlink =
     tree_cons (NULL_TREE, integer_type_node, long_endlink);
-  tree pchar_type_node = build_pointer_type (char_type_node);
   tree long_int_int_int_endlink =
     tree_cons (NULL_TREE, long_integer_type_node, int_int_int_endlink);
 
-  tree int_ftype_void, int_ftype_int, int_ftype_int_int, void_ftype_pchar;
-  tree long_ftype_int, long_ftype_int_int, long_ftype_int_int_int;
+  tree int_ftype_int, int_ftype_int_int;
+  tree long_ftype_int, long_ftype_int_int_int;
   tree void_ftype_int_long, int_ftype_int_int_int,
     void_ftype_long_int_int_int;
-  tree void_ftype_void, void_ftype_int, unsigned_ftype_unsigned;
+  tree void_ftype_void, unsigned_ftype_unsigned;
 
   /* void func (void) */
   void_ftype_void = build_function_type (void_type_node, endlink);
 
-  /* void func (void *) */
-  void_ftype_pchar
-    = build_function_type (void_type_node,
-                          tree_cons (NULL_TREE, pchar_type_node, endlink));
-
-  /* int func (void) */
-  int_ftype_void = build_function_type (integer_type_node, endlink);
-
-  /* void func (int) */
-  void_ftype_int = build_function_type (void_type_node, int_endlink);
-
   /* int func (int) */
   int_ftype_int = build_function_type (integer_type_node, int_endlink);
 
@@ -4248,10 +4246,6 @@ picochip_init_builtins (void)
   /* long func(int) */
   long_ftype_int = build_function_type (long_integer_type_node, int_endlink);
 
-  /* long func(int, int) */
-  long_ftype_int_int
-    = build_function_type (long_integer_type_node, int_int_endlink);
-
   /* long func(int, int, int) */
   long_ftype_int_int_int
     = build_function_type (long_integer_type_node, int_int_int_endlink);