<commit_before>/*
 * Project:     libFIRM
 * File name:   ir/ir/irnode.c
 * Purpose:     Representation of an intermediate operation.
 * Author:      <NAME>, <NAME>
 * Modified by: <NAME>
 * Created:
 * CVS-ID:      $Id$
 * Copyright:   (c) 1998-2003 Universitt Karlsruhe
 * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
 */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <string.h>

#include "ident.h"
#include "irnode_t.h"
#include "irgraph_t.h"
#include "irmode_t.h"
#include "typegmod.h"
#include "array.h"
#include "irbackedge_t.h"
#include "irdump.h"
#include "irflag_t.h"
#include "irop_t.h"

#include "irprog_t.h"

/* some constants fixing the positions of nodes predecessors
   in the in array */
#define CALL_PARAM_OFFSET 2
#define SEL_INDEX_OFFSET 2
#define RETURN_RESULT_OFFSET 1  /* mem is not a result */
#define END_KEEPALIVE_OFFSET 0

/* Declarations for inlineing */
INLINE ir_node ** get_irn_in (const ir_node *node);
INLINE ir_mode *get_irn_mode (const ir_node *node);
INLINE ir_op *get_irn_op (const ir_node *node);
INLINE opcode get_irn_opcode (const ir_node *node);
INLINE ident *get_irn_opident (const ir_node *node);
INLINE type *get_SymConst_type (ir_node *node);
INLINE ir_node *skip_nop (ir_node *node);
INLINE int is_Proj (const ir_node *node);


static const char *pnc_name_arr [] = {
  "False", "Eq", "Lt", "Le",
  "Gt", "Ge", "Lg", "Leg", "Uo",
  "Ue", "Ul", "Ule", "Ug", "Uge",
  "Ne", "True"
};

INLINE const char *get_pnc_string(int pnc) {
  return pnc_name_arr[pnc];
}


int
get_negated_pnc(int pnc) {
  switch (pnc) {
  case False: return True;  break;
  case Eq:    return Ne;    break;
  case Lt:    return Uge;   break;
  case Le:    return Ug;    break;
  case Gt:    return Ule;   break;
  case Ge:    return Ul;    break;
  case Lg:    return Ue;    break;
  case Leg:   return Uo;    break;
  case Uo:    return Leg;   break;
  case Ue:    return Lg;    break;
  case Ul:    return Ge;    break;
  case Ule:   return Gt;    break;
  case Ug:    return Le;    break;
  case Uge:   return Lt;    break;
  case Ne:    return Eq;    break;
  case True:  return False; break;
  }
  return 99; /* to shut up gcc */
}

const char *pns_name_arr [] = {
  "initial_exec", "global_store",
  "frame_base", "globals", "args"
};

const char *symconst_name_arr [] = {
  "type_tag", "size", "linkage_ptr_info"
};

void
init_irnode (void)
{
}

/*
 * irnode constructor.
 * Create a new irnode in irg, with an op, mode, arity and
 * some incoming irnodes.
 * If arity is negative, a node with a dynamic array is created.
 */
INLINE ir_node *
new_ir_node (dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op, ir_mode *mode,
	     int arity, ir_node **in)
{
  ir_node *res;
  int node_size = offsetof (ir_node, attr) +  op->attr_size;

  res = (ir_node *) obstack_alloc (irg->obst, node_size);

  res->kind = k_ir_node;
  res->op = op;
  res->mode = mode;
  res->visited = 0;
  res->link = NULL;
  if (arity < 0) {
    res->in = NEW_ARR_F (ir_node *, 1);  /* 1: space for block */
  } else {
    res->in = NEW_ARR_D (ir_node *, irg->obst, (arity+1));
    memcpy (&res->in[1], in, sizeof (ir_node *) * arity);
  }
  res->in[0] = block;
  set_irn_dbg_info(res, db);
  res->out = NULL;

#ifdef DEBUG_libfirm
  res->node_nr = get_irp_new_node_nr();
#endif

  return res;
}

/* Copies all attributes stored in the old node to the new node.
   Assumes both have the same opcode and sufficient size. */
void
copy_attrs (const ir_node *old_node, ir_node *new_node) {
  assert(get_irn_op(old_node) == get_irn_op(new_node));
  memcpy(&new_node->attr, &old_node->attr, get_op_attr_size(get_irn_op(old_node)));
}

/** getting some parameters from ir_nodes **/

