I'm getting ready to submit the ptx port and the various changes that
are necessary for it. To start with, here are some patches to deal with
address space issues.
ptx has the concept of an implicit address space: everything (objects on
the stack as well as constant data and global variables) lives in its
own address space. These are applied by a lower-as pass which I'll
submit later.
Since address spaces are more pervasive than on other targets and can
show up in places the compiler doesn't yet expect them (such as local
variables), this uncovers a few bugs in the optimizers. These are
typically of the kind where we recreate a memory reference and aren't
quite careful enough to preserve the existing address space.
The first patch below just introduces a utility function that the
following patches will use. All were bootstrapped and tested together
on x86_64-linux. Ok?
Bernd
commit 9a63fbecf0ccf9dd9cf18073958e4cfccf6ecaf2
Author: Bernd Schmidt <ber...@codesourcery.com>
Date: Wed Sep 10 16:32:27 2014 +0200
* tree.c (apply_as_to_type): New function.
* tree.h (apply_as_to_type): Declare.
diff --git a/gcc/tree.c b/gcc/tree.c
index d1d67ef..a7438b2 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -6156,6 +6156,21 @@ handle_dll_attribute (tree * pnode, tree name, tree args, int flags,
#endif /* TARGET_DLLIMPORT_DECL_ATTRIBUTES */
+/* Build a type like TYPE, but with address space AS (which can be
+ ADDR_SPACE_GENERIC to remove an existing address space), and return it. */
+
+tree
+apply_as_to_type (tree type, addr_space_t as)
+{
+ int quals = TYPE_QUALS_NO_ADDR_SPACE (type);
+ if (!ADDR_SPACE_GENERIC_P (as))
+ quals |= ENCODE_QUAL_ADDR_SPACE (as);
+ type = build_qualified_type (type, quals);
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ TREE_TYPE (type) = apply_as_to_type (TREE_TYPE (type), as);
+ return type;
+}
+
/* Set the type qualifiers for TYPE to TYPE_QUALS, which is a bitmask
of the various TYPE_QUAL values. */
diff --git a/gcc/tree.h b/gcc/tree.h
index e000e4e..8e1aa6b 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -3845,6 +3845,8 @@ extern tree build_qualified_type (tree, int);
extern tree build_aligned_type (tree, unsigned int);
+extern tree apply_as_to_type (tree, addr_space_t);
+
/* Like build_qualified_type, but only deals with the `const' and
`volatile' qualifiers. This interface is retained for backwards
compatibility with the various front-ends; new code should use