Richard Sandiford wrote:
> "Omar Torres" <[EMAIL PROTECTED]> writes:
> More importantly:
>
>>        operands[4] = simplify_gen_subreg(QImode,operands[1],HImode,0);
>>        operands[5] = simplify_gen_subreg(QImode,operands[1],HImode,1);
>
> ..this code is designed to handle REGs and CONST_INTs correctly,
> and avoid the problem you were seeing.  (As Eric says, gen_int_mode
> is the canonical way of generating a correct CONST_INT in cases where
> you do need to create one manually.  In this case it's simpler to use
> simplify_gen_subreg though.)

Now, the insn:
(insn 84 5 9 (set (reg:HI 1 %r3)
         (const_int 32767 [0x7fff])) 3 {*movhi} (nil)
     (nil))

get's split into
  (set (reg:QI 1 %r3)
       (const_int 127 [0x7f])
  (set (reg:QI 2 %r2)
       (const_int -1 [0xffffffff])

and my movqi patter is able to match both of this patterns as expected.

But, now the output asm is
  move %r2,#0xffffffff
Instead of the expected:
  move %r2,#0xff

I am not fully familiar with how to fix this, but seems like there are
at least two ways of fixing this:
  1- Detect the sign in the rtl template and manipulate the operand so
that the asm value is outputted. That is, use something like this:

(define_insn "movqi"
   [(set (match_operand:QI 0 "nonimmediate_operand" "=r,m")
        (match_operand:QI 1 "general_operand"      "g,r"))]
   ""
   "*
   if (CONST_INT == GET_CODE (operands[1])) {
     if (0 > INTVAL(operands[1])) {
       fprintf (stderr, \"\nOperand 1 Value: %d, %d\", INTVAL
(operands[1]),0xff & INTVAL (operands[1]) );
       operands[1] = gen_rtx_CONST_INT (VOIDmode, 0xff & INTVAL
(operands[1]));
     }
   }
  return \"move.a\t%0,%1\";
  ")

  2- Use a special letter in the asm template, to communicate with the
print_operand() function.

  Is there any other way of doing this? If not, is there any advantage
of using one option over the other above?

Thanks,
-Omar

Reply via email to