aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Perta <sebastian.perta@renesas.com>2018-02-13 11:55:39 +0000
committerSebastian Perta <sebastianperta@gcc.gnu.org>2018-02-13 11:55:39 +0000
commite4c1b7e32283b3886847f9e14b33bda5e5d5d448 (patch)
treeb84b7ca84fa98f3b659afa9a2064e92e74c9787d
parent9bc5ecf3bcb25abbf868d52e7db076248e0ef174 (diff)
downloadgcc-e4c1b7e32283b3886847f9e14b33bda5e5d5d448.zip
gcc-e4c1b7e32283b3886847f9e14b33bda5e5d5d448.tar.gz
gcc-e4c1b7e32283b3886847f9e14b33bda5e5d5d448.tar.bz2
rl78.c (add_vector_labels): New function.
2018-02-13 Sebastian Perta <sebastian.perta@renesas.com> * config/rl78/rl78.c (add_vector_labels): New function. * config/rl78/rl78.c (rl78_handle_vector_attribute): New function. * config/rl78/rl78.c (rl78_start_function): Call add_vector_labels. * config/rl78/rl78.c (rl78_handle_func_attribute): Removed the assert which checks that no arguments are passed. * config/rl78/rl78.c (rl78_attribute_table): Add "vector" attribute. * doc/extend.texi: Documentation for the new attribute. 2018-02-13 Sebastian Perta <sebastian.perta@renesas.com> * gcc.target/rl78/test_auto_vector.c: New test. From-SVN: r257622
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/config/rl78/rl78.c86
-rw-r--r--gcc/doc/extend.texi2
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.target/rl78/test_auto_vector.c21
5 files changed, 120 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1bb2af7..4a79c7b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2018-02-13 Sebastian Perta <sebastian.perta@renesas.com>
+
+ * config/rl78/rl78.c (add_vector_labels): New function.
+ * config/rl78/rl78.c (rl78_handle_vector_attribute): New function.
+ * config/rl78/rl78.c (rl78_start_function): Call add_vector_labels.
+ * config/rl78/rl78.c (rl78_handle_func_attribute): Removed the assert
+ which checks that no arguments are passed.
+ * config/rl78/rl78.c (rl78_attribute_table): Add "vector" attribute.
+ * doc/extend.texi: Documentation for the new attribute.
+
2018-02-13 Andreas Schwab <schwab@suse.de>
* config/riscv/linux.h (CPP_SPEC): Define.
diff --git a/gcc/config/rl78/rl78.c b/gcc/config/rl78/rl78.c
index b8c1e7b..7b2be23 100644
--- a/gcc/config/rl78/rl78.c
+++ b/gcc/config/rl78/rl78.c
@@ -809,7 +809,6 @@ rl78_handle_func_attribute (tree * node,
bool * no_add_attrs)
{
gcc_assert (DECL_P (* node));
- gcc_assert (args == NULL_TREE);
if (TREE_CODE (* node) != FUNCTION_DECL)
{
@@ -868,6 +867,28 @@ rl78_handle_saddr_attribute (tree * node,
return NULL_TREE;
}
+/* Check "vector" attribute. */
+
+static tree
+rl78_handle_vector_attribute (tree * node,
+ tree name,
+ tree args,
+ int flags ATTRIBUTE_UNUSED,
+ bool * no_add_attrs)
+{
+ gcc_assert (DECL_P (* node));
+ gcc_assert (args != NULL_TREE);
+
+ if (TREE_CODE (* node) != FUNCTION_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute only applies to functions",
+ name);
+ * no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
#undef TARGET_ATTRIBUTE_TABLE
#define TARGET_ATTRIBUTE_TABLE rl78_attribute_table
@@ -876,7 +897,7 @@ const struct attribute_spec rl78_attribute_table[] =
{
/* Name, min_len, max_len, decl_req, type_req, fn_type_req,
affects_type_identity, handler, exclude. */
- { "interrupt", 0, 0, true, false, false, false,
+ { "interrupt", 0, -1, true, false, false, false,
rl78_handle_func_attribute, NULL },
{ "brk_interrupt", 0, 0, true, false, false, false,
rl78_handle_func_attribute, NULL },
@@ -884,6 +905,8 @@ const struct attribute_spec rl78_attribute_table[] =
rl78_handle_naked_attribute, NULL },
{ "saddr", 0, 0, true, false, false, false,
rl78_handle_saddr_attribute, NULL },
+ { "vector", 1, -1, true, false, false,
+ rl78_handle_vector_attribute, false },
{ NULL, 0, 0, false, false, false, false, NULL, NULL }
};
@@ -1583,6 +1606,62 @@ rl78_expand_eh_epilogue (rtx x ATTRIBUTE_UNUSED)
#undef TARGET_ASM_FUNCTION_PROLOGUE
#define TARGET_ASM_FUNCTION_PROLOGUE rl78_start_function
+static void
+add_vector_labels (FILE *file, const char *aname)
+{
+ tree vec_attr;
+ tree val_attr;
+ const char *vname = "vect";
+ const char *s;
+ int vnum;
+
+ /* This node is for the vector/interrupt tag itself */
+ vec_attr = lookup_attribute (aname, DECL_ATTRIBUTES (current_function_decl));
+ if (!vec_attr)
+ return;
+
+ /* Now point it at the first argument */
+ vec_attr = TREE_VALUE (vec_attr);
+
+ /* Iterate through the arguments. */
+ while (vec_attr)
+ {
+ val_attr = TREE_VALUE (vec_attr);
+ switch (TREE_CODE (val_attr))
+ {
+ case STRING_CST:
+ s = TREE_STRING_POINTER (val_attr);
+ goto string_id_common;
+
+ case IDENTIFIER_NODE:
+ s = IDENTIFIER_POINTER (val_attr);
+
+ string_id_common:
+ if (strcmp (s, "$default") == 0)
+ {
+ fprintf (file, "\t.global\t$tableentry$default$%s\n", vname);
+ fprintf (file, "$tableentry$default$%s:\n", vname);
+ }
+ else
+ vname = s;
+ break;
+
+ case INTEGER_CST:
+ vnum = TREE_INT_CST_LOW (val_attr);
+
+ fprintf (file, "\t.global\t$tableentry$%d$%s\n", vnum, vname);
+ fprintf (file, "$tableentry$%d$%s:\n", vnum, vname);
+ break;
+
+ default:
+ ;
+ }
+
+ vec_attr = TREE_CHAIN (vec_attr);
+ }
+
+}
+
/* We don't use this to actually emit the function prologue. We use
this to insert a comment in the asm file describing the
function. */
@@ -1590,6 +1669,9 @@ static void
rl78_start_function (FILE *file)
{
int i;
+
+ add_vector_labels (file, "interrupt");
+ add_vector_labels (file, "vector");
if (cfun->machine->framesize == 0)
return;
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index cb9df97..4f79a92 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -5182,7 +5182,7 @@ that the specified function is an interrupt handler. The compiler generates
function entry and exit sequences suitable for use in an interrupt handler
when this attribute is present.
-On RX targets, you may specify one or more vector numbers as arguments
+On RX and RL78 targets, you may specify one or more vector numbers as arguments
to the attribute, as well as naming an alternate table name.
Parameters are handled sequentially, so one handler can be assigned to
multiple entries in multiple tables. One may also pass the magic
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 42bd190..613a327 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2018-02-13 Sebastian Perta <sebastian.perta@renesas.com>
+
+ * gcc.target/rl78/test_auto_vector.c: New test.
+
2018-02-13 Richard Sandiford <richard.sandiford@linaro.org>
PR c/84305
diff --git a/gcc/testsuite/gcc.target/rl78/test_auto_vector.c b/gcc/testsuite/gcc.target/rl78/test_auto_vector.c
new file mode 100644
index 0000000..7055363
--- /dev/null
+++ b/gcc/testsuite/gcc.target/rl78/test_auto_vector.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+
+void __attribute__ ((interrupt (5))) interrupt_5_handler ();
+
+void interrupt_5_handler ()
+{
+}
+
+void __attribute__ ((vector (4))) interrupt_4_handler ();
+
+void interrupt_4_handler ()
+{
+}
+
+void __attribute__ ((interrupt)) interrupt_handler ();
+
+void interrupt_handler ()
+{
+}
+
+/* { dg-final { scan-assembler "tableentry" } } */