From: Andrew Burgess <andrew.burgess@embecosm.com>
To: binutils@sourceware.org
Cc: Claudiu.Zissulescu@synopsys.com, noamca@mellanox.com,
Andrew Burgess <andrew.burgess@embecosm.com>
Subject: [PATCH 3/6] gas/arc: Additional work to support multiple arc_opcode chains
Date: Sat, 02 Apr 2016 22:51:00 -0000 [thread overview]
Message-ID: <1459637470-30538-3-git-send-email-andrew.burgess@embecosm.com> (raw)
In-Reply-To: <1459637470-30538-1-git-send-email-andrew.burgess@embecosm.com>
Building on earlier commits, this commit pushes along support for having
multiple arc_opcode entries in the arc_opcodes table that have the same
mnemonic (name) field, but are not stored in a contiguous block in the
table.
In this commit we support looking up the arc_opcode_hash_entry from the
has table, and passing this along to the find_opcode_match function,
which finds the specific arc_opcode that we're assembling. We still
don't actually support the multiple chains of arc_opcode entries in this
commit, but the problem is now isolated to find_opcode_match.
There is no functional change in this commit over the current state of
the assembler.
gas/ChangeLog:
* config/tc-arc.c (arc_find_opcode): Now returns
arc_opcode_hash_entry pointer.
(find_opcode_match): Update argument type, extract arc_opcode from
incoming arc_opcode_hash_entry.
(find_special_case_pseudo): Update return type.
(find_special_case_flag): Update return type.
(find_special_case): Update return type.
(assemble_tokens): Lookup arc_opcode_hash_entry based on
instruction mnemonic, then use find_opcode_match to identify
specific arc_opcode.
---
gas/ChangeLog | 13 ++++++++++
gas/config/tc-arc.c | 68 ++++++++++++++++++++++++++---------------------------
2 files changed, 46 insertions(+), 35 deletions(-)
diff --git a/gas/config/tc-arc.c b/gas/config/tc-arc.c
index 814691c..f80bd2d 100644
--- a/gas/config/tc-arc.c
+++ b/gas/config/tc-arc.c
@@ -561,27 +561,17 @@ static bfd_boolean assembling_insn = FALSE;
/* Functions implementation. */
-/* Return a pointer to the first entry in ARC_OPCODE_HASH that matches
- NAME, or NULL if there are no matching entries. */
+/* Return a pointer to ARC_OPCODE_HASH_ENTRY that identifies all
+ ARC_OPCODE entries in ARC_OPCODE_HASH that match NAME, or NULL if there
+ are no matching entries in ARC_OPCODE_HASH. */
-static const struct arc_opcode *
+static const struct arc_opcode_hash_entry *
arc_find_opcode (const char *name)
{
const struct arc_opcode_hash_entry *entry;
- const struct arc_opcode *opcode;
entry = hash_find (arc_opcode_hash, name);
- if (entry != NULL)
- {
- if (entry->count > 1)
- as_fatal (_("unable to lookup `%s', too many opcode chains"),
- name);
- opcode = *entry->opcode;
- }
- else
- opcode = NULL;
-
- return opcode;
+ return entry;
}
/* Like md_number_to_chars but used for limms. The 4-byte limm value,
@@ -1381,13 +1371,14 @@ allocate_tok (expressionS *tok, int ntok, int cidx)
syntax match. */
static const struct arc_opcode *
-find_opcode_match (const struct arc_opcode *first_opcode,
+find_opcode_match (const struct arc_opcode_hash_entry *entry,
expressionS *tok,
int *pntok,
struct arc_flags *first_pflag,
int nflgs,
int *pcpumatch)
{
+ const struct arc_opcode *first_opcode = entry->opcode[0];
const struct arc_opcode *opcode = first_opcode;
int ntok = *pntok;
int got_cpu_match = 0;
@@ -1395,6 +1386,10 @@ find_opcode_match (const struct arc_opcode *first_opcode,
int bkntok;
expressionS emptyE;
+ gas_assert (entry->count > 0);
+ if (entry->count > 1)
+ as_fatal (_("unable to lookup `%s', too many opcode chains"),
+ first_opcode->name);
memset (&emptyE, 0, sizeof (emptyE));
memcpy (bktok, tok, MAX_INSN_ARGS * sizeof (*tok));
bkntok = ntok;
@@ -1843,7 +1838,7 @@ find_pseudo_insn (const char *opname,
/* Assumes the expressionS *tok is of sufficient size. */
-static const struct arc_opcode *
+static const struct arc_opcode_hash_entry *
find_special_case_pseudo (const char *opname,
int *ntok,
expressionS *tok,
@@ -1938,7 +1933,7 @@ find_special_case_pseudo (const char *opname,
return arc_find_opcode (pseudo_insn->mnemonic_r);
}
-static const struct arc_opcode *
+static const struct arc_opcode_hash_entry *
find_special_case_flag (const char *opname,
int *nflgs,
struct arc_flags *pflags)
@@ -1948,7 +1943,7 @@ find_special_case_flag (const char *opname,
unsigned flag_idx, flag_arr_idx;
size_t flaglen, oplen;
const struct arc_flag_special *arc_flag_special_opcode;
- const struct arc_opcode *opcode;
+ const struct arc_opcode_hash_entry *entry;
/* Search for special case instruction. */
for (i = 0; i < arc_num_flag_special; i++)
@@ -1971,14 +1966,14 @@ find_special_case_flag (const char *opname,
flaglen = strlen (flagnm);
if (strcmp (opname + oplen, flagnm) == 0)
{
- opcode = arc_find_opcode (arc_flag_special_opcode->name);
+ entry = arc_find_opcode (arc_flag_special_opcode->name);
if (*nflgs + 1 > MAX_INSN_FLGS)
break;
memcpy (pflags[*nflgs].name, flagnm, flaglen);
pflags[*nflgs].name[flaglen] = '\0';
(*nflgs)++;
- return opcode;
+ return entry;
}
}
}
@@ -1987,21 +1982,21 @@ find_special_case_flag (const char *opname,
/* Used to find special case opcode. */
-static const struct arc_opcode *
+static const struct arc_opcode_hash_entry *
find_special_case (const char *opname,
int *nflgs,
struct arc_flags *pflags,
expressionS *tok,
int *ntok)
{
- const struct arc_opcode *opcode;
+ const struct arc_opcode_hash_entry *entry;
- opcode = find_special_case_pseudo (opname, ntok, tok, nflgs, pflags);
+ entry = find_special_case_pseudo (opname, ntok, tok, nflgs, pflags);
- if (opcode == NULL)
- opcode = find_special_case_flag (opname, nflgs, pflags);
+ if (entry == NULL)
+ entry = find_special_case_flag (opname, nflgs, pflags);
- return opcode;
+ return entry;
}
/* Given an opcode name, pre-tockenized set of argumenst and the
@@ -2015,27 +2010,30 @@ assemble_tokens (const char *opname,
int nflgs)
{
bfd_boolean found_something = FALSE;
- const struct arc_opcode *opcode;
+ const struct arc_opcode_hash_entry *entry;
int cpumatch = 1;
/* Search opcodes. */
- opcode = arc_find_opcode (opname);
+ entry = arc_find_opcode (opname);
/* Couldn't find opcode conventional way, try special cases. */
- if (!opcode)
- opcode = find_special_case (opname, &nflgs, pflags, tok, &ntok);
+ if (entry == NULL)
+ entry = find_special_case (opname, &nflgs, pflags, tok, &ntok);
- if (opcode)
+ if (entry != NULL)
{
+ const struct arc_opcode *opcode;
+
pr_debug ("%s:%d: assemble_tokens: %s trying opcode 0x%08X\n",
frag_now->fr_file, frag_now->fr_line, opcode->name,
opcode->opcode);
-
found_something = TRUE;
- opcode = find_opcode_match (opcode, tok, &ntok, pflags, nflgs, &cpumatch);
- if (opcode)
+ opcode = find_opcode_match (entry, tok, &ntok, pflags,
+ nflgs, &cpumatch);
+ if (opcode != NULL)
{
struct arc_insn insn;
+
assemble_insn (opcode, tok, ntok, pflags, nflgs, &insn);
emit_insn (&insn);
return;
--
2.5.1
next prev parent reply other threads:[~2016-04-02 22:51 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-02 22:51 [PATCH 1/6] gas/arc: Modify structure used to hold opcodes Andrew Burgess
2016-04-02 22:51 ` [PATCH 4/6] gas/arc: Handle multiple arc_opcode chains for same mnemonic Andrew Burgess
2016-04-02 22:51 ` [PATCH 2/6] gas/arc: Remove preprocess_operands function Andrew Burgess
2016-04-05 14:23 ` Nick Clifton
2016-04-02 22:51 ` [PATCH 5/6] gas/arc: Allow greater range of characters into flag names Andrew Burgess
2016-04-04 7:52 ` Claudiu Zissulescu
2016-04-05 14:25 ` Nick Clifton
2016-04-02 22:51 ` Andrew Burgess [this message]
2016-04-02 22:51 ` [PATCH 6/6] arc/nps400: Add new control instructions Andrew Burgess
2016-04-04 7:52 ` Claudiu Zissulescu
2016-04-05 14:26 ` Nick Clifton
2016-04-04 8:22 ` [PATCH 1/6] gas/arc: Modify structure used to hold opcodes Claudiu Zissulescu
2016-04-04 9:10 ` Andrew Burgess
2016-04-04 14:45 ` Claudiu Zissulescu
2016-04-07 12:51 ` Andrew Burgess
2016-04-07 13:08 ` Claudiu Zissulescu
2016-04-07 15:34 ` Nick Clifton
2016-04-07 12:57 ` [PATCHv2 4/4] arc/nps400: Add new instructions Andrew Burgess
2016-04-07 13:18 ` Claudiu Zissulescu
2016-04-07 15:38 ` Nick Clifton
2016-04-07 12:57 ` [PATCHv2 1/4] gas/arc: Modify structure used to hold opcodes Andrew Burgess
2016-04-07 13:10 ` Claudiu Zissulescu
2016-04-07 15:35 ` Nick Clifton
2016-04-07 12:57 ` [PATCHv2 3/4] gas/arc: Handle multiple arc_opcode chains for same mnemonic Andrew Burgess
2016-04-07 13:16 ` Claudiu Zissulescu
2016-04-07 15:37 ` Nick Clifton
2016-04-07 12:57 ` [PATCHv2 2/4] gas/arc: Additional work to support multiple arc_opcode chains Andrew Burgess
2016-04-07 13:14 ` Claudiu Zissulescu
2016-04-07 15:36 ` Nick Clifton
2016-04-07 12:57 ` [PATCHv2 0/4] arc/nps: Add pipeline control instructions Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1459637470-30538-3-git-send-email-andrew.burgess@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=Claudiu.Zissulescu@synopsys.com \
--cc=binutils@sourceware.org \
--cc=noamca@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).