Use movi to load string values.

String values are known to be 2-value bits, so they are natural
candidates for using the movi instruction to load the value in
far fewer instructions. With this patch, up to 16bits (two bytes)
at a time can be loaded per instruction.

Signed-off-by: Stephen Williams <steve@icarus.com>
This commit is contained in:
Stephen Williams 2007-11-13 21:14:07 -08:00
parent 4356f9c478
commit 0456a1b339
2 changed files with 20 additions and 14 deletions

View File

@ -16,9 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: eval_expr.c,v 1.137 2007/04/14 04:43:01 steve Exp $"
#endif
# include "vvp_priv.h"
# include <string.h>
@ -1584,7 +1581,7 @@ static struct vector_info draw_string_expr(ivl_expr_t exp, unsigned wid)
struct vector_info res;
char *p, *fp;
unsigned ewid, nwid;
unsigned bit = 0, idx;
unsigned idx;
res.wid = wid;
nwid = wid;
@ -1604,25 +1601,31 @@ static struct vector_info draw_string_expr(ivl_expr_t exp, unsigned wid)
load the constant bit values. */
res.base = allocate_vector(wid);
/* Since this is a string, we know that all the bits are
defined and each character represents exactly 8 bits. Use
the %movi instruction to more efficiently move the string
around. */
idx = 0;
while (idx < nwid) {
unsigned this_bit = ((*p) & (1 << bit)) ? 1 : 0;
unsigned bits;
unsigned trans = 16;
if (nwid-idx < 16)
trans = nwid-idx;
fprintf(vvp_out, " %%mov %u, %d, 1;\n",
res.base+idx, this_bit);
bit++;
if (bit == 8) {
bit = 0;
p--;
bits = *p;
p -= 1;
if (trans > 8) {
bits |= *p << 8;
p -= 1;
}
fprintf(vvp_out, " %%movi %u, %u, %u;\n", res.base+idx,bits,trans);
idx++;
idx += trans;
}
/* Pad the number up to the expression width. */
if (idx < wid)
fprintf(vvp_out, " %%mov %u, 0, %u;\n", res.base+idx, wid-idx);
fprintf(vvp_out, " %%mov %u, 0, %u;\n", res.base+idx, wid-idx);
if (res.base >= 8)
save_expression_lookaside(res.base, exp, wid);

View File

@ -462,6 +462,7 @@ This opcode is the real-valued modulus of the two real values.
* %mov <dst>, <src>, <wid>
* %mov/wr <dst>, <src>
* %movi <dst>, <value>, <wid>
This instruction copies a vector from one place in register space to
another. The destination and source vectors are assumed to be the same
@ -469,6 +470,8 @@ width and non-overlapping. The <dst> may not be 0-3, but if the <src>
is one of the 4 constant bits, the effect is to replicate the value
into the destination vector. This is useful for filling a vector.
The %movi variant moves a binary value, LSB first, into the
destination vector.
* %mul <bit-l>, <bit-r>, <wid>