FreeBSD/contrib/gcc/varasm.c
/* Decode an `asm' spec for a declaration as a register name.
   Return the register number, or -1 if nothing specified,
   or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized,
   or -3 if ASMSPEC is `cc' and is not recognized,
   or -4 if ASMSPEC is `memory' and is not recognized.
   Accept an exact spelling or a decimal number.
   Prefixes such as % are optional.  */
Decode an `asm' spec for a declaration as a register name.
Return the register number, or -1 if nothing specified,
or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized,
or -3 if ASMSPEC is `cc' and is not recognized,
or -4 if ASMSPEC is `memory' and is not recognized.
Accept an exact spelling or a decimal number.
Prefixes such as % are optional.
Decode an ` asm ' spec for a declaration as a register name . Return the register number or - 1 if nothing specified or - 2 if the ASMSPEC is not ` cc ' or ` memory ' and is not recognized or - 3 if ASMSPEC is ` cc ' and is not recognized or - 4 if ASMSPEC is ` memory ' and is not recognized . Accept an exact spelling or a decimal number . Prefixes such as % are optional .
int
decode_reg_name (const char *asmspec)
{
  if (asmspec != 0)
    {
      int i;
      asmspec = strip_reg_name (asmspec);
      for (i = strlen (asmspec) - 1; i >= 0; i--)
	if (! ISDIGIT (asmspec[i]))
	  break;
      if (asmspec[0] != 0 && i < 0)
	{
	  i = atoi (asmspec);
	  if (i < FIRST_PSEUDO_REGISTER && i >= 0)
	    return i;
	  else
	    return -2;
	}
      for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
	if (reg_names[i][0]
	    && ! strcmp (asmspec, strip_reg_name (reg_names[i])))
	  return i;
#ifdef ADDITIONAL_REGISTER_NAMES
      {
	static const struct { const char *const name; const int number; } table[]
	  = ADDITIONAL_REGISTER_NAMES;
	for (i = 0; i < (int) ARRAY_SIZE (table); i++)
	  if (table[i].name[0]
	      && ! strcmp (asmspec, table[i].name))
	    return table[i].number;
      }
#endif 
      if (!strcmp (asmspec, "memory"))
	return -4;
      if (!strcmp (asmspec, "cc"))
	return -3;
      return -2;
    }
  return -1;
}
int decode_reg_name ( const char * asmspec ) { if ( asmspec != 0 ) { int i ; asmspec = strip_reg_name ( asmspec ) ; for ( i = strlen ( asmspec ) - 1 ; i >= 0 ; i -- ) if ( ! ISDIGIT ( asmspec [ i ] ) ) break ; if ( asmspec [ 0 ] != 0 && i < 0 ) { i = atoi ( asmspec ) ; if ( i < FIRST_PSEUDO_REGISTER && i >= 0 ) return i ; else return -2 ; } for ( i = 0 ; i < FIRST_PSEUDO_REGISTER ; i ++ ) if ( reg_names [ i ] [ 0 ] && ! strcmp ( asmspec , strip_reg_name ( reg_names [ i ] ) ) ) return i ; #ifdef ADDITIONAL_REGISTER_NAMES { static const struct { const char * const name ; const int number ; } table [ ] = ADDITIONAL_REGISTER_NAMES ; for ( i = 0 ; i < ( int ) ARRAY_SIZE ( table ) ; i ++ ) if ( table [ i ] . name [ 0 ] && ! strcmp ( asmspec , table [ i ] . name ) ) return table [ i ] . number ; } #endif if ( ! strcmp ( asmspec , " " ) ) return -4 ; if ( ! strcmp ( asmspec , " " ) ) return -3 ; return -2 ; } return -1 ; }
Decode an `asm' spec for a declaration as a register name.
Decode an ` asm ' spec for a declaration as a register name .
/* Get rid of confusing prefixes.  */ /* Allow a decimal number as a "register name".  */ /* ADDITIONAL_REGISTER_NAMES */