From 2357b5d5138a926d7b3f054aa66549482bec9be6 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Wed, 26 Oct 2022 16:06:53 +0200 Subject: intrinsics: Use lambdas for wrapping_ intrinsics --- gcc/rust/backend/rust-compile-intrinsic.cc | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'gcc/rust/backend') diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc b/gcc/rust/backend/rust-compile-intrinsic.cc index 7c592da..8c6fbd7 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); -- cgit v1.1