moved firmext code into the backend dir
[libfirm] / ir / be / grgen / simd / create_pattern_t.h
1 /*************************************************************************
2 * Program:  create_pattern_t.h
3 * Function: Extracts nodes to be dumped as search pattern out of the
4 *                       the initial pattern
5 * Author:   Andreas Schoesser
6 * Date:     2006-12-07
7 *************************************************************************/
8
9 #ifndef CREATE_PATTERN_T_H
10 #define CREATE_PATTERN_T_H
11
12 #include "irgraph.h"
13
14 // * This struct contains information that was collected during the pattern
15 // * analysis.
16 typedef struct
17 {
18         ir_graph *irg;                                  // The irg that was analysed
19         struct pmap *nodes_to_dump;             // Contains all nodes which have to be dumped to create the pattern
20         struct pmap *register_access;   // Contains additional information for nodes which represent a register access
21         struct pmap *memory_access;             // Contains additional information for nodes which represent a memory access
22         struct pmap *argument_nodes;    // Contains additional information for nodes which represent an arument for the complex operatione
23         struct pmap *destroyed_regs;     // Contains an entry for each extra register a complex operation destroys (except the target register which is clear to be destroyed)
24         struct obstack *obst;                   // Memory allocated during analysis, will be killed after analysis is finished
25         int num_simd_arguments;         // Number of arguments the complex operation will have
26         ir_node *complex_operation_block, // Used to match the block the complex operation will be placed in
27                         *node_to_match_block;     // Currently, only one pattern node's block is matched
28         char *emit_statement;                   // String that describes the assembly emit statement
29         int  has_result;                // Is set to 1 if the complex operation has a result
30         int  variant_nr;
31         int  priority;
32         int  cost_savings;
33         int  dump_everything;
34 } graph_ana_info_t;
35
36
37 // * Additional information for nodes which represent a register access
38 typedef struct
39 {
40         int load_store;                         // REGISTER_STORE or REGISTER_LOAD
41         int array_index;                        // The vector component of that access
42         char *replace_node_name;        // The node name of the VProj that replaces the node that generates the result (Register STORE)
43         ir_node *pointer_base;      // Represents the complex operation in case of a register LOAD
44 } register_access_descr_t;
45
46
47 // * Additional information for nodes which represent a memory access
48 typedef struct
49 {
50         int load_store;                         // MEMORY_STORE or MEMORY_LOAD
51         int array_index;                        // The vector component of that access
52         ir_node *projm;                         // Represents the projm node in case of a memory store
53 } memory_access_descr_t;
54
55
56 typedef enum
57 {
58         ARGUMENT_SIMD_REGISTER = 0,
59         ARGUMENT_GP_REGISTER,
60         ARGUMENT_MEMORY,
61         ARGUMENT_RESULT
62 } argument_location_t;
63
64 typedef enum
65 {
66         ARGUMENT_SCALAR = 0,
67         ARGUMENT_VECTOR
68 } argument_type_t;
69
70
71
72 // * Additional information for nodes which represent an argument for the complex operation
73 typedef struct
74 {
75         argument_location_t argument_location;      // ARGUMENT_SIMD_REGISTER or MEMORY
76         argument_type_t     argument_type;          // VECTOR or SCALAR
77     int arg_nr;                                                         // The argument number, this node will be for the complex operation
78         char *register_class;                                       // The register class used for the backend specification
79         ir_node *vec_op_input;                      // This is important for variants:
80                                                                                                 // Points to the node that computes the vector address inside a
81                                                                                                 // (multi dim) array.
82 } argument_descr_t;
83
84
85 // Internal prototypes
86
87 static ir_node *search_call(ir_node *start_node, unsigned int *array_index, ir_node **add, ir_node **pointer_root);
88 static int is_memory_access(ir_node *call);
89 void search_emit_statement(ir_node *call_node, graph_ana_info_t *walker_info);
90 static void mark_argument_node(graph_ana_info_t *walker_info, ir_node *call_node, ir_node *argument_node, ir_node *add_node);
91 void get_operation_name(const char *irg_name, char *operation_name);
92 void get_firmnode_name(const char *irg_name, char *firmnode_name);
93 void analyze_complex_operation_block(ir_node *n, graph_ana_info_t *walker_info);
94 int get_SymConst_strlen(ir_node *symC);
95 void get_SymConst_string(ir_node *symC, char *string);
96 static void walk_pre(ir_node *n, void * env);
97 static void walk_post(ir_node *n, void * env);
98 static int is_vector(ir_node *call);
99 int add_address_variant(graph_ana_info_t *walker_info);
100 void get_rule_name(graph_ana_info_t *walker_info, char *rule_name);
101 void mark_node_for_dumping(ir_node *n, graph_ana_info_t *walker_info);
102 static void run_grgen();
103
104 #endif