moved firmext code into the backend dir
[libfirm] / ir / be / grgen / matchplan_t.h
1 #ifndef _EXT_GRS_MATCHPLAN_T_H_
2 #define _EXT_GRS_MATCHPLAN_T_H_
3
4 /*
5  * Project:     libFIRM/extension module/GRS-matcher
6  * File name:   ext/grs/plan_t.h
7  * Purpose:     provides an interface for search planers planing
8  *                              the matching process with respect to information
9  *                              provided by appropriate analyzers
10  * Author:      Veit Batz
11  * Created:             7. July 2005
12  * CVS-ID:      $Id$
13  * Copyright:   (c) 2005 Universität Karlsruhe
14  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
15  */
16
17 #include "action_t.h"
18 #include "analyze_t.h"
19 #include "matchplan.h"
20
21 typedef enum {
22         ext_grs_k_mop_node,
23         ext_grs_k_mop_edge,
24         ext_grs_k_mop_condition,
25         ext_grs_k_mop_preset,
26         ext_grs_k_mop_preset_edge
27 } ext_grs_mop_kind_t;
28
29 typedef struct {
30         /** tells wether this op matches a node or an edge */
31         ext_grs_mop_kind_t kind;
32         /** if this match op matches an edge, then this is the respective pattern edge */
33         ext_grs_edge_t *edge;
34         /** if this match op matches a node, then this is the respective pattern node,
35          * if this op matches an edge, then this node is the pattern node where the
36          * edge is retrieved from */
37         ext_grs_node_t *node;
38         /** a condition to be checked by this matching op */
39         ext_grs_condition_func_t condition;
40         /** an op condition to be checked by this matching op (for node-ops only) */
41         ext_grs_op_condition_func_t op_condition;
42         /** a mode condition to be checked by this matching op (for node-ops only) */
43         ext_grs_mode_condition_func_t mode_condition;
44 } ext_grs_match_op_t;
45
46 /** a plan the matching process will follow */
47 struct _ext_grs_match_plan_t {
48         /** the action this matching plan belongs to */
49         ext_grs_action_t *action;
50         /** the number of matching ops of this search plan */
51         /*int length;*/
52         int num_progs;
53         int *length;
54         /** a sequence (array) of match ops (i.e. the matching 'program') */
55         /* Contains pointers to all search plans (positive and negative) */
56         ext_grs_match_op_t **progs;
57         /* Just for "backward compatibility:
58            Contains pointer to the positive search plan */
59         ext_grs_match_op_t *prog;
60 };
61
62 /** a planer fir the creation of matching plans */
63 struct _ext_grs_planer_t {
64         /** a tag identifying a planer */
65         const char *tag;
66         /** this planers analyzer  */
67         ext_grs_analyzer_t *analyzer;
68
69         /** initialize this planer */
70         void (*init) (struct _ext_grs_planer_t *, ext_grs_analyzer_t *);
71         /** compute a match plan according to analysis data of a given  ir graph */
72         ext_grs_match_plan_t * (*compute_plan)
73                 (struct _ext_grs_planer_t *, ir_graph *, ext_grs_action_t *);
74         /** compute a match plan according to analysis data of all ir graphs */
75         ext_grs_match_plan_t * (*ext_grs_compute_plan_global)
76                 (struct _ext_grs_planer_t *, ext_grs_action_t *);
77
78         /** this planers private data area */
79         void *data;
80 };
81
82
83
84 #endif /*_EXT_GRS_MATCHPLAN_T_H_*/