OSDN Git Service

* config/sh/sh.c (sh_output_mi_thunk): Update the use of
[pf3gnuchains/gcc-fork.git] / gcc / tree-gimple.c
index 93e99e6..da84777 100644 (file)
@@ -155,7 +155,10 @@ is_gimple_lvalue (tree t)
 bool
 is_gimple_condexpr (tree t)
 {
-  return (is_gimple_val (t) || COMPARISON_CLASS_P (t));
+  return (is_gimple_val (t) || (COMPARISON_CLASS_P (t)
+                               && !tree_could_trap_p (t)
+                               && is_gimple_val (TREE_OPERAND (t, 0))
+                               && is_gimple_val (TREE_OPERAND (t, 1))));
 }
 
 /*  Return true if T is something whose address can be taken.  */
@@ -194,6 +197,45 @@ is_gimple_constant (const_tree t)
     }
 }
 
+/* Return true if T is a gimple address.  */
+
+bool
+is_gimple_address (const_tree t)
+{
+  tree op;
+
+  if (TREE_CODE (t) != ADDR_EXPR)
+    return false;
+
+  op = TREE_OPERAND (t, 0);
+  while (handled_component_p (op))
+    {
+      if ((TREE_CODE (op) == ARRAY_REF
+          || TREE_CODE (op) == ARRAY_RANGE_REF)
+         && !is_gimple_val (TREE_OPERAND (op, 1)))
+           return false;
+
+      op = TREE_OPERAND (op, 0);
+    }
+
+  if (CONSTANT_CLASS_P (op) || INDIRECT_REF_P (op))
+    return true;
+
+  switch (TREE_CODE (op))
+    {
+    case PARM_DECL:
+    case RESULT_DECL:
+    case LABEL_DECL:
+    case FUNCTION_DECL:
+    case VAR_DECL:
+    case CONST_DECL:
+      return true;
+
+    default:
+      return false;
+    }
+}
+
 /* Return true if T is a gimple invariant address.  */
 
 bool
@@ -227,40 +269,7 @@ is_gimple_invariant_address (const_tree t)
       op = TREE_OPERAND (op, 0);
     }
 
-  if (CONSTANT_CLASS_P (op))
-    return true;
-
-  if (INDIRECT_REF_P (op))
-    return false;
-
-  switch (TREE_CODE (op))
-    {
-    case PARM_DECL:
-    case RESULT_DECL:
-    case LABEL_DECL:
-    case FUNCTION_DECL:
-      return true;
-
-    case VAR_DECL:
-      if (((TREE_STATIC (op) || DECL_EXTERNAL (op))
-          && ! DECL_DLLIMPORT_P (op))
-         || DECL_THREAD_LOCAL_P (op)
-         || DECL_CONTEXT (op) == current_function_decl
-         || decl_function_context (op) == current_function_decl)
-       return true;
-      break;
-
-    case CONST_DECL:
-      if ((TREE_STATIC (op) || DECL_EXTERNAL (op))
-         || decl_function_context (op) == current_function_decl)
-       return true;
-      break;
-
-    default:
-      gcc_unreachable ();
-    }
-
-  return false;
+  return CONSTANT_CLASS_P (op) || decl_address_invariant_p (op);
 }
 
 /* Return true if T is a GIMPLE minimal invariant.  It's a restricted
@@ -325,6 +334,7 @@ is_gimple_stmt (tree t)
 
     case CALL_EXPR:
     case GIMPLE_MODIFY_STMT:
+    case PREDICT_EXPR:
       /* These are valid regardless of their type.  */
       return true;
 
@@ -505,8 +515,7 @@ is_gimple_min_lval (tree t)
 bool
 is_gimple_cast (tree t)
 {
-  return (TREE_CODE (t) == NOP_EXPR
-         || TREE_CODE (t) == CONVERT_EXPR
+  return (CONVERT_EXPR_P (t)
           || TREE_CODE (t) == FIX_TRUNC_EXPR);
 }
 
@@ -641,12 +650,7 @@ canonicalize_cond_expr_cond (tree t)
                  TREE_OPERAND (top0, 0), TREE_OPERAND (top0, 1));
     }
 
-  /* A valid conditional for a COND_EXPR is either a gimple value
-     or a comparison with two gimple value operands.  */
-  if (is_gimple_val (t)
-      || (COMPARISON_CLASS_P (t)
-         && is_gimple_val (TREE_OPERAND (t, 0))
-         && is_gimple_val (TREE_OPERAND (t, 1))))
+  if (is_gimple_condexpr (t))
     return t;
 
   return NULL_TREE;