bool
lto_output_decl_index (struct lto_output_stream *obs,
		       struct lto_tree_ref_encoder *encoder,
		       tree name, unsigned int *this_index)
{
  unsigned *slot;
  unsigned int index;
  bool new_entry_p = FALSE;
  bool existed_p;

  slot = encoder->tree_hash_table->insert (name, &existed_p);
  if (!existed_p)
    {
      index = encoder->trees.length ();
      *slot = index;
      encoder->trees.safe_push (name);
      new_entry_p = TRUE;
    }
  else
    index = *slot;

  if (obs)
    streamer_write_uhwi_stream (obs, index);
  *this_index = index;
  return new_entry_p;
}
Exemplo n.º 2
0
bool
lto_output_decl_index (struct lto_output_stream *obs,
		       struct lto_tree_ref_encoder *encoder,
		       tree name, unsigned int *this_index)
{
  void **slot;
  struct lto_decl_slot d_slot;
  int index;
  bool new_entry_p = FALSE;

  d_slot.t = name;
  slot = htab_find_slot (encoder->tree_hash_table, &d_slot, INSERT);
  if (*slot == NULL)
    {
      struct lto_decl_slot *new_slot
	= (struct lto_decl_slot *) xmalloc (sizeof (struct lto_decl_slot));
      index = encoder->next_index++;

      new_slot->t = name;
      new_slot->slot_num = index;
      *slot = new_slot;
      VEC_safe_push (tree, heap, encoder->trees, name);
      new_entry_p = TRUE;
    }
  else
    {
      struct lto_decl_slot *old_slot = (struct lto_decl_slot *)*slot;
      index = old_slot->slot_num;
    }

  if (obs)
    streamer_write_uhwi_stream (obs, index);
  *this_index = index;
  return new_entry_p;
}