OSDN Git Service

* config/iq2000/iq2000.c (function_arg): Handle TImode values.
[pf3gnuchains/gcc-fork.git] / gcc / config / iq2000 / iq2000.c
index 57e24ea..d853b1f 100644 (file)
@@ -1,11 +1,12 @@
 /* Subroutines used for code generation on Vitesse IQ2000 processors
-   Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
+   Free Software Foundation, Inc.
 
 This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GCC is distributed in the hope that it will be useful,
@@ -14,9 +15,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to
-the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
 #include "system.h"
@@ -89,7 +89,7 @@ struct iq2000_frame_info
   int  num_gp;                 /* Number of gp registers saved.  */
 } iq2000_frame_info;
 
-struct machine_function GTY(())
+struct GTY(()) machine_function
 {
   /* Current frame information, calculated by compute_frame_size.  */
   long total_size;             /* # bytes that the entire frame takes up.  */
@@ -154,21 +154,22 @@ static enum machine_mode gpr_mode;
 /* Initialize the GCC target structure.  */
 static struct machine_function* iq2000_init_machine_status (void);
 static bool iq2000_handle_option      (size_t, const char *, int);
-static void iq2000_select_rtx_section (enum machine_mode, rtx, unsigned HOST_WIDE_INT);
+static section *iq2000_select_rtx_section (enum machine_mode, rtx,
+                                          unsigned HOST_WIDE_INT);
 static void iq2000_init_builtins      (void);
 static rtx  iq2000_expand_builtin     (tree, rtx, rtx, enum machine_mode, int);
-static bool iq2000_return_in_memory   (tree, tree);
+static bool iq2000_return_in_memory   (const_tree, const_tree);
 static void iq2000_setup_incoming_varargs (CUMULATIVE_ARGS *,
                                           enum machine_mode, tree, int *,
                                           int);
-static bool iq2000_rtx_costs          (rtx, int, int, int *);
-static int  iq2000_address_cost       (rtx);
-static void iq2000_select_section     (tree, int, unsigned HOST_WIDE_INT);
-static bool iq2000_return_in_memory   (tree, tree);
+static bool iq2000_rtx_costs          (rtx, int, int, int *, bool);
+static int  iq2000_address_cost       (rtx, bool);
+static section *iq2000_select_section (tree, int, unsigned HOST_WIDE_INT);
 static bool iq2000_pass_by_reference  (CUMULATIVE_ARGS *, enum machine_mode,
-                                      tree, bool);
+                                      const_tree, bool);
 static int  iq2000_arg_partial_bytes  (CUMULATIVE_ARGS *, enum machine_mode,
                                       tree, bool);
+static void iq2000_va_start          (tree, rtx);
 
 #undef  TARGET_INIT_BUILTINS
 #define TARGET_INIT_BUILTINS           iq2000_init_builtins
