public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* CGEN Regex support
@ 2001-07-12 14:51 J. Johnston
  0 siblings, 0 replies; only message in thread
From: J. Johnston @ 2001-07-12 14:51 UTC (permalink / raw)
  To: cgen

I have just checked in some changes originally written by Graydon which enhance insn parsing.  They
take advantage of the regex support just recently added to libiberty.  At initialization, various
insn formats are translated into simple regular expressions (operands are treated as .*).  Before
parsing an insn, a check is made to see if the insn at least has all the fixed characters in the
right position before parsing any further.  This reduces the chance that a valid error message from
one of the parsing routines gets stomped on because a bad match is attempted because it has the same
mnemonic.

For example, if you had two insns:

    move k,reg
    move reg,k

where "k" is a fixed register and reg cannot be "k", then if a user has

    move k,l,m

This should give a message about unexpected characters found at the end of the line.  In the old
scenario, the parser would fail the first attempt and then try the second form of the move insn. 
This would then result in an error regarding the fact that "k" is not valid as a reg which is not
meaningful to the user.  The new code will not attempt the second case so the error message from the
first parsing is preserved.

The following are the ChangeLogs:

From cgen:

2001-07-12  Jeff Johnston  <jjohnstn@redhat.com>

        * opc-itab.scm (@arch@_cgen_init_opcode_table): Unconditionally
        call @arch@_cgen_build_insn_regex now that regex support is in
        libiberty.


From opcodes:

2001-07-12  Jeff Johnston  <jjohnstn@redhat.com>

        * cgen-asm.in: Include "xregex.h" always to enable the libiberty
        regex support.
        (@arch@_cgen_build_insn_regex): New routine from Graydon.
        (@arch@_cgen_assemble_insn): Add Graydon's code to use regex
        to verify if it is worth parsing the insn as insn "x".  Also update
        error message when insn is not a recognized format of the insn vs
        when the insn is completely unrecognized.

and from include:

2001-07-12  Jeff Johnston  <jjohnstn@redhat.com>

        * opcode/cgen.h (CGEN_INSN): Add regex support.
        (build_insn_regex): Declare.

-- Jeff J.

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

only message in thread, other threads:[~2001-07-12 14:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-12 14:51 CGEN Regex support 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).