From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id F36E3386C587; Thu, 27 Oct 2022 18:56:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F36E3386C587 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666896968; bh=//90HPlPEo33nB4NFEtHCQcGFDnIQPcxeUg3an+8AFk=; h=From:To:Subject:Date:From; b=Cxrf/X3iNlno+yvs6j18c7msPI3LbpEFJTgnN2SZ2jZp3FqbrfeOINf+qz/LW0YKA IongE8Cs0SprV9JC/Aw6Mh6K1yWmyOJqVOoXKrIocnc6/7GAL4opKGv41Z/hYAuI2o euHKkgEXCF5BmY+QAxWumc9VC2lORQJJVrOTP4g8= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] intrinsics: Use lambdas for wrapping_ intrinsics X-Act-Checkin: gcc X-Git-Author: Arthur Cohen X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: d8a8061f2e884aa2aa31d746c4cc104083bbbbb6 X-Git-Newrev: 2357b5d5138a926d7b3f054aa66549482bec9be6 Message-Id: <20221027185607.F36E3386C587@sourceware.org> Date: Thu, 27 Oct 2022 18:56:01 +0000 (GMT) List-Id: https://gcc.gnu.org/g:2357b5d5138a926d7b3f054aa66549482bec9be6 commit 2357b5d5138a926d7b3f054aa66549482bec9be6 Author: Arthur Cohen Date: Wed Oct 26 16:06:53 2022 +0200 intrinsics: Use lambdas for wrapping_ intrinsics Diff: --- 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 7c592dabb38..8c6fbd70a3f 100644 --- a/gcc/rust/backend/rust-compile-intrinsic.cc +++ b/gcc/rust/backend/rust-compile-intrinsic.cc @@ -43,7 +43,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); @@ -67,21 +67,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) +const static std::function +wrapping_op_handler (tree_code op) { - 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) -{ - 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) { @@ -121,9 +114,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);