This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH bfin] Don't use regno for multiple purpose
- From: Jie Zhang <jie dot zhang at analog dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Fri, 4 Sep 2009 01:16:22 +0800
- Subject: [PATCH bfin] Don't use regno for multiple purpose
Internally, register data structure has a 'flags' member, but which is
never used. All flags are added to 'regno' member, which is intended for
register number. This patch makes use of 'flags' for flags and 'regno'
only for register number. No functional changes. Committed.
Jie
* config/bfin-defs.h (F_REG_ALL): Remove macro.
(F_REG_HIGH): Redefine.
(F_REG_NONE): New macro.
(F_REG_LOW): New macro.
(REG_CLASS): Enclose macro argument in parentheses when used.
(REG_EVEN): Likewise.
(IS_H): Use flags.
(IS_HCOMPL): Use flags.
* config/bfin-lex.l (SP.L, SP.H, FP.L, FP.H): Set flags.
(parse_reg): Set flags.
(parse_halfreg): Set flags.
Index: config/bfin-defs.h
===================================================================
RCS file: /cvs/src/src/gas/config/bfin-defs.h,v
retrieving revision 1.10
diff -u -p -r1.10 bfin-defs.h
--- config/bfin-defs.h 3 Sep 2009 16:17:36 -0000 1.10
+++ config/bfin-defs.h 3 Sep 2009 17:04:30 -0000
@@ -82,8 +82,9 @@ typedef enum
#define T_NOGROUP 0xa0
/* Flags. */
-#define F_REG_ALL 0x1000
-#define F_REG_HIGH 0x2000 /* Half register: high half. */
+#define F_REG_NONE 0
+#define F_REG_HIGH 1
+#define F_REG_LOW 2
enum machine_registers
{
@@ -180,12 +181,12 @@ enum reg_class
#define REG_SAME(a, b) ((a).regno == (b).regno)
#define REG_EQUAL(a, b) (((a).regno & CODE_MASK) == ((b).regno & CODE_MASK))
-#define REG_CLASS(a) ((a.regno) & 0xf0)
+#define REG_CLASS(a) ((a).regno & 0xf0)
#define IS_A1(a) ((a).regno == REG_A1)
-#define IS_H(a) ((a).regno & F_REG_HIGH ? 1: 0)
-#define IS_EVEN(r) (r.regno % 2 == 0)
+#define IS_H(a) ((a).flags & F_REG_HIGH ? 1: 0)
+#define IS_EVEN(r) ((r).regno % 2 == 0)
#define IS_HCOMPL(a, b) (REG_EQUAL(a, b) && \
- ((a).regno & F_REG_HIGH) != ((b).regno & F_REG_HIGH))
+ ((a).flags & F_REG_HIGH) != ((b).flags & F_REG_HIGH))
/* register type checking. */
#define _TYPECHECK(r, x) (((r).regno & CLASS_MASK) == T_REG_##x)
Index: config/bfin-lex.l
===================================================================
RCS file: /cvs/src/src/gas/config/bfin-lex.l,v
retrieving revision 1.7
diff -u -p -r1.7 bfin-lex.l
--- config/bfin-lex.l 2 Sep 2009 07:24:20 -0000 1.7
+++ config/bfin-lex.l 3 Sep 2009 17:04:30 -0000
@@ -63,8 +63,8 @@ int yylex (void);
[sS][yY][sS][cC][fF][gG] _REG.regno = REG_SYSCFG; return REG;
[sS][tT][iI] return STI;
[sS][sS][yY][nN][cC] return SSYNC;
-[sS][pP]"."[lL] _REG.regno = REG_SP; return HALF_REG;
-[sS][pP]"."[hH] _REG.regno = REG_SP | F_REG_HIGH; return HALF_REG;
+[sS][pP]"."[lL] _REG.regno = REG_SP; _REG.flags = F_REG_LOW; return HALF_REG;
+[sS][pP]"."[hH] _REG.regno = REG_SP; _REG.flags = F_REG_HIGH; return HALF_REG;
[sS][pP] _REG.regno = REG_SP; return REG;
[sS][iI][gG][nN][bB][iI][tT][sS] return SIGNBITS;
[sS][iI][gG][nN] return SIGN;
@@ -158,8 +158,8 @@ int yylex (void);
[gG][eE] return GE;
[fF][uU] yylval.value = M_FU; return MMOD;
[fF][pP] _REG.regno = REG_FP; return REG;
-[fF][pP]"."[lL] _REG.regno = REG_FP; return HALF_REG;
-[fF][pP]"."[hH] _REG.regno = REG_FP | F_REG_HIGH; return HALF_REG;
+[fF][pP]"."[lL] _REG.regno = REG_FP; _REG.flags = F_REG_LOW; return HALF_REG;
+[fF][pP]"."[hH] _REG.regno = REG_FP; _REG.flags = F_REG_HIGH; return HALF_REG;
[eE][xX][tT][rR][aA][cC][tT] return EXTRACT;
[eE][xX][pP][aA][dD][jJ] return EXPADJ;
@@ -509,6 +509,7 @@ static long parse_int (char **end)
static int parse_reg (Register *r, int cl, char *rt)
{
r->regno = cl | (rt[1] - '0');
+ r->flags = F_REG_NONE;
return REG;
}
@@ -524,11 +525,12 @@ static int parse_halfreg (Register *r, i
case 'l':
case 'L':
+ r->flags = F_REG_LOW;
break;
case 'h':
case 'H':
- r->regno |= F_REG_HIGH;
+ r->flags = F_REG_HIGH;
break;
}