From patchwork Tue Mar 1 21:59:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 547260 Delivered-To: patch@linaro.org Received: by 2002:ac0:9f50:0:0:0:0:0 with SMTP id l16csp4063646imf; Tue, 1 Mar 2022 14:02:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUuEnvAcXWSGf2aeEPpvce2DOCEY4DUIKT/Z80MYwxuRVcD71dcFfZ6dDq+NHowXFTGP24 X-Received: by 2002:ac8:5f4d:0:b0:2de:7e49:199c with SMTP id y13-20020ac85f4d000000b002de7e49199cmr21641569qta.48.1646172174958; Tue, 01 Mar 2022 14:02:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646172174; cv=none; d=google.com; s=arc-20160816; b=pCQvi+rDbKxzoW+PKCC/g0JcO/EtAsdJzdlTZ+1wYcXvBEUCWUpwDBCY7W3iIsFkdZ VDFG+yLtOUdNPoE+5h8kzMPJihrETTbyhwkMaZbozc6uL0b+D1YmEHdDEQtRN+qoZ560 5cJ1Ol+22UjKqDq3Vg6TCQPrq+kUPVmRRjQSdQTQpJW3N9OarsnzIq8kctDb7D/x+Erl zsHldEAm11Cgtj/osWTZ+z9Y4q6qPYmnXhRhuJA5PV0TLQM4BeNCD7veTXJcPGypQklv Hh19qHJH0vX8MCM6LX49DqFfqH1vk1ewsCbpuyXZ4umCMw4tlOTWtyrZL0OiNlnbAsg6 fakA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=zkNbMXCqLzhadKWhMyb5sf6Jtr4mvpt/QguB9jnfEUo=; b=w9x+JSi+fHlZhEGP1T3mYrkSwIrEbkiT2nIy98t0Wtvp87nvq7shs9YeNBesE0akul 66NIk+DvUCa8oFD9afvT8/p5eP5Io8q+sjnXwWX5pozEDdbdmYy86RNFaXwF5gX/vD24 V9+uS+p7MSf+CDpqL0VZarlNXC9IiCYyhuzyWik0sBfegoSQ5jNQLENQ0KaKowVjg5Iw 1LdjBGwH9lL2jcSjP7z+pP1+f9FnmSp4Q8b5QlVzHAgTS+esvdixkWg2J06dmLIaV8pz PAs4TAC9Wot0pps1N6lhPQL9I+V3bB4io5YR5L70jri1ErSuVXsmqWpxhM+UWflrJgaR 9Mpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="EJ3kfT/3"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j3-20020ad453a3000000b0042c3a3d62e4si4466188qvv.283.2022.03.01.14.02.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 01 Mar 2022 14:02:54 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="EJ3kfT/3"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPAa6-0003HT-CR for patch@linaro.org; Tue, 01 Mar 2022 17:02:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPAXX-0001Ft-8d for qemu-devel@nongnu.org; Tue, 01 Mar 2022 17:00:15 -0500 Received: from [2607:f8b0:4864:20::62c] (port=42879 helo=mail-pl1-x62c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nPAXT-0004w7-QT for qemu-devel@nongnu.org; Tue, 01 Mar 2022 17:00:14 -0500 Received: by mail-pl1-x62c.google.com with SMTP id p17so14573226plo.9 for ; Tue, 01 Mar 2022 14:00:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zkNbMXCqLzhadKWhMyb5sf6Jtr4mvpt/QguB9jnfEUo=; b=EJ3kfT/32tEKtDZICqVQu68dz5nljHJIm3YDkO+5ks9AmTzxfmJReyqASVaKT+8Qpz nxwQXSOy7O9F7cfbFdQsp1wRKvu6tYO5oD1OZtsoQOE+oEPj7og8AgR8FNBS9ejJpSRY IWy2999/H3a/0lqvCGcv0cDJG5455rydiXFFMatmHva88ZGk04DoIr44ipfvWLlItTY/ mF8zjRryf5kmC6tQWOJ5+zbqz1FUrbCkKoCecdJR4gRZi3LgmoTDtmSvwT4LC4xBbA2T NPZcMA/T0u5G3QLMeBukX63SBklCRvWxYGYfVgmYFlwX8aPIIXSn7mT/YPVH5fJlcWl3 Dkng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zkNbMXCqLzhadKWhMyb5sf6Jtr4mvpt/QguB9jnfEUo=; b=8CeNWTsYfEoi98F1rG1zSHGd7Z3hWbO/19zVMKjcbJL0ugsdoSiv0KlHNZ9g+d+vkK WXzil64w81Y9GLp9nJ1PdstdQ0K8ybtzpyM6y5mkg9tkyiXyqVPIvAUtxTXJYvcDyU9u eTFpoQGPzKODoCO1d2PKSPS7swOAtghTe/NKBqKs+oz4c7aBwOQ4XgMsS1n+CaPtBnRV MCZQZyfZJlspJuAbwc8Ln4zXv3gUBIqsYDOh3dMsspMDC7ab8lAqVuF3CB60FW321LFd BDtPkjBNEUO1a1jR8utoWJgZ/KnFpL5DruceJ/kTp4BMBlZgHRYbB1eMILEbZLFTvyZG akXg== X-Gm-Message-State: AOAM533vUztyp4Vt41JhCohYBU1RoQYti/WLk+99zHL59OZYo+rS18GK 0QoXiuC381upjvtsBR+SOxFDNGe1TvTf7w== X-Received: by 2002:a17:902:9045:b0:14f:14e7:f3aa with SMTP id w5-20020a170902904500b0014f14e7f3aamr26471266plz.69.1646172004414; Tue, 01 Mar 2022 14:00:04 -0800 (PST) Received: from localhost.localdomain (cpe-50-113-46-110.hawaii.res.rr.com. [50.113.46.110]) by smtp.gmail.com with ESMTPSA id m4-20020a17090a7f8400b001bef3fc3938sm284392pjl.49.2022.03.01.14.00.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 14:00:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 01/18] hw/registerfields: Add FIELD_SEX and FIELD_SDP Date: Tue, 1 Mar 2022 11:59:41 -1000 Message-Id: <20220301215958.157011-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220301215958.157011-1-richard.henderson@linaro.org> References: <20220301215958.157011-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::62c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Add new macros to manipulate signed fields within the register. Reviewed-by: Philippe Mathieu-Daudé Suggested-by: Peter Maydell Signed-off-by: Richard Henderson --- include/hw/registerfields.h | 48 ++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/include/hw/registerfields.h b/include/hw/registerfields.h index f2a3c9c41f..3a88e135d0 100644 --- a/include/hw/registerfields.h +++ b/include/hw/registerfields.h @@ -59,6 +59,19 @@ extract64((storage), R_ ## reg ## _ ## field ## _SHIFT, \ R_ ## reg ## _ ## field ## _LENGTH) +#define FIELD_SEX8(storage, reg, field) \ + sextract8((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH) +#define FIELD_SEX16(storage, reg, field) \ + sextract16((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH) +#define FIELD_SEX32(storage, reg, field) \ + sextract32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH) +#define FIELD_SEX64(storage, reg, field) \ + sextract64((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH) + /* Extract a field from an array of registers */ #define ARRAY_FIELD_EX32(regs, reg, field) \ FIELD_EX32((regs)[R_ ## reg], reg, field) @@ -95,7 +108,40 @@ _d; }) #define FIELD_DP64(storage, reg, field, val) ({ \ struct { \ - uint64_t v:R_ ## reg ## _ ## field ## _LENGTH; \ + uint64_t v:R_ ## reg ## _ ## field ## _LENGTH; \ + } _v = { .v = val }; \ + uint64_t _d; \ + _d = deposit64((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH, _v.v); \ + _d; }) + +#define FIELD_SDP8(storage, reg, field, val) ({ \ + struct { \ + signed int v:R_ ## reg ## _ ## field ## _LENGTH; \ + } _v = { .v = val }; \ + uint8_t _d; \ + _d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH, _v.v); \ + _d; }) +#define FIELD_SDP16(storage, reg, field, val) ({ \ + struct { \ + signed int v:R_ ## reg ## _ ## field ## _LENGTH; \ + } _v = { .v = val }; \ + uint16_t _d; \ + _d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH, _v.v); \ + _d; }) +#define FIELD_SDP32(storage, reg, field, val) ({ \ + struct { \ + signed int v:R_ ## reg ## _ ## field ## _LENGTH; \ + } _v = { .v = val }; \ + uint32_t _d; \ + _d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH, _v.v); \ + _d; }) +#define FIELD_SDP64(storage, reg, field, val) ({ \ + struct { \ + int64_t v:R_ ## reg ## _ ## field ## _LENGTH; \ } _v = { .v = val }; \ uint64_t _d; \ _d = deposit64((storage), R_ ## reg ## _ ## field ## _SHIFT, \