Hello everyone,

I need to specify constraints for registers used in the memory
operands in a load pattern. For these the following are the things
that i have done.

#define CONSTRAINT_LEN(CHAR,STR) \
        ((CHAR) == 'R' ? 3 \
         : DEFAULT_CONSTRAINT_LEN(CHAR,STR))

#define EXTRA_MEMORY_CONSTRAINT(C, STR) \
          ((C) == 'R')

#define REG_CLASS_FROM_CONSTRAINT(CHAR,STR) \
                 reg_class_from_constraint (CHAR, STR)

#define EXTRA_CONSTRAINT_STR(VALUE,C,STR) \
                 extra_constraint (VALUE, C, STR)

in extra_constraints i have the following code:

{
  if (GET_CODE(value) != MEM)
    return 0;

  if (c == 'R')
    {
      r = XEXP(value,0);
      if ((GET_CODE(r) == REG) && (REGNO(r) < FIRST_PSEUDO_REGISTER))
        {
          rclass = REG_CLASS_FROM_CONSTRAINT(c, str);
          if (rclass == REGNO_REG_CLASS (REGNO(r)))
            return 1;
        }
    }
  return 0;
}

And i have the following pattern in the md file:

(define_insn "movhi_load"
  [(set (match_operand:HI 0 "register_operand" "=R01,R03,R05,R07,R09,R13,R15,r")
        (match_operand:HI 1 "memory_operand"   
"R00,R02,R04,R06,R08,R12,R14,m"))]

Is this the proper way to do this?

Thank you for taking the time to read this.

Regards,
Shafi

Reply via email to