<commit_before>#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif

#include "impl.h"
#include "irprintf.h"
#include "irgwalk.h"
#include "irnode_t.h"
#include "irgraph_t.h"
#include "iredges_t.h"
#include "debug.h"

#include "bearch.h"
#include "besched_t.h"
#include "beutil.h"
#include "belistsched.h"

FIRM_IMPL1(sched_get_time_step, int, const ir_node *)
FIRM_IMPL1(sched_has_next, int, const ir_node *)
FIRM_IMPL1(sched_has_prev, int, const ir_node *)
FIRM_IMPL1(sched_next, ir_node *, const ir_node *)
FIRM_IMPL1(sched_prev, ir_node *, const ir_node *)
FIRM_IMPL1(sched_first, ir_node *, const ir_node *)
FIRM_IMPL1(sched_last, ir_node *, const ir_node *)
FIRM_IMPL2(sched_add_after, ir_node *, ir_node *, ir_node *)
FIRM_IMPL2(sched_add_before, ir_node *, ir_node *, ir_node *)
FIRM_IMPL2(sched_comes_after, int, const ir_node *, const ir_node *)
FIRM_IMPL1_VOID(sched_remove, ir_node *)

size_t sched_irn_data_offset = 0;

static void block_sched_dumper(ir_node *block, void *env)
{
	FILE *f = env;
	const ir_node *curr;

	ir_fprintf(f, "%+F:\n", block);
	sched_foreach(block, curr) {
    sched_info_t *info = get_irn_sched_info(curr);
		ir_fprintf(f, "\t%6d: %+F\n", info->time_step, curr);
	}
}

void be_sched_dump(FILE *f, ir_graph *irg)
{
	irg_block_walk_graph(irg, block_sched_dumper, NULL, f);
}

/* Init the scheduling stuff. */
void be_sched_init(void)
{
	sched_irn_data_offset = register_additional_node_data(sizeof(sched_info_t));
}

void sched_renumber(const ir_node *block)
{
  ir_node *irn;
  sched_info_t *inf;
  sched_timestep_t step = 0;

  sched_foreach(block, irn) {
    inf = get_irn_sched_info(irn);
    inf->time_step = step;
    step += SCHED_INITIAL_GRANULARITY;
  }
}

/* Verify a schedule. */
int sched_verify(const ir_node *block)
{
  int res = 1;
  const ir_node *irn;
  int i, n;
  int *save_time_step;
  const ir_node **save_nodes;
  const ir_edge_t *edge;
  pset *scheduled_nodes = pset_new_ptr_default();
  FIRM_DBG_REGISTER(firm_dbg_module_t *dbg_sched, "firm.be.sched");

  firm_dbg_set_mask(dbg_sched, -1);

  /* Count the number of nodes in the schedule. */
  n = 0;
  sched_foreach(block, irn)
    n++;

  if(n <= 0)
    return 1;

  save_time_step = xmalloc(n * sizeof(save_time_step[0]));
  save_nodes = xmalloc(n * sizeof(save_nodes[0]));

  i = 0;
  sched_foreach(block, irn) {
    sched_info_t *info = get_irn_sched_info(irn);
    save_time_step[i] = info->time_step;
    save_nodes[i] = (ir_node *)irn;
    info->time_step = i;
    pset_insert_ptr(scheduled_nodes, irn);

    i += 1;
  }

  /*
   * Check if each relevant operand of a node is scheduled before
   * the node itself.
   */
  sched_foreach(block, irn) {
    int i, n;<commit_msg>removed explicit set for debug mask<commit_after>#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif

#include "impl.h"
#include "irprintf.h"
#include "irgwalk.h"
#include "irnode_t.h"
#include "irgraph_t.h"
#include "iredges_t.h"
#include "debug.h"

#include "bearch.h"
#include "besched_t.h"
#include "beutil.h"
#include "belistsched.h"

FIRM_IMPL1(sched_get_time_step, int, const ir_node *)
FIRM_IMPL1(sched_has_next, int, const ir_node *)
FIRM_IMPL1(sched_has_prev, int, const ir_node *)
FIRM_IMPL1(sched_next, ir_node *, const ir_node *)
FIRM_IMPL1(sched_prev, ir_node *, const ir_node *)
FIRM_IMPL1(sched_first, ir_node *, const ir_node *)
FIRM_IMPL1(sched_last, ir_node *, const ir_node *)
FIRM_IMPL2(sched_add_after, ir_node *, ir_node *, ir_node *)
FIRM_IMPL2(sched_add_before, ir_node *, ir_node *, ir_node *)
FIRM_IMPL2(sched_comes_after, int, const ir_node *, const ir_node *)
FIRM_IMPL1_VOID(sched_remove, ir_node *)

size_t sched_irn_data_offset = 0;

static void block_sched_dumper(ir_node *block, void *env)
{
	FILE *f = env;
	const ir_node *curr;

	ir_fprintf(f, "%+F:\n", block);
	sched_foreach(block, curr) {
    sched_info_t *info = get_irn_sched_info(curr);
		ir_fprintf(f, "\t%6d: %+F\n", info->time_step, curr);
	}
}

void be_sched_dump(FILE *f, ir_graph *irg)
{
	irg_block_walk_graph(irg, block_sched_dumper, NULL, f);
}

/* Init the scheduling stuff. */
void be_sched_init(void)
{
	sched_irn_data_offset = register_additional_node_data(sizeof(sched_info_t));
}

void sched_renumber(const ir_node *block)
{
  ir_node *irn;
  sched_info_t *inf;
  sched_timestep_t step = 0;

  sched_foreach(block, irn) {
    inf = get_irn_sched_info(irn);
    inf->time_step = step;
    step += SCHED_INITIAL_GRANULARITY;
  }
}

/* Verify a schedule. */
int sched_verify(const ir_node *block)
{
  int res = 1;
  const ir_node *irn;
  int i, n;
  int *save_time_step;
  const ir_node **save_nodes;
  const ir_edge_t *edge;
  pset *scheduled_nodes = pset_new_ptr_default();
  FIRM_DBG_REGISTER(firm_dbg_module_t *dbg_sched, "firm.be.sched");

  /* Count the number of nodes in the schedule. */
  n = 0;
  sched_foreach(block, irn)
    n++;

  if(n <= 0)
    return 1;

  save_time_step = xmalloc(n * sizeof(save_time_step[0]));
  save_nodes = xmalloc(n * sizeof(save_nodes[0]));

  i = 0;
  sched_foreach(block, irn) {
    sched_info_t *info = get_irn_sched_info(irn);
    save_time_step[i] = info->time_step;
    save_nodes[i] = (ir_node *)irn;
    info->time_step = i;
    pset_insert_ptr(scheduled_nodes, irn);

    i += 1;
  }

  /*
   * Check if each relevant operand of a node is scheduled before
   * the node itself.
   */
  sched_foreach(block, irn) {
    int i, n;
{'fraction_non_alphanumeric': 0.12968721419425644, 'fraction_numerical': 0.008231205414304006, 'mean_word_length': 4.75578947368421, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '6910394', 'n_tokens_mistral': 2308, 'n_tokens_neox': 2296, 'n_words': 466}