This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: RFC: define_predicate


(define_predicate "call_operand" "subreg,reg,symbol_ref"
{
  if (mode != GET_MODE (op) && mode != VOIDmode)
    return 0;

  return (GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == REG
          || (GET_CODE (op) == SUBREG && GET_CODE (XEXP (op, 0)) == REG));
})

This could be simplified more, as in


if (GET_CODE (op) == SUBREG)
  return REG_P (XEXP (op, 0)) && call_operand (XEXP (op, 0), mode);
else
  return (mode == GET_MODE (op) || mode == VOIDmode);

if genpreds.c would put an additional switch statement before the user code. Well, maybe in this case it is not that much more readable (maybe the opposite is true), but in many predicates the third argument to define_predicate would be superfluous, as in

+;; Return 1 if OP refers to a symbol.
+(define_predicate "symbolic_operand" "symbol_ref,const,label_ref"
+{
+  switch (GET_CODE (op))
+    {
+    case CONST:
+    case SYMBOL_REF:
+    case LABEL_REF:
+      return 1;
+
+    default:
+      break;
+    }
+  return 0;
+})

and that argument could be made optional (defaulting to "return 1;"). Does this make sense?

Paolo


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