OSDN Git Service

./:
[pf3gnuchains/gcc-fork.git] / gcc / builtins.c
index b704394..8476f00 100644 (file)
@@ -1169,7 +1169,7 @@ get_memory_rtx (tree exp, tree len)
          gcc_assert (TREE_CODE (inner) == COMPONENT_REF);
 
          if (MEM_OFFSET (mem)
-             && GET_CODE (MEM_OFFSET (mem)) == CONST_INT)
+             && CONST_INT_P (MEM_OFFSET (mem)))
            offset = INTVAL (MEM_OFFSET (mem));
 
          if (offset >= 0 && len && host_integerp (len, 0))
@@ -1532,7 +1532,7 @@ expand_builtin_apply (rtx function, rtx arguments, rtx argsize)
 
   dest = virtual_outgoing_args_rtx;
 #ifndef STACK_GROWS_DOWNWARD
-  if (GET_CODE (argsize) == CONST_INT)
+  if (CONST_INT_P (argsize))
     dest = plus_constant (dest, -INTVAL (argsize));
   else
     dest = gen_rtx_PLUS (Pmode, dest, negate_rtx (Pmode, argsize));
@@ -1975,6 +1975,8 @@ expand_builtin_mathfn (tree exp, rtx target, rtx subtarget)
       /* Else fallthrough and expand as rint.  */
     CASE_FLT_FN (BUILT_IN_RINT):
       builtin_optab = rint_optab; break;
+    CASE_FLT_FN (BUILT_IN_SIGNIFICAND):
+      builtin_optab = significand_optab; break;
     default:
       gcc_unreachable ();
     }
