summaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorBernd Schmidt <bernds@codesourcery.com>2006-09-15 17:02:35 +0000
committerBernd Schmidt <bernds@codesourcery.com>2006-09-15 17:02:35 +0000
commitc4ae04ceb1e1daf63f1aed9c8b244875f167878d (patch)
treee4239aaab32fdf9e15d3aabc1bc3f0ad2e35bf39 /gas
parent76052d04e0caac458a79d96c73d9e6f7331dc9b3 (diff)
downloadbinutils-c4ae04ceb1e1daf63f1aed9c8b244875f167878d.tar.gz
binutils-c4ae04ceb1e1daf63f1aed9c8b244875f167878d.tar.bz2
binutils-c4ae04ceb1e1daf63f1aed9c8b244875f167878d.zip
* config/bfin-parse.y (binary): Do some more constant folding for
additions.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog5
-rw-r--r--gas/config/bfin-parse.y27
2 files changed, 26 insertions, 6 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index b6c256286ff..c589c091d74 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,8 @@
+2006-09-15 Bernd Schmidt <bernd.schmidt@analog.com>
+
+ * config/bfin-parse.y (binary): Do some more constant folding for
+ additions.
+
2006-09-13 Jan Beulich <jbeulich@novell.com>
* input-file.c (input_file_give_next_buffer): Demote as_bad to
diff --git a/gas/config/bfin-parse.y b/gas/config/bfin-parse.y
index 609c282d497..f74074e55a1 100644
--- a/gas/config/bfin-parse.y
+++ b/gas/config/bfin-parse.y
@@ -4270,6 +4270,8 @@ value_match (Expr_Node *expr, int sz, int sign, int mul, int issigned)
static Expr_Node *
binary (Expr_Op_Type op, Expr_Node *x, Expr_Node *y)
{
+ Expr_Node_Value val;
+
if (x->type == Expr_Node_Constant && y->type == Expr_Node_Constant)
{
switch (op)
@@ -4319,13 +4321,26 @@ binary (Expr_Op_Type op, Expr_Node *x, Expr_Node *y)
}
return x;
}
- else
+ /* Canonicalize order to EXPR OP CONSTANT. */
+ if (x->type == Expr_Node_Constant)
+ {
+ Expr_Node *t = x;
+ x = y;
+ y = t;
+ }
+ if (y->type == Expr_Node_Constant && x->type == Expr_Node_Binop
+ && x->Right_Child->type == Expr_Node_Constant)
{
- /* Create a new expression structure. */
- Expr_Node_Value val;
- val.op_value = op;
- return Expr_Node_Create (Expr_Node_Binop, val, x, y);
- }
+ if (op == x->value.op_value && x->value.op_value == Expr_Op_Type_Add)
+ {
+ x->Right_Child->value.i_value += y->value.i_value;
+ return x;
+ }
+ }
+
+ /* Create a new expression structure. */
+ val.op_value = op;
+ return Expr_Node_Create (Expr_Node_Binop, val, x, y);
}
static Expr_Node *