From patchwork Tue May 30 18:59:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 686898 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp894277wru; Tue, 30 May 2023 12:03:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ63TETpIKwXU+pYZVJk0jUPQNl1GxdeDoqqHqsGI+ZnK5URXKG55TS9lIBSoX78ZGkVY1zv X-Received: by 2002:a05:620a:439b:b0:75b:23a1:830f with SMTP id a27-20020a05620a439b00b0075b23a1830fmr2937213qkp.10.1685473433273; Tue, 30 May 2023 12:03:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685473433; cv=none; d=google.com; s=arc-20160816; b=Sjs3CfjDRXIoCBNxVOhoxmDPzBwZpLOMn3QW+SecNrH++ZP/smD1QQwDhnG9FQzOFe HSzvrBMn5J5+mwxUHEm3axTNVPG22nf5RWkp3tZq3rqrq0aXF2z9GdEO+sB3RTzIoFDr 3nqRbb2TJS3eSnxm/uMa/WdH76kzjyvWpTQllCalL+spZ4tv49kBwQ5bxFMSjFsrPpkM LK/IEMvcB16z87wyWMgd1zjY6vV+ucdGcnpZznJOZirgQWWy4Zyc12lck/mOG4vRWZ5h OjKA7mLndLDdEP/dEc+QyOT6jbE1W/bGHatYzwYnuwzXLSrSJJGqYPSY3RGKxE1m3Hq8 rsig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=0TO6p4PSEQ7x4gG5VCvqOcrj7NhLU97TFrPxxkMMo4M=; b=xubyM97uttaoMvJIATGCqaV4MWqxLGDKRmlGls0p3Ul8F04JoapN9POYuZCXLRPVUf +uea/hpeDWsfgUpDxoCK7bZX37H16rUIp6amHGfOEtzyP6pqbGzGUuXlYHZu1/C+6IT8 oRsTve4BEpsHSo8GHvlmXApWyqN1j3zwQTmL9K0IMetitvozLtepX2+rLc03f9gGl+jw GuUndvqdKe9Gxr0RQAtX4Kk+tSeW1cYIhX4DKtRTVEoNJ6hBt2w1Az4GswEBJSICxlHD X66UXbT7sp3S1UF7K6dQMMP4QWmYHQ39hjCEbhW9WvnUdvLfudZQThplOKXWM+6fuAVj x1Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kQa0NMiT; 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=pass (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 du45-20020a05620a47ed00b0075b88f76812si6775353qkb.106.2023.05.30.12.03.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 May 2023 12:03:53 -0700 (PDT) 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=pass header.i=@linaro.org header.s=google header.b=kQa0NMiT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q44Zo-0000pl-0r; Tue, 30 May 2023 15:00:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q44ZY-0000mm-9D for qemu-devel@nongnu.org; Tue, 30 May 2023 14:59:56 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q44ZW-0000sb-Hk for qemu-devel@nongnu.org; Tue, 30 May 2023 14:59:56 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-64fd7723836so2037670b3a.1 for ; Tue, 30 May 2023 11:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685473193; x=1688065193; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0TO6p4PSEQ7x4gG5VCvqOcrj7NhLU97TFrPxxkMMo4M=; b=kQa0NMiTCAiwjBbcCudy/nmpdGmWZibM5CmMso71h9S8Xx22CSo1BoBN0Gzk6ALJJ5 PCqHZI8xTWxtiYwn3CQsxEiqs/VvqloGHlAwN1VbIgHE0g1hmZlv174APFR4PYOau05H GVb7TozBBtfTT18OquTYat1Kb11DL8+FAbYyr/yrThIQErH0UcZEQwmgz7vc7modXDpg 7XKxtc/BkWNrfpF3eS84CnbXBB7ISPJQDzi5NJFOHVQOvLZbU51+GMVEcSJkBSy3/QGT e51ZyK21o+5XVj5MLKCbkALgd1WQZ4HyUStKxyRMxcEVr1eXn9d0bfq+e4Y1UajHoOW1 JhHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685473193; x=1688065193; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0TO6p4PSEQ7x4gG5VCvqOcrj7NhLU97TFrPxxkMMo4M=; b=ZWPv2+mJFb8EIvmqyNbbw14Xbqch72vXeGyF/AK/+Nz2fBWwJ62tKpdSZUhXEjmDTk GYGZrsTXuPgFIFyrE3Ae/VPMc91YM4+4gK61xBDcb08k0+LAdHDCIrEA40O8NXguaP/8 hN3oIjzRrdczmsyD26TpbO1bVz+6f3Db2BXP2TiEN83TiGVH0Ie82plYqfY+gwHNhPER DfFOTRAs1Wf5ckQeWtuL7P6u+sdxt7ACf0oYnSJ3zPnioAmLAJ2Kmi62AnavgsCx6UgS TeK03qoUUpTDtLY6HNt/TLlbqY5PU3g8Pe21DYR7ZzqrQtKD5x7yvP4jgDFbLSVzJQ7P g93Q== X-Gm-Message-State: AC+VfDwTJfAG2UvRLzg5r66zTahTjp98IGLVHHsGGsYGye7BEp1Wl2g9 aE1etZnYe0av9zvJS6F+WUUk08W1XU2IVqbHXMc= X-Received: by 2002:a05:6a20:9c8f:b0:110:9210:f6af with SMTP id mj15-20020a056a209c8f00b001109210f6afmr3302349pzb.27.1685473193325; Tue, 30 May 2023 11:59:53 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:35a2:c45d:7485:f488]) by smtp.gmail.com with ESMTPSA id g18-20020a63fa52000000b0051f14839bf3sm9128496pgk.34.2023.05.30.11.59.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 11:59:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Peter Maydell Subject: [PULL 03/27] meson: Split test for __int128_t type from __int128_t arithmetic Date: Tue, 30 May 2023 11:59:25 -0700 Message-Id: <20230530185949.410208-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230530185949.410208-1-richard.henderson@linaro.org> References: <20230530185949.410208-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Older versions of clang have missing runtime functions for arithmetic with -fsanitize=undefined (see 464e3671f9d5c), so we cannot use __int128_t for implementing Int128. But __int128_t is present, data movement works, and it can be used for atomic128. Probe for both CONFIG_INT128_TYPE and CONFIG_INT128, adjust qemu/int128.h to define Int128Alias if CONFIG_INT128_TYPE, and adjust the meson probe for atomics to use has_int128_type. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- meson.build | 15 ++++++++++----- include/qemu/int128.h | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index 2d48aa1e2e..bc76ea96bf 100644 --- a/meson.build +++ b/meson.build @@ -2543,7 +2543,13 @@ config_host_data.set('CONFIG_ATOMIC64', cc.links(''' return 0; }''')) -has_int128 = cc.links(''' +has_int128_type = cc.compiles(''' + __int128_t a; + __uint128_t b; + int main(void) { b = a; }''') +config_host_data.set('CONFIG_INT128_TYPE', has_int128_type) + +has_int128 = has_int128_type and cc.links(''' __int128_t a; __uint128_t b; int main (void) { @@ -2552,10 +2558,9 @@ has_int128 = cc.links(''' a = a * a; return 0; }''') - config_host_data.set('CONFIG_INT128', has_int128) -if has_int128 +if has_int128_type # "do we have 128-bit atomics which are handled inline and specifically not # via libatomic". The reason we can't use libatomic is documented in the # comment starting "GCC is a house divided" in include/qemu/atomic128.h. @@ -2564,7 +2569,7 @@ if has_int128 # __alignof(unsigned __int128) for the host. atomic_test_128 = ''' int main(int ac, char **av) { - unsigned __int128 *p = __builtin_assume_aligned(av[ac - 1], 16); + __uint128_t *p = __builtin_assume_aligned(av[ac - 1], 16); p[1] = __atomic_load_n(&p[0], __ATOMIC_RELAXED); __atomic_store_n(&p[2], p[3], __ATOMIC_RELAXED); __atomic_compare_exchange_n(&p[4], &p[5], p[6], 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED); @@ -2586,7 +2591,7 @@ if has_int128 config_host_data.set('CONFIG_CMPXCHG128', cc.links(''' int main(void) { - unsigned __int128 x = 0, y = 0; + __uint128_t x = 0, y = 0; __sync_val_compare_and_swap_16(&x, y, x); return 0; } diff --git a/include/qemu/int128.h b/include/qemu/int128.h index 9e46cfaefc..73624e8be7 100644 --- a/include/qemu/int128.h +++ b/include/qemu/int128.h @@ -481,7 +481,7 @@ static inline void bswap128s(Int128 *s) * a possible structure and the native types. Ease parameter passing * via use of the transparent union extension. */ -#ifdef CONFIG_INT128 +#ifdef CONFIG_INT128_TYPE typedef union { __uint128_t u; __int128_t i; @@ -489,6 +489,6 @@ typedef union { } Int128Alias __attribute__((transparent_union)); #else typedef Int128 Int128Alias; -#endif /* CONFIG_INT128 */ +#endif /* CONFIG_INT128_TYPE */ #endif /* INT128_H */