Ejemplo n.º 1
0
tree
streamer_get_builtin_tree (struct lto_input_block *ib, struct data_in *data_in)
{
  enum built_in_class fclass;
  enum built_in_function fcode;
  const char *asmname;
  tree result;

  fclass = streamer_read_enum (ib, built_in_class, BUILT_IN_LAST);
  gcc_assert (fclass == BUILT_IN_NORMAL || fclass == BUILT_IN_MD);

  fcode = (enum built_in_function) streamer_read_uhwi (ib);

  if (fclass == BUILT_IN_NORMAL)
    {
      if (fcode >= END_BUILTINS)
	fatal_error (input_location,
		     "machine independent builtin code out of range");
      result = builtin_decl_explicit (fcode);
      if (!result)
	{
	  if (fcode > BEGIN_CHKP_BUILTINS && fcode < END_CHKP_BUILTINS)
	    {
	      fcode = (enum built_in_function)
		      (fcode - BEGIN_CHKP_BUILTINS - 1);
	      result = builtin_decl_explicit (fcode);
	      result = chkp_maybe_clone_builtin_fndecl (result);
	    }
	  else if (fcode > BEGIN_SANITIZER_BUILTINS
		   && fcode < END_SANITIZER_BUILTINS)
	    {
	      initialize_sanitizer_builtins ();
	      result = builtin_decl_explicit (fcode);
	    }
	}
      gcc_assert (result);
    }
  else if (fclass == BUILT_IN_MD)
    {
      result = targetm.builtin_decl (fcode, true);
      if (!result || result == error_mark_node)
	fatal_error (input_location, "target specific builtin not available");
    }
  else
    gcc_unreachable ();

  asmname = streamer_read_string (data_in, ib);
  if (asmname)
    set_builtin_user_assembler_name (result, asmname);

  streamer_tree_cache_append (data_in->reader_cache, result, 0);

  return result;
}
Ejemplo n.º 2
0
/* Return no-check version of string function FNCODE.  */
static tree
chkp_get_nochk_fndecl (enum built_in_function fncode)
{
    /* Check if we are allowed to use fast string functions.  */
    if (!flag_chkp_use_nochk_string_functions)
        return NULL_TREE;

    tree fndecl = NULL_TREE;

    switch (fncode)
    {
    case BUILT_IN_MEMCPY_CHKP:
        fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMCPY_NOCHK);
        break;

    case BUILT_IN_MEMPCPY_CHKP:
        fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMPCPY_NOCHK);
        break;

    case BUILT_IN_MEMMOVE_CHKP:
        fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMMOVE_NOCHK);
        break;

    case BUILT_IN_MEMSET_CHKP:
        fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMSET_NOCHK);
        break;

    case BUILT_IN_CHKP_MEMCPY_NOBND_CHKP:
        fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMCPY_NOBND_NOCHK);
        break;

    case BUILT_IN_CHKP_MEMPCPY_NOBND_CHKP:
        fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMPCPY_NOBND_NOCHK);
        break;

    case BUILT_IN_CHKP_MEMMOVE_NOBND_CHKP:
        fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMMOVE_NOBND_NOCHK);
        break;

    case BUILT_IN_CHKP_MEMSET_NOBND_CHKP:
        fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMSET_NOBND_NOCHK);
        break;

    default:
        break;
    }

    if (fndecl)
        fndecl = chkp_maybe_clone_builtin_fndecl (fndecl);

    return fndecl;
}