From: Michael Beck Date: Thu, 15 Sep 2005 11:03:15 +0000 (+0000) Subject: added a generic function pointer to an opcode X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=4f8115163591236f4f7e26bc94f9e939127dbe6e;p=libfirm added a generic function pointer to an opcode [r6624] --- diff --git a/ir/ir/irop.c b/ir/ir/irop.c index a2497ea13..2fec76631 100644 --- a/ir/ir/irop.c +++ b/ir/ir/irop.c @@ -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); +} diff --git a/ir/ir/irop.h b/ir/ir/irop.h index 30d6249ee..070830a0e 100644 --- a/ir/ir/irop.h +++ b/ir/ir/irop.h @@ -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_ */ diff --git a/ir/ir/irop_t.h b/ir/ir/irop_t.h index fc18e3fdd..1ac54f360 100644 --- a/ir/ir/irop_t.h +++ b/ir/ir/irop_t.h @@ -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)