int
is_ir_node (const void *thing) {
  assert(thing);
  if (get_kind(thing) == k_ir_node)
    return 1;
  else
    return 0;
}

/* returns the number of predecessors without the block predecessor. */
INLINE int
get_irn_intra_arity (const ir_node *node) {
  assert(node);
  return ARR_LEN(node->in) - 1;
}

/* returns the number of predecessors without the block predecessor. */
INLINE int
get_irn_inter_arity (const ir_node *node) {
  assert(node);
  if (get_irn_opcode(node) == iro_Filter) {
    assert(node->attr.filter.in_cg);
    return ARR_LEN(node->attr.filter.in_cg) - 1;
  } else if (get_irn_opcode(node) == iro_Block && node->attr.block.in_cg) {
    return ARR_LEN(node->attr.block.in_cg) - 1;
  }
  return get_irn_intra_arity(node);
}

/* returns the number of predecessors without the block predecessor. */
INLINE int
get_irn_arity (const ir_node *node) {
  assert(node);
  if (interprocedural_view) return get_irn_inter_arity(node);
  return get_irn_intra_arity(node);
}

/* Returns the array with ins. This array is shifted with respect to the
   array accessed by get_irn_n: The block operand is at position 0 not -1.
   (@@@ This should be changed.)
   The order of the predecessors in this array is not guaranteed, except that
   lists of operands as predecessors of Block or arguments of a Call are
   consecutive. */
INLINE ir_node **
get_irn_in (const ir_node *node) {
  assert(node);
  if (interprocedural_view) { /* handle Filter and Block specially */
    if (get_irn_opcode(node) == iro_Filter) {
      assert(node->attr.filter.in_cg);
      return node->attr.filter.in_cg;
    } else if (get_irn_opcode(node) == iro_Block && node->attr.block.in_cg) {
      return node->attr.block.in_cg;
    }
    /* else fall through */
  }
  return node->in;
}

INLINE void
set_irn_in (ir_node *node, int arity, ir_node **in) {
  ir_node *** arr;
  assert(node);
  if (interprocedural_view) { /* handle Filter and Block specially */
    if (get_irn_opcode(node) == iro_Filter) {
      assert(node->attr.filter.in_cg);
      arr = &node->attr.filter.in_cg;
    } else if (get_irn_opcode(node) == iro_Block && node->attr.block.in_cg) {
      arr = &node->attr.block.in_cg;
    } else {
      arr = &node->in;
    }
  } else {
    arr = &node->in;
  }
  if (arity != ARR_LEN(*arr) - 1) {
    ir_node * block = (*arr)[0];
    *arr = NEW_ARR_D(ir_node *, current_ir_graph->obst, arity + 1);
    (*arr)[0] = block;
  }
  fix_backedges(current_ir_graph->obst, node);
  memcpy((*arr) + 1, in, sizeof(ir_node *) * arity);
}

INLINE ir_node *
get_irn_intra_n (ir_node *node, int n) {
  return (node->in[n + 1] = skip_nop(node->in[n + 1]));
}

INLINE ir_node*
get_irn_inter_n (ir_node *node, int n) {
  /* handle Filter and Block specially */
  if (get_irn_opcode(node) == iro_Filter) {
    assert(node->attr.filter.in_cg);
    return (node->attr.filter.in_cg[n + 1] = skip_nop(node->attr.filter.in_cg[n + 1]));
  } else if (get_irn_opcode(node) == iro_Block && node->attr.block.in_cg) {
    return (node->attr.block.in_cg[n + 1] = skip_nop(node->attr.block.in_cg[n + 1]));
  }

  return get_irn_intra_n (node, n);
}

/* to iterate through the predecessors without touching the array */
/* To iterate over the operands iterate from 0 to i < get_irn_arity(),
   to iterate including the Block predecessor iterate from i = -1 to
   i < get_irn_arity.
   If it is a block, the entry -1 is NULL. */
INLINE ir_node *
get_irn_n (ir_node *node, int n) {
  assert(node); assert(-1 <= n && n < get_irn_arity(node));
  if (interprocedural_view)  return get_irn_inter_n (node, n);
  return get_irn_intra_n (node, n);
}


