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 5BEE93858403 for ; Wed, 15 Sep 2021 16:32:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5BEE93858403 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18FEpCFS009463 for ; Wed, 15 Sep 2021 16:32:38 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3b3jy7gcc2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 15 Sep 2021 16:32:38 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 18FGGqN2031217 for ; Wed, 15 Sep 2021 16:32:37 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by aserp3030.oracle.com with ESMTP id 3b0jgevske-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 15 Sep 2021 16:32:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cq0EINelAUIKiOHw3+sH2z1DRcGrw642Bhwe3Qyq9XjITL5X+yyw/7Ptj2aQVbjkP59KfCNBnbeUNh7TE4hWmRQqh2Lmrt95cJuMkpqqOaxr7yRoLjWy+IDx2O3S4AGe5iTSwIFoO+CExAiBOhchmhyrFZNH8y74aaiMgPUzGiIoNcLQOJRBR9pUhao+GiogQBLbYfnX8jD0WrRN2mGt4EHk/FOZlOxvVv/fszUu8n3QuF3p61Z8sKzoJjP8APTOjlCdQkYJiTkzXlKj3VHmW76YBahwosMxmsLT8atdS7k3G8kLnGldNrIr+y8lqCKzJLSf5ZjPIY9F83YSS5VIxA== 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; bh=5ra8OWNrAaqh07AokoAGeaM0MGMCr7BJ5ONsNuRQCB4=; b=JM5GCxarDIXv43szUuEkquwlqqECzPyjPVSOYATR6hFT/NFYGihEzdfM8KCI5WdOifrYWr/tTbdJ7HqX6ehCjZHoI2HTR8FIMGWaBP0dWWCkFQUWouxAiC3DcjwJZ9c/G9r3DuF6XquIzgkxkZyFOXhRGz7Zs2QI666nEL8h5zOvUUOeEUOsi7QQsAQjXcw/iM5CfiBqIBeLoYhhQLMx+geK3o0ZRHaR2ww7Vl28EmlO3GzF49jV11IMfiQZLn8s9JStyU7oUBgylaLapsdyAfnzvCyMcqD6/niwU46TMe0DqbyyOurvpBiDfAw/26b3ljgKBI79LzUeUM8v/6Zfpg== 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 BLAPR10MB4979.namprd10.prod.outlook.com (2603:10b6:208:30d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Wed, 15 Sep 2021 16:32:35 +0000 Received: from BL0PR10MB2852.namprd10.prod.outlook.com ([fe80::3dec:9a58:e63e:c452]) by BL0PR10MB2852.namprd10.prod.outlook.com ([fe80::3dec:9a58:e63e:c452%6]) with mapi id 15.20.4500.019; Wed, 15 Sep 2021 16:32:35 +0000 From: "Guillermo E. Martinez" To: cgen@sourceware.org Subject: [PATCH v2] cgen: Compute correct mask and values when offset in define-ifield is not 0. Date: Wed, 15 Sep 2021 11:32:12 -0500 Message-Id: <20210915163212.157394-1-guillermo.e.martinez@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210820023254.2575757-1-guillermo.e.martinez@oracle.com> References: <20210820023254.2575757-1-guillermo.e.martinez@oracle.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SN4PR0501CA0038.namprd05.prod.outlook.com (2603:10b6:803:41::15) To BL0PR10MB2852.namprd10.prod.outlook.com (2603:10b6:208:76::22) MIME-Version: 1.0 Received: from sali.us.oracle.com (2606:b400:8004:44::22) by SN4PR0501CA0038.namprd05.prod.outlook.com (2603:10b6:803:41::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.9 via Frontend Transport; Wed, 15 Sep 2021 16:32:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9b0f3487-86f0-44d8-0025-08d978666c71 X-MS-TrafficTypeDiagnostic: BLAPR10MB4979: 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: /jT7/oLaf3cc9zHILYOjyMHcdHGxanK2+vqrBo01xLiMqH54H7718Z+dY2flRJAB5cH3aA+Fz+3PWOnKW+VmKsMpUYDf365Zh2mOt6SFw/SywlsowHxaVq5zZG0UiYsUlE2p1bGvDbdU46vZ+jFyNYCaUZLTSNKWuJNBAiPhAf4NmCL1sFnqvODA7QGlx55bzm8amBnMe3qqjyjuCUBqAcc26csQCUfIceE/oLtB5qs0Z0f57WqDrlQqCiwXS0WVOatdTlZ/zmUHNHgiBm3UvomLBRb/cLlRpN3HzfHRn6+Wqv4ogNvVBoh7kAGT0qEjm4NNS9d4YOuxS+CbiZ0gOBdP/TReybdrohm9ONe0faW9SgP2nE5s2rGdCKTGBTTj/XpWAjbObbnd+GJI9bU6qR9tDGIHqI9nOs4JnkdiCJNCLoW1jRMMBXKTSVZnAkgY/36GLYlr44aRbwAQj8xjENPowbvb1d75dgguX8ZyiIp+o6ABtg46FX3h3FnL+E8gWqNKN0pDt8ewzRzL9/WtFaFVIl2CQcDDB/gVzGDOTcyTGPMbZOUb+HGyqD7fkY34MgO+/BywOi0dwCCYTlycd0KRtimEG2bSzJQiF96Cq+S5/T2pR5g0V5NAmBLGkUFFPBEJGFQ9JJtM8Pnz/wqQTg== 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:(376002)(39860400002)(136003)(366004)(396003)(346002)(38100700002)(107886003)(86362001)(186003)(6916009)(4326008)(6666004)(36756003)(5660300002)(103116003)(2906002)(478600001)(2616005)(83380400001)(66946007)(6486002)(316002)(1076003)(66476007)(8936002)(8676002)(66556008)(52116002)(7696005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?fiWuNYcInpv2P4NBp1C7YO0p7GhRHyWoEYydkqwOHePzAz68tVTtoo0V4qof?= =?us-ascii?Q?bhigPTEZGa5LNKXQi735XR3VDxIQh9p/Bamq57byEn/hhX7nvSp3HaO/XFL0?= =?us-ascii?Q?8ZzPyvGlEV+y8eWuJJbIxTa4+O90wyElrh3TACtpWlZIrpLDnW0xLprV1Ao9?= =?us-ascii?Q?xjuH40aymGnsaLuuhCEF7amKuNL5c7gtMbftXTZ5G14XmH3sElGyJV3uWLfq?= =?us-ascii?Q?0hTHyojco+SZHBeqdxU0/KNcRB7yDhsuLrykh4jFP1nX1Txa+tl/aIFnXWEV?= =?us-ascii?Q?ERnz9ZkPhM0wXvUWyyKZQJ4owYzH+Po0rHE8kCbhVi6/LJyuw4oOYw4cEpmE?= =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nTJJnI6EI/zbApLWf?= =?us-ascii?Q?EjjVkji9iU4VjVBkF040vU2wkoQwHPahTJ/h1oWCTFngYC47U+i9dXNSHW4M?= =?us-ascii?Q?EFYdZiZCNaco29s1G/YYtLJvUE9htr51y/VlVpvcg+4t3w=3D=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b0f3487-86f0-44d8-0025-08d978666c71 X-MS-Exchange-CrossTenant-AuthSource: BL0PR10MB2852.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2021 16:32:35.2797 (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: UjwWTIlow64CMQT3lqUAC6YrX+SU3TJfeposTKsMGLMrw4o2Okqfy2306c1GxAbAEFgmjZRzStZ78b0a57SYqKfehIuL3lZBtUFbnwgdUag= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4979 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10108 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109150101 X-Proofpoint-GUID: fDi5Imn4j0R9EhhZAblhD7Xv5A0dnqh3 X-Proofpoint-ORIG-GUID: fDi5Imn4j0R9EhhZAblhD7Xv5A0dnqh3 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_H2, 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: Wed, 15 Sep 2021 16:32:41 -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 | 18 ++++++++++-------- 4 files changed, 24 insertions(+), 19 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..a6d2d53 100644 --- a/utils.scm +++ b/utils.scm @@ -797,37 +797,39 @@ (define (minmax min max) (cons min max)) -; Move VALUE of LENGTH bits to position START in a word of SIZE bits. +; Move VALUE of LENGTH bits to position START plus an OFFSET bits +; in a word of SIZE bits. ; LSB0? is non-#f if bit numbering goes LSB->MSB. ; Otherwise it goes MSB->LSB. ; START-LSB? is non-#f if START denotes the least significant bit. ; 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. +; Return a bit mask of LENGTH bits in a word of SIZE bits starting +; at START plus an OFFSET bits. ; LSB0? is non-#f if bit numbering goes LSB->MSB. ; Otherwise it goes MSB->LSB. ; 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