From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by sourceware.org (Postfix) with ESMTPS id B4AF03861821 for ; Thu, 21 Dec 2023 01:01:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B4AF03861821 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B4AF03861821 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703120485; cv=none; b=ddaJAjgWqvumSuq0vFmllte1IUkUHtIK/PU1NtSyfJZuA+Vm36sVOwZeYzgZFsC7eLFhwIwDAYsIX1KUa3IOLcpLnnsgK7nZRf9JcURPor0DgIgN7sNxm6BtLgrtM85XXo2/lR+ipknfGBftyE38tIkkDDbzaBIsF4MuvHCitA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703120485; c=relaxed/simple; bh=jjTAtGe8eNlBM9oKSdjwh5jbqQ4p/11asjPHWwO0E6Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=LS1SGzVUYgyo46DM7knvNr4Un57StEMOErAdRGi5kCpmDO2qGEKHqZHemSIukyz1i0S8/wN4SfdkdyFDrtI1KqE0bdoZ78gTLBHIB+wGE3+aGeuswi7iH1wpfC7lLP5dXkbw1X6Zo85Ney8VVFyrG/JoIt5oM7U3grGJUhnD5E8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-28bea16a56aso164023a91.2 for ; Wed, 20 Dec 2023 17:01:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1703120480; x=1703725280; darn=gcc.gnu.org; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=1kFG4ReQxzwDxU39Ilh7EhktDqA04EcfV8JGcj+Z3P0=; b=cArv2spVUB8YPtfu6Y5uJWmY5S8gB1Vu+5UA8vu7ssIHi4EmewEvV6elhwe2/I7zVz XSt57xG07OVovIW06S0l8g6LB7LRUnyZ8MVqbCLCYVCE5VxxxHGi3GaTnO+g59My71QE K3YaYk+3T0b8VWFhYm+e2qqP/ES57Yvr/uUv1K2BpOZTz9rgOgGkFsvGzrYnbgmhvs3b o2YYTUuQ9K4oYwX6wULlh+QwkXma12J9Cuieta/Z3S5F4NcySp3nVR+7C6l5Zs/bYGgH oeSwbv+/4dPM+nL+2W0lFGsmckM7KpsopfNHrvQnMaGrNIB6jYOKiw54qQvwX1jJWpBc Jrsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703120480; x=1703725280; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1kFG4ReQxzwDxU39Ilh7EhktDqA04EcfV8JGcj+Z3P0=; b=CokdX7L+GPszSLMaQ3kRouW0gtNA9NSxXKRdaXm9YkSYlM2ATwh26yt/8A3NAkQaLu EsdIRmrcpWe7yNY5rvPro1cETSKD4hQpBcpnN07KChHlrDb/jrG4Fe25+POhYqS/uhpi SuhiYyiW6/5IHxgfD0+1O+clgKRnoYVshSs0BAk+XJRSSHL3Xeks3PMPRkIOup4btBln lVuVtg+Vzx+xMh21V1C1kPQK06P8qFGJGWAqXzfW6t3x25ttqAg2WrsVIKItAY1zqUJZ eg3ayjMLMSQVYuaCFUTF4mNs+RuTvJjYYwA/yodkePaq1aF+VTxMx9vegTZkKhi85CsE bseQ== X-Gm-Message-State: AOJu0YxYRLQsxtCDmCJMU8o//DVIjHLyLSuB4cIK/L3rSDfNq5jyNrJ1 Tjk5NOlMbRT7ZpPqXLyeCJi0wg== X-Google-Smtp-Source: AGHT+IHxEfhTeu2gAEvhdmpGcY2FvZN+KWQpUeZh93Rijz9v+Vgsf3FgfEj5RgL8124y0ErLVUrSYg== X-Received: by 2002:a17:902:64c9:b0:1d3:ead1:dc06 with SMTP id y9-20020a17090264c900b001d3ead1dc06mr2007198pli.104.1703120480331; Wed, 20 Dec 2023 17:01:20 -0800 (PST) Received: from free.home ([2804:7f1:2080:e946:8ecf:6d68:6986:b9a]) by smtp.gmail.com with ESMTPSA id jj17-20020a170903049100b001d3cb4e3302sm328749plb.214.2023.12.20.17.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 17:01:19 -0800 (PST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 3BL119Hi729414 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 20 Dec 2023 22:01:10 -0300 From: Alexandre Oliva To: Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] untyped calls: enable target switching [PR112334] Organization: Free thinker, does not speak for AdaCore References: <990b6f19-d294-48a0-a202-bb27ddde632e@gmail.com> Date: Wed, 20 Dec 2023 22:01:09 -0300 In-Reply-To: <990b6f19-d294-48a0-a202-bb27ddde632e@gmail.com> (Jeff Law's message of "Tue, 19 Dec 2023 22:08:49 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,WEIRD_QUOTING autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Dec 20, 2023, Jeff Law wrote: > Sorry it was meant to be an ACK for the trunk for both patches. Aah, I see. So this is what I installed last night, upon seeing your message. untyped calls: use wrapper class type for implicit plus_one Instead of get and set macros to apply a delta, use a single macro that resorts to a temporary wrapper class to apply it. for gcc/ChangeLog * builtins.cc (delta_type): New template class. (set_apply_args_size, get_apply_args_size): Replace with... (saved_apply_args_size): ... this. (set_apply_result_size, get_apply_result_size): Replace with... (saved_apply_result_size): ... this. (apply_args_size, apply_result_size): Adjust. --- gcc/builtins.cc | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/gcc/builtins.cc b/gcc/builtins.cc index 7c2732ab79e6f..23cc6b6838a01 100644 --- a/gcc/builtins.cc +++ b/gcc/builtins.cc @@ -1403,16 +1403,24 @@ get_memory_rtx (tree exp, tree len) /* Built-in functions to perform an untyped call and return. */ -#define set_apply_args_size(x) \ - (this_target_builtins->x_apply_args_size_plus_one = 1 + (x)) -#define get_apply_args_size() \ - (this_target_builtins->x_apply_args_size_plus_one - 1) +/* Wrapper that implicitly applies a delta when getting or setting the + enclosed value. */ +template +class delta_type +{ + T &value; T const delta; +public: + delta_type (T &val, T dlt) : value (val), delta (dlt) {} + operator T () const { return value + delta; } + T operator = (T val) const { value = val - delta; return val; } +}; + +#define saved_apply_args_size \ + (delta_type (this_target_builtins->x_apply_args_size_plus_one, -1)) #define apply_args_mode \ (this_target_builtins->x_apply_args_mode) -#define set_apply_result_size(x) \ - (this_target_builtins->x_apply_result_size_plus_one = 1 + (x)) -#define get_apply_result_size() \ - (this_target_builtins->x_apply_result_size_plus_one - 1) +#define saved_apply_result_size \ + (delta_type (this_target_builtins->x_apply_result_size_plus_one, -1)) #define apply_result_mode \ (this_target_builtins->x_apply_result_mode) @@ -1422,7 +1430,7 @@ get_memory_rtx (tree exp, tree len) static int apply_args_size (void) { - int size = get_apply_args_size (); + int size = saved_apply_args_size; int align; unsigned int regno; @@ -1456,7 +1464,7 @@ apply_args_size (void) else apply_args_mode[regno] = as_a (VOIDmode); - set_apply_args_size (size); + saved_apply_args_size = size; } return size; } @@ -1467,7 +1475,7 @@ apply_args_size (void) static int apply_result_size (void) { - int size = get_apply_result_size (); + int size = saved_apply_result_size; int align, regno; /* The values computed by this function never change. */ @@ -1500,7 +1508,7 @@ apply_result_size (void) size = APPLY_RESULT_SIZE; #endif - set_apply_result_size (size); + saved_apply_result_size = size; } return size; } -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer More tolerance and less prejudice are key for inclusion and diversity Excluding neuro-others for not behaving ""normal"" is *not* inclusive