diff options
author | Kazu Hirata <kazu@cs.umass.edu> | 2005-03-22 17:36:37 +0000 |
---|---|---|
committer | Kazu Hirata <kazu@gcc.gnu.org> | 2005-03-22 17:36:37 +0000 |
commit | ba199a5345bb20427b46b0de24e80feb5afd7e0d (patch) | |
tree | 0ffafddb8f7c25fe5cb7637b2509823c28d945e1 | |
parent | 7cf572596f5c190e40fe851a86ef182ed5190783 (diff) | |
download | gcc-ba199a5345bb20427b46b0de24e80feb5afd7e0d.zip gcc-ba199a5345bb20427b46b0de24e80feb5afd7e0d.tar.gz gcc-ba199a5345bb20427b46b0de24e80feb5afd7e0d.tar.bz2 |
fold-const.c (fold_build1, [...]): New.
* fold-const.c (fold_build1, fold_build2, fold_build3): New.
* tree.h: Add corresponding prototypes.
From-SVN: r96881
-rw-r--r-- | gcc/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/fold-const.c | 45 | ||||
-rw-r--r-- | gcc/tree.h | 3 |
3 files changed, 51 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ca33ce1..a22363f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -4,6 +4,9 @@ CALL_EXPR. (fold): Update a call to fold_ternary. + * fold-const.c (fold_build1, fold_build2, fold_build3): New. + * tree.h: Add corresponding prototypes. + 2005-03-22 Jakub Jelinek <jakub@redhat.com> PR target/20561 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 603deef..5937963 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -10168,6 +10168,51 @@ fold_checksum_tree (tree expr, struct md5_ctx *ctx, htab_t ht) #endif +/* Fold a unary tree expression with code CODE of type TYPE with an + operand OP0. Return a folded expresion if successful. Otherwise, + return a tree expression with code CODE of type TYPE with an + operand OP0. */ + +tree +fold_build1 (enum tree_code code, tree type, tree op0) +{ + tree tem = fold_unary (code, type, op0); + if (tem) + return tem; + + return build1 (code, type, op0); +} + +/* Fold a binary tree expression with code CODE of type TYPE with + operands OP0 and OP1. Return a folded expresion if successful. + Otherwise, return a tree expression with code CODE of type TYPE + with operands OP0 and OP1. */ + +tree +fold_build2 (enum tree_code code, tree type, tree op0, tree op1) +{ + tree tem = fold_binary (code, type, op0, op1); + if (tem) + return tem; + + return build2 (code, type, op0, op1); +} + +/* Fold a ternary tree expression with code CODE of type TYPE with + operands OP0, OP1, and OP2. Return a folded expresion if + successful. Otherwise, return a tree expression with code CODE of + type TYPE with operands OP0, OP1, and OP2. */ + +tree +fold_build3 (enum tree_code code, tree type, tree op0, tree op1, tree op2) +{ + tree tem = fold_ternary (code, type, op0, op1, op2); + if (tem) + return tem; + + return build3 (code, type, op0, op1, op2); +} + /* Perform constant folding and related simplification of initializer expression EXPR. This behaves identically to "fold" but ignores potential run-time traps and exceptions that fold must preserve. */ @@ -3495,6 +3495,9 @@ extern void using_eh_for_cleanups (void); subexpressions are not changed. */ extern tree fold (tree); +extern tree fold_build1 (enum tree_code, tree, tree); +extern tree fold_build2 (enum tree_code, tree, tree, tree); +extern tree fold_build3 (enum tree_code, tree, tree, tree, tree); extern tree fold_initializer (tree); extern tree fold_convert (tree, tree); extern tree fold_single_bit_test (enum tree_code, tree, tree, tree); |