@@ -185,12 +186,17 @@ static int  iq2000_arg_partial_bytes  (CUMULATIVE_ARGS *, enum machine_mode,
 #undef  TARGET_ASM_SELECT_SECTION
 #define TARGET_ASM_SELECT_SECTION      iq2000_select_section
 
+/* The assembler supports switchable .bss sections, but
+   iq2000_select_section doesn't yet make use of them.  */
+#undef  TARGET_HAVE_SWITCHABLE_BSS_SECTIONS
+#define TARGET_HAVE_SWITCHABLE_BSS_SECTIONS false
+
 #undef  TARGET_PROMOTE_FUNCTION_ARGS
-#define TARGET_PROMOTE_FUNCTION_ARGS   hook_bool_tree_true
+#define TARGET_PROMOTE_FUNCTION_ARGS   hook_bool_const_tree_true
 #undef  TARGET_PROMOTE_FUNCTION_RETURN
-#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_tree_true
+#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_const_tree_true
 #undef  TARGET_PROMOTE_PROTOTYPES
-#define TARGET_PROMOTE_PROTOTYPES      hook_bool_tree_true
+#define TARGET_PROMOTE_PROTOTYPES      hook_bool_const_tree_true
 
 #undef  TARGET_RETURN_IN_MEMORY
 #define TARGET_RETURN_IN_MEMORY                iq2000_return_in_memory
@@ -206,6 +212,9 @@ static int  iq2000_arg_partial_bytes  (CUMULATIVE_ARGS *, enum machine_mode,
 #undef  TARGET_STRICT_ARGUMENT_NAMING
 #define TARGET_STRICT_ARGUMENT_NAMING  hook_bool_CUMULATIVE_ARGS_true
 
+#undef TARGET_EXPAND_BUILTIN_VA_START
+#define        TARGET_EXPAND_BUILTIN_VA_START  iq2000_va_start
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
 /* Return nonzero if we split the address into high and low parts.  */
@@ -736,7 +745,7 @@ iq2000_move_1word (rtx operands[], rtx insn, int unsignedp)
 /* Provide the costs of an addressing mode that contains ADDR.  */
 
 static int
-iq2000_address_cost (rtx addr)
+iq2000_address_cost (rtx addr, bool speed)
 {
   switch (GET_CODE (addr))
     {
@@ -787,7 +796,7 @@ iq2000_address_cost (rtx addr)
          case LABEL_REF:
          case HIGH:
          case LO_SUM:
-           return iq2000_address_cost (plus1) + 1;
+           return iq2000_address_cost (plus1, speed) + 1;
 
          default:
            break;
@@ -929,15 +938,15 @@ gen_int_relational (enum rtx_code test_code, rtx result, rtx cmp0, rtx cmp1,
     {
       if (p_info->const_add != 0)
        {
-         HOST_WIDE_INT new = INTVAL (cmp1) + p_info->const_add;
+         HOST_WIDE_INT new_const = INTVAL (cmp1) + p_info->const_add;
 
          /* If modification of cmp1 caused overflow,
             we would get the wrong answer if we follow the usual path;
             thus, x > 0xffffffffU would turn into x > 0U.  */
          if ((p_info->unsignedp
-              ? (unsigned HOST_WIDE_INT) new >
+              ? (unsigned HOST_WIDE_INT) new_const >
               (unsigned HOST_WIDE_INT) INTVAL (cmp1)
-              : new > INTVAL (cmp1))
+              : new_const > INTVAL (cmp1))
              != (p_info->const_add > 0))
            {
              /* This test is always true, but if INVERT is true then
@@ -947,7 +956,7 @@ gen_int_relational (enum rtx_code test_code, rtx result, rtx cmp0, rtx cmp1,
              return result;
            }
          else
-           cmp1 = GEN_INT (new);
+           cmp1 = GEN_INT (new_const);
        }
     }
 
@@ -1124,7 +1133,7 @@ function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode, tree type,
               "function_adv({gp reg found = %d, arg # = %2d, words = %2d}, %4s, ",
               cum->gp_reg_found, cum->arg_number, cum->arg_words,
               GET_MODE_NAME (mode));
-      fprintf (stderr, HOST_PTR_PRINTF, (const PTR) type);
+      fprintf (stderr, "%p", (void *) type);
       fprintf (stderr, ", %d )\n\n", named);
     }
 
@@ -1166,6 +1175,11 @@ function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode, tree type,
       cum->arg_words += 2;
       break;
 
+    case TImode:
+      cum->gp_reg_found = 1;
+      cum->arg_words += 4;
+      break;
+
     case QImode:
     case HImode:
     case SImode:
@@ -1179,7 +1193,7 @@ function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode, tree type,
    and type TYPE in CUM, or 0 if the argument is to be passed on the stack.  */
 
 struct rtx_def *
-function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, tree type,
+function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, const_tree type,
              int named)
 {
   rtx ret;
@@ -1197,7 +1211,7 @@ function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, tree type,
               "function_arg( {gp reg found = %d, arg # = %2d, words = %2d}, %4s, ",
               cum->gp_reg_found, cum->arg_number, cum->arg_words,
               GET_MODE_NAME (mode));
-      fprintf (stderr, HOST_PTR_PRINTF, (const PTR) type);
+      fprintf (stderr, "%p", (const void *) type);
       fprintf (stderr, ", %d ) = ", named);
     }
 
@@ -1236,6 +1250,12 @@ function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, tree type,
     case DImode:
       cum->arg_words += (cum->arg_words & 1);
       regbase = GP_ARG_FIRST;
+      break;
+
+    case TImode:
+      cum->arg_words += (cum->arg_words & 3);
+      regbase = GP_ARG_FIRST;
+      break;
     }
 
   if (*arg_words >= (unsigned) MAX_ARGS_IN_REGISTERS)
@@ -1353,14 +1373,14 @@ iq2000_arg_partial_bytes (CUMULATIVE_ARGS *cum, enum machine_mode mode,
 \f
 /* Implement va_start.  */
 
-void
+static void
 iq2000_va_start (tree valist, rtx nextarg)
 {
   int int_arg_words;
   /* Find out how many non-float named formals.  */
   int gpr_save_area_size;
   /* Note UNITS_PER_WORD is 4 bytes.  */
-  int_arg_words = current_function_args_info.arg_words;
+  int_arg_words = crtl->args.info.arg_words;
 
   if (int_arg_words < 8 )
     /* Adjust for the prologue's economy measure.  */
@@ -1381,7 +1401,7 @@ iq2000_init_machine_status (void)
 {
   struct machine_function *f;
 
-  f = ggc_alloc_cleared (sizeof (struct machine_function));
+  f = GGC_CNEW (struct machine_function);
 
   return f;
 }
@@ -1607,11 +1627,11 @@ compute_frame_size (HOST_WIDE_INT size)
   mask = 0;
   extra_size = IQ2000_STACK_ALIGN ((0));
   var_size = IQ2000_STACK_ALIGN (size);
-  args_size = IQ2000_STACK_ALIGN (current_function_outgoing_args_size);
+  args_size = IQ2000_STACK_ALIGN (crtl->outgoing_args_size);
 
   /* If a function dynamically allocates the stack and
      has 0 for STACK_DYNAMIC_OFFSET then allocate some stack space.  */
-  if (args_size == 0 && current_function_calls_alloca)
+  if (args_size == 0 && cfun->calls_alloca)
     args_size = 4 * UNITS_PER_WORD;
 
   total_size = var_size + args_size + extra_size;
@@ -1627,7 +1647,7 @@ compute_frame_size (HOST_WIDE_INT size)
     }
 
   /* We need to restore these for the handler.  */
-  if (current_function_calls_eh_return)
+  if (crtl->calls_eh_return)
     {
       unsigned int i;
 
@@ -1652,7 +1672,7 @@ compute_frame_size (HOST_WIDE_INT size)
       && ! profile_flag)
     total_size = extra_size = 0;
 
-  total_size += IQ2000_STACK_ALIGN (current_function_pretend_args_size);
+  total_size += IQ2000_STACK_ALIGN (crtl->args.pretend_args_size);
 
   /* Save other computed information.  */
   cfun->machine->total_size = total_size;
@@ -1864,7 +1884,7 @@ iq2000_expand_prologue (void)
 
   /* If struct value address is treated as the first argument.  */
   if (aggregate_value_p (DECL_RESULT (fndecl), fndecl)
-      && ! current_function_returns_pcc_struct
+      && !cfun->returns_pcc_struct
       && targetm.calls.struct_value_rtx (TREE_TYPE (fndecl), 1) == 0)
     {
       tree type = build_pointer_type (fntype);
@@ -1958,13 +1978,6 @@ iq2000_expand_prologue (void)
          PUT_CODE (SET_SRC (pattern), ASHIFTRT);
 
          insn = emit_insn (pattern);
-
-         /* Global life information isn't valid at this point, so we
-            can't check whether these shifts are actually used.  Mark
-            them MAYBE_DEAD so that flow2 will remove them, and not
-            complain about dead code in the prologue.  */
-         REG_NOTES(insn) = gen_rtx_EXPR_LIST (REG_MAYBE_DEAD, NULL_RTX,
-                                              REG_NOTES (insn));
        }
     }
 
@@ -2063,7 +2076,7 @@ iq2000_expand_epilogue (void)
 
       save_restore_insns (0);
 
-      if (current_function_calls_eh_return)
+      if (crtl->calls_eh_return)
        {
          rtx eh_ofs = EH_RETURN_STACKADJ_RTX;
          emit_insn (gen_addsi3 (eh_ofs, eh_ofs, tsize_rtx));
@@ -2072,20 +2085,19 @@ iq2000_expand_epilogue (void)
 
       emit_insn (gen_blockage ());
 
-      if (tsize != 0 || current_function_calls_eh_return)
+      if (tsize != 0 || crtl->calls_eh_return)
        {
          emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
                                 tsize_rtx));
        }
     }
 
-  if (current_function_calls_eh_return)
+  if (crtl->calls_eh_return)
     {
       /* Perform the additional bump for __throw.  */
       emit_move_insn (gen_rtx_REG (Pmode, HARD_FRAME_POINTER_REGNUM),
                      stack_pointer_rtx);
-      emit_insn (gen_rtx_USE (VOIDmode, gen_rtx_REG (Pmode,
-                                                 HARD_FRAME_POINTER_REGNUM)));
+      emit_use (gen_rtx_REG (Pmode, HARD_FRAME_POINTER_REGNUM));
       emit_jump_insn (gen_eh_return_internal ());
     }
   else
@@ -2113,7 +2125,7 @@ iq2000_can_use_return_insn (void)
   if (! reload_completed)
     return 0;
 
-  if (regs_ever_live[31] || profile_flag)
+  if (df_regs_ever_live_p (31) || profile_flag)
     return 0;
 
   if (cfun->machine->initialized)
@@ -2146,15 +2158,13 @@ symbolic_expression_p (rtx x)
 /* Choose the section to use for the constant rtx expression X that has
    mode MODE.  */
 
-static void
+static section *
 iq2000_select_rtx_section (enum machine_mode mode, rtx x ATTRIBUTE_UNUSED,
                           unsigned HOST_WIDE_INT align)
 {
   /* For embedded applications, always put constants in read-only data,
      in order to reduce RAM usage.  */
-      /* For embedded applications, always put constants in read-only data,
-         in order to reduce RAM usage.  */
-  mergeable_constant_section (mode, align, 0);
+  return mergeable_constant_section (mode, align, 0);
 }
 
 /* Choose the section to use for DECL.  RELOC is true if its value contains
@@ -2164,7 +2174,7 @@ iq2000_select_rtx_section (enum machine_mode mode, rtx x ATTRIBUTE_UNUSED,
    ENCODE_SECTION_INFO in iq2000.h so that references to these symbols
    are done correctly.  */
 
-static void
+static section *
 iq2000_select_section (tree decl, int reloc ATTRIBUTE_UNUSED,
                       unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
 {
@@ -2179,9 +2189,9 @@ iq2000_select_section (tree decl, int reloc ATTRIBUTE_UNUSED,
               || TREE_CONSTANT (DECL_INITIAL (decl))))
          /* Deal with calls from output_constant_def_contents.  */
          || TREE_CODE (decl) != VAR_DECL)
-       readonly_data_section ();
+       return readonly_data_section;
       else
-       data_section ();
+       return data_section;
     }
   else
     {
@@ -2194,16 +2204,16 @@ iq2000_select_section (tree decl, int reloc ATTRIBUTE_UNUSED,
               || TREE_CONSTANT (DECL_INITIAL (decl))))
          /* Deal with calls from output_constant_def_contents.  */
          || TREE_CODE (decl) != VAR_DECL)
