moved firmext code into the backend dir
[libfirm] / ir / be / grgen / simd / simd_opt_t.h
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
6 * Date:     05.02.2007
7 *******************************************************************************************/
8
9 #ifndef __SIMD_OPT_H__
10 #define __SIMD_OPT_H__
11
12 #include "simd_presets.h"
13 #include "simd_opt.h"
14
15 #include "pmap.h"
16 #include "irdump.h"
17 #include "iroptimize.h"
18 #include "irgmod.h"
19 #include "../ir/be/benode_t.h"
20
21 #include "grs/grs.h"
22
23
24 #include <time.h>
25 #include <grs/action_t.h>
26 #include <grs/match_t.h>
27
28 typedef struct
29 {
30         struct list_head list;
31         ir_node *node;
32 } nodes_stack_t;
33
34 typedef struct
35 {
36         struct list_head *nodes_stack;
37         struct pmap              *pattern_nodes;
38         struct pmap              *memory_preds;
39         ir_graph                 *irg;
40 } mem_preds_info_t;
41
42 typedef struct
43 {
44         int             num_instructions_inserted;
45         int     num_matches;
46         int     num_matched_nodes;
47         int     num_replaced_nodes;
48         int             *rewritten_patterns;
49         clock_t start_time, end_time;
50 } statistics_t;
51
52 typedef struct
53 {
54         struct pmap *node_map_hash;
55         int                     found_dependency;
56 } argdep_ana_info_t;
57
58
59
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);
67
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);
83
84 #endif