This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[Xtensa Patch] Use custom copy function for vinsns
- From: Sterling Augustine <sterling at tensilica dot com>
- To: <binutils at sourceware dot org>
- Date: Thu, 20 Aug 2009 11:18:08 -0700
- Subject: [Xtensa Patch] Use custom copy function for vinsns
While looking at the performance issues for my last check in, I noticed
several other performance bottlenecks in the Xtensa port.
I have committed this patch which addresses one of them: vinsns are
sized for worst case configurations, but the vast majority of
configurations aren't worst case. The enclosed patch maintains the
worst-case sizing, but adds a custom copy function for this data
structure which only copies the actual case, thereby improving
performance substantially on most configs.
Sterling
2009-08-20 Sterling Augustine <sterling@jaw.hq.tensilica.com>
* config/tc-xtensa.c (xg_copy_vinsn): New function.
(finish_vinsn): Call xg_copy_vinsn.
Index: gas/config/tc-xtensa.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-xtensa.c,v
retrieving revision 1.113
diff -u -p -r1.113 tc-xtensa.c
--- gas/config/tc-xtensa.c 19 Aug 2009 16:10:46 -0000 1.113
+++ gas/config/tc-xtensa.c 20 Aug 2009 18:08:49 -0000
@@ -527,6 +527,7 @@ static int get_num_stack_literal_bytes (
/* vliw_insn functions. */
static void xg_init_vinsn (vliw_insn *);
+static void xg_copy_vinsn (vliw_insn *, vliw_insn *);
static void xg_clear_vinsn (vliw_insn *);
static bfd_boolean vinsn_has_specific_opcodes (vliw_insn *);
static void xg_free_vinsn (vliw_insn *);
@@ -6653,7 +6654,6 @@ xg_find_narrowest_format (vliw_insn *vin
xtensa_isa isa = xtensa_default_isa;
xtensa_format format;
- vliw_insn v_copy = *vinsn;
xtensa_opcode nop_opcode = xtensa_nop_opcode;
if (vinsn->num_slots == 1)
@@ -6661,7 +6661,8 @@ xg_find_narrowest_format (vliw_insn *vin
for (format = 0; format < xtensa_isa_num_formats (isa); format++)
{
- v_copy = *vinsn;
+ vliw_insn v_copy;
+ xg_copy_vinsn (&v_copy, vinsn);
if (xtensa_format_num_slots (isa, format) == v_copy.num_slots)
{
int slot;
@@ -6696,7 +6697,7 @@ xg_find_narrowest_format (vliw_insn *vin
}
if (fit == v_copy.num_slots)
{
- *vinsn = v_copy;
+ xg_copy_vinsn (vinsn, &v_copy);
xtensa_format_encode (isa, format, vinsn->insnbuf);
vinsn->format = format;
break;
@@ -11702,6 +11703,16 @@ xg_clear_vinsn (vliw_insn *v)
}
+static void
+xg_copy_vinsn (vliw_insn *dst, vliw_insn *src)
+{
+ memcpy (dst, src,
+ offsetof(vliw_insn, slots) + src->num_slots * sizeof(TInsn));
+ dst->insnbuf = src->insnbuf;
+ memcpy (dst->slotbuf, src->slotbuf, src->num_slots * sizeof(xtensa_insnbuf));
+}
+
+
static bfd_boolean
vinsn_has_specific_opcodes (vliw_insn *v)
{