INLINE void
set_irn_n (ir_node *node, int n, ir_node *in) {
  assert(node && -1 <= n && n < get_irn_arity(node));
  if ((n == -1) && (get_irn_opcode(node) == iro_Filter)) {
    /* Change block pred in both views! */
    node->in[n + 1] = in;
    assert(node->attr.filter.in_cg);
    node->attr.filter.in_cg[n + 1] = in;
    return;
  }
  if (interprocedural_view) { /* handle Filter and Block specially */
    if (get_irn_opcode(node) == iro_Filter) {
      assert(node->attr.filter.in_cg);
      node->attr.filter.in_cg[n + 1] = in;
      return;
    } else if (get_irn_opcode(node) == iro_Block && node->attr.block.in_cg) {
      node->attr.block.in_cg[n + 1] = in;
      return;
    }
    /* else fall through */
  }
  node->in[n + 1] = in;
}

INLINE ir_mode *
get_irn_mode (const ir_node *node)
{
  assert (node);
  return node->mode;
}

INLINE void
set_irn_mode (ir_node *node, ir_mode *mode)
{
  assert (node);
  node->mode=mode;
  return;
}

INLINE modecode
get_irn_modecode (const ir_node *node)
{
  assert (node);
  return node->mode->code;
}

/** Gets the string representation of the mode .*/
INLINE const char *
get_irn_modename (const ir_node *node)
{
  assert(node);
  return get_mode_name(node->mode);
}

INLINE ident *
get_irn_modeident (const ir_node *node)
{
  assert(node);
  return get_mode_ident(node->mode);
}

INLINE ir_op *
get_irn_op (const ir_node *node)
{
  assert (node);
  return node->op;
}

/* should be private to the library: */
INLINE void
set_irn_op (ir_node *node, ir_op *op)
{
  assert (node);
  node->op = op;
}

INLINE opcode
get_irn_opcode (const ir_node *node)
{
  assert (node);
  assert (k_ir_node == get_kind(node));
  assert (node -> op);
  return node->op->code;
}

INLINE const char *
get_irn_opname (const ir_node *node)
{
  assert(node);
  return get_id_str(node->op->name);
}

INLINE ident *
get_irn_opident (const ir_node *node)
{
  assert(node);
  return node->op->name;
}
<commit_msg>Some doxygen commnets removed some unneded assert's<commit_after>/*
 * Project:     libFIRM
 * File name:   ir/ir/irnode.c
 * Purpose:     Representation of an intermediate operation.
 * Author:      <NAME>, <NAME>
 * Modified by: <NAME>
 * Created:
 * CVS-ID:      $Id$
 * Copyright:   (c) 1998-2003 Universitt Karlsruhe
 * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
 */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <string.h>

#include "ident.h"
#include "irnode_t.h"
#include "irgraph_t.h"
#include "irmode_t.h"
#include "typegmod.h"
#include "array.h"
#include "irbackedge_t.h"
#include "irdump.h"
#include "irflag_t.h"
#include "irop_t.h"

#include "irprog_t.h"

/* some constants fixing the positions of nodes predecessors
   in the in array */
#define CALL_PARAM_OFFSET 2
#define SEL_INDEX_OFFSET 2
#define RETURN_RESULT_OFFSET 1  /* mem is not a result */
#define END_KEEPALIVE_OFFSET 0

/* Declarations for inlineing */
INLINE ir_node ** get_irn_in (const ir_node *node);
INLINE ir_mode *get_irn_mode (const ir_node *node);
INLINE ir_op *get_irn_op (const ir_node *node);
INLINE opcode get_irn_opcode (const ir_node *node);
INLINE ident *get_irn_opident (const ir_node *node);
INLINE type *get_SymConst_type (ir_node *node);
INLINE ir_node *skip_nop (ir_node *node);
INLINE int is_Proj (const ir_node *node);


static const char *pnc_name_arr [] = {
  "False", "Eq", "Lt", "Le",
  "Gt", "Ge", "Lg", "Leg", "Uo",
  "Ue", "Ul", "Ule", "Ug", "Uge",
  "Ne", "True"
};

/**
 * returns the pnc name from an pnc constant
 */
INLINE const char *get_pnc_string(int pnc) {
  return pnc_name_arr[pnc];
}

/**
 * Calculates the negated pnc condition.
 */
int
get_negated_pnc(int pnc) {
  switch (pnc) {
  case False: return True;  break;
  case Eq:    return Ne;    break;
  case Lt:    return Uge;   break;
  case Le:    return Ug;    break;
  case Gt:    return Ule;   break;
  case Ge:    return Ul;    break;
  case Lg:    return Ue;    break;
  case Leg:   return Uo;    break;
  case Uo:    return Leg;   break;
  case Ue:    return Lg;    break;
  case Ul:    return Ge;    break;
  case Ule:   return Gt;    break;
  case Ug:    return Le;    break;
  case Uge:   return Lt;    break;
  case Ne:    return Eq;    break;
  case True:  return False; break;
  }
  return 99; /* to shut up gcc */
}

