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] insn_mnemonic insn attribute with automated generation


On 09/29/2010 04:45 AM, Andreas Krebbel wrote:
> + struct attr_hash
> + {
> +   struct attr_hash *next;
> +   int hashcode;
> +   char *str;
> + };
> + 
> + static struct obstack obstack1;
> + static struct obstack *hash_obstack = &obstack1;
> + 
> + #define STRING_HASH_SIZE 4093
> + static struct attr_hash *mnemonic_hash_table[STRING_HASH_SIZE];

Please use hashtab.c from libiberty.  That'll give you 
a nice string hash function as well. 

> +   while (*cp)
> +     {
> +       const char *ep, *sp;
> +       int size = 0;
> + 
> +       while (ISSPACE (*cp))
> + 	cp++;
> + 
> +       for (ep = sp = cp; !IS_VSPACE (*ep) && *ep != '\0'; ++ep)
> + 	if (!ISSPACE (*ep))
> + 	  sp = ep + 1;
> + 
> +       while (cp < sp && ((*cp >= '0' && *cp <= '9')
> + 			 || (*cp >= 'a' && *cp <= 'z')))
> + 
> + 	{
> + 	  obstack_1grow (&string_obstack, *cp);
> + 	  cp++;
> + 	  size++;
> + 	}

So it would appear that you're going to collect the portion of the mnemonic
that makes up a valid identifier (more or less)?

What about constructed mnemonics like "j%C"?  Do we want to return just J
or do we want to skip it?

I think it would be a Good Thing if this decision-making were done in
gensupport.c so that it would be shared between the two genprogs that
need it, rather than duplicating code as you do now.


> +       /* The insn_mnemonic attribute will be layed out later after the

Typo.

> +   /* Construct extra attribute for the insn mnemonic.  */
> +   make_insn_mnemonic_attr ();

I don't see any conditionalization, either here or inside the
function.  You're *always* generating this attribute, for all ports?


r~


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