From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id 12A32385BF84 for ; Fri, 20 Aug 2021 02:33:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 12A32385BF84 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 17K2MtHZ020936 for ; Fri, 20 Aug 2021 02:33:44 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3ahsxd15ed-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 20 Aug 2021 02:33:44 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 17K2LS0q115440 for ; Fri, 20 Aug 2021 02:33:43 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2107.outbound.protection.outlook.com [104.47.58.107]) by userp3030.oracle.com with ESMTP id 3ae2y5ph5t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 20 Aug 2021 02:33:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GeqmRAZGbwwLrqaXT40S8pC4bpLchH12tmroQZLLADIBAymMTdGv9cig/UjasMlpa8dAxHppBgCo6BZUBDoro5Z0mRTes9zwnvcFThzftYNAirR9H5K8c/pufrM3lfjur/4hoQ7zb2Zk18XbBwDEQ1PEVKLMJDR5miTRrpxNgxwq+RuFYAoucOUE3eHvBICkUiXDizs1Ix/jz6PG6yzcN8DPcMgwEaIuNLt/X0RuDH77hL06QUgeE57ywzv7iWpVvB0EcRWtgTl5VwZw46lnVxfTuIkNb/Hvs+SH3T/s0YiA9VTYG2Nsh3jBO7ho9Ah3istZqnVw/skhtyrS5D7vMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zFwQjx1FrJhtcMFlnfaWTdLAmhZkCSvkNGwGBDnVDbM=; b=UEP7aGj42db2QIzilGxwTjXPKJKgWuCjwlCRUB4QpEPrLv7njYYF4bmJdI0lUcyF43XT4JJPRDc1AA0sL2VkpGJakc8S7skLgEdegWogOfHMzTyd10pVW5hex8TO5knecGZunOS/Jv50MDt91znkDtzIOBSo06LYkqja2x+oRbtZt8WaXnBLg6HQvn498azkC4oetouScnNz0nw5WFT3xtzS6GcLFmPYsjIMtau9OxLvlzdNwCMQzbTyVLGzhlJR2sbD+pQRT/JXdOeSIBI/bX0Q7kATdIEibsFfbDY3P65Kcm042ycyWoDCEByOKRCuRN8P64dEzX1i6Cn2bAtP8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from BL0PR10MB2852.namprd10.prod.outlook.com (2603:10b6:208:76::22) by MN2PR10MB3853.namprd10.prod.outlook.com (2603:10b6:208:180::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Fri, 20 Aug 2021 02:33:41 +0000 Received: from BL0PR10MB2852.namprd10.prod.outlook.com ([fe80::61a4:9f80:cac3:e157]) by BL0PR10MB2852.namprd10.prod.outlook.com ([fe80::61a4:9f80:cac3:e157%3]) with mapi id 15.20.4415.024; Fri, 20 Aug 2021 02:33:41 +0000 From: "Guillermo E. Martinez" To: cgen@sourceware.org Cc: "Guillermo E. Martinez" Subject: [PATCH CGEN v1] cgen: Compute correct mask and values when offset in define-ifield is not 0. Date: Thu, 19 Aug 2021 21:32:54 -0500 Message-Id: <20210820023254.2575757-1-guillermo.e.martinez@oracle.com> X-Mailer: git-send-email 2.30.2 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BY5PR17CA0058.namprd17.prod.outlook.com (2603:10b6:a03:167::35) To BL0PR10MB2852.namprd10.prod.outlook.com (2603:10b6:208:76::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sali.us.oracle.com (2606:b400:8004:44::20) by BY5PR17CA0058.namprd17.prod.outlook.com (2603:10b6:a03:167::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Fri, 20 Aug 2021 02:33:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d0ecb706-efdf-4aa0-de5a-08d96382ec23 X-MS-TrafficTypeDiagnostic: MN2PR10MB3853: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mMYXpRxLM1PaajySTIAJJ2SyBofq3TOu1qkdImCPkAk1gJAokooBtiZFOvwqMS8yFJGnCA2bvl1joY36Mg2t7f772RbDlEr4I5dLmA9SxO3NSTyGWKDpiYDZsnfNVrir+SwGuYhu2nnWeBpFplkwEr9wBBp3LqpmZonltCOr+uPk6dy31BQ8fj8OKFitx2T27rl45D2CVAdOh96Q/kDHW1y2leJt4S/sl+F6TYLDdRZNdCqUNWuyQzyfyshtX6eAbhfqjA/O7Ap8/Fea6E2TrI0hQa7sCyQgD1H5Rqv6X2ZQGN4Z/ak5XVu0VkLygzInQJSrFBWnzBcQtVC0CJ+IN3v+O934rmpQilPJKlmmWUZKxlhm4X2QMtEtXu+xoYARLkUad4GpJERxNnI3y/uVMzL2p5JKL2b1ZrcmRC8Tf0AJ2X9xvmweuUEYFWvdrbJq7JytAYPRe0aVzhO4u8+AAcXVOtwOkHcHzeqtFg8iRt8od+xr7AUPwyOForplPhfc5voCa75pFau6e+C3qhCJFSWFanOHqn8QSa1FnkLrVovlRjkZmCupBnEGgI9Hg6957yFxGuSGB4gALm16499p/wyjMC+vAsUJ5Dy3WUu2PQDGGDZifVogIji7C0L9oY6lMMMk/GafQBWwHr5s5SPM4w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR10MB2852.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(86362001)(38100700002)(103116003)(36756003)(83380400001)(186003)(52116002)(7696005)(6486002)(316002)(8676002)(66946007)(5660300002)(66556008)(66476007)(8936002)(508600001)(6916009)(107886003)(4326008)(1076003)(2616005)(6666004)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?4/mDazl7bqO+5vDkSiATAwrrJWq4QCAvDDj0xAJEdptyrS2PC1Ry3wJMcY7m?= =?us-ascii?Q?0uzCJI+2ay6KOi1HVxOPGZ6yhybnP1rIYUzcEGqUDthb6Q2WjnHiF0E+EJ8V?= =?us-ascii?Q?+Z/mg+cc0EWjsmfEOOYyyBMPvnY1kMUs7936HhxJ/icp06TKq26Ve8ZDCWTq?= =?us-ascii?Q?6NT1zLoGIpSFkSc9FpB8gLpeDbZOvNna7sqZrEbxpL5CM5rlSJCVqHXVDVTn?= =?us-ascii?Q?HtnD3DnUAOHSyoutsaIe0TZXT9xVBlcIhnk3a7WMo3L/RmC/i9AI7YIe/28n?= =?us-ascii?Q?HWyzm+UU7zzQGCudUj7p0SnhaJMtV4v3DoonMwBnstC8xWTLOJj9kHvwCD3U?= =?us-ascii?Q?J2g3M4clmc7hEo62M3CPOIztqUYD11sEI6FC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PKpq22/IpvFpQqTSoZrmJ6uGTUN4/TbPZLPMtWL9abQn9rQ5b2?= =?us-ascii?Q?nUffGfZI6N1jVPYxcxGDt9Pe1SjcUhKW5YNsPGU/o+x5Wg=3D=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0ecb706-efdf-4aa0-de5a-08d96382ec23 X-MS-Exchange-CrossTenant-AuthSource: BL0PR10MB2852.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2021 02:33:40.9826 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EsxkglY5o70e1sZfxUwBYYsXzBFWf8ynvOj9DNGKeZsqRy71hXf0olraAKztwEXyzOGDNrVJklCk1lGhqShj8UthLh3MGlBxzKM+KMinTms= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB3853 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10081 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108200011 X-Proofpoint-GUID: iruY_LJloSsULV89CPVerZovK843pulm X-Proofpoint-ORIG-GUID: iruY_LJloSsULV89CPVerZovK843pulm X-Spam-Status: No, score=-14.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_BL, RCVD_IN_MSPIKE_L3, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: cgen@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cgen mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Aug 2021 02:33:56 -0000 If an instruction field is defined in a long form, assigning an offset different to 0 the mask and constant values are not computed appropriately: (dwf f-op-fld-offset "field with an offset" (all-isas) 32 64 31 32 UINT) ;; ;; 63 39 32 31 7 0 ;; +---------------------+-------....-------------+ ;; |/////////////////////| | | ;; +---------------------+-------....-------------+ ;; | ;; | ;; | ;; | ;; +---> OP_FLD_OFFSET_... bitrange: #(object 29 32 31 32 64 #t) mask: 0xffffffff value: simplify.inc:173:3: Error: Instruction has opcode bits outside of its mask. Fixed to: bitrange: #(object 29 32 31 32 64 #t) mask: 0xffffffff00000000 value: 0xaa00000000 word-length relies in base-len (sum of length of all fields in bitrange objects that conform the instruction), word-value and word-mask are not using the offset entry in the bitrange object to calculate the accurate values when constant fields are provided (ifld-constant? #t), so one more argument is passed to those procedures to be used in the compute. Regression tests to the following targets were done: bpf arm-linuxeabi arm-nacl arm-netbsdelf arm-nto arm-pe arm-symbianelf arm-vxworks arm-wince-pe aarch64-linux alpha-dec-vms alpha-linux alpha-linuxecoff alpha-netbsd alpha-unknown-freebsd4.7 am33_2.0-linux arc-linux-uclibc avr-elf bfin-elf cr16-elf cris-elf crisv32-linux crx-elf d10v-elf d30v-elf dlx-elf epiphany-elf fr30-elf frv-elf frv-linux ft32-elf h8300-elf hppa-linux hppa-hp-hpux10 hppa64-hp-hpux11.23 hppa64-linux mips-linux mips-vxworks mips64-linux mipsel-linux-gnu mipsisa32el-linux mips64-openbsd mipstx39-elf ia64-elf ia64-freebsd5 ia64-hpux ia64-linux ia64-netbsd ia64-vms ip2k-elf iq2000-elf lm32-elf m32c-elf m32r-elf m68hc11-elf m68hc12-elf m68k-elf m68k-linux m68k-netbsd mcore-elf mcore-pe mep-elf metag-linux microblaze-elf mmix mn10200-elf mn10300-elf moxie-elf ms1-elf msp430-elf mt-elf nds32le-elf nios2-linux or1k-elf pdp11-dec-aout pj-elf powerpc-eabisim powerpc-eabivle powerpc-linux powerpc-nto powerpc-wrs-vxworks powerpc64-linux powerpcle-cygwin powerpcle-elf powerpc64le-linux ppc-lynxos pru-elf riscv32-elf riscv64-elf rl78-elf rs6000-aix4.3.3 rs6000-aix5.1 rx-elf s390-linux s390x-linux score-elf sh-linux sh-nto sh-pe sh-rtems sh-vxworks shl-unknown-netbsdelf sparc-aout sparc-linux sparc-vxworks sparc64-linux sparc-sun-solaris2.12 spu-elf tic30-unknown-aout tic30-unknown-coff tic4x-coff tic54x-coff tic6x-elf tilegx-linux tilepro-linux v850-elf vax-netbsdelf visium-elf i386-darwin i386-lynxos i586-linux i686-nacl i686-pc-beos i686-pc-elf i686-pe i686-vxworks x86_64-linux x86_64-w64-mingw32 x86_64-nacl xgate-elf xstormy16-elf xtensa-elf z8k-coff z80-coff. --- ChangeLog | 9 +++++++++ ifield.scm | 12 ++++-------- insn.scm | 4 +--- utils.scm | 12 ++++++------ 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 93eafe4..7b2b885 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2021-08-19 Guillermo E. Martinez + + * ifield.scm: word-len has a relative value depending of word-offset + value, method field-value use word-offset parameter. + * insn.scm: remove condition ifld-beyond-base? in insn-base-value + procedure to allow field access when its offset is different to zero. + * utils.scm: word-value/work-mask accept an offset as argument to + compute the mask and get the value when offset is different that zero. + 2020-05-29 Jose E. Marchesi * desc-cpu.scm (/gen-cpu-open): Support passing the instruction diff --git a/ifield.scm b/ifield.scm index 13e0c4f..c1c8cbd 100644 --- a/ifield.scm +++ b/ifield.scm @@ -216,16 +216,13 @@ (let ((lsb0? (bitrange-lsb0? bitrange)) (start (bitrange-start bitrange)) (length (bitrange-length bitrange)) - (word-length (or (and (= word-offset 0) base-len) - recorded-word-length)) + (word-length base-len) (container-word-offset (bitrange-word-offset container)) (container-word-length (bitrange-word-length container))) (cond ; must be same lsb0 ((not (eq? lsb0? (bitrange-lsb0? container))) (error "field-mask: different lsb0? values")) - ((not (= word-length container-word-length)) - 0) ; container occurs after? ((<= (+ word-offset word-length) container-word-offset) 0) @@ -233,7 +230,7 @@ ((>= word-offset (+ container-word-offset container-word-length)) 0) (else - (word-mask start length word-length lsb0? #f)))))) + (word-mask start length word-length word-offset lsb0? #f)))))) ) (define (ifld-mask ifld base-len container) @@ -251,11 +248,11 @@ (let* ((bitrange (/ifld-bitrange self)) (recorded-word-length (bitrange-word-length bitrange)) (word-offset (bitrange-word-offset bitrange)) - (word-length (or (and (= word-offset 0) base-len) - recorded-word-length))) + (word-length base-len)) (word-value (ifld-start self) (bitrange-length bitrange) word-length + word-offset (bitrange-lsb0? bitrange) #f value))) ) @@ -441,7 +438,6 @@ ; collision with the proc named `length'. ; ; FIXME: More error checking. - (define (/ifield-parse context name comment attrs word-offset word-length start flength follows mode encode decode) diff --git a/insn.scm b/insn.scm index e62bb87..7a230df 100644 --- a/insn.scm +++ b/insn.scm @@ -982,9 +982,7 @@ (elm-get insn '/insn-base-value) (let* ((base-len (insn-base-mask-length insn)) (constant-base-iflds - (find (lambda (f) - (and (ifld-constant? f) - (not (ifld-beyond-base? f)))) + (find ifld-constant? (ifields-base-ifields (insn-iflds insn)))) (base-value (apply + (map (lambda (f) diff --git a/utils.scm b/utils.scm index 29b72ff..3573eff 100644 --- a/utils.scm +++ b/utils.scm @@ -804,14 +804,14 @@ ; Otherwise START denotes the most significant bit. ; N is assumed to fit in the field. -(define (word-value start length size lsb0? start-lsb? value) +(define (word-value start length size offset lsb0? start-lsb? value) (if lsb0? (if start-lsb? (logsll value start) - (logsll value (+ (- start length) 1))) + (logsll value (+ (- start length) offset 1))) (if start-lsb? (logsll value (- size start 1)) - (logsll value (- size (+ start length))))) + (logsll value (- size (+ start length offset))))) ) ; Return a bit mask of LENGTH bits in a word of SIZE bits starting at START. @@ -820,14 +820,14 @@ ; START-LSB? is non-#f if START denotes the least significant bit. ; Otherwise START denotes the most significant bit. -(define (word-mask start length size lsb0? start-lsb?) +(define (word-mask start length size offset lsb0? start-lsb?) (if lsb0? (if start-lsb? (logsll (mask length) start) - (logsll (mask length) (+ (- start length) 1))) + (logsll (mask length) (+ (- start length) offset 1))) (if start-lsb? (logsll (mask length) (- size start 1)) - (logsll (mask length) (- size (+ start length))))) + (logsll (mask length) (- size (+ start length offset))))) ) ; Extract LENGTH bits at bit number START in a word of SIZE bits from VALUE. -- 2.30.2