This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: v850 simulator patch for v850e bit twiddle instructions


This fixes bugs in the handling of v850e bit twiddle instructions that take the
bit position operand as a register, e.g. "set1 reg2, [reg1]".   The operand
is a bit position from 0-7 which can be in any register.  The simulator is
masking the operand with 7 and then reading the register.  This is wrong.
We need to read the register first, and then mask with 7.  This patch fixes
the problem.
	
Gcc doesn't generate these instructions unfortunately, so I need an asm to
show the problem.  Gcc also unfortunately doesn't have any print operand code
for the address I need here, so I need a badly written asm (grumble), but
anways, here is a testcase.

char c = 0;

int
sub (int bp)
{
  char *ptr = &c;
  asm volatile ("set1 %1,[%0]" : : "r" (ptr), "r" (bp));
  return 0;
}

int
main()
{
  sub (5);
  if (c != 0x20)
    abort ();
  return 0;
}

If I compile this with -mv850e, and run it with an unpatched simulator it
hits the abort.  With the patched simulator, it runs correctly returning zero.

I ran the gdb testsuite to test this, but it was pretty pointless since the
instruction is not generated by gcc, and it passed with no regressions as
expected.
The sim/testsuite directory can be used to add SIM specific tests (it contains two different styles so take care :-). For tests like the above, people are often reduced to using .word ....

2002-09-27  Jim Wilson  <wilson@redhat.com>

	* simops.c (OP_E6077E0): And op1 with 7 after reading register, not
	before.
	(BIT_CHANGE_OP): Likewise.
Since the sim/v850 has no maintainer, and these are all straight forward, I'm assuming that these are each being checked in.

Andrew



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]