aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Zissulescu <claziss@synopsys.com>2018-07-25 16:31:04 +0200
committerClaudiu Zissulescu <claziss@gcc.gnu.org>2018-07-25 16:31:04 +0200
commit3e4a5f5485c15381c67a940d5da449242ace9029 (patch)
treede686ee247f43917dfce99fc46c5f2c266beff04
parent8f176ba232f6c0a452c059cceb1ce5fcdd8177e1 (diff)
downloadgcc-3e4a5f5485c15381c67a940d5da449242ace9029.zip
gcc-3e4a5f5485c15381c67a940d5da449242ace9029.tar.gz
gcc-3e4a5f5485c15381c67a940d5da449242ace9029.tar.bz2
[ARC] Fix uncache attribute.
gcc/ 2018-05-09 Claudiu Zissulescu <claziss@synopsys.com> * config/arc/arc.c (compact_memory_operand_p): Check for uncached accesses as well. (arc_is_uncached_mem_p): uncached applies to both the variable and the pointer. testsuite/ 2018-05-09 Claudiu Zissulescu <claziss@synopsys.com> * gcc.target/arc/uncached-1.c: New test. * gcc.target/arc/uncached-2.c: Likewise. From-SVN: r262970
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/config/arc/arc.c40
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.target/arc/uncached-1.c11
-rw-r--r--gcc/testsuite/gcc.target/arc/uncached-2.c9
5 files changed, 58 insertions, 14 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0c0c644..db3d91b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
2018-07-25 Claudiu Zissulescu <claziss@synopsys.com>
+ * config/arc/arc.c (compact_memory_operand_p): Check for uncached
+ accesses as well.
+ (arc_is_uncached_mem_p): uncached applies to both the variable and
+ the pointer.
+
+2018-07-25 Claudiu Zissulescu <claziss@synopsys.com>
+
* config/arc/arc.h (ADDITIONAL_REGISTER_NAMES): Add additional
register names.
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index 4cbf7ab..c186e02 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -10420,6 +10420,10 @@ compact_memory_operand_p (rtx op, machine_mode mode,
if (MEM_VOLATILE_P (op) && !TARGET_VOLATILE_CACHE_SET)
return false;
+ /* likewise for uncached types. */
+ if (arc_is_uncached_mem_p (op))
+ return false;
+
if (mode == VOIDmode)
mode = GET_MODE (op);
@@ -10703,28 +10707,36 @@ arc_handle_uncached_attribute (tree *node,
bool
arc_is_uncached_mem_p (rtx pat)
{
- tree attrs;
- tree ttype;
- struct mem_attrs *refattrs;
+ tree attrs = NULL_TREE;
+ tree addr;
if (!MEM_P (pat))
return false;
/* Get the memory attributes. */
- refattrs = MEM_ATTRS (pat);
- if (!refattrs
- || !refattrs->expr)
+ addr = MEM_EXPR (pat);
+ if (!addr)
return false;
- /* Get the type declaration. */
- ttype = TREE_TYPE (refattrs->expr);
- if (!ttype)
- return false;
+ /* Get the attributes. */
+ if (TREE_CODE (addr) == MEM_REF)
+ {
+ attrs = TYPE_ATTRIBUTES (TREE_TYPE (addr));
+ if (lookup_attribute ("uncached", attrs))
+ return true;
- /* Get the type attributes. */
- attrs = TYPE_ATTRIBUTES (ttype);
- if (lookup_attribute ("uncached", attrs))
- return true;
+ attrs = TYPE_ATTRIBUTES (TREE_TYPE (TREE_OPERAND (addr, 0)));
+ if (lookup_attribute ("uncached", attrs))
+ return true;
+ }
+
+ /* For COMPONENT_REF, use the FIELD_DECL from tree operand 1. */
+ if (TREE_CODE (addr) == COMPONENT_REF)
+ {
+ attrs = TYPE_ATTRIBUTES (TREE_TYPE (TREE_OPERAND (addr, 1)));
+ if (lookup_attribute ("uncached", attrs))
+ return true;
+ }
return false;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index af40567..76f935a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-07-25 Claudiu Zissulescu <claziss@synopsys.com>
+
+ * gcc.target/arc/uncached-1.c: New test.
+ * gcc.target/arc/uncached-2.c: Likewise.
+
2018-07-24 Martin Sebor <msebor@redhat.com>
PR tree-optimization/86622
diff --git a/gcc/testsuite/gcc.target/arc/uncached-1.c b/gcc/testsuite/gcc.target/arc/uncached-1.c
new file mode 100644
index 0000000..7a6bade
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/uncached-1.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+
+volatile __attribute__((uncached)) int * status =
+ (volatile __attribute__((uncached)) int *) 0x04 ;
+
+int get_stat (void)
+{
+ return *status;
+}
+
+/* { dg-final { scan-assembler-times "ld\.di" 1 } } */
diff --git a/gcc/testsuite/gcc.target/arc/uncached-2.c b/gcc/testsuite/gcc.target/arc/uncached-2.c
new file mode 100644
index 0000000..89eed32
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/uncached-2.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+
+void clkgen_switch(unsigned int base, unsigned int offset, int val)
+{
+ volatile unsigned int __attribute__ ((uncached)) *dest =
+ (volatile unsigned int __attribute__ ((uncached)) *) (base + offset);
+ *dest = val;
+}
+/* { dg-final { scan-assembler-times "st\.di" 1 } } */