removed include
[libfirm] / ir / ir / irreflect.h
1 /**
2  * @file reflect.h
3  * @date 9.9.2004
4  * @author Sebastian Hack
5  * @brief Reflection for Firm operations.
6  *
7 <<<<<<< irreflect.h
8  * $Id$
9 =======
10  * $Id$
11 >>>>>>> 1.2
12  */
13
14 #ifndef __REFLECT_H
15 #define __REFLECT_H
16
17 #include <limits.h>
18 #include <stdbool.h>
19
20 #include "irop.h"
21 #include "irnode.h"
22
23 #define RFLCT_MC(m) rflct_ms_ ## m
24 typedef enum {
25   RFLCT_MC(None)  = 0,
26   RFLCT_MC(Mem)   = 2,
27   RFLCT_MC(Bool)  = 4,
28   RFLCT_MC(IntS)  = 8,
29   RFLCT_MC(IntU)  = 16,
30   RFLCT_MC(Float) = 32,
31   RFLCT_MC(Ref)   = 64,
32   RFLCT_MC(Char)  = 128,
33   RFLCT_MC(X)     = 256,
34   RFLCT_MC(BB)    = 512,
35   RFLCT_MC(Cf)    = RFLCT_MC(X) | RFLCT_MC(BB),
36
37   RFLCT_MC(Int) = RFLCT_MC(IntS) | RFLCT_MC(IntU),
38   RFLCT_MC(Intb) = RFLCT_MC(Int) | RFLCT_MC(Bool),
39   RFLCT_MC(Num) = RFLCT_MC(Int) | RFLCT_MC(Float),
40   RFLCT_MC(NumP) = RFLCT_MC(Num) | RFLCT_MC(Ref),
41   RFLCT_MC(Data) = RFLCT_MC(NumP) | RFLCT_MC(Char),
42   RFLCT_MC(Datab) = RFLCT_MC(Data) | RFLCT_MC(Bool),
43   RFLCT_MC(DataM) = RFLCT_MC(Data) | RFLCT_MC(Mem),
44   RFLCT_MC(DataMX) = RFLCT_MC(Data) | RFLCT_MC(Mem) | RFLCT_MC(X),
45   RFLCT_MC(Lh) = RFLCT_MC(Mem) | RFLCT_MC(BB),
46
47   RFLCT_MC(Any) = -1
48
49 } rflct_mode_class_t;
50
51 typedef struct {
52   const char *name;  /**< The name of the argument (just a description). */
53
54   bool is_variadic; /**< True, if this argument can have multiple parameters. */
55   rflct_mode_class_t accepted_modes; /**< The set of accepted modes. */
56
57   int mode_equals; /**< If not variadic: You can specify the index of
58                         another argument meaning, that the mode of the
59                         operand binding at this argument must be the same
60                         as the mode of the operand binding to the argument
61                         at index. If you don't want to express such a
62                         dependency, just give -1 here.
63
64                         If variadic: If true, the modes of all
65                         variadic operands binding to this argument
66                         must be the same. If false, they can differ. */
67 } rflct_arg_t;
68
69 #define RFLCT_ARG_IS_A(arg,modes) (((arg)->accepted_modes & modes) != 0)
70 #define RFLCT_ARG_VALID(arg) ((arg)->name != NULL)
71 #define RFLCT_SIG_VALID(sig) ((sig) != INT_MAX)
72
73 /**
74  * Get the mode class for an IR mode.
75  * @param mode An IR mode.
76  * @return The corresponding smallest reflection mode class.
77  */
78 rflct_mode_class_t rflct_get_mode_class(const ir_mode *mode);
79
80 /**
81  * Get the number of signatures for a Firm opcode.
82  * @param opc The opcode.
83  * @return The number of signatures for this opcode.
84  */
85 int rflct_get_signature_count(opcode opc);
86
87 /**
88  * Try to get the signature, that matches to a given instance
89  * of a Firm node.
90  * @param irn The node.
91  * @return The first matching signature or -1, if no signature matches.
92  */
93 int rflct_get_signature(ir_node *irn);
94
95 /**
96  * Get the number of in arguments.
97  * An in argument is a use of a value.
98  * @param opc The opcode.
99  * @param sig The signature you are refering to.
100  * @return The number of arguments.
101  */
102 int rflct_get_in_args_count(opcode opc, int sig);
103
104 /**
105  * Get the number of out arguments.
106  * An out argument is a def of a value.
107  * @param opc The opcode.
108  * @param sig The signature you are refering to.
109  * @return The number of arguments.
110  */
111 int rflct_get_out_args_count(opcode opc, int sig);
112
113 /**
114  * Get the array of use args.
115  * The array is terminated with an entry for which
116  * <code>RFLCT_ARG_VALID</code> is 0.
117  * @param opc The opcode.
118  * @param sig The signature you are referring to (Must be between
119  * 0 and the signature count).
120  * @return The array.
121  */
122 const rflct_arg_t *rflct_get_in_args(opcode opc, int sig);
123
124 /**
125  * Get the array of def args.
126  * The array is terminated with an entry for which
127  * <code>RFLCT_ARG_VALID</code> is 0.
128  * @param opc The opcode.
129  * @param sig The signature you are referring to (Must be between
130  * 0 and the signature count).
131  * @return The array.
132  */
133 const rflct_arg_t *rflct_get_out_args(opcode opc, int sig);
134
135 /**
136  * Make a string representation of a signature of an opcode.
137  * @param buf The buffer to put the string to.
138  * @param n The size of buf.
139  * @param opc The opcode.
140  * @param sig The signature.
141  * @return buf.
142  */
143 char *rflct_to_string(char *buf, int n, opcode opc, int sig);
144
145 /**
146  * Get a string representation of a mode class.
147  * @param str The buffer to put the string to.
148  * @param n The size of the buffer.
149  * @param mc The mode class.
150  * @return str.
151  */
152 char *rflct_mode_class_name(char *str, int n, rflct_mode_class_t mc);
153
154 #endif