This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] split up epiphany's md_assemble ()
- From: tbsaunde+binutils at tbsaunde dot org
- To: binutils at sourceware dot org
- Cc: Trevor Saunders <tbsaunde+binutils at tbsaunde dot org>
- Date: Sun, 28 Feb 2016 15:01:07 -0500
- Subject: [PATCH] split up epiphany's md_assemble ()
- Authentication-results: sourceware.org; auth=none
From: Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
Hi,
$subject. The old code would cause some -Wwrite-strings warnings because it
passed literals to md_assemble () which took a char *. It is also a rather
long function that does several things so breaking independent parts out seems
useful.
built and regtested epiphany-elf with no regressions, ok?
Trev
gas/ChangeLog:
2016-02-28 Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
* gas/config/tc-epiphany.c (md_assemble): Adjust.
(epiphany_assemble): New function.
---
gas/config/tc-epiphany.c | 30 +++++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/gas/config/tc-epiphany.c b/gas/config/tc-epiphany.c
index 6ee0917..aef9175 100644
--- a/gas/config/tc-epiphany.c
+++ b/gas/config/tc-epiphany.c
@@ -405,16 +405,14 @@ parse_reglist (const char * s, int * mask)
}
+static void epiphany_assemble (const char *str);
+
void
md_assemble (char *str)
{
- epiphany_insn insn;
- char *errmsg = 0;
const char * pperr = 0;
int regmask=0, push=0, pop=0;
- memset (&insn, 0, sizeof (insn));
-
/* Special-case push/pop instruction macros. */
if (0 == strncmp (str, "push {", 6))
{
@@ -440,8 +438,8 @@ md_assemble (char *str)
char buff[20];
int i,p ATTRIBUTE_UNUSED;
- md_assemble ("mov r15,4");
- md_assemble ("sub sp,sp,r15");
+ epiphany_assemble ("mov r15,4");
+ epiphany_assemble ("sub sp,sp,r15");
for (i = 0, p = 1; i <= 15; ++i, regmask >>= 1)
{
@@ -451,7 +449,7 @@ md_assemble (char *str)
sprintf (buff, "str r%d,[sp],-r15", i);
else
continue;
- md_assemble (buff);
+ epiphany_assemble (buff);
}
return;
}
@@ -460,17 +458,31 @@ md_assemble (char *str)
char buff[20];
int i,p;
- md_assemble ("mov r15,4");
+ epiphany_assemble ("mov r15,4");
for (i = 15, p = 1 << 15; i >= 0; --i, p >>= 1)
if (regmask & p)
{
sprintf (buff, "ldr r%d,[sp],+r15", i);
- md_assemble (buff);
+ epiphany_assemble (buff);
}
return;
}
+ epiphany_assemble (str);
+}
+
+/* Assemble an instruction, push and pop pseudo instructions should have
+ already been expanded. */
+
+static void
+ epiphany_assemble (const char *str)
+ {
+ epiphany_insn insn;
+ char *errmsg = 0;
+
+ memset (&insn, 0, sizeof (insn));
+
/* Initialize GAS's cgen interface for a new instruction. */
gas_cgen_init_parse ();
--
2.5.0.rc1.5.gc07173f