get_divop_resmod() added
[libfirm] / ir / ir / irreflect.c
index feb5049..0b6633a 100644 (file)
@@ -1,15 +1,35 @@
-/**
- * @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.
  */
@@ -60,7 +79,7 @@ typedef struct {
 } rflct_args_t;
 
 typedef struct {
-       opcode opc;
+       ir_opcode opc;
        const char *name;
        int commutative;
        int sig_count;
@@ -123,12 +142,12 @@ rflct_mode_class_t rflct_get_mode_class(const ir_mode *mode) {
        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");
@@ -138,12 +157,12 @@ static INLINE const rflct_arg_t *get_args(opcode opc, int sig) {
 #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;
 
@@ -152,7 +171,7 @@ int rflct_get_in_args_count(opcode opc, int sig) {
        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++);
@@ -160,7 +179,7 @@ int rflct_get_out_args_count(opcode opc, int sig) {
 }
 
 
-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;
 
@@ -168,12 +187,12 @@ const rflct_arg_t *rflct_get_in_args(opcode opc, int sig) {
        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;
@@ -299,7 +318,7 @@ static void rflct_obstack_grow_args(struct obstack *obst,
 
 }
 
-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);
@@ -402,7 +421,7 @@ arg->name = _name; \
        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));
 
@@ -415,7 +434,7 @@ void rflct_new_opcode(opcode opc, const char *name, int commutative)
        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];