From patchwork Tue Dec 13 21:25:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 633516 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp3342256pvb; Tue, 13 Dec 2022 13:26:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf4sRwsbMLbhfSfzbjZAHpMY/C9gX6NmKC2nNGYfilnfm0bu9G2AxEjm2kcs2S/D9i8u9DdC X-Received: by 2002:a05:6214:5a0b:b0:4c6:d665:a6ba with SMTP id lu11-20020a0562145a0b00b004c6d665a6bamr33583804qvb.22.1670966786961; Tue, 13 Dec 2022 13:26:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670966786; cv=none; d=google.com; s=arc-20160816; b=CKOzLNz4Mu4aOUBkSnmZw8kiWdhCKaHftCXhqqiOEhVy7DcDDbH7YmI8OLcU1Xn1dP bhKR+scU16Dx8bkv1Gc0NVm/qymyhZaxxTQiJzcPu6zHche0f2BkC52qz2XiDzcxa6E1 IbotCRbKY8MO3jycc95FcqOBE3ZCXR5EnuDmh+v99UvFVsa1V1Dh1YrvnanHyaUPjl/Y KvpY/6wO9N0uTa1jJQ2y8yaifJLmt1s77LN0RX2n+YoN8kF3xlvUWH3qXLoZmgH6BLAJ 7vxOv8p1pjSHeiUKwNDlMOkrYFAlOKZKM53HIkI//qIrenTcdrSA2rD/37RPrifEzfRP XPjw== 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=kcsaITVUaZwX2W3VYFeAudOGzYmg0UWJ+TXMDg4IToo=; b=fcfV3FcN/ndWeARQb17a+d9xNFYCSZ6W/bts5Bv6a6oaBDgoDifA9FoXLbA9rR/Qtw fCBeaiB4zvDPhhQl366+FIRaRowUBIDd4PMaHUu75ulF3wfLNhh4F4tRrHbyF+9coERp yMhCPcs3fFEHJdUf8EDu9zcDEU5sS/WAEjCXUzv8tEQbUuv6Wb8/Zp1ZHPy3lScFk0Sx vRK2NFhQFsTWNz0ju18cyi8nR3pO6/mRxMoFmyJf/g2GDv4XzSbTiDpKQczckwrUN2FT UBpMuRu4IB88TV5s5bgsPnw3VeokCcRm012Tvnf2yy/bRlJRDMY47JP6ydzOEjv4fJAr xrug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kx0pnFct; 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 s4-20020a0562140ca400b004bbf102de7fsi8043630qvs.249.2022.12.13.13.26.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Dec 2022 13:26:26 -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=pass header.i=@linaro.org header.s=google header.b=kx0pnFct; 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 1p5Cmv-0000gg-EV; Tue, 13 Dec 2022 16:26:09 -0500 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 1p5Cmu-0000g3-2V for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:08 -0500 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmm-0003EK-PK for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:03 -0500 Received: by mail-oi1-x229.google.com with SMTP id s186so1044038oia.5 for ; Tue, 13 Dec 2022 13:26:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=kcsaITVUaZwX2W3VYFeAudOGzYmg0UWJ+TXMDg4IToo=; b=kx0pnFcthsKGbAbpVx4cshbd9Bl0sGXGRBqTqBJa6AH0L4i4fYPd5n87jgMjbuGUi7 3q7OkH1WDbw20toRhp0/Rm2zIZRwVj8X0Uv48Zao/g/LlupdP/v64l+svNiC06aMa0xJ D2bC4onp1tCrM9eEfLLwXPzK5nNanKW+rIRc2iLUqtyJjk+d6pW2EoOK3Pqd8U2kLud6 aZXk1vN+FeLahxKbv4g+MwRetR6R928jIYiJW2lAZQvpy9i2nfEqhB5jqEO2pJjP3wUs W6ul3bh1De/hJM8Hq2Ojc470ZGLzgpceYOwy43jUnwJOKU4VYH2jF5vugSUxZoUF8pHe Ellw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=kcsaITVUaZwX2W3VYFeAudOGzYmg0UWJ+TXMDg4IToo=; b=y/LfQY7ODOBXuBpfjTuRuQ9wF8mY6tfoj3pU2ucOu4jRgwBbHMyW0yjJ23vlBUeGwM CUqbICAbEsFLushbQHKsCKD5PJpMAGGM4bLPw7nNjb6ZZCdQRMswMRJypTkNHYSrsv5f yiRwHQtSmxUQOvQ6Hrf9E96Vi5vYaY8qtMdRNkaqAjrfWxGA4vpN6FO54bIvaBXJJhEN ghjQEX77KYgh/rbAL2FSFfLdxPZTOPuz3T+HR21xOKYR9XcD+7XbR0TpoSxMYU3F1vIf tDD2YOOBqMkcvgAKPGJQJfdGZVEKoGPAVl1u8uFid97A93s+4SynX06UK2oRiee+89/K t49A== X-Gm-Message-State: ANoB5plNoFP0H7jjdC3BmnNXD0QNAL5fAfqFLudVkrSwfRaGWTpCntHC fyk40tProkHo+I+sUCtQ0FRmsokmImRKblZjS0Q= X-Received: by 2002:a05:6808:404c:b0:35e:bc7b:20ea with SMTP id cz12-20020a056808404c00b0035ebc7b20eamr213228oib.57.1670966760075; Tue, 13 Dec 2022 13:26:00 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.25.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:25:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4 16/27] tcg: Use TCG_CALL_ARG_EVEN for TCI special case Date: Tue, 13 Dec 2022 15:25:30 -0600 Message-Id: <20221213212541.1820840-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::229; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x229.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 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 Change 32-bit tci TCG_TARGET_CALL_ARG_I32 to TCG_CALL_ARG_EVEN, to force 32-bit values to be aligned to 64-bit. With a small reorg to the argument processing loop, this neatly replaces an ifdef for CONFIG_TCG_INTERPRETER. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tci/tcg-target.h | 3 +- tcg/tcg.c | 70 ++++++++++++++++++++++++++++---------------- 2 files changed, 47 insertions(+), 26 deletions(-) diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index d6e0450ed8..94ec541b4e 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -158,10 +158,11 @@ typedef enum { /* Used for function call generation. */ #define TCG_TARGET_CALL_STACK_OFFSET 0 #define TCG_TARGET_STACK_ALIGN 8 -#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #if TCG_TARGET_REG_BITS == 32 +# define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_EVEN # define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN #else +# define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL # define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL #endif diff --git a/tcg/tcg.c b/tcg/tcg.c index 4c397cb0fa..aae4046e1b 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1533,36 +1533,56 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) real_args = 0; for (i = 0; i < nargs; i++) { int argtype = extract32(typemask, (i + 1) * 3, 3); - bool is_64bit = (argtype & ~1) == dh_typecode_i64; - bool want_align = false; + TCGCallArgumentKind kind; + TCGType type; -#if defined(CONFIG_TCG_INTERPRETER) - /* - * Align all arguments, so that they land in predictable places - * for passing off to ffi_call. - */ - want_align = true; -#else - /* Some targets want aligned 64 bit args */ - if (is_64bit) { - want_align = TCG_TARGET_CALL_ARG_I64 == TCG_CALL_ARG_EVEN; - } -#endif - - if (TCG_TARGET_REG_BITS < 64 && want_align && (real_args & 1)) { - op->args[pi++] = TCG_CALL_DUMMY_ARG; - real_args++; + switch (argtype) { + case dh_typecode_i32: + case dh_typecode_s32: + type = TCG_TYPE_I32; + break; + case dh_typecode_i64: + case dh_typecode_s64: + type = TCG_TYPE_I64; + break; + case dh_typecode_ptr: + type = TCG_TYPE_PTR; + break; + default: + g_assert_not_reached(); } - if (TCG_TARGET_REG_BITS < 64 && is_64bit) { + switch (type) { + case TCG_TYPE_I32: + kind = TCG_TARGET_CALL_ARG_I32; + break; + case TCG_TYPE_I64: + kind = TCG_TARGET_CALL_ARG_I64; + break; + default: + g_assert_not_reached(); + } + + switch (kind) { + case TCG_CALL_ARG_EVEN: + if (real_args & 1) { + op->args[pi++] = TCG_CALL_DUMMY_ARG; + real_args++; + } + /* fall through */ + case TCG_CALL_ARG_NORMAL: + if (TCG_TARGET_REG_BITS == 32 && type == TCG_TYPE_I64) { + op->args[pi++] = temp_arg(args[i]); + op->args[pi++] = temp_arg(args[i] + 1); + real_args += 2; + break; + } op->args[pi++] = temp_arg(args[i]); - op->args[pi++] = temp_arg(args[i] + 1); - real_args += 2; - continue; + real_args++; + break; + default: + g_assert_not_reached(); } - - op->args[pi++] = temp_arg(args[i]); - real_args++; } op->args[pi++] = (uintptr_t)func; op->args[pi++] = (uintptr_t)info;