summaryrefslogtreecommitdiffstats
path: root/gcc/tree-gimple.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-14 18:16:48 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-14 18:16:48 +0000
commit94aac5172dccc0c7aaaaf8d61ec636f2b283e108 (patch)
tree2cec016794db7f4edc897fa4b5d68c8d7bb1ec15 /gcc/tree-gimple.c
parent0e2db0a28a647ac94e2e3402a8f90d6288a3c921 (diff)
downloadppe42-gcc-94aac5172dccc0c7aaaaf8d61ec636f2b283e108.tar.gz
ppe42-gcc-94aac5172dccc0c7aaaaf8d61ec636f2b283e108.zip
* tree-gimple.c (is_gimple_reg_rhs, is_gimple_mem_rhs): New fns.
(rhs_test_for): New fn. (is_gimple_tmp_rhs): Rename from is_gimple_rhs. * tree-gimple.h: Declare them. * gimplify.c (gimplify_modify_expr): Use the new fns. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84696 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-gimple.c')
-rw-r--r--gcc/tree-gimple.c56
1 files changed, 54 insertions, 2 deletions
diff --git a/gcc/tree-gimple.c b/gcc/tree-gimple.c
index 97a34a1182a..193f093a8e3 100644
--- a/gcc/tree-gimple.c
+++ b/gcc/tree-gimple.c
@@ -27,6 +27,7 @@ Boston, MA 02111-1307, USA. */
#include "tm.h"
#include "tree.h"
#include "tree-gimple.h"
+#include "tree-flow.h"
#include "output.h"
#include "rtl.h"
#include "expr.h"
@@ -172,10 +173,10 @@ static inline bool is_gimple_id (tree);
/* Validation of GIMPLE expressions. */
-/* Return true if T is a GIMPLE RHS. */
+/* Return true if T is a GIMPLE RHS for an assignment to a temporary. */
bool
-is_gimple_rhs (tree t)
+is_gimple_tmp_rhs (tree t)
{
enum tree_code code = TREE_CODE (t);
@@ -217,6 +218,57 @@ is_gimple_rhs (tree t)
return is_gimple_lvalue (t) || is_gimple_val (t);
}
+/* Returns true iff T is a valid RHS for an assignment to a renamed user
+ variable. */
+
+bool
+is_gimple_reg_rhs (tree t)
+{
+ /* If the RHS of the MODIFY_EXPR may throw or make a nonlocal goto and
+ the LHS is a user variable, then we need to introduce a temporary.
+ ie temp = RHS; LHS = temp.
+
+ This way the optimizers can determine that the user variable is
+ only modified if evaluation of the RHS does not throw. */
+ if (is_gimple_reg_type (TREE_TYPE (t))
+ && TREE_SIDE_EFFECTS (t)
+ && (TREE_CODE (t) == CALL_EXPR
+ || (flag_non_call_exceptions && tree_could_trap_p (t))))
+ return is_gimple_val (t);
+ else
+ /* Don't force a temp of a non-renamable type; the copy could be
+ arbitrarily expensive. Instead we will generate a V_MAY_DEF for
+ the assignment. */
+ return is_gimple_tmp_rhs (t);
+}
+
+/* Returns true iff T is a valid RHS for an assignment to an un-renamed
+ LHS, or for a call argument. */
+
+bool
+is_gimple_mem_rhs (tree t)
+{
+ /* If we're dealing with a renamable type, either source or dest
+ must be a renamed variable. */
+ if (is_gimple_reg_type (TREE_TYPE (t)))
+ return is_gimple_val (t);
+ else
+ return is_gimple_tmp_rhs (t);
+}
+
+/* Returns the appropriate RHS predicate for this LHS. */
+
+gimple_predicate
+rhs_predicate_for (tree lhs)
+{
+ if (is_gimple_tmp_var (lhs))
+ return is_gimple_tmp_rhs;
+ else if (is_gimple_reg (lhs))
+ return is_gimple_reg_rhs;
+ else
+ return is_gimple_mem_rhs;
+}
+
/* Returns true if T is a valid CONSTRUCTOR component in GIMPLE, either
a val or another CONSTRUCTOR. */
OpenPOWER on IntegriCloud