-       readonly_data_section ();
+       return readonly_data_section;
       else
-       data_section ();
+       return data_section;
     }
 }
 /* Return register to use for a function return value with VALTYPE for function
    FUNC.  */
 
 rtx
-iq2000_function_value (tree valtype, tree func ATTRIBUTE_UNUSED)
+iq2000_function_value (const_tree valtype, const_tree func ATTRIBUTE_UNUSED)
 {
   int reg = GP_RETURN;
   enum machine_mode mode = TYPE_MODE (valtype);
@@ -2220,7 +2230,7 @@ iq2000_function_value (tree valtype, tree func ATTRIBUTE_UNUSED)
 
 static bool
 iq2000_pass_by_reference (CUMULATIVE_ARGS *cum, enum machine_mode mode,
-                         tree type, bool named ATTRIBUTE_UNUSED)
+                         const_tree type, bool named ATTRIBUTE_UNUSED)
 {
   int size;
 
@@ -2432,8 +2442,8 @@ iq2000_output_conditional_branch (rtx insn, rtx * operands, int two_operands_p,
 }
 
 #define def_builtin(NAME, TYPE, CODE)                                  \
-  lang_hooks.builtin_function ((NAME), (TYPE), (CODE), BUILT_IN_MD,    \
-                              NULL, NULL_TREE)
+  add_builtin_function ((NAME), (TYPE), (CODE), BUILT_IN_MD,   \
+                      NULL, NULL_TREE)
 
 static void
 iq2000_init_builtins (void)
@@ -2565,11 +2575,11 @@ void_ftype_int_int_int
   def_builtin ("__builtin_syscall", void_ftype, IQ2000_BUILTIN_SYSCALL);
 }
 
