added a generic function pointer to an opcode
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Thu, 15 Sep 2005 11:03:15 +0000 (11:03 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Thu, 15 Sep 2005 11:03:15 +0000 (11:03 +0000)
[r6624]

ir/ir/irop.c
ir/ir/irop.h
ir/ir/irop_t.h

index a2497ea..2fec766 100644 (file)
@@ -359,3 +359,13 @@ void      set_op_pinned(ir_op *op, op_pin_state op_pin_state_pinned) {
 unsigned get_next_ir_opcode(void) {
   return next_iro++;
 }
+
+/* Returns the generic function pointer from an ir operation. */
+op_func (get_generic_function_ptr)(const ir_op *op) {
+  return _get_generic_function_ptr(op);
+}
+
+/* Store a generic function pointer into an ir operation. */
+void (set_generic_function_ptr)(ir_op *op, op_func func) {
+  _set_generic_function_ptr(op, func);
+}
index 30d6249..070830a 100644 (file)
@@ -188,4 +188,22 @@ unsigned get_next_ir_opcode(void);
 ir_op * new_ir_op(opcode code, const char *name, op_pin_state p,
                   unsigned flags, op_arity opar, int op_index, size_t attr_size);
 
+/**
+ * A generic function pointer.
+ */
+typedef void (*op_func)(void);
+
+/** The NULL-function. */
+#define NULL_FUNC       ((generic_func)(NULL))
+
+/**
+ * Returns the generic function pointer from an ir operation.
+ */
+op_func get_generic_function_ptr(const ir_op *op);
+
+/**
+ * Store a generic function pointer into an ir operation.
+ */
+void set_generic_function_ptr(ir_op *op, op_func func);
+
 # endif /* _IROP_H_ */
index fc18e3f..1ac54f3 100644 (file)
@@ -102,7 +102,7 @@ struct ir_op {
   unsigned flags;         /**< flags describing the behavior of the ir_op, a bitmaks of irop_flags */
 
   /* CallBacks */
-  computed_value_func    computed_value;               /**< evaluates a node into a tarval if possible. */
+  computed_value_func  computed_value;         /**< evaluates a node into a tarval if possible. */
   equivalent_node_func  equivalent_node;       /**< optimizes the node by returning an equivalent one. */
   transform_node_func   transform_node;                /**< optimizes the node by transforming it. */
   node_cmp_attr_func    node_cmp_attr;         /**< compares two node attributes. */
@@ -111,6 +111,7 @@ struct ir_op {
   get_type_func         get_type;               /**< return the type of a node */
   verify_node_func      verify_node;            /**< verify the node */
   verify_proj_node_func verify_proj_node;       /**< verify the Proj node */
+  op_func               generic;                /**< a generic function */
 };
 
 /**
@@ -184,6 +185,13 @@ static INLINE op_pin_state _get_op_pinned(const ir_op *op) {
   return op->op_pin_state_pinned;
 }
 
+static INLINE void _set_generic_function_ptr(ir_op *op, op_func func) {
+  op->generic = func;
+}
+
+static INLINE op_func _get_generic_function_ptr(const ir_op *op) {
+  return op->generic;
+}
 
 #define get_op_code(op)         _get_op_code(op)
 #define get_op_ident(op)        _get_op_ident(op)