* [PATCH] Use variadic template functions for the gimple_build forwarders
@ 2022-05-11 13:22 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-05-11 13:22 UTC (permalink / raw)
To: gcc-patches
The following consolidates the forwarders to gimple_build with
UNKNOWN_LOCATION by using two variadic template functions. This
makes the code visually less disturbing and is in preparation
of adding more forwarders with different stmt insertion schemes.
Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
2022-05-11 Richard Biener <rguenther@suse.de>
* gimple-fold.h (gimple_build): Use variadic template
functions for the gimple_build API forwarders without
location_t argument.
---
gcc/gimple-fold.h | 45 +++++++++++----------------------------------
1 file changed, 11 insertions(+), 34 deletions(-)
diff --git a/gcc/gimple-fold.h b/gcc/gimple-fold.h
index 3a0ef54394e..850f917bbc1 100644
--- a/gcc/gimple-fold.h
+++ b/gcc/gimple-fold.h
@@ -73,55 +73,32 @@ extern tree tree_vec_extract (gimple_stmt_iterator *, tree, tree, tree, tree);
Supposed to replace force_gimple_operand (fold_buildN (...), ...). */
extern tree gimple_build (gimple_seq *, location_t,
enum tree_code, tree, tree);
-inline tree
-gimple_build (gimple_seq *seq,
- enum tree_code code, tree type, tree op0)
-{
- return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0);
-}
extern tree gimple_build (gimple_seq *, location_t,
enum tree_code, tree, tree, tree);
-inline tree
-gimple_build (gimple_seq *seq,
- enum tree_code code, tree type, tree op0, tree op1)
-{
- return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0, op1);
-}
extern tree gimple_build (gimple_seq *, location_t,
enum tree_code, tree, tree, tree, tree);
+template<class ...Args>
inline tree
-gimple_build (gimple_seq *seq,
- enum tree_code code, tree type, tree op0, tree op1, tree op2)
+gimple_build (gimple_seq *seq, enum tree_code code, tree type, Args ...ops)
{
- return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0, op1, op2);
+ static_assert (sizeof...(ops) > 0 && sizeof...(ops) <= 3,
+ "Number of operands must be from one to three");
+ return gimple_build (seq, UNKNOWN_LOCATION, code, type, ops...);
}
+
extern tree gimple_build (gimple_seq *, location_t, combined_fn, tree);
-inline tree
-gimple_build (gimple_seq *seq, combined_fn fn, tree type)
-{
- return gimple_build (seq, UNKNOWN_LOCATION, fn, type);
-}
extern tree gimple_build (gimple_seq *, location_t, combined_fn, tree, tree);
-inline tree
-gimple_build (gimple_seq *seq, combined_fn fn, tree type, tree arg0)
-{
- return gimple_build (seq, UNKNOWN_LOCATION, fn, type, arg0);
-}
extern tree gimple_build (gimple_seq *, location_t, combined_fn,
tree, tree, tree);
-inline tree
-gimple_build (gimple_seq *seq, combined_fn fn,
- tree type, tree arg0, tree arg1)
-{
- return gimple_build (seq, UNKNOWN_LOCATION, fn, type, arg0, arg1);
-}
extern tree gimple_build (gimple_seq *, location_t, combined_fn,
tree, tree, tree, tree);
+template<class ...Args>
inline tree
-gimple_build (gimple_seq *seq, combined_fn fn,
- tree type, tree arg0, tree arg1, tree arg2)
+gimple_build (gimple_seq *seq, combined_fn fn, tree type, Args ...args)
{
- return gimple_build (seq, UNKNOWN_LOCATION, fn, type, arg0, arg1, arg2);
+ static_assert (sizeof...(args) < 4,
+ "Number of arguments must be less than four");
+ return gimple_build (seq, UNKNOWN_LOCATION, fn, type, args...);
}
extern tree gimple_convert (gimple_seq *, location_t, tree, tree);
--
2.35.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-11 13:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11 13:22 [PATCH] Use variadic template functions for the gimple_build forwarders Richard Biener
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).