-/* Builtin for ICODE having ARGCOUNT args in ARGLIST where each arg
+/* Builtin for ICODE having ARGCOUNT args in EXP where each arg
    has an rtx CODE.  */
 
 static rtx
-expand_one_builtin (enum insn_code icode, rtx target, tree arglist,
+expand_one_builtin (enum insn_code icode, rtx target, tree exp,
                    enum rtx_code *code, int argcount)
 {
   rtx pat;
@@ -2581,8 +2591,7 @@ expand_one_builtin (enum insn_code icode, rtx target, tree arglist,
   mode[0] = insn_data[icode].operand[0].mode;
   for (i = 0; i < argcount; i++)
     {
-      arg[i] = TREE_VALUE (arglist);
-      arglist = TREE_CHAIN (arglist);
+      arg[i] = CALL_EXPR_ARG (exp, i);
       op[i] = expand_expr (arg[i], NULL_RTX, VOIDmode, 0);
       mode[i] = insn_data[icode].operand[i].mode;
       if (code[i] == CONST_INT && GET_CODE (op[i]) != CONST_INT)
@@ -2651,8 +2660,7 @@ iq2000_expand_builtin (tree exp, rtx target, rtx subtarget ATTRIBUTE_UNUSED,
                       enum machine_mode mode ATTRIBUTE_UNUSED,
                       int ignore ATTRIBUTE_UNUSED)
 {
-  tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
-  tree arglist = TREE_OPERAND (exp, 1);
+  tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
   int fcode = DECL_FUNCTION_CODE (fndecl);
   enum rtx_code code [5];
 
@@ -2667,162 +2675,162 @@ iq2000_expand_builtin (tree exp, rtx target, rtx subtarget ATTRIBUTE_UNUSED,
       break;
       
     case IQ2000_BUILTIN_ADO16:
-      return expand_one_builtin (CODE_FOR_ado16, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_ado16, target, exp, code, 2);
 
     case IQ2000_BUILTIN_RAM:
       code[1] = CONST_INT;
       code[2] = CONST_INT;
       code[3] = CONST_INT;
-      return expand_one_builtin (CODE_FOR_ram, target, arglist, code, 4);
+      return expand_one_builtin (CODE_FOR_ram, target, exp, code, 4);
       
     case IQ2000_BUILTIN_CHKHDR:
-      return expand_one_builtin (CODE_FOR_chkhdr, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_chkhdr, target, exp, code, 2);
       
     case IQ2000_BUILTIN_PKRL:
-      return expand_one_builtin (CODE_FOR_pkrl, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_pkrl, target, exp, code, 2);
 
     case IQ2000_BUILTIN_CFC0:
       code[0] = CONST_INT;
-      return expand_one_builtin (CODE_FOR_cfc0, target, arglist, code, 1);
+      return expand_one_builtin (CODE_FOR_cfc0, target, exp, code, 1);
 
     case IQ2000_BUILTIN_CFC1:
       code[0] = CONST_INT;
-      return expand_one_builtin (CODE_FOR_cfc1, target, arglist, code, 1);
+      return expand_one_builtin (CODE_FOR_cfc1, target, exp, code, 1);
 
     case IQ2000_BUILTIN_CFC2:
       code[0] = CONST_INT;
-      return expand_one_builtin (CODE_FOR_cfc2, target, arglist, code, 1);
+      return expand_one_builtin (CODE_FOR_cfc2, target, exp, code, 1);
 
     case IQ2000_BUILTIN_CFC3:
       code[0] = CONST_INT;
-      return expand_one_builtin (CODE_FOR_cfc3, target, arglist, code, 1);
+      return expand_one_builtin (CODE_FOR_cfc3, target, exp, code, 1);
 
     case IQ2000_BUILTIN_CTC0:
       code[1] = CONST_INT;
-      return expand_one_builtin (CODE_FOR_ctc0, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_ctc0, target, exp, code, 2);
 
     case IQ2000_BUILTIN_CTC1:
       code[1] = CONST_INT;
-      return expand_one_builtin (CODE_FOR_ctc1, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_ctc1, target, exp, code, 2);
 
     case IQ2000_BUILTIN_CTC2:
       code[1] = CONST_INT;
-      return expand_one_builtin (CODE_FOR_ctc2, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_ctc2, target, exp, code, 2);
 
     case IQ2000_BUILTIN_CTC3:
       code[1] = CONST_INT;
-      return expand_one_builtin (CODE_FOR_ctc3, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_ctc3, target, exp, code, 2);
 
     case IQ2000_BUILTIN_MFC0:
       code[0] = CONST_INT;
-      return expand_one_builtin (CODE_FOR_mfc0, target, arglist, code, 1);
+      return expand_one_builtin (CODE_FOR_mfc0, target, exp, code, 1);
 
     case IQ2000_BUILTIN_MFC1:
       code[0] = CONST_INT;
-      return expand_one_builtin (CODE_FOR_mfc1, target, arglist, code, 1);
+      return expand_one_builtin (CODE_FOR_mfc1, target, exp, code, 1);
 
     case IQ2000_BUILTIN_MFC2:
       code[0] = CONST_INT;
-      return expand_one_builtin (CODE_FOR_mfc2, target, arglist, code, 1);
+      return expand_one_builtin (CODE_FOR_mfc2, target, exp, code, 1);
 
     case IQ2000_BUILTIN_MFC3:
       code[0] = CONST_INT;
-      return expand_one_builtin (CODE_FOR_mfc3, target, arglist, code, 1);
+      return expand_one_builtin (CODE_FOR_mfc3, target, exp, code, 1);
 
     case IQ2000_BUILTIN_MTC0:
       code[1] = CONST_INT;
-      return expand_one_builtin (CODE_FOR_mtc0, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_mtc0, target, exp, code, 2);
 
     case IQ2000_BUILTIN_MTC1:
       code[1] = CONST_INT;
-      return expand_one_builtin (CODE_FOR_mtc1, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_mtc1, target, exp, code, 2);
 
     case IQ2000_BUILTIN_MTC2:
       code[1] = CONST_INT;
-      return expand_one_builtin (CODE_FOR_mtc2, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_mtc2, target, exp, code, 2);
 
     case IQ2000_BUILTIN_MTC3:
       code[1] = CONST_INT;
-      return expand_one_builtin (CODE_FOR_mtc3, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_mtc3, target, exp, code, 2);
 
     case IQ2000_BUILTIN_LUR:
-      return expand_one_builtin (CODE_FOR_lur, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_lur, target, exp, code, 2);
 
     case IQ2000_BUILTIN_RB:
-      return expand_one_builtin (CODE_FOR_rb, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_rb, target, exp, code, 2);
 
     case IQ2000_BUILTIN_RX:
-      return expand_one_builtin (CODE_FOR_rx, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_rx, target, exp, code, 2);
 
     case IQ2000_BUILTIN_SRRD:
-      return expand_one_builtin (CODE_FOR_srrd, target, arglist, code, 1);
+      return expand_one_builtin (CODE_FOR_srrd, target, exp, code, 1);
 
     case IQ2000_BUILTIN_SRWR:
-      return expand_one_builtin (CODE_FOR_srwr, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_srwr, target, exp, code, 2);
 
     case IQ2000_BUILTIN_WB:
-      return expand_one_builtin (CODE_FOR_wb, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_wb, target, exp, code, 2);
 
     case IQ2000_BUILTIN_WX:
-      return expand_one_builtin (CODE_FOR_wx, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_wx, target, exp, code, 2);
 
     case IQ2000_BUILTIN_LUC32L:
-      return expand_one_builtin (CODE_FOR_luc32l, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_luc32l, target, exp, code, 2);
 
     case IQ2000_BUILTIN_LUC64:
-      return expand_one_builtin (CODE_FOR_luc64, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_luc64, target, exp, code, 2);
 
     case IQ2000_BUILTIN_LUC64L:
-      return expand_one_builtin (CODE_FOR_luc64l, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_luc64l, target, exp, code, 2);
 
     case IQ2000_BUILTIN_LUK:
-      return expand_one_builtin (CODE_FOR_luk, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_luk, target, exp, code, 2);
 
     case IQ2000_BUILTIN_LULCK:
-      return expand_one_builtin (CODE_FOR_lulck, target, arglist, code, 1);
+      return expand_one_builtin (CODE_FOR_lulck, target, exp, code, 1);
 
     case IQ2000_BUILTIN_LUM32:
-      return expand_one_builtin (CODE_FOR_lum32, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_lum32, target, exp, code, 2);
 
     case IQ2000_BUILTIN_LUM32L:
-      return expand_one_builtin (CODE_FOR_lum32l, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_lum32l, target, exp, code, 2);
 
     case IQ2000_BUILTIN_LUM64:
-      return expand_one_builtin (CODE_FOR_lum64, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_lum64, target, exp, code, 2);
 
     case IQ2000_BUILTIN_LUM64L:
-      return expand_one_builtin (CODE_FOR_lum64l, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_lum64l, target, exp, code, 2);
 
     case IQ2000_BUILTIN_LURL:
-      return expand_one_builtin (CODE_FOR_lurl, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_lurl, target, exp, code, 2);
 
     case IQ2000_BUILTIN_MRGB:
       code[2] = CONST_INT;
-      return expand_one_builtin (CODE_FOR_mrgb, target, arglist, code, 3);
+      return expand_one_builtin (CODE_FOR_mrgb, target, exp, code, 3);
 
     case IQ2000_BUILTIN_SRRDL:
-      return expand_one_builtin (CODE_FOR_srrdl, target, arglist, code, 1);
+      return expand_one_builtin (CODE_FOR_srrdl, target, exp, code, 1);
 
     case IQ2000_BUILTIN_SRULCK:
-      return expand_one_builtin (CODE_FOR_srulck, target, arglist, code, 1);
+      return expand_one_builtin (CODE_FOR_srulck, target, exp, code, 1);
 
     case IQ2000_BUILTIN_SRWRU:
-      return expand_one_builtin (CODE_FOR_srwru, target, arglist, code, 2);
+      return expand_one_builtin (CODE_FOR_srwru, target, exp, code, 2);
 
     case IQ2000_BUILTIN_TRAPQFL:
-      return expand_one_builtin (CODE_FOR_trapqfl, target, arglist, code, 0);
+      return expand_one_builtin (CODE_FOR_trapqfl, target, exp, code, 0);
 
     case IQ2000_BUILTIN_TRAPQNE:
-      return expand_one_builtin (CODE_FOR_trapqne, target, arglist, code, 0);
+      return expand_one_builtin (CODE_FOR_trapqne, target, exp, code, 0);
 
     case IQ2000_BUILTIN_TRAPREL:
-      return expand_one_builtin (CODE_FOR_traprel, target, arglist, code, 1);
+      return expand_one_builtin (CODE_FOR_traprel, target, exp, code, 1);
 
     case IQ2000_BUILTIN_WBU:
-      return expand_one_builtin (CODE_FOR_wbu, target, arglist, code, 3);
+      return expand_one_builtin (CODE_FOR_wbu, target, exp, code, 3);
 
     case IQ2000_BUILTIN_SYSCALL:
-      return expand_one_builtin (CODE_FOR_syscall, target, arglist, code, 0);
+      return expand_one_builtin (CODE_FOR_syscall, target, exp, code, 0);
     }
   
   return NULL_RTX;
@@ -2831,7 +2839,7 @@ iq2000_expand_builtin (tree exp, rtx target, rtx subtarget ATTRIBUTE_UNUSED,
 /* Worker function for TARGET_RETURN_IN_MEMORY.  */
 
 static bool
-iq2000_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED)
+iq2000_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED)
 {
   return ((int_size_in_bytes (type) > (2 * UNITS_PER_WORD))
          || (int_size_in_bytes (type) == -1));
@@ -3207,7 +3215,8 @@ print_operand (FILE *file, rtx op, int letter)
 }
 
 static bool
-iq2000_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, int * total)
+iq2000_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, int * total,
+                 bool speed ATTRIBUTE_UNUSED)
 {
   enum machine_mode mode = GET_MODE (x);