public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] intrinsics: Use lambdas for wrapping_<op> intrinsics Date: Thu, 27 Oct 2022 18:56:01 +0000 (GMT) [thread overview] Message-ID: <20221027185607.F36E3386C587@sourceware.org> (raw) https://gcc.gnu.org/g:2357b5d5138a926d7b3f054aa66549482bec9be6 commit 2357b5d5138a926d7b3f054aa66549482bec9be6 Author: Arthur Cohen <arthur.cohen@embecosm.com> Date: Wed Oct 26 16:06:53 2022 +0200 intrinsics: Use lambdas for wrapping_<op> 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<tree (Context *, TyTy::FnType *)> +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<std::string, {"transmute", transmute_handler}, {"rotate_left", rotate_left_handler}, {"rotate_right", rotate_right_handler}, - {"wrapping_add", wrapping_add_handler}, - {"wrapping_sub", wrapping_sub_handler}, - {"wrapping_mul", wrapping_mul_handler}, + {"wrapping_add", wrapping_op_handler (PLUS_EXPR)}, + {"wrapping_sub", wrapping_op_handler (MINUS_EXPR)}, + {"wrapping_mul", wrapping_op_handler (MULT_EXPR)}, {"copy_nonoverlapping", copy_nonoverlapping_handler}, {"prefetch_read_data", prefetch_read_data}, {"prefetch_write_data", prefetch_write_data}, @@ -459,7 +452,7 @@ rotate_handler (Context *ctx, TyTy::FnType *fntype, tree_code op) * pub fn wrapping_{add, sub, mul}<T>(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_<op> intrinsics have two parameter rust_assert (fntype->get_params ().size () == 2);
reply other threads:[~2022-10-27 18:56 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221027185607.F36E3386C587@sourceware.org \ --to=tschwinge@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).