4 * @author Sebastian Hack
5 * @brief Reflection for Firm operations.
19 #define RFLCT_MC(m) rflct_ms_ ## m
31 RFLCT_MC(Cf) = RFLCT_MC(X) | RFLCT_MC(BB),
33 RFLCT_MC(Int) = RFLCT_MC(IntS) | RFLCT_MC(IntU),
34 RFLCT_MC(Intb) = RFLCT_MC(Int) | RFLCT_MC(Bool),
35 RFLCT_MC(Num) = RFLCT_MC(Int) | RFLCT_MC(Float),
36 RFLCT_MC(NumP) = RFLCT_MC(Num) | RFLCT_MC(Ref),
37 RFLCT_MC(Data) = RFLCT_MC(NumP) | RFLCT_MC(Char),
38 RFLCT_MC(Datab) = RFLCT_MC(Data) | RFLCT_MC(Bool),
39 RFLCT_MC(DataM) = RFLCT_MC(Data) | RFLCT_MC(Mem),
40 RFLCT_MC(DataMX) = RFLCT_MC(Data) | RFLCT_MC(Mem) | RFLCT_MC(X),
41 RFLCT_MC(Lh) = RFLCT_MC(Mem) | RFLCT_MC(BB),
48 const char *name; /**< The name of the argument (just a description). */
50 bool is_variadic; /**< True, if this argument can have multiple parameters. */
51 rflct_mode_class_t accepted_modes; /**< The set of accepted modes. */
53 int mode_equals; /**< If not variadic: You can specify the index of
54 another argument meaning, that the mode of the
55 operand binding at this argument must be the same
56 as the mode of the operand binding to the argument
57 at index. If you don't want to express such a
58 dependency, just give -1 here.
60 If variadic: If true, the modes of all
61 variadic operands binding to this argument
62 must be the same. If false, they can differ. */
65 #define RFLCT_ARG_IS_A(arg,modes) (((arg)->accepted_modes & modes) != 0)
66 #define RFLCT_ARG_VALID(arg) ((arg)->name != NULL)
67 #define RFLCT_SIG_VALID(sig) ((sig) != INT_MAX)
70 * Get the mode class for an IR mode.
71 * @param mode An IR mode.
72 * @return The corresponding smallest reflection mode class.
74 rflct_mode_class_t rflct_get_mode_class(const ir_mode *mode);
77 * Get the number of signatures for a Firm opcode.
78 * @param opc The opcode.
79 * @return The number of signatures for this opcode.
81 int rflct_get_signature_count(opcode opc);
84 * Try to get the signature, that matches to a given instance
86 * @param irn The node.
87 * @return The first matching signature or -1, if no signature matches.
89 int rflct_get_signature(ir_node *irn);
92 * Get the number of in arguments.
93 * An in argument is a use of a value.
94 * @param opc The opcode.
95 * @param sig The signature you are refering to.
96 * @return The number of arguments.
98 int rflct_get_in_args_count(opcode opc, int sig);
101 * Get the number of out arguments.
102 * An out argument is a def of a value.
103 * @param opc The opcode.
104 * @param sig The signature you are refering to.
105 * @return The number of arguments.
107 int rflct_get_out_args_count(opcode opc, int sig);
110 * Get the array of use args.
111 * The array is terminated with an entry for which
112 * <code>RFLCT_ARG_VALID</code> is 0.
113 * @param opc The opcode.
114 * @param sig The signature you are referring to (Must be between
115 * 0 and the signature count).
118 const rflct_arg_t *rflct_get_in_args(opcode opc, int sig);
121 * Get the array of def args.
122 * The array is terminated with an entry for which
123 * <code>RFLCT_ARG_VALID</code> is 0.
124 * @param opc The opcode.
125 * @param sig The signature you are referring to (Must be between
126 * 0 and the signature count).
129 const rflct_arg_t *rflct_get_out_args(opcode opc, int sig);
132 * Make a string representation of a signature of an opcode.
133 * @param buf The buffer to put the string to.
134 * @param n The size of buf.
135 * @param opc The opcode.
136 * @param sig The signature.
139 char *rflct_to_string(char *buf, int n, opcode opc, int sig);
142 * Get a string representation of a mode class.
143 * @param str The buffer to put the string to.
144 * @param n The size of the buffer.
145 * @param mc The mode class.
148 char *rflct_mode_class_name(char *str, int n, rflct_mode_class_t mc);