* [PATCH 2/3] opcodes: blackfin: simplify decode_CC2stat_0 logic
2014-08-13 11:13 [PATCH 1/3] opcodes: blackfin: avoid duplicate memory reads Mike Frysinger
@ 2014-08-13 11:13 ` Mike Frysinger
2014-08-13 11:13 ` [PATCH 3/3] opcodes: bfin: convert ad-hoc ints to bfd_boolean Mike Frysinger
2014-08-14 13:22 ` [PATCH 1/3] opcodes: blackfin: avoid duplicate memory reads Mike Frysinger
2 siblings, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2014-08-13 11:13 UTC (permalink / raw)
To: binutils
These multiple if statements can be condensed down into a single if
statement and an array of strings.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-12-03 Mike Frysinger <vapier@gentoo.org>
* bfin-dis.c (OUT): Define.
(decode_CC2stat_0): Declare new op_names array.
Replace multiple if statements with a single one.
---
opcodes/bfin-dis.c | 46 +++++-----------------------------------------
1 file changed, 5 insertions(+), 41 deletions(-)
diff --git a/opcodes/bfin-dis.c b/opcodes/bfin-dis.c
index e7d6706..ba33152 100644
--- a/opcodes/bfin-dis.c
+++ b/opcodes/bfin-dis.c
@@ -484,6 +484,7 @@ static const enum machine_registers decode_allregs[] =
#ifndef OUTS
#define OUTS(p, txt) (p)->fprintf_func ((p)->stream, "%s", txt)
#endif
+#define OUT(p, txt, ...) (p)->fprintf_func ((p)->stream, txt, ## __VA_ARGS__)
static void
amod0 (int s0, int x0, disassemble_info *outf)
@@ -1224,6 +1225,7 @@ decode_CC2stat_0 (TIword iw0, disassemble_info *outf)
int cbit = ((iw0 >> CC2stat_cbit_bits) & CC2stat_cbit_mask);
const char *bitname = statbits (cbit);
+ const char * const op_names[] = { "", "|", "&", "^" } ;
if (priv->parallel)
return 0;
@@ -1241,48 +1243,10 @@ decode_CC2stat_0 (TIword iw0, disassemble_info *outf)
bitname = bitnames;
}
- if (op == 0 && D == 0)
- {
- OUTS (outf, "CC = ");
- OUTS (outf, bitname);
- }
- else if (op == 1 && D == 0)
- {
- OUTS (outf, "CC |= ");
- OUTS (outf, bitname);
- }
- else if (op == 2 && D == 0)
- {
- OUTS (outf, "CC &= ");
- OUTS (outf, bitname);
- }
- else if (op == 3 && D == 0)
- {
- OUTS (outf, "CC ^= ");
- OUTS (outf, bitname);
- }
- else if (op == 0 && D == 1)
- {
- OUTS (outf, bitname);
- OUTS (outf, " = CC");
- }
- else if (op == 1 && D == 1)
- {
- OUTS (outf, bitname);
- OUTS (outf, " |= CC");
- }
- else if (op == 2 && D == 1)
- {
- OUTS (outf, bitname);
- OUTS (outf, " &= CC");
- }
- else if (op == 3 && D == 1)
- {
- OUTS (outf, bitname);
- OUTS (outf, " ^= CC");
- }
+ if (D == 0)
+ OUT (outf, "CC %s= %s", op_names[op], bitname);
else
- return 0;
+ OUT (outf, "%s %s= CC", bitname, op_names[op]);
return 2;
}
--
2.0.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] opcodes: bfin: convert ad-hoc ints to bfd_boolean
2014-08-13 11:13 [PATCH 1/3] opcodes: blackfin: avoid duplicate memory reads Mike Frysinger
2014-08-13 11:13 ` [PATCH 2/3] opcodes: blackfin: simplify decode_CC2stat_0 logic Mike Frysinger
@ 2014-08-13 11:13 ` Mike Frysinger
2014-08-14 13:22 ` [PATCH 1/3] opcodes: blackfin: avoid duplicate memory reads Mike Frysinger
2 siblings, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2014-08-13 11:13 UTC (permalink / raw)
To: binutils
These various int fields are being used as booleans, so change to the
existing bfd_boolean style.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
opcodes/bfin-dis.c | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/opcodes/bfin-dis.c b/opcodes/bfin-dis.c
index ba33152..56336be 100644
--- a/opcodes/bfin-dis.c
+++ b/opcodes/bfin-dis.c
@@ -45,7 +45,7 @@ typedef unsigned int bu32;
struct private
{
TIword iw0;
- int comment, parallel;
+ bfd_boolean comment, parallel;
};
typedef enum
@@ -1569,7 +1569,7 @@ decode_LOGI2op_0 (TIword iw0, disassemble_info *outf)
OUTS (outf, ");\t\t/* bit");
OUTS (outf, imm7d (src));
OUTS (outf, " */");
- priv->comment = 1;
+ priv->comment = TRUE;
}
else if (opc == 1)
{
@@ -1580,7 +1580,7 @@ decode_LOGI2op_0 (TIword iw0, disassemble_info *outf)
OUTS (outf, ");\t\t/* bit");
OUTS (outf, imm7d (src));
OUTS (outf, " */");
- priv->comment = 1;
+ priv->comment = TRUE;
}
else if (opc == 2)
{
@@ -1591,7 +1591,7 @@ decode_LOGI2op_0 (TIword iw0, disassemble_info *outf)
OUTS (outf, ");\t\t/* bit");
OUTS (outf, imm7d (src));
OUTS (outf, " */");
- priv->comment = 1;
+ priv->comment = TRUE;
}
else if (opc == 3)
{
@@ -1602,7 +1602,7 @@ decode_LOGI2op_0 (TIword iw0, disassemble_info *outf)
OUTS (outf, ");\t\t/* bit");
OUTS (outf, imm7d (src));
OUTS (outf, " */");
- priv->comment = 1;
+ priv->comment = TRUE;
}
else if (opc == 4)
{
@@ -1613,7 +1613,7 @@ decode_LOGI2op_0 (TIword iw0, disassemble_info *outf)
OUTS (outf, ");\t\t/* bit");
OUTS (outf, imm7d (src));
OUTS (outf, " */");
- priv->comment = 1;
+ priv->comment = TRUE;
}
else if (opc == 5)
{
@@ -1771,7 +1771,7 @@ decode_COMPI2opD_0 (TIword iw0, disassemble_info *outf)
OUTS (outf, "(");
OUTS (outf, imm32 (*pval));
OUTS (outf, ") */");
- priv->comment = 1;
+ priv->comment = TRUE;
}
else if (op == 1)
{
@@ -1781,7 +1781,7 @@ decode_COMPI2opD_0 (TIword iw0, disassemble_info *outf)
OUTS (outf, ";\t\t/* (");
OUTS (outf, imm7d (src));
OUTS (outf, ") */");
- priv->comment = 1;
+ priv->comment = TRUE;
}
else
return 0;
@@ -1827,7 +1827,7 @@ decode_COMPI2opP_0 (TIword iw0, disassemble_info *outf)
OUTS (outf, "(");
OUTS (outf, imm32 (*pval));
OUTS (outf, ") */");
- priv->comment = 1;
+ priv->comment = TRUE;
}
else if (op == 1)
{
@@ -1837,7 +1837,7 @@ decode_COMPI2opP_0 (TIword iw0, disassemble_info *outf)
OUTS (outf, ";\t\t/* (");
OUTS (outf, imm7d (src));
OUTS (outf, ") */");
- priv->comment = 1;
+ priv->comment = TRUE;
}
else
return 0;
@@ -2043,7 +2043,7 @@ decode_dagMODik_0 (TIword iw0, disassemble_info *outf)
else if (op == 2 || op == 3)
OUTS (outf, "4");
OUTS (outf, ") */");
- priv->comment = 1;
+ priv->comment = TRUE;
}
return 2;
@@ -2743,7 +2743,7 @@ decode_LDIMMhalf_0 (TIword iw0, TIword iw1, disassemble_info *outf)
}
OUTS (outf, " */");
- priv->comment = 1;
+ priv->comment = TRUE;
}
if (S == 1 || Z == 1)
{
@@ -2754,7 +2754,7 @@ decode_LDIMMhalf_0 (TIword iw0, TIword iw1, disassemble_info *outf)
OUTS (outf, "(");
OUTS (outf, imm32 (*pval));
OUTS (outf, ") */");
- priv->comment = 1;
+ priv->comment = TRUE;
}
return 4;
}
@@ -2919,7 +2919,7 @@ decode_linkage_0 (TIword iw0, TIword iw1, disassemble_info *outf)
OUTS (outf, ";\t\t/* (");
OUTS (outf, uimm16s4d (framesize));
OUTS (outf, ") */");
- priv->comment = 1;
+ priv->comment = TRUE;
}
else if (R == 1)
OUTS (outf, "UNLINK");
@@ -4771,8 +4771,8 @@ print_insn_bfin (bfd_vma pc, disassemble_info *outf)
struct private priv;
int count;
- priv.parallel = 0;
- priv.comment = 0;
+ priv.parallel = FALSE;
+ priv.comment = FALSE;
outf->private_data = &priv;
count = _print_insn_bfin (pc, outf);
@@ -4784,29 +4784,29 @@ print_insn_bfin (bfd_vma pc, disassemble_info *outf)
if (count == 4 && (priv.iw0 & 0xc000) == 0xc000 && (priv.iw0 & BIT_MULTI_INS)
&& ((priv.iw0 & 0xe800) != 0xe800 /* Not Linkage. */ ))
{
- int legal = 1;
+ bfd_boolean legal = TRUE;
int len;
- priv.parallel = 1;
+ priv.parallel = TRUE;
OUTS (outf, " || ");
len = _print_insn_bfin (pc + 4, outf);
if (len == -1)
return -1;
OUTS (outf, " || ");
if (len != 2)
- legal = 0;
+ legal = FALSE;
len = _print_insn_bfin (pc + 6, outf);
if (len == -1)
return -1;
if (len != 2)
- legal = 0;
+ legal = FALSE;
if (legal)
count = 8;
else
{
OUTS (outf, ";\t\t/* ILLEGAL PARALLEL INSTRUCTION */");
- priv.comment = 1;
+ priv.comment = TRUE;
count = 0;
}
}
--
2.0.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] opcodes: blackfin: avoid duplicate memory reads
@ 2014-08-13 11:13 Mike Frysinger
2014-08-13 11:13 ` [PATCH 2/3] opcodes: blackfin: simplify decode_CC2stat_0 logic Mike Frysinger
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mike Frysinger @ 2014-08-13 11:13 UTC (permalink / raw)
To: binutils
Rather than reading the same memory twice, pass the value back up.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-02-05 Mike Frysinger <vapier@gentoo.org>
* bfin-dis.c (struct private): Add iw0.
(_print_insn_bfin): Assign iw0 to priv.iw0.
(print_insn_bfin): Drop ifetch and use priv.iw0.
---
opcodes/bfin-dis.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/opcodes/bfin-dis.c b/opcodes/bfin-dis.c
index b8bc087..e7d6706 100644
--- a/opcodes/bfin-dis.c
+++ b/opcodes/bfin-dis.c
@@ -44,6 +44,7 @@ typedef unsigned int bu32;
struct private
{
+ TIword iw0;
int comment, parallel;
};
@@ -4697,6 +4698,7 @@ _print_insn_bfin (bfd_vma pc, disassemble_info *outf)
if (ifetch (pc, outf, &iw0))
return -1;
+ priv->iw0 = iw0;
if ((iw0 & 0xc000) == 0xc000)
{
@@ -4803,12 +4805,8 @@ int
print_insn_bfin (bfd_vma pc, disassemble_info *outf)
{
struct private priv;
- TIword iw0;
int count;
- if (ifetch (pc, outf, &iw0) == -1)
- return -1;
-
priv.parallel = 0;
priv.comment = 0;
outf->private_data = &priv;
@@ -4819,8 +4817,8 @@ print_insn_bfin (bfd_vma pc, disassemble_info *outf)
/* Proper display of multiple issue instructions. */
- if (count == 4 && (iw0 & 0xc000) == 0xc000 && (iw0 & BIT_MULTI_INS)
- && ((iw0 & 0xe800) != 0xe800 /* Not Linkage. */ ))
+ if (count == 4 && (priv.iw0 & 0xc000) == 0xc000 && (priv.iw0 & BIT_MULTI_INS)
+ && ((priv.iw0 & 0xe800) != 0xe800 /* Not Linkage. */ ))
{
int legal = 1;
int len;
--
2.0.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] opcodes: blackfin: avoid duplicate memory reads
2014-08-13 11:13 [PATCH 1/3] opcodes: blackfin: avoid duplicate memory reads Mike Frysinger
2014-08-13 11:13 ` [PATCH 2/3] opcodes: blackfin: simplify decode_CC2stat_0 logic Mike Frysinger
2014-08-13 11:13 ` [PATCH 3/3] opcodes: bfin: convert ad-hoc ints to bfd_boolean Mike Frysinger
@ 2014-08-14 13:22 ` Mike Frysinger
2 siblings, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2014-08-14 13:22 UTC (permalink / raw)
To: binutils
[-- Attachment #1: Type: text/plain, Size: 34 bytes --]
i've pushed these three now
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-08-14 13:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-13 11:13 [PATCH 1/3] opcodes: blackfin: avoid duplicate memory reads Mike Frysinger
2014-08-13 11:13 ` [PATCH 2/3] opcodes: blackfin: simplify decode_CC2stat_0 logic Mike Frysinger
2014-08-13 11:13 ` [PATCH 3/3] opcodes: bfin: convert ad-hoc ints to bfd_boolean Mike Frysinger
2014-08-14 13:22 ` [PATCH 1/3] opcodes: blackfin: avoid duplicate memory reads Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).