Unifying asm and normal insn handling

Jeffrey A Law law@cygnus.com
Wed Oct 14 22:01:00 GMT 1998


  In message <Pine.GSO.4.02A.9810121047090.12879-100000@colt.informatik.rwth-aa
chen.de>you write:
  > 	* Makefile.in (insn-extract.o): Fix dependencies.
  > 	* genextract.c (main): Generate includes for insn-config.h and
  > 	recog.h.
  > 	Delete generation of declarations which are now in recog.h.
  > 	* genrecog.c (main): Delete generation of definitions which are
  > 	now in recog.c.
  > 	* local-alloc.c (block_alloc): Use extract_insn and the variables
  > 	it sets up instead of looking up values by insn_code.
  > 	* recog.c (recog_operand, recog_operand_loc, recog_dup_loc,
  > 	recog_dup_num): Define here instead of generating the definition in
  > 	genrecog.c.
  > 	(recog_n_operands, recog_n_dups, recog_n_alternatives,
  > 	recog_operand_mode, recog_constraints, recog_operand_address_p):
  > 	New variables.
  > 	(extract_insn): New function.
  > 	* recog.h (extract_insn): Declare function.
  > 	(which_alternative, recog_n_operands, recog_n_dups,
  > 	recog_n_alternatives, recog_operand_mode, recog_constraints,
  > 	recog_operand_address_p): Declare variables.
  > 	* regclass.c (n_occurrences): New static function.
  > 	* reload.c (n_occurrences): Delete function.
  > 	(find_reloads): Use extract_insn.
  > 	* reload.h (n_occurrences): Delete declaration.
Looks good.  You need a comment for extract_insn
 
  > +	{
  > +	  char *p;
  > +	  /* This insn is an `asm' with operands.  */
  > +
  > +	  /* expand_asm_operands makes sure there aren't too many operands.  */
  > +	  if (noperands > MAX_RECOG_OPERANDS)
  > +	    abort ();
  > +
  > +	  /* Now get the operand values and constraints out of the insn.  */
  > +	  decode_asm_operands (body, recog_operand, recog_operand_loc,
  > +			       recog_constraints, recog_operand_mode);
  > +	  if (noperands > 0)
  > +	    {
  > +	      char *p =  recog_constraints[0];
  > +	      recog_n_alternatives = 1;
  > +	      while (*p)
  > +		recog_n_alternatives += (*p++ == ',');
  > +	    }
  > +#ifndef REGISTER_CONSTRAINTS
  > +	  bzero (recog_operand_address_p, sizeof recog_operand_address_p);
  > +#endif
  > +	  break;
  > +	}

You should probably indicate explicitly that we fall through the case into
the default.  Usually we mark such things with /* FALLTHROUGH */

  > +  /* Just return "no reloads" if insn has no operands with constraints.  */
  > +  if (noperands == 0 || n_alternatives == 0)
  > +    return;
I'm not sure this is safe, believe it or not.

We force reloads for things like paradoxical SUBREGs of a MEM.

We also force reloads for certain unary operands, regardless of what the
constraints may say.

I think it's safe to return if noperands is zero, but nto if n_alternatives is
zero.

Otherwise it looks pretty good.  If you can fix up those few minor problems I
will install the patch.

Thanks!

jeff





More information about the Gcc-patches mailing list