From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16809 invoked by alias); 21 Sep 2005 16:10:19 -0000 Mailing-List: contact cgen-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cgen-owner@sources.redhat.com Received: (qmail 16189 invoked by uid 22791); 21 Sep 2005 16:10:04 -0000 Received: from multi.imgtec.com (HELO multi.imgtec.com) (194.200.65.239) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 21 Sep 2005 16:10:04 +0000 X-SEF-Processed: 5_0_0_812__2005_09_21_17_09_44 Received: from Unknown [192.168.5.239] by multi.imgtec.com - SurfControl E-mail Filter (5.0); Wed, 21 Sep 2005 17:09:44 +0100 Received: from lemail1.le.imgtec.org ([192.168.152.65]) by klmail1.kl.imgtec.org with Microsoft SMTPSVC(6.0.3790.1830); Wed, 21 Sep 2005 17:09:44 +0100 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: Parsing mnemonic suffixes Date: Wed, 21 Sep 2005 16:10:00 -0000 Message-ID: <0D107966AF6D79418315B7C5549F4B5104E01C@lemail1.le.imgtec.org> From: "Will Newton" To: "Doug Evans" Cc: X-SW-Source: 2005-q3/txt/msg00034.txt.bz2 =20 > > I'm having a little trouble with getting a cgen generated=20 > assembler to > parse multiple suffixes on a mnemonic. The=20 > instruction is specified like > this: > > > > "add$sc$cond $reg,$reg,$reg" > > > > The operand "sc" can have a value of "S" or "" depending=20 > on whether this > instruction sets condition flags. > > The operand "cond" can have one of a number of values=20 > ("Z", "EQ", "NE", > "", etc.) depending on whether this=20 > instruction is conditional or not. > > > > When either $sc or $cond is used in isolation (e.g.=20 > "ADDS", "ADDEQ") the > mnemonic is parsed correctly, when=20 > the two are used together (e.g. > > "ADDSEQ") the parse fails. Is it possible to parse an=20 > instruction like > this with a cgen description? >=20 > 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.