public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* Instruction Parsing
@ 2001-04-05 15:18 J. Johnston
  0 siblings, 0 replies; only message in thread
From: J. Johnston @ 2001-04-05 15:18 UTC (permalink / raw)
  To: cgen

I have recently run into some problems with a port whereby there are multiple instructions with the
same mnemonic, but different operands.  In particular, there is a fixed register in each version of
the instruction that is either the source or the destination.

For example, a load instruction of the two forms:

              load x,offset(gpr)
              load gpr,x

where x is fixed in both cases and the offset and gpr fields are parsed operands.

What happens is that the parser tries each in succession and so we end up getting the error message
from the last attempt, no matter how poorly a fit that is.

What I would like to propose is that the instruction parser uses regular expressions and verifies
when a match on the fixed portion of the instruction occurs.  If the fixed portion doesn't match, we
don't start parsing the operands in the instruction.  This will stop us from overwriting meaningful
parse messages.

For example, let's say gprs can be one of k or l and that the offset must be <1024.

         load x,1025(k)

will fail when the parse for offset occurs.  It sets the error message to be something appropriate:
"gpr offset too large - must be <1024"

Currently, we continue on and try to do the load gpr,x version.  The parser for gpr complains that:
"x is not a gpr".

If instead, we rule out the second case because load .*,x is not matched, then we avoid trashing the
first and more appropriate error message.

This could have other benefits in truly recognizing when parentheses are required as part of the
instruction format rather than being treated as expression delimiters. 

-- Jeff J.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-04-05 15:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-05 15:18 Instruction Parsing J. Johnston

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