-/**
- * @file irreflect.c
- * @date 9.9.2004
- * @author Sebastian Hack
- * @brief Reflection for Firm operands.
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
*
- * $Id$
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Reflection for Firm operands.
+ * @author Sebastian Hack
+ * @date 9.9.2004
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include <assert.h>
+
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#include "obst.h"
+#include "irnode_t.h"
#include "irmode.h"
#include "irreflect.h"
#define obstack_grow_str(obst,s) obstack_grow((obst), (s), strlen((s)))
#define obstack_grow_str_const(obst,s) obstack_grow((obst), (s), sizeof((s)))
-extern int obstack_printf(struct obstack *obst, const char *fmt, ...);
-
/**
* Get the number of bits set in a word.
*/
} rflct_args_t;
typedef struct {
- opcode opc;
+ ir_opcode opc;
const char *name;
int commutative;
int sig_count;
return RFLCT_MC(None);
}
-static INLINE const rflct_opcode_t *get_opcode(opcode opc) {
+static INLINE const rflct_opcode_t *get_opcode(ir_opcode opc) {
assert(opc >= 0 && opc < OPCODES_COUNT && "Invalid opcode");
return opcodes[opc];
}
-static INLINE const rflct_arg_t *get_args(opcode opc, int sig) {
+static INLINE const rflct_arg_t *get_args(ir_opcode opc, int sig) {
const rflct_opcode_t *opcode = get_opcode(opc);
assert(sig >= 0 && sig < opcode->sig_count
&& "Invalid signature");
#define GET_OPCODE(opc) get_opcode(opc)
#define GET_ARGS(opc,args) get_args(opc, args)
-int rflct_get_signature_count(opcode opc) {
+int rflct_get_signature_count(ir_opcode opc) {
const rflct_opcode_t *opcode = GET_OPCODE(opc);
return opcode->sig_count;
}
-int rflct_get_in_args_count(opcode opc, int sig) {
+int rflct_get_in_args_count(ir_opcode opc, int sig) {
const rflct_arg_t *args = GET_ARGS(opc, sig);
int res = 0, i = 0;
return res;
}
-int rflct_get_out_args_count(opcode opc, int sig) {
+int rflct_get_out_args_count(ir_opcode opc, int sig) {
const rflct_arg_t *args = GET_ARGS(opc, sig);
int i = 0;
for(i = 0; args[i].name != NULL; i++);
}
-const rflct_arg_t *rflct_get_in_args(opcode opc, int sig) {
+const rflct_arg_t *rflct_get_in_args(ir_opcode opc, int sig) {
const rflct_arg_t *args = GET_ARGS(opc, sig);
int i;
return &args[i + 1];
}
-const rflct_arg_t *rflct_get_out_args(opcode opc, int sig) {
+const rflct_arg_t *rflct_get_out_args(ir_opcode opc, int sig) {
return GET_ARGS(opc, sig);
}
int rflct_signature_match(const ir_node *irn, int sig) {
- opcode op = get_irn_opcode(irn);
+ ir_opcode op = get_irn_opcode(irn);
const rflct_arg_t *args = rflct_get_in_args(op, sig);
int dst = 0;
int i, j;
}
-char *rflct_to_string(char *buf, int n, opcode opc, int sig) {
+char *rflct_to_string(char *buf, int n, ir_opcode opc, int sig) {
struct obstack obst;
char *s;
const rflct_opcode_t *opcode = GET_OPCODE(opc);
arg->is_variadic = _var; \
arg->mode_equals = _me;
-void rflct_new_opcode(opcode opc, const char *name, int commutative)
+void rflct_new_opcode(ir_opcode opc, const char *name, int commutative)
{
rflct_opcode_t *ropc = obstack_alloc(&obst, sizeof(*ropc));
opcodes[opc] = ropc;
}
-int rflct_opcode_add_signature(opcode opc, rflct_sig_t *sig)
+int rflct_opcode_add_signature(ir_opcode opc, rflct_sig_t *sig)
{
rflct_arg_t *args = sig->args;
rflct_opcode_t *op = opcodes[opc];