+2016-10-04 Alan Modra <amodra@gmail.com>
+
+ * ldexp.c (exp_value_fold): New function.
+ (exp_unop, exp_binop, exp_trinop): Use it.
+
2016-09-30 Alan Modra <amodra@gmail.com>
* scripttempl/v850.sc: Don't reference __ctbp, __ep, __gp when
exp_fold_tree_1 (tree);
}
+static void
+exp_value_fold (etree_type *tree)
+{
+ exp_fold_tree_no_dot (tree);
+ if (expld.result.valid_p)
+ {
+ tree->type.node_code = INT;
+ tree->value.value = expld.result.value;
+ tree->value.str = NULL;
+ tree->type.node_class = etree_value;
+ }
+}
+
etree_type *
exp_binop (int code, etree_type *lhs, etree_type *rhs)
{
new_e->binary.lhs = lhs;
new_e->binary.rhs = rhs;
new_e->type.node_class = etree_binary;
+ if (lhs->type.node_class == etree_value
+ && rhs->type.node_class == etree_value
+ && code != ALIGN_K
+ && code != DATA_SEGMENT_ALIGN
+ && code != DATA_SEGMENT_RELRO_END)
+ exp_value_fold (new_e);
return new_e;
}
new_e->trinary.cond = cond;
new_e->trinary.rhs = rhs;
new_e->type.node_class = etree_trinary;
+ if (cond->type.node_class == etree_value
+ && lhs->type.node_class == etree_value
+ && rhs->type.node_class == etree_value)
+ exp_value_fold (new_e);
return new_e;
}
new_e->unary.type.lineno = child->type.lineno;
new_e->unary.child = child;
new_e->unary.type.node_class = etree_unary;
+ if (child->type.node_class == etree_value
+ && code != ALIGN_K
+ && code != ABSOLUTE
+ && code != NEXT
+ && code != DATA_SEGMENT_END)
+ exp_value_fold (new_e);
return new_e;
}