const char *pns_name_arr [] = {
  "initial_exec", "global_store",
  "frame_base", "globals", "args"
};

const char *symconst_name_arr [] = {
  "type_tag", "size", "linkage_ptr_info"
};

void
init_irnode (void)
{
}

/*
 * irnode constructor.
 * Create a new irnode in irg, with an op, mode, arity and
 * some incoming irnodes.
 * If arity is negative, a node with a dynamic array is created.
 */
INLINE ir_node *
new_ir_node (dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op, ir_mode *mode,
	     int arity, ir_node **in)
{
  ir_node *res;
  int node_size = offsetof (ir_node, attr) +  op->attr_size;

  res = (ir_node *) obstack_alloc (irg->obst, node_size);

  res->kind = k_ir_node;
  res->op = op;
  res->mode = mode;
  res->visited = 0;
  res->link = NULL;
  if (arity < 0) {
    res->in = NEW_ARR_F (ir_node *, 1);  /* 1: space for block */
  } else {
    res->in = NEW_ARR_D (ir_node *, irg->obst, (arity+1));
    memcpy (&res->in[1], in, sizeof (ir_node *) * arity);
  }
  res->in[0] = block;
  set_irn_dbg_info(res, db);
  res->out = NULL;

#ifdef DEBUG_libfirm
  res->node_nr = get_irp_new_node_nr();
#endif

  return res;
}

/* Copies all attributes stored in the old node to the new node.
   Assumes both have the same opcode and sufficient size. */
void
copy_attrs (const ir_node *old_node, ir_node *new_node) {
  assert(get_irn_op(old_node) == get_irn_op(new_node));
  memcpy(&new_node->attr, &old_node->attr, get_op_attr_size(get_irn_op(old_node)));
}

/** getting some parameters from ir_nodes **/

int
is_ir_node (const void *thing) {
  if (get_kind(thing) == k_ir_node)
    return 1;
  else
    return 0;
}

/* returns the number of predecessors without the block predecessor. */
INLINE int
get_irn_intra_arity (const ir_node *node) {
  assert(node);
  return ARR_LEN(node->in) - 1;
}

/* returns the number of predecessors without the block predecessor. */
INLINE int
get_irn_inter_arity (const ir_node *node) {
  assert(node);
  if (get_irn_opcode(node) == iro_Filter) {
    assert(node->attr.filter.in_cg);
    return ARR_LEN(node->attr.filter.in_cg) - 1;
  } else if (get_irn_opcode(node) == iro_Block && node->attr.block.in_cg) {
    return ARR_LEN(node->attr.block.in_cg) - 1;
  }
  return get_irn_intra_arity(node);
}

/* returns the number of predecessors without the block predecessor. */
INLINE int
get_irn_arity (const ir_node *node) {
  assert(node);
  if (interprocedural_view) return get_irn_inter_arity(node);
  return get_irn_intra_arity(node);
}

/* Returns the array with ins. This array is shifted with respect to the
   array accessed by get_irn_n: The block operand is at position 0 not -1.
   (@@@ This should be changed.)
   The order of the predecessors in this array is not guaranteed, except that
   lists of operands as predecessors of Block or arguments of a Call are
   consecutive. */
INLINE ir_node **
get_irn_in (const ir_node *node) {
  assert(node);
  if (interprocedural_view) { /* handle Filter and Block specially */
    if (get_irn_opcode(node) == iro_Filter) {
      assert(node->attr.filter.in_cg);
      return node->attr.filter.in_cg;
    } else if (get_irn_opcode(node) == iro_Block && node->attr.block.in_cg) {
      return node->attr.block.in_cg;
    }
    /* else fall through */
  }
  return node->in;
}

