This is the mail archive of the
cgen@sources.redhat.com
mailing list for the CGEN project.
CGEN Regex support
- To: cgen at sources dot redhat dot com
- Subject: CGEN Regex support
- From: "J. Johnston" <jjohnstn at cygnus dot com>
- Date: Thu, 12 Jul 2001 17:51:11 -0400
- Organization: Red Hat Inc.
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.