1 /*******************************************************************************************
2 * Program: simd_opt_t.h
3 * Function: Part of the simd optimization. Searches match of complex operation pattern and
4 * inserts the complex operation if possible.
5 * Author: Andreas Schoesser
7 *******************************************************************************************/
10 #define __SIMD_OPT_H__
12 #include "simd_presets.h"
17 #include "iroptimize.h"
19 #include "../ir/be/benode_t.h"
25 #include <grs/action_t.h>
26 #include <grs/match_t.h>
30 struct list_head list;
36 struct list_head *nodes_stack;
37 struct pmap *pattern_nodes;
38 struct pmap *memory_preds;
44 int num_instructions_inserted;
46 int num_matched_nodes;
47 int num_replaced_nodes;
48 int *rewritten_patterns;
49 clock_t start_time, end_time;
54 struct pmap *node_map_hash;
60 struct pmap *find_memory_preds(ir_graph *irg, ir_node **match_node_map, int max_node_aiid);
61 static void find_mem_preds_pre(ir_node *n, void * env);
62 static void find_mem_preds_post(ir_node *n, void * env);
63 static ir_node *find_memory_pred(ir_node *n, int *edge_nr, int start_edge);
64 static int walk_mem_edge_alias(ir_node *orgn, ir_node *cn, struct pmap *memory_preds, struct pmap *node_map_hash, struct pmap *replaced_ptrs);
65 int test_alias_relation(ir_node **node_map, int max_node_aiid, struct pmap *memory_preds, struct pmap *replaced_ptrs);
66 struct pmap *generate_nodemap_hash(ir_node **node_map, int max_node_aiid);
68 static int find_bad_node(ir_node *n);
69 void connect_complex_memory(ext_grs_action_t *action, ext_grs_match_t *match, int which, struct pmap *mem_preds);
70 void save_complex_operation(ext_grs_action_t *action, ext_grs_match_t *match, int which, struct pmap *vec_operations, int nr);
71 void save_keep_nodes(ext_grs_action_t *action, ext_grs_match_t *match, int which, struct pmap *keep_nodes);
72 static void rename_complex_operations(struct pmap *vec_operations);
73 static void visit_mem_nodes(ir_node *node, mem_preds_info_t *mem_preds_info);
74 static void exchange_keep_nodes(struct pmap *keep_nodes);
75 int perform_rewrite(ir_graph *irg, struct pmap *vec_operations, struct pmap *keep_nodes, int start, statistics_t *statistics, struct pmap *replaced_ptrs);
76 static void view_statistics(statistics_t *statistics);
77 int analyze_arguments(ext_grs_action_t *action, ext_grs_match_t *match, int which, ir_graph *irg, struct pmap *memory_preds);
78 int search_mem_node(ir_node *n, ir_node *start, ir_graph *irg);
79 void compute_match_plans(ir_graph *irg, ext_grs_planer_t *planer, ext_grs_analyzer_t *analyzer);
80 static void walk_arg_dep(ir_node *n, void * env);
81 int ext_result_costs(ext_grs_match_t *match, int which);
82 int single_node_costs(ir_node *n);