This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH bfin] 64bit constant folding
- From: Jie Zhang <jie dot zhang at analog dot com>
- To: binutils at sourceware dot org
- Date: Wed, 2 Sep 2009 17:08:55 +0800
- Subject: [PATCH bfin] 64bit constant folding
This patch tries to make Blackfin gas assemble such instruction:
R0 = (19088743 * 19088743 / 19088743 / 19088743)
Blackfin gas has its own expression parsing routines. While other
targets are able to do such calculation, Blackfin gas can not without
this patch.
Committed.
Jie
* config/bfin-parse.y (value_match): Use int instead of long.
From Michael Frysinger <michael.frysinger@analog.com>
* config/bfin-defs.h (Expr_Node_Value): Declare the i_value
member as long long.
Index: config/bfin-defs.h
===================================================================
RCS file: /cvs/src/src/gas/config/bfin-defs.h,v
retrieving revision 1.8
diff -u -p -r1.8 bfin-defs.h
--- config/bfin-defs.h 2 Sep 2009 07:24:20 -0000 1.8
+++ config/bfin-defs.h 2 Sep 2009 08:53:16 -0000
@@ -287,7 +287,7 @@ typedef enum
typedef union
{
const char *s_value; /* if relocation symbol, the text. */
- int i_value; /* if constant, the value. */
+ long long i_value; /* if constant, the value. */
Expr_Op_Type op_value; /* if operator, the value. */
} Expr_Node_Value;
Index: config/bfin-parse.y
===================================================================
RCS file: /cvs/src/src/gas/config/bfin-parse.y,v
retrieving revision 1.27
diff -u -p -r1.27 bfin-parse.y
--- config/bfin-parse.y 2 Sep 2009 07:30:32 -0000 1.27
+++ config/bfin-parse.y 2 Sep 2009 08:53:16 -0000
@@ -4376,11 +4376,11 @@ mkexpr (int x, SYMBOL_T s)
static int
value_match (Expr_Node *expr, int sz, int sign, int mul, int issigned)
{
- long umax = (1L << sz) - 1;
- long min = -1L << (sz - 1);
- long max = (1L << (sz - 1)) - 1;
+ int umax = (1 << sz) - 1;
+ int min = -1 << (sz - 1);
+ int max = (1 << (sz - 1)) - 1;
- long v = EXPR_VALUE (expr);
+ int v = (EXPR_VALUE (expr)) & 0xffffffff;
if ((v % mul) != 0)
{