public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* RE: Parsing mnemonic suffixes
@ 2005-09-21 16:10 Will Newton
  0 siblings, 0 replies; 3+ messages in thread
From: Will Newton @ 2005-09-21 16:10 UTC (permalink / raw)
  To: Doug Evans; +Cc: cgen

 
>  > I'm having a little trouble with getting a cgen generated 
> assembler to  > parse multiple suffixes on a mnemonic. The 
> instruction is specified like  > this:
>  >
>  > "add$sc$cond $reg,$reg,$reg"
>  >
>  > The operand "sc" can have a value of "S" or "" depending 
> on whether this  > instruction sets condition flags.
>  > The operand "cond" can have one of a number of values 
> ("Z", "EQ", "NE",  > "", etc.) depending on whether this 
> instruction is conditional or not.
>  >
>  > When either $sc or $cond is used in isolation (e.g. 
> "ADDS", "ADDEQ") the  > mnemonic is parsed correctly, when 
> the two are used together (e.g.
>  > "ADDSEQ") the parse fails. Is it possible to parse an 
> instruction like  > this with a cgen description?
> 
> I would expect this to work.  I'll look into it.

Cgen/cpu/arm7.cpu does this, but I have no idea if it works. It seems
that what happens is that the mnemonic is parsed, and the trailing
suffixes as one big block are passed to cgen_parse_keyword with the
keyword table for the first suffix, e.g.:

ADDSNE -> cgen_parse_keyword is called with "SNE" and keyword table for
$sc ("", "S").

Cgen_parse_keyword then calls cgen_keyword_lookup_name with the keyword
table, which does a hash lookup of "SNE" in the keyword table. This
fails and returns the null keyword as you would expect.
Cgen_parse_keyword is then called again with "SNE" and the keyword table
for $cond ("NE", ...) which doesn't match either.

My current plan is to write a custom parse handler that doesn't use a
hash table and parses as greedily as possible.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Parsing mnemonic suffixes
  2005-09-20 14:10 Will Newton
@ 2005-09-21 15:19 ` Doug Evans
  0 siblings, 0 replies; 3+ messages in thread
From: Doug Evans @ 2005-09-21 15:19 UTC (permalink / raw)
  To: Will Newton; +Cc: cgen

Will Newton writes:
 > 
 > I'm having a little trouble with getting a cgen generated assembler to
 > parse multiple suffixes on a mnemonic. The instruction is specified like
 > this:
 > 
 > "add$sc$cond $reg,$reg,$reg"
 > 
 > The operand "sc" can have a value of "S" or "" depending on whether this
 > instruction sets condition flags.
 > The operand "cond" can have one of a number of values ("Z", "EQ", "NE",
 > "", etc.) depending on whether this instruction is conditional or not.
 > 
 > When either $sc or $cond is used in isolation (e.g. "ADDS", "ADDEQ") the
 > mnemonic is parsed correctly, when the two are used together (e.g.
 > "ADDSEQ") the parse fails. Is it possible to parse an instruction like
 > this with a cgen description?

I would expect this to work.  I'll look into it.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Parsing mnemonic suffixes
@ 2005-09-20 14:10 Will Newton
  2005-09-21 15:19 ` Doug Evans
  0 siblings, 1 reply; 3+ messages in thread
From: Will Newton @ 2005-09-20 14:10 UTC (permalink / raw)
  To: cgen


I'm having a little trouble with getting a cgen generated assembler to
parse multiple suffixes on a mnemonic. The instruction is specified like
this:

"add$sc$cond $reg,$reg,$reg"

The operand "sc" can have a value of "S" or "" depending on whether this
instruction sets condition flags.
The operand "cond" can have one of a number of values ("Z", "EQ", "NE",
"", etc.) depending on whether this instruction is conditional or not.

When either $sc or $cond is used in isolation (e.g. "ADDS", "ADDEQ") the
mnemonic is parsed correctly, when the two are used together (e.g.
"ADDSEQ") the parse fails. Is it possible to parse an instruction like
this with a cgen description?

Thanks,

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-09-21 16:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-21 16:10 Parsing mnemonic suffixes Will Newton
  -- strict thread matches above, loose matches on Subject: below --
2005-09-20 14:10 Will Newton
2005-09-21 15:19 ` Doug Evans

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).