From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17480 invoked by alias); 28 May 2009 22:53:20 -0000 Received: (qmail 17463 invoked by uid 22791); 28 May 2009 22:53:19 -0000 X-SWARE-Spam-Status: No, hits=-51.0 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_33,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 28 May 2009 22:53:13 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n4SMrBDP031624; Thu, 28 May 2009 18:53:11 -0400 Received: from greed.delorie.com (vpn-12-119.rdu.redhat.com [10.11.12.119]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n4SMrADO001949; Thu, 28 May 2009 18:53:11 -0400 Received: from greed.delorie.com (greed.delorie.com [127.0.0.1] (may be forged)) by greed.delorie.com (8.14.3/8.14.3) with ESMTP id n4SMrAFn009257; Thu, 28 May 2009 18:53:10 -0400 Received: (from dj@localhost) by greed.delorie.com (8.14.3/8.14.3/Submit) id n4SMrAoi009254; Thu, 28 May 2009 18:53:10 -0400 Date: Thu, 28 May 2009 22:53:00 -0000 Message-Id: <200905282253.n4SMrAoi009254@greed.delorie.com> From: DJ Delorie To: cgen@sourceware.org, binutils@sourceware.org Subject: [patch] mep-ivc2: range checking Mailing-List: contact cgen-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cgen-owner@sourceware.org X-SW-Source: 2009-q2/txt/msg00022.txt.bz2 This patch adds a custom parser for IVC2 move-immedate insns that includes range checking, since those insns use multi-fields. Committed. [cgen] * cpu/mep.opc (parse_signed16_range): New. (parse_unsigned16_range): New. * cpu/mep-ivc2.cpu (imm16p0, simm16p0): Use them. [opcodes] * mep-asm.c: Regenerate. * mep-desc.c: Regenerate. Index: cgen/cpu/mep-ivc2.cpu =================================================================== RCS file: /cvs/src/src/cgen/cpu/mep-ivc2.cpu,v retrieving revision 1.3 diff -p -U3 -r1.3 mep-ivc2.cpu --- cgen/cpu/mep-ivc2.cpu 27 May 2009 01:49:44 -0000 1.3 +++ cgen/cpu/mep-ivc2.cpu 28 May 2009 22:51:13 -0000 @@ -213,8 +213,8 @@ (dnop ivc-x-0-4 "filler" (all-mep-isas) h-uint f-ivc2-4u0) (dnop ivc-x-0-5 "filler" (all-mep-isas) h-uint f-ivc2-5u0) -(dnop imm16p0 "Imm16p0" (all-mep-isas) h-uint f-ivc2-imm16p0) -(dnop simm16p0 "sImm16p0" (all-mep-isas) h-sint f-ivc2-simm16p0) +(dpop imm16p0 "Imm16p0" (all-mep-isas) h-uint f-ivc2-imm16p0 "unsigned16_range") +(dpop simm16p0 "sImm16p0" (all-mep-isas) h-sint f-ivc2-simm16p0 "signed16_range") (df f-ivc2-ccrn-c3hi "ccrn hi 2u28" (all-mep-isas) 28 2 UINT #f #f) Index: cgen/cpu/mep.opc =================================================================== RCS file: /cvs/src/src/cgen/cpu/mep.opc,v retrieving revision 1.6 diff -p -U3 -r1.6 mep.opc --- cgen/cpu/mep.opc 22 May 2009 17:37:43 -0000 1.6 +++ cgen/cpu/mep.opc 28 May 2009 22:51:13 -0000 @@ -88,7 +88,9 @@ extern int mep_cgen_insn_supported (CGEN const char * parse_mep_align (CGEN_CPU_DESC, const char **, enum cgen_operand_type, long *); const char * parse_mep_alignu (CGEN_CPU_DESC, const char **, enum cgen_operand_type, unsigned long *); static const char * parse_signed16 (CGEN_CPU_DESC, const char **, int, long *); +static const char * parse_signed16_range (CGEN_CPU_DESC, const char **, int, long *); static const char * parse_unsigned16 (CGEN_CPU_DESC, const char **, int, unsigned long *); +static const char * parse_unsigned16_range (CGEN_CPU_DESC, const char **, int, unsigned long *); static const char * parse_lo16 (CGEN_CPU_DESC, const char **, int, long *, long); static const char * parse_unsigned7 (CGEN_CPU_DESC, const char **, enum cgen_operand_type, unsigned long *); static const char * parse_zero (CGEN_CPU_DESC, const char **, int, long *); @@ -343,6 +345,46 @@ parse_unsigned16 (CGEN_CPU_DESC cd, return parse_lo16 (cd, strp, opindex, (long *) valuep, 0); } +static const char * +parse_signed16_range (CGEN_CPU_DESC cd, + const char **strp, + int opindex, + signed long *valuep) +{ + const char *errmsg = 0; + signed long value; + + errmsg = cgen_parse_signed_integer (cd, strp, opindex, & value); + if (errmsg) + return errmsg; + + if (value < -32768 || value > 32767) + return _("Immediate is out of range -32768 to 32767"); + + *valuep = value; + return 0; +} + +static const char * +parse_unsigned16_range (CGEN_CPU_DESC cd, + const char **strp, + int opindex, + unsigned long *valuep) +{ + const char *errmsg = 0; + unsigned long value; + + errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, & value); + if (errmsg) + return errmsg; + + if (value > 65535) + return _("Immediate is out of range 0 to 65535"); + + *valuep = value; + return 0; +} + /* A special case of parse_signed16 which accepts only the value zero. */ static const char *