From mboxrd@z Thu Jan 1 00:00:00 1970 From: "J. Johnston" To: cgen@sources.redhat.com Subject: CGEN Regex support Date: Thu, 12 Jul 2001 14:51:00 -0000 Message-id: <3B4E1BCF.73F24B77@cygnus.com> X-SW-Source: 2001-q3/msg00041.html 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 * 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 * 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 * opcode/cgen.h (CGEN_INSN): Add regex support. (build_insn_regex): Declare. -- Jeff J.