From patchwork Tue Feb 21 12:01:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 60050 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1843483wrn; Tue, 21 Feb 2023 04:52:30 -0800 (PST) X-Google-Smtp-Source: AK7set/Q/KB+QOvS8Cvk7Zm9c5wSrdp0VADUBNzB3YW1gT/KoAxjHPRAIyGwgZ5Xsx+SOCL4NFAB X-Received: by 2002:a05:6402:799:b0:4ac:bf55:e943 with SMTP id d25-20020a056402079900b004acbf55e943mr5388419edy.34.1676983950771; Tue, 21 Feb 2023 04:52:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676983950; cv=none; d=google.com; s=arc-20160816; b=agqKgH3+58/iucZ7gJOEfM1K20MzgBFKpiOWeMST2qRW4P6oYo6l1K4vFHhStVdr2H FiVEsjpJtgS2uf+P93j0YIjksPnXAYCLeVtM5W1unhw7K+0YNqzj/xhjo2ThB/XWwmkR 4GyanGGMT88tSJiiwCJHwqGhigQBeOhCEV4+wr4ZgQhLnVEeVCsiTGm9mdgPIGKD8fwt l7THjrfa+6Na0X1f6BPepHTXrOBG4VspeHN7Qpm5GFP85Tr0QrWNDGNCF0ybhaOuqa9z b3i2JY2oEDwqPzapwtdvKkTo8x06NDFFNQoeHceh7HrTE6+CTd6d1Lm6Ik++IHkMnmdG ZDcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-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:dmarc-filter :delivered-to; bh=rFq0pn8FQeq3f3KVEDXQ7ZU0b3akL46rDfTt6VT0s+E=; b=apsSHSI1+f468xFsUBiUH2CvH3pq+hkRMWcWKuwtQYufRh6Ppt/sJPyZ1TmUktcrrY EgG6YAmmc8aMhSNlT8rccd9M0Ls37skCzviEy4E1z6EGbM54E8543X+zBq8Miljp5uE8 ++lkjdgxUpT8yBl7K+N+fUe8NuKFoCc4AnpyG2Apjv6EP4VCulsPqKhiy1Z4S88MaTAV K4ckD57lnWca/oq0tmWwxloveKZdkJM/ukWbWRgwOiQFQ15pjPhpxyiFQH0ugkYQgYD6 9RGo4VhNKoLp5/NEiUNtRvhfG+dEHXxr3U0TNNUEg3A7BOFqpHDTsB3f90hWB7IRtAbP mCEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=IDXVW2i4; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id e12-20020a50ec8c000000b004acc6c6ecc0si2962365edr.228.2023.02.21.04.52.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:52:30 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=IDXVW2i4; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 11BBE39730D5 for ; Tue, 21 Feb 2023 12:17:47 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id 0DA0C383E281 for ; Tue, 21 Feb 2023 12:04:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0DA0C383E281 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wr1-x434.google.com with SMTP id l25so3759207wrb.3 for ; Tue, 21 Feb 2023 04:04:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=rFq0pn8FQeq3f3KVEDXQ7ZU0b3akL46rDfTt6VT0s+E=; b=IDXVW2i4XwCuYiAjoCQ3pcAKUCeAyVbz3Sw6l7p3PFP+cidAm23QhK/Fqb/3i5owNJ KqX/6X65v3JT4PFk6HRLYtBWTVY3rK04xryaUEdJU3MW+jlly+xjxMn/e8J4DcWu5Qpb 1lvPqd2SXY5B2913hPHYP9dgXwF8KN0rQ0K0kk3cBivVHJh1YharTSeTnXOrOqRzNDMQ UuOE1mlOMRGiqhQxm7Xo+eT1FFw7MrkmWg/yNe6tFxOkMhv3YcsOfbVog1k2W7QbXhht a9osYgqPImdWG1UEGw1L7nkCb1LoJHDC6cNneP+QLkBEabv0yicV2+wy9341ZFePSU9W yy3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to: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=rFq0pn8FQeq3f3KVEDXQ7ZU0b3akL46rDfTt6VT0s+E=; b=KkCFtNaZtUXLtSwdt/uOvAbYb6MJMeshiTRGd/Y5f/KsetA99XnRBw4F+8GqxG0kl5 tBoncBdaGNE3afPJLgqrleIr6sK/NKZ1ohnhjs7CSBhnatFzNsHUb/U8GlPWeo5ly6HB 4qNCfmKoa4RVpudcBafATj2xYhEnRr+eSfWbQoBPmcIl96f5b1m75IC4tp6z2E81D5zH HUISpp272f+BwTLri3R982nYfiDAFg+bT+MqmfsCsl8vFuW7ioPsdhz2UGKcfm6dSh3Y 1Q1ODP9fTbzGFHP7X5QwozW5Sr+qZgd3/n49Y23cGSLVMGmNpuSHgE+TS/rSgk8Tdj76 fWHQ== X-Gm-Message-State: AO0yUKXdxgwvbn2qW+jxh03Fyn0LBNHcUIgkK7jyoXi3/321IMtUdQ+w kzyeTd9W020Tz2FP+UhzVWhbAjDmAfiDppg+sg== X-Received: by 2002:a5d:53c5:0:b0:2c5:581d:5a1d with SMTP id a5-20020a5d53c5000000b002c5581d5a1dmr4068874wrw.43.1676981053397; Tue, 21 Feb 2023 04:04:13 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id c15-20020adffb4f000000b002c55b0e6ef1sm5013811wrs.4.2023.02.21.04.04.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:04:13 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Arthur Cohen Subject: [committed 062/103] gccrs: intrinsics: Use lambdas for wrapping_ intrinsics Date: Tue, 21 Feb 2023 13:01:52 +0100 Message-Id: <20230221120230.596966-63-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230221120230.596966-1-arthur.cohen@embecosm.com> References: <20230221120230.596966-1-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.8 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: arthur.cohen@embecosm.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758445123105845356?= X-GMAIL-MSGID: =?utf-8?q?1758445123105845356?= From: Arthur Cohen gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc (wrapping_op_handler): Refactor to return an `std::function`. (wrapping_op_handler_inner): Rename. (wrapping_add_handler): Remove function. (wrapping_sub_handler): Likewise. (wrapping_mul_handler): Likewise. --- gcc/rust/backend/rust-compile-intrinsic.cc | 29 ++++++++-------------- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc b/gcc/rust/backend/rust-compile-intrinsic.cc index 46ea5b3f795..142a2173672 100644 --- a/gcc/rust/backend/rust-compile-intrinsic.cc +++ b/gcc/rust/backend/rust-compile-intrinsic.cc @@ -59,7 +59,7 @@ transmute_handler (Context *ctx, TyTy::FnType *fntype); static tree rotate_handler (Context *ctx, TyTy::FnType *fntype, tree_code op); static tree -wrapping_op_handler (Context *ctx, TyTy::FnType *fntype, tree_code op); +wrapping_op_handler_inner (Context *ctx, TyTy::FnType *fntype, tree_code op); static tree copy_nonoverlapping_handler (Context *ctx, TyTy::FnType *fntype); @@ -83,21 +83,14 @@ rotate_right_handler (Context *ctx, TyTy::FnType *fntype) return rotate_handler (ctx, fntype, RROTATE_EXPR); } -static inline tree -wrapping_add_handler (Context *ctx, TyTy::FnType *fntype) -{ - return wrapping_op_handler (ctx, fntype, PLUS_EXPR); -} -static inline tree -wrapping_sub_handler (Context *ctx, TyTy::FnType *fntype) -{ - return wrapping_op_handler (ctx, fntype, MINUS_EXPR); -} -static inline tree -wrapping_mul_handler (Context *ctx, TyTy::FnType *fntype) +const static std::function +wrapping_op_handler (tree_code op) { - return wrapping_op_handler (ctx, fntype, MULT_EXPR); + return [op] (Context *ctx, TyTy::FnType *fntype) { + return wrapping_op_handler_inner (ctx, fntype, op); + }; } + static inline tree prefetch_read_data (Context *ctx, TyTy::FnType *fntype) { @@ -148,9 +141,9 @@ static const std::map(lhs: T, rhs: T) -> T; */ static tree -wrapping_op_handler (Context *ctx, TyTy::FnType *fntype, tree_code op) +wrapping_op_handler_inner (Context *ctx, TyTy::FnType *fntype, tree_code op) { // wrapping_ intrinsics have two parameter rust_assert (fntype->get_params ().size () == 2);