From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121150 invoked by alias); 14 May 2019 18:09:35 -0000 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 Received: (qmail 121141 invoked by uid 89); 14 May 2019 18:09:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 spammy=HTo:U*cgen, H*Ad:U*cgen, H*r:sk:cgen@so, modra X-HELO: aserp2130.oracle.com Received: from aserp2130.oracle.com (HELO aserp2130.oracle.com) (141.146.126.79) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 14 May 2019 18:09:33 +0000 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4EI9Oeo006207 for ; Tue, 14 May 2019 18:09:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id; s=corp-2018-07-02; bh=mCKPZk8NGhLN8L+FrBf71Qr92bzX6wMlYxF490o4Rps=; b=ahOrDY6mB/G+5kwrcParFvCo7jt62+LLGTrzk4ur0dpSp0uHZZF+8onXsZfFzoEL8aY6 OxGvOjB/DY9fNXmGE5owFv4oEmuS7YcFGALCm+goe3J7apMtLzqR5aRwfoXKTzYXNGgT /UQ8d9oJO/FK2apZWDfbed2Bqn3jowlb5QwqY/GnBDJpPIOBrPw4VhbLWFhM3vFpzpsC 2egan3vUukH1QzTzQGwjVNQYN/mGEBsJ7LJQmYBzBhhHpL88S119qoh7uGqaVJVYbUs/ cX/3aN97olsH/QJHwvzMelWPRWkO/czQcUSd+dYau9Hxb+sP15Bx+tvDXlZAFiJUuxpS /Q== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 2sdkwdr5p2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 14 May 2019 18:09:31 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4EI9Jsh126459 for ; Tue, 14 May 2019 18:09:31 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2sdmeb7xbb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 14 May 2019 18:09:30 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x4EI9UJU030126 for ; Tue, 14 May 2019 18:09:30 GMT Received: from termi.localdomain (/10.175.3.41) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 14 May 2019 11:09:29 -0700 From: "Jose E. Marchesi" To: cgen@sourceware.org Subject: [PATCH] cgen: partial support for 64-bit wide fields in 32-bit hosts Date: Tue, 14 May 2019 18:09:00 -0000 Message-Id: <20190514180925.4712-1-jose.marchesi@oracle.com> X-SW-Source: 2019-q2/txt/msg00008.txt.bz2 Hi people! This patch adds support for having 64-bit wide fields working in 32-bit hosts. This is not a complete solution, but it is enough for supporting: - Defining a 64-bit h-sint in your .cpu file. - Using that hardware to define an operand featuring as index a 64-bit wide multi-ifield. Note that the current CGEN support in binutils provides cgen_{extract,insert}_normal functions that get `long' values, hence the need for the operand to be indexed by a multi-ifield. This is used by an eBPF binutils port which I will be upstreaming this week. All other CGEN-based ports currently in binutils are not impacted by this change. Eventually, we shall make the "portable" INT/UINT modes (and associated hardwares s-int/s-uint) to work properly in 32-bit hosts when holding 64-bit values. I have a tentative large patch attempting that, including changes in binutils's opcodes CGEN support, that I will send for comments soon, but in the meanwhile I would really appreciate if this gets into cgen. (Without this patch applied, the eBPF assembler doesn't work properly in 32-bit hosts.) Thanks! 2019-05-14 Jose E. Marchesi * opcodes.scm (gen-ifield-default-type): Use int64_t for fields wider than 32-bits. (/gen-parse-number): Use u?int64_t for > 32-bit modes. (gen-ifield-value-decl): Fix call to gen-ifield-default-type. (, gen-insert): Likewise. (, gen-extract): Likewise. * opc-asmdis.scm (char): Likewise. --- ChangeLog | 10 ++++++++++ opc-asmdis.scm | 2 +- opcodes.scm | 21 +++++++++++++-------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9add333..058fc6d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2019-05-14 Jose E. Marchesi + + * opcodes.scm (gen-ifield-default-type): Use int64_t for fields + wider than 32-bits. + (/gen-parse-number): Use u?int64_t for > 32-bit modes. + (gen-ifield-value-decl): Fix call to gen-ifield-default-type. + (, gen-insert): Likewise. + (, gen-extract): Likewise. + * opc-asmdis.scm (char): Likewise. + 2019-01-01 Alan Modra * utils.scm: Update emitted copyright dates. diff --git a/opc-asmdis.scm b/opc-asmdis.scm index 6bdd44c..b268bf5 100644 --- a/opc-asmdis.scm +++ b/opc-asmdis.scm @@ -32,7 +32,7 @@ const char * { const char * errmsg = NULL; /* Used by scalar operands that still need to be parsed. */ - " (gen-ifield-default-type) " junk ATTRIBUTE_UNUSED; + " (gen-ifield-default-type #f) " junk ATTRIBUTE_UNUSED; switch (opindex) { diff --git a/opcodes.scm b/opcodes.scm index f24b368..66ce9dd 100644 --- a/opcodes.scm +++ b/opcodes.scm @@ -73,9 +73,10 @@ ; Default type of variable to use to hold ifield value. -(define (gen-ifield-default-type) - ; FIXME: Use long for now. - "long" +(define (gen-ifield-default-type f) + (if (and f (> (mode:bits (ifld-mode f)) 32)) + "int64_t" + "long") ) ; Given field F, return a C definition of a variable big enough to hold @@ -83,7 +84,7 @@ (define (gen-ifield-value-decl f) (gen-obj-sanitize f (string-append " " - (gen-ifield-default-type) + (gen-ifield-default-type f) " " (gen-sym f) ";\n")) ) @@ -113,7 +114,7 @@ (if need-extra? (string-append " {\n" " " - (gen-ifield-default-type) + (gen-ifield-default-type self) " value = " varname ";\n") "") (if encode @@ -175,7 +176,7 @@ (string-append (if need-extra? (string-append " {\n " - (gen-ifield-default-type) + (gen-ifield-default-type self) " value;\n ") "") " length = " @@ -372,8 +373,12 @@ ; This is to pacify gcc 4.x which will complain about ; incorrect signed-ness of pointers passed to functions. (case (obj:name mode) - ((QI HI SI INT) "(long *)") - ((BI UQI UHI USI UINT) "(unsigned long *)") + ((QI HI SI DI INT) + (if (> (mode:bits mode) 32) "(int64_t *)" "(long *)")) + ((BI UQI UHI USI UDI UINT) + (if (> (mode:bits mode) 32) "(uint64_t *)" "(unsigned long *)")) + (else (error "unsupported (as yet) mode for parsing" + (obj:name mode))) ) " (& " result-var-name "));\n" -- 2.11.0