From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id B92FF383905E for ; Tue, 21 Feb 2023 12:04:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B92FF383905E 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-x42c.google.com with SMTP id j2so3983445wrh.9 for ; Tue, 21 Feb 2023 04:04:13 -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=KHuNa8sVwsZDeUvsMb6lCkWu7Qg4RHY6WSTxtXLRNVMZMcTMcJpy7oJOoYPi+3RxA+ zFW+fDoX436+WracWC2a08JZLj9Ry7aQ1IRbUpBy0HRErWNgBacI77m7Tsgmmymx8/tf KtywoadlakVT1ectd34JvAHbR37ZATTymjlbLR7n3o4J0yGD6fuMX3B4She4mXEIMgYw bi7xbNR/Hpb/+p7HQxXdVweRr2nFQCvswNBPT5C4TCyyLWBW0u642v09LAFS3b6fV6hP EMfIQz/wxk4kGBVwLnGoj4i9wjKLht3vRkbUM0771P3sHVFPCD3WUVylWhKpOrPuRPvm 6tQQ== X-Gm-Message-State: AO0yUKUocOSiibSt1IvHOTVE2+0wjKgCAm1qH2UJx+hLEF06W9ld98Et vNFMOYrEz2M5oeoMBG1ODKon1SWDP9dIYlmvTg== X-Google-Smtp-Source: AK7set9gLx4HUgTRR4ZsSJ7RCmVL37gZ1B2EMvAZ7oGK8PyCkjdK47mvB9mdBga2ENNNhSOGK4fijQ== 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> Reply-To: arthur.cohen@embecosm.com MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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=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: 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); -- 2.39.1