summaryrefslogtreecommitdiffstats
path: root/gcc/tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c175
1 files changed, 56 insertions, 119 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 04fddb26dd3..1bfb66bf6d2 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -31,6 +31,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "config.h"
#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
#include "flags.h"
#include "tree.h"
#include "real.h"
@@ -723,6 +725,24 @@ integer_pow2p (expr)
|| (low == 0 && (high & (high - 1)) == 0));
}
+/* Return 1 if EXPR is an integer constant other than zero or a
+ complex constant other than zero. */
+
+int
+integer_nonzerop (expr)
+ tree expr;
+{
+ STRIP_NOPS (expr);
+
+ return ((TREE_CODE (expr) == INTEGER_CST
+ && ! TREE_CONSTANT_OVERFLOW (expr)
+ && (TREE_INT_CST_LOW (expr) != 0
+ || TREE_INT_CST_HIGH (expr) != 0))
+ || (TREE_CODE (expr) == COMPLEX_CST
+ && (integer_nonzerop (TREE_REALPART (expr))
+ || integer_nonzerop (TREE_IMAGPART (expr)))));
+}
+
/* Return the power of two represented by a tree node known to be a
power of two. */
@@ -944,41 +964,6 @@ chain_member (elem, chain)
return 0;
}
-/* Return nonzero if ELEM is equal to TREE_VALUE (CHAIN) for any piece of
- chain CHAIN. This and the next function are currently unused, but
- are retained for completeness. */
-
-int
-chain_member_value (elem, chain)
- tree elem, chain;
-{
- while (chain)
- {
- if (elem == TREE_VALUE (chain))
- return 1;
- chain = TREE_CHAIN (chain);
- }
-
- return 0;
-}
-
-/* Return nonzero if ELEM is equal to TREE_PURPOSE (CHAIN)
- for any piece of chain CHAIN. */
-
-int
-chain_member_purpose (elem, chain)
- tree elem, chain;
-{
- while (chain)
- {
- if (elem == TREE_PURPOSE (chain))
- return 1;
- chain = TREE_CHAIN (chain);
- }
-
- return 0;
-}
-
/* Return the length of a chain of nodes chained through TREE_CHAIN.
We expect a null pointer to mark the end of the chain.
This is the Lisp primitive `length'. */
@@ -1071,31 +1056,6 @@ nreverse (t)
}
return prev;
}
-
-/* Given a chain CHAIN of tree nodes,
- construct and return a list of those nodes. */
-
-tree
-listify (chain)
- tree chain;
-{
- tree result = NULL_TREE;
- tree in_tail = chain;
- tree out_tail = NULL_TREE;
-
- while (in_tail)
- {
- tree next = tree_cons (NULL_TREE, in_tail, NULL_TREE);
- if (out_tail)
- TREE_CHAIN (out_tail) = next;
- else
- result = next;
- out_tail = next;
- in_tail = TREE_CHAIN (in_tail);
- }
-
- return result;
-}
/* Return a newly created TREE_LIST node whose
purpose and value fields are PARM and VALUE. */
@@ -3228,24 +3188,6 @@ tree_low_cst (t, pos)
abort ();
}
-/* Return the most significant bit of the integer constant T. */
-
-int
-tree_int_cst_msb (t)
- tree t;
-{
- int prec;
- HOST_WIDE_INT h;
- unsigned HOST_WIDE_INT l;
-
- /* Note that using TYPE_PRECISION here is wrong. We care about the
- actual bits, not the (arbitrary) range of the type. */
- prec = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (t))) - 1;
- rshift_double (TREE_INT_CST_LOW (t), TREE_INT_CST_HIGH (t), prec,
- 2 * HOST_BITS_PER_WIDE_INT, &l, &h, 0);
- return (l & 1) == 1;
-}
-
/* Return an indication of the sign of the integer constant T.
The return value is -1 if T < 0, 0 if T == 0, and 1 if T > 0.
Note that -1 will never be returned it T's type is unsigned. */
@@ -3449,26 +3391,28 @@ compare_tree_int (t, u)
(RECORD_TYPE, UNION_TYPE and ENUMERAL_TYPE nodes are
constructed by language-dependent code, not here.) */
-/* Construct, lay out and return the type of pointers to TO_TYPE.
- If such a type has already been constructed, reuse it. */
+/* Construct, lay out and return the type of pointers to TO_TYPE
+ with mode MODE. If such a type has already been constructed,
+ reuse it. */
tree
-build_pointer_type (to_type)
+build_pointer_type_for_mode (to_type, mode)
tree to_type;
+ enum machine_mode mode;
{
tree t = TYPE_POINTER_TO (to_type);
/* First, if we already have a type for pointers to TO_TYPE, use it. */
-
- if (t != 0)
+ if (t != 0 && mode == ptr_mode)
return t;
- /* We need a new one. */
t = make_node (POINTER_TYPE);
TREE_TYPE (t) = to_type;
+ TYPE_MODE (t) = mode;
/* Record this type as the pointer to TO_TYPE. */
+ if (mode == ptr_mode)
TYPE_POINTER_TO (to_type) = t;
/* Lay out the type. This function has many callers that are concerned
@@ -3479,25 +3423,37 @@ build_pointer_type (to_type)
return t;
}
-/* Build the node for the type of references-to-TO_TYPE. */
+/* By default build pointers in ptr_mode. */
tree
-build_reference_type (to_type)
+build_pointer_type (to_type)
+ tree to_type;
+{
+ return build_pointer_type_for_mode (to_type, ptr_mode);
+}
+
+/* Construct, lay out and return the type of references to TO_TYPE
+ with mode MODE. If such a type has already been constructed,
+ reuse it. */
+
+tree
+build_reference_type_for_mode (to_type, mode)
tree to_type;
+ enum machine_mode mode;
{
tree t = TYPE_REFERENCE_TO (to_type);
/* First, if we already have a type for pointers to TO_TYPE, use it. */
-
- if (t)
+ if (t != 0 && mode == ptr_mode)
return t;
- /* We need a new one. */
t = make_node (REFERENCE_TYPE);
TREE_TYPE (t) = to_type;
+ TYPE_MODE (t) = mode;
/* Record this type as the pointer to TO_TYPE. */
+ if (mode == ptr_mode)
TYPE_REFERENCE_TO (to_type) = t;
layout_type (t);
@@ -3505,6 +3461,17 @@ build_reference_type (to_type)
return t;
}
+
+/* Build the node for the type of references-to-TO_TYPE by default
+ in ptr_mode. */
+
+tree
+build_reference_type (to_type)
+ tree to_type;
+{
+ return build_reference_type_for_mode (to_type, ptr_mode);
+}
+
/* Build a type that is compatible with t but has no cv quals anywhere
in its type, thus
@@ -3599,36 +3566,6 @@ build_index_2_type (lowval, highval)
return build_range_type (sizetype, lowval, highval);
}
-/* Return nonzero iff ITYPE1 and ITYPE2 are equal (in the LISP sense).
- Needed because when index types are not hashed, equal index types
- built at different times appear distinct, even though structurally,
- they are not. */
-
-int
-index_type_equal (itype1, itype2)
- tree itype1, itype2;
-{
- if (TREE_CODE (itype1) != TREE_CODE (itype2))
- return 0;
-
- if (TREE_CODE (itype1) == INTEGER_TYPE)
- {
- if (TYPE_PRECISION (itype1) != TYPE_PRECISION (itype2)
- || TYPE_MODE (itype1) != TYPE_MODE (itype2)
- || simple_cst_equal (TYPE_SIZE (itype1), TYPE_SIZE (itype2)) != 1
- || TYPE_ALIGN (itype1) != TYPE_ALIGN (itype2))
- return 0;
-
- if (1 == simple_cst_equal (TYPE_MIN_VALUE (itype1),
- TYPE_MIN_VALUE (itype2))
- && 1 == simple_cst_equal (TYPE_MAX_VALUE (itype1),
- TYPE_MAX_VALUE (itype2)))
- return 1;
- }
-
- return 0;
-}
-
/* Construct, lay out and return the type of arrays of elements with ELT_TYPE
and number of elements specified by the range of values of INDEX_TYPE.
If such a type has already been constructed, reuse it. */
OpenPOWER on IntegriCloud