On Thu, Apr 24, 2008 at 12:01 PM, Mohamed Shafi <[EMAIL PROTECTED]> wrote:
> Hello all,
>
>  The target that i am porting in gcc 4.1.2, has the following instructions
>
>  setb Rx, bitno
>  clrb Rx, bitno
>
>  where bit bitno of Rx will either be set or reset.
>
>  For statements like
>
>  a |= (1 << 2); and
>  b &= ~(1 << 2);
>
>  I can use the above instructions directly. But i am not sure how to
>  write the patterns for the above instructions.
>  Can anybody help me with this?
>

What i have done is to have the following pattern

(define_insn "setbhi3"
  [(set (match_operand:HI 0 "register_operand" "=r")
        (ior:HI (match_operand:HI 1 "register_operand" "%0")
                (match_operand:HI 2 "setclrb_operand" "I")))]
  ""
  "setb\\t%0, %2"
)
 where setclrb_operand is

(define_predicate "setclrb_operand"
  (match_code "const_int")
{
  if (CONSTANT_P (op))
      {
        if (INTVAL(op) && !(INTVAL(op) & (INTVAL(op) - 1)))
          if (INTVAL(op) < BITS_PER_WORD)
            return 1;
      }

  return 0;
})

I am now able to generate the instruction.
Is this OK?

Thank you for your time.

Regards,
Shafi.

Reply via email to