INLINE void
set_irn_in (ir_node *node, int arity, ir_node **in) {
  ir_node *** arr;
  assert(node);
  if (interprocedural_view) { /* handle Filter and Block specially */
    if (get_irn_opcode(node) == iro_Filter) {
      assert(node->attr.filter.in_cg);
      arr = &node->attr.filter.in_cg;
    } else if (get_irn_opcode(node) == iro_Block && node->attr.block.in_cg) {
      arr = &node->attr.block.in_cg;
    } else {
      arr = &node->in;
    }
  } else {
    arr = &node->in;
  }
  if (arity != ARR_LEN(*arr) - 1) {
    ir_node * block = (*arr)[0];
    *arr = NEW_ARR_D(ir_node *, current_ir_graph->obst, arity + 1);
    (*arr)[0] = block;
  }
  fix_backedges(current_ir_graph->obst, node);
  memcpy((*arr) + 1, in, sizeof(ir_node *) * arity);
}

INLINE ir_node *
get_irn_intra_n (ir_node *node, int n) {
  return (node->in[n + 1] = skip_nop(node->in[n + 1]));
}

INLINE ir_node*
get_irn_inter_n (ir_node *node, int n) {
  /* handle Filter and Block specially */
  if (get_irn_opcode(node) == iro_Filter) {
    assert(node->attr.filter.in_cg);
    return (node->attr.filter.in_cg[n + 1] = skip_nop(node->attr.filter.in_cg[n + 1]));
  } else if (get_irn_opcode(node) == iro_Block && node->attr.block.in_cg) {
    return (node->attr.block.in_cg[n + 1] = skip_nop(node->attr.block.in_cg[n + 1]));
  }

  return get_irn_intra_n (node, n);
}

/* to iterate through the predecessors without touching the array */
/* To iterate over the operands iterate from 0 to i < get_irn_arity(),
   to iterate including the Block predecessor iterate from i = -1 to
   i < get_irn_arity.
   If it is a block, the entry -1 is NULL. */
INLINE ir_node *
get_irn_n (ir_node *node, int n) {
  assert(node); assert(-1 <= n && n < get_irn_arity(node));
  if (interprocedural_view)  return get_irn_inter_n (node, n);
  return get_irn_intra_n (node, n);
}


INLINE void
set_irn_n (ir_node *node, int n, ir_node *in) {
  assert(node && -1 <= n && n < get_irn_arity(node));
  if ((n == -1) && (get_irn_opcode(node) == iro_Filter)) {
    /* Change block pred in both views! */
    node->in[n + 1] = in;
    assert(node->attr.filter.in_cg);
    node->attr.filter.in_cg[n + 1] = in;
    return;
  }
  if (interprocedural_view) { /* handle Filter and Block specially */
    if (get_irn_opcode(node) == iro_Filter) {
      assert(node->attr.filter.in_cg);
      node->attr.filter.in_cg[n + 1] = in;
      return;
    } else if (get_irn_opcode(node) == iro_Block && node->attr.block.in_cg) {
      node->attr.block.in_cg[n + 1] = in;
      return;
    }
    /* else fall through */
  }
  node->in[n + 1] = in;
}

INLINE ir_mode *
get_irn_mode (const ir_node *node)
{
  assert (node);
  return node->mode;
}

INLINE void
set_irn_mode (ir_node *node, ir_mode *mode)
{
  assert (node);
  node->mode=mode;
  return;
}

INLINE modecode
get_irn_modecode (const ir_node *node)
{
  assert (node);
  return node->mode->code;
}

/** Gets the string representation of the mode .*/
INLINE const char *
get_irn_modename (const ir_node *node)
{
  assert(node);
  return get_mode_name(node->mode);
}

INLINE ident *
get_irn_modeident (const ir_node *node)
{
  assert(node);
  return get_mode_ident(node->mode);
}

INLINE ir_op *
get_irn_op (const ir_node *node)
{
  assert (node);
  return node->op;
}

/* should be private to the library: */
INLINE void
set_irn_op (ir_node *node, ir_op *op)
{
  assert (node);
  node->op = op;
}

INLINE opcode
get_irn_opcode (const ir_node *node)
{
  assert (k_ir_node == get_kind(node));
  assert (node -> op);
  return node->op->code;
}

INLINE const char *
get_irn_opname (const ir_node *node)
{
  assert(node);
  return get_id_str(node->op->name);
}

INLINE ident *
get_irn_opident (const ir_node *node)
{
  assert(node);
  return node->op->name;
}

{'fraction_non_alphanumeric': 0.13876805756941088, 'fraction_numerical': 0.005370280865689275, 'mean_word_length': 3.5210002427773732, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 143, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7608919', 'n_tokens_mistral': 7351, 'n_tokens_neox': 7149, 'n_words': 1918}