summaryrefslogtreecommitdiff
path: root/gcc/gimple-expr.h
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2013-11-05 19:26:07 +0000
committerAndrew Macleod <amacleod@gcc.gnu.org>2013-11-05 19:26:07 +0000
commit2a0603f1899262a11e21aba32da9a94d6f1129c3 (patch)
tree37108019bb346797ef0336eb829491d4143b53c6 /gcc/gimple-expr.h
parentc180e49596bb20aef9c887cf9817e21a7f1e0d2b (diff)
gimple.h: Move some prototypes to gimple-expr.h and add to include list.
* gimple.h: Move some prototypes to gimple-expr.h and add to include list. (extract_ops_from_tree, gimple_call_addr_fndecl, is_gimple_reg_type): Move to gimple-expr.h. * gimple-expr.h: New file. Relocate some prototypes from gimple.h. (types_compatible_p, is_gimple_reg_type, is_gimple_variable, is_gimple_id, virtual_operand_p, is_gimple_addressable, is_gimple_constant, extract_ops_from_tree, gimple_call_addr_fndecl): Relocate here. * gimple.c (extract_ops_from_tree_1, gimple_cond_get_ops_from_tree, gimple_set_body, gimple_body, gimple_has_body_p, is_gimple_lvalue, is_gimple_condexpr, is_gimple_addressable, is_gimple_constant, is_gimple_address, is_gimple_invariant_address, is_gimple_ip_invariant_address, is_gimple_min_invariant, is_gimple_ip_invariant, is_gimple_variable, is_gimple_id, virtual_operand_p, is_gimple_reg, is_gimple_val, is_gimple_asm_val, is_gimple_min_lval, is_gimple_call_addr, is_gimple_mem_ref_addr, gimple_decl_printable_name, useless_type_conversion_p, types_compatible_p, gimple_can_coalesce_p, copy_var_decl): Move to gimple-expr.[ch]. * gimple-expr.c: New File. (useless_type_conversion_p, gimple_set_body, gimple_body, gimple_has_body_p, gimple_decl_printable_name, copy_var_decl, gimple_can_coalesce_p, extract_ops_from_tree_1, gimple_cond_get_ops_from_tree, is_gimple_lvalue, is_gimple_condexpr, is_gimple_address, is_gimple_invariant_address, is_gimple_ip_invariant_address, is_gimple_min_invariant, is_gimple_ip_invariant, is_gimple_reg, is_gimple_val, is_gimple_asm_val, is_gimple_min_lval, is_gimple_call_addr, is_gimple_mem_ref_addr): Relocate here. * Makefile.in (OBJS): Add gimple-expr.o. From-SVN: r204412
Diffstat (limited to 'gcc/gimple-expr.h')
-rw-r--r--gcc/gimple-expr.h171
1 files changed, 171 insertions, 0 deletions
diff --git a/gcc/gimple-expr.h b/gcc/gimple-expr.h
new file mode 100644
index 00000000000..aad558cebb7
--- /dev/null
+++ b/gcc/gimple-expr.h
@@ -0,0 +1,171 @@
+/* Header file for gimple decl, type and expressions.
+ Copyright (C) 2013 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 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of 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 COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#ifndef GCC_GIMPLE_EXPR_H
+#define GCC_GIMPLE_EXPR_H
+
+extern bool useless_type_conversion_p (tree, tree);
+
+extern void gimple_set_body (tree, gimple_seq);
+extern gimple_seq gimple_body (tree);
+extern bool gimple_has_body_p (tree);
+extern const char *gimple_decl_printable_name (tree, int);
+extern tree copy_var_decl (tree, tree, tree);
+extern bool gimple_can_coalesce_p (tree, tree);
+
+extern void extract_ops_from_tree_1 (tree, enum tree_code *, tree *, tree *,
+ tree *);
+extern void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *,
+ tree *);
+extern bool is_gimple_lvalue (tree);
+extern bool is_gimple_condexpr (tree);
+extern bool is_gimple_address (const_tree);
+extern bool is_gimple_invariant_address (const_tree);
+extern bool is_gimple_ip_invariant_address (const_tree);
+extern bool is_gimple_min_invariant (const_tree);
+extern bool is_gimple_ip_invariant (const_tree);
+extern bool is_gimple_reg (tree);
+extern bool is_gimple_val (tree);
+extern bool is_gimple_asm_val (tree);
+extern bool is_gimple_min_lval (tree);
+extern bool is_gimple_call_addr (tree);
+extern bool is_gimple_mem_ref_addr (tree);
+
+/* Return true if a conversion from either type of TYPE1 and TYPE2
+ to the other is not required. Otherwise return false. */
+
+static inline bool
+types_compatible_p (tree type1, tree type2)
+{
+ return (type1 == type2
+ || (useless_type_conversion_p (type1, type2)
+ && useless_type_conversion_p (type2, type1)));
+}
+
+/* Return true if TYPE is a suitable type for a scalar register variable. */
+
+static inline bool
+is_gimple_reg_type (tree type)
+{
+ return !AGGREGATE_TYPE_P (type);
+}
+
+/* Return true if T is a variable. */
+
+static inline bool
+is_gimple_variable (tree t)
+{
+ return (TREE_CODE (t) == VAR_DECL
+ || TREE_CODE (t) == PARM_DECL
+ || TREE_CODE (t) == RESULT_DECL
+ || TREE_CODE (t) == SSA_NAME);
+}
+
+/* Return true if T is a GIMPLE identifier (something with an address). */
+
+static inline bool
+is_gimple_id (tree t)
+{
+ return (is_gimple_variable (t)
+ || TREE_CODE (t) == FUNCTION_DECL
+ || TREE_CODE (t) == LABEL_DECL
+ || TREE_CODE (t) == CONST_DECL
+ /* Allow string constants, since they are addressable. */
+ || TREE_CODE (t) == STRING_CST);
+}
+
+/* Return true if OP, an SSA name or a DECL is a virtual operand. */
+
+static inline bool
+virtual_operand_p (tree op)
+{
+ if (TREE_CODE (op) == SSA_NAME)
+ {
+ op = SSA_NAME_VAR (op);
+ if (!op)
+ return false;
+ }
+
+ if (TREE_CODE (op) == VAR_DECL)
+ return VAR_DECL_IS_VIRTUAL_OPERAND (op);
+
+ return false;
+}
+
+/* Return true if T is something whose address can be taken. */
+
+static inline bool
+is_gimple_addressable (tree t)
+{
+ return (is_gimple_id (t) || handled_component_p (t)
+ || TREE_CODE (t) == MEM_REF);
+}
+
+/* Return true if T is a valid gimple constant. */
+
+static inline bool
+is_gimple_constant (const_tree t)
+{
+ switch (TREE_CODE (t))
+ {
+ case INTEGER_CST:
+ case REAL_CST:
+ case FIXED_CST:
+ case STRING_CST:
+ case COMPLEX_CST:
+ case VECTOR_CST:
+ return true;
+
+ default:
+ return false;
+ }
+}
+
+/* A wrapper around extract_ops_from_tree_1, for callers which expect
+ to see only a maximum of two operands. */
+
+static inline void
+extract_ops_from_tree (tree expr, enum tree_code *code, tree *op0,
+ tree *op1)
+{
+ tree op2;
+ extract_ops_from_tree_1 (expr, code, op0, op1, &op2);
+ gcc_assert (op2 == NULL_TREE);
+}
+
+/* Given a valid GIMPLE_CALL function address return the FUNCTION_DECL
+ associated with the callee if known. Otherwise return NULL_TREE. */
+
+static inline tree
+gimple_call_addr_fndecl (const_tree fn)
+{
+ if (fn && TREE_CODE (fn) == ADDR_EXPR)
+ {
+ tree fndecl = TREE_OPERAND (fn, 0);
+ if (TREE_CODE (fndecl) == MEM_REF
+ && TREE_CODE (TREE_OPERAND (fndecl, 0)) == ADDR_EXPR
+ && integer_zerop (TREE_OPERAND (fndecl, 1)))
+ fndecl = TREE_OPERAND (TREE_OPERAND (fndecl, 0), 0);
+ if (TREE_CODE (fndecl) == FUNCTION_DECL)
+ return fndecl;
+ }
+ return NULL_TREE;
+}
+
+#endif /* GCC_GIMPLE_EXPR_H */