@@ -3401,7 +3403,7 @@ expand_builtin_memcpy (tree exp, rtx target, enum machine_mode mode)
         by pieces, we can avoid loading the string from memory
         and only stored the computed constants.  */
       if (src_str
-         && GET_CODE (len_rtx) == CONST_INT
+         && CONST_INT_P (len_rtx)
          && (unsigned HOST_WIDE_INT) INTVAL (len_rtx) <= strlen (src_str) + 1
          && can_store_by_pieces (INTVAL (len_rtx), builtin_memcpy_read_str,
                                  CONST_CAST (char *, src_str),
@@ -3519,7 +3521,7 @@ expand_builtin_mempcpy_args (tree dest, tree src, tree len, tree type,
         by pieces, we can avoid loading the string from memory
         and only stored the computed constants.  */
       if (src_str
-         && GET_CODE (len_rtx) == CONST_INT
+         && CONST_INT_P (len_rtx)
          && (unsigned HOST_WIDE_INT) INTVAL (len_rtx) <= strlen (src_str) + 1
          && can_store_by_pieces (INTVAL (len_rtx), builtin_memcpy_read_str,
                                  CONST_CAST (char *, src_str),
@@ -3536,7 +3538,7 @@ expand_builtin_mempcpy_args (tree dest, tree src, tree len, tree type,
          return dest_mem;
        }
 
-      if (GET_CODE (len_rtx) == CONST_INT
+      if (CONST_INT_P (len_rtx)
          && can_move_by_pieces (INTVAL (len_rtx),
                                 MIN (dest_align, src_align)))
        {
@@ -3784,7 +3786,7 @@ expand_builtin_stpcpy (tree exp, rtx target, enum machine_mode mode)
        {
          rtx len_rtx = expand_normal (len);
 
-         if (GET_CODE (len_rtx) == CONST_INT)
+         if (CONST_INT_P (len_rtx))
            {
              ret = expand_builtin_strcpy_args (get_callee_fndecl (exp),
                                                dst, src, target, mode);
@@ -4189,10 +4191,10 @@ expand_builtin_memcmp (tree exp, rtx target, enum machine_mode mode)
 
     arg1_rtx = get_memory_rtx (arg1, len);
     arg2_rtx = get_memory_rtx (arg2, len);
-    arg3_rtx = expand_normal (len);
+    arg3_rtx = expand_normal (fold_convert (sizetype, len));
 
     /* Set MEM_SIZE as appropriate.  */
-    if (GET_CODE (arg3_rtx) == CONST_INT)
+    if (CONST_INT_P (arg3_rtx))
       {
        set_mem_size (arg1_rtx, arg3_rtx);
        set_mem_size (arg2_rtx, arg3_rtx);
@@ -4975,6 +4977,8 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
   tree valist = TREE_OPERAND (*expr_p, 0);
   tree type = TREE_TYPE (*expr_p);
   tree t;
+  location_t loc = EXPR_HAS_LOCATION (*expr_p) ? EXPR_LOCATION (*expr_p) :
+    UNKNOWN_LOCATION;
 
   /* Verify that valist is of the proper type.  */
   have_va_type = TREE_TYPE (valist);
@@ -4984,7 +4988,7 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
 
   if (have_va_type == NULL_TREE)
     {
-      error ("first argument to %<va_arg%> not of type %<va_list%>");
+      error_at (loc, "first argument to %<va_arg%> not of type %<va_list%>");
       return GS_ERROR;
     }
 
@@ -4999,19 +5003,20 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
       /* Unfortunately, this is merely undefined, rather than a constraint
         violation, so we cannot make this an error.  If this call is never
         executed, the program is still strictly conforming.  */
-      warned = warning (0, "%qT is promoted to %qT when passed through %<...%>",
-                       type, promoted_type);
+      warned = warning_at (loc, 0,
+                          "%qT is promoted to %qT when passed through %<...%>",
+                          type, promoted_type);
       if (!gave_help && warned)
        {
          gave_help = true;
-         inform (input_location, "(so you should pass %qT not %qT to %<va_arg%>)",
-                  promoted_type, type);
+         inform (loc, "(so you should pass %qT not %qT to %<va_arg%>)",
+                 promoted_type, type);
        }
 
       /* We can, however, treat "undefined" any way we please.
         Call abort to encourage the user to fix the program.  */
       if (warned)
-       inform (input_location, "if this code is reached, the program will abort");
+       inform (loc, "if this code is reached, the program will abort");
       /* Before the abort, allow the evaluation of the va_list
         expression to exit or longjmp.  */
       gimplify_and_add (valist, pre_p);
@@ -5298,6 +5303,17 @@ expand_builtin_trap (void)
   emit_barrier ();
 }
 
+/* Expand a call to __builtin_unreachable.  We do nothing except emit
+   a barrier saying that control flow will not pass here.
+
+   It is the responsibility of the program being compiled to ensure
+   that control flow does never reach __builtin_unreachable.  */
+static void
+expand_builtin_unreachable (void)
+{
+  emit_barrier ();
+}
+
 /* Expand EXP, a call to fabs, fabsf or fabsl.
    Return NULL_RTX if a normal call should be emitted rather than expanding
    the function inline.  If convenient, the result should be placed
@@ -5973,7 +5989,8 @@ expand_builtin_fork_or_exec (tree fn, tree exp, rtx target, int ignore)
       gcc_unreachable ();
     }
 
-  decl = build_decl (FUNCTION_DECL, id, TREE_TYPE (fn));
+  decl = build_decl (DECL_SOURCE_LOCATION (fn),
+                    FUNCTION_DECL, id, TREE_TYPE (fn));
   DECL_EXTERNAL (decl) = 1;
   TREE_PUBLIC (decl) = 1;
   DECL_ARTIFICIAL (decl) = 1;
@@ -6039,6 +6056,7 @@ expand_builtin_sync_operation (enum machine_mode mode, tree exp,
 {
   rtx val, mem;
   enum machine_mode old_mode;
+  location_t loc = EXPR_LOCATION (exp);
 
   if (code == NOT && warn_sync_nand)
     {
@@ -6059,8 +6077,7 @@ expand_builtin_sync_operation (enum machine_mode mode, tree exp,
            break;
 
          fndecl = implicit_built_in_decls[BUILT_IN_FETCH_AND_NAND_N];
-         inform (input_location,
-                 "%qD changed semantics in GCC 4.4", fndecl);
+         inform (loc, "%qD changed semantics in GCC 4.4", fndecl);
          warned_f_a_n = true;
          break;
 
@@ -6074,8 +6091,7 @@ expand_builtin_sync_operation (enum machine_mode mode, tree exp,
            break;
 
          fndecl = implicit_built_in_decls[BUILT_IN_NAND_AND_FETCH_N];
-         inform (input_location,
-                 "%qD changed semantics in GCC 4.4", fndecl);
+         inform (loc, "%qD changed semantics in GCC 4.4", fndecl);
          warned_n_a_f = true;
          break;
 
@@ -6318,6 +6334,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
     CASE_FLT_FN (BUILT_IN_ASIN):
     CASE_FLT_FN (BUILT_IN_ACOS):
     CASE_FLT_FN (BUILT_IN_ATAN):
+    CASE_FLT_FN (BUILT_IN_SIGNIFICAND):
       /* Treat these like sqrt only if unsafe math optimizations are allowed,
         because of possible accuracy problems.  */
       if (! flag_unsafe_math_optimizations)
@@ -6795,6 +6812,10 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
       expand_builtin_trap ();
       return const0_rtx;
 
+    case BUILT_IN_UNREACHABLE:
+      expand_builtin_unreachable ();
+      return const0_rtx;
+
     case BUILT_IN_PRINTF:
       target = expand_builtin_printf (exp, target, mode, false);
       if (target)
@@ -11231,7 +11252,7 @@ validate_gimple_arglist (const_gimple call, ...)
 
   do
     {
-      code = va_arg (ap, enum tree_code);
+      code = (enum tree_code) va_arg (ap, int);
       switch (code)
        {
        case 0:
@@ -11282,7 +11303,7 @@ validate_arglist (const_tree callexpr, ...)
 
   do
     {
-      code = va_arg (ap, enum tree_code);
+      code = (enum tree_code) va_arg (ap, int);
       switch (code)
        {
        case 0:
@@ -13216,21 +13237,21 @@ do_mpc_ckconv (mpc_srcptr m, tree type, int inexact)
   /* Proceed iff we get a normal number, i.e. not NaN or Inf and no
      overflow/underflow occurred.  If -frounding-math, proceed iff the
      result of calling FUNC was exact.  */
-  if (mpfr_number_p (MPC_RE (m)) && mpfr_number_p (MPC_IM (m))
+  if (mpfr_number_p (mpc_realref (m)) && mpfr_number_p (mpc_imagref (m))
       && !mpfr_overflow_p () && !mpfr_underflow_p ()
       && (!flag_rounding_math || !inexact))
     {
       REAL_VALUE_TYPE re, im;
 
-      real_from_mpfr (&re, MPC_RE (m), type, GMP_RNDN);
-      real_from_mpfr (&im, MPC_IM (m), type, GMP_RNDN);
+      real_from_mpfr (&re, mpc_realref (m), type, GMP_RNDN);
+      real_from_mpfr (&im, mpc_imagref (m), type, GMP_RNDN);
       /* Proceed iff GCC's REAL_VALUE_TYPE can hold the MPFR values,
         check for overflow/underflow.  If the REAL_VALUE_TYPE is zero
         but the mpft_t is not, then we underflowed in the
         conversion.  */
       if (real_isfinite (&re) && real_isfinite (&im)
-         && (re.cl == rvc_zero) == (mpfr_zero_p (MPC_RE (m)) != 0)
-         && (im.cl == rvc_zero) == (mpfr_zero_p (MPC_IM (m)) != 0))
+         && (re.cl == rvc_zero) == (mpfr_zero_p (mpc_realref (m)) != 0)
+         && (im.cl == rvc_zero) == (mpfr_zero_p (mpc_imagref (m)) != 0))
         {
          REAL_VALUE_TYPE re_mode, im_mode;
 
@@ -13671,14 +13692,15 @@ do_mpc_arg1 (tree arg, tree type, int (*func)(mpc_ptr, mpc_srcptr, mpc_rnd_t))
            REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (type)));
          const int prec = fmt->p;
          const mp_rnd_t rnd = fmt->round_towards_zero ? GMP_RNDZ : GMP_RNDN;
+         const mpc_rnd_t crnd = fmt->round_towards_zero ? MPC_RNDZZ : MPC_RNDNN;
          int inexact;
          mpc_t m;
          
          mpc_init2 (m, prec);
-         mpfr_from_real (MPC_RE(m), re, rnd);
-         mpfr_from_real (MPC_IM(m), im, rnd);
+         mpfr_from_real (mpc_realref(m), re, rnd);
+         mpfr_from_real (mpc_imagref(m), im, rnd);
          mpfr_clear_flags ();
-         inexact = func (m, m, rnd);
+         inexact = func (m, m, crnd);
          result = do_mpc_ckconv (m, type, inexact);
          mpc_clear (m);
        }