From: Michael Beck Date: Fri, 23 Nov 2007 10:29:50 +0000 (+0000) Subject: - renamed irop_flag_side_effect to irop_flag_uses_memory X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=f179a008298758428bd9a0e685fad2d99ad13481;p=libfirm - renamed irop_flag_side_effect to irop_flag_uses_memory - renamed op_pin_state field to pin_state (was probaly refactored wrong) - improved doxygen comments [r16830] --- diff --git a/include/libfirm/irop.h b/include/libfirm/irop.h index f9761125d..e6e7c9100 100644 --- a/include/libfirm/irop.h +++ b/include/libfirm/irop.h @@ -37,19 +37,19 @@ #include #include "ident.h" -/** The allowed parities */ +/** The allowed arities. */ typedef enum { oparity_invalid = 0, - oparity_unary, /**< an unary operator -- considering 'numeric' arguments. */ - oparity_binary, /**< an binary operator -- considering 'numeric' arguments.*/ - oparity_trinary, /**< an trinary operator -- considering 'numeric' arguments.*/ - oparity_zero, /**< no operators, as e.g. Const. */ - oparity_variable, /**< arity not fixed by opcode, but statically + oparity_unary, /**< An unary operator -- considering 'numeric' arguments. */ + oparity_binary, /**< A binary operator -- considering 'numeric' arguments.*/ + oparity_trinary, /**< A trinary operator -- considering 'numeric' arguments.*/ + oparity_zero, /**< A zero arity operator, e.g. a Const. */ + oparity_variable, /**< The arity is not fixed by opcode, but statically known. E.g., number of arguments to call. */ - oparity_dynamic, /**< arity depends on state of firm representation. - Can change by optimizations... + oparity_dynamic, /**< The arity depends on state of Firm representation. + Can be changed by optimizations... We must allocate a dynamic in array for the node! */ - oparity_any /**< other arity */ + oparity_any /**< Any other arity. */ } op_arity; @@ -70,7 +70,7 @@ typedef enum { irop_flag_always_opt = 0x00000100, /**< This operation must always be optimized .*/ irop_flag_keep = 0x00000200, /**< This operation can be kept in End's keep-alive list. */ irop_flag_start_block = 0x00000400, /**< This operation is always placed in the Start block. */ - irop_flag_side_effect = 0x00000800, /**< this operation produces side effects */ + irop_flag_uses_memory = 0x00000800, /**< This operation has a memory input and may change the memory state. */ irop_flag_machine = 0x00001000, /**< This operation is a machine operation. */ irop_flag_machine_op = 0x00002000, /**< This operation is a machine operand. */ irop_flag_user = 0x00004000 /**< This flag and all higher ones are free for machine user. */ @@ -182,7 +182,7 @@ const char *get_op_name(const ir_op *op); /** Returns the enum for the opcode */ unsigned get_op_code(const ir_op *op); -/** op_pin_state_pinned states */ +/** op_pin_state_pinned states. */ typedef enum { op_pin_state_floats = 0, /**< Nodes of this opcode can be placed in any basic block. */ op_pin_state_pinned = 1, /**< Nodes must remain in this basic block. */ @@ -192,23 +192,24 @@ typedef enum { exception or uses memory, else can float. Used internally. */ } op_pin_state; +/** Returns a human readable name of an op_pin_state. */ const char *get_op_pin_state_name(op_pin_state s); -/** gets pinned state of an opcode */ +/** Gets pinned state of an opcode. */ op_pin_state get_op_pinned(const ir_op *op); /** Sets pinned in the opcode. Setting it to floating has no effect for Block, Phi and control flow nodes. */ void set_op_pinned(ir_op *op, op_pin_state pinned); -/** Returns the next free IR opcode number, allows to register user ops */ +/** Returns the next free IR opcode number, allows to register user ops. */ unsigned get_next_ir_opcode(void); -/** Returns the next free n IR opcode number, allows to register a bunch of user ops */ +/** Returns the next free n IR opcode number, allows to register a bunch of user ops. */ unsigned get_next_ir_opcodes(unsigned num); /** - * A generic function pointer. + * A generic function pointer type. */ typedef void (*op_func)(void); @@ -216,12 +217,12 @@ typedef void (*op_func)(void); #define NULL_FUNC ((generic_func)(NULL)) /** - * Returns the generic function pointer from an ir operation. + * 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. + * Store a generic function pointer into an IR operation. */ void set_generic_function_ptr(ir_op *op, op_func func); @@ -270,7 +271,7 @@ typedef int (*reassociate_func)(ir_node **n); /** * The copy attribute operation. - * Copy the node attributes from a 'old' node to a 'new' one. + * Copy the node attributes from an 'old' node to a 'new' one. */ typedef void (*copy_attr_func)(const ir_node *old_node, ir_node *new_node); @@ -316,10 +317,10 @@ typedef int (*verify_proj_node_func)(ir_node *self, ir_node *proj); * Reasons to call the dump_node operation: */ typedef enum { - dump_node_opcode_txt, /**< dump the opcode */ - dump_node_mode_txt, /**< dump the mode */ - dump_node_nodeattr_txt, /**< dump node attributes to be shown in the label */ - dump_node_info_txt /**< dump node attributes into info1 */ + dump_node_opcode_txt, /**< Dump the opcode. */ + dump_node_mode_txt, /**< Dump the mode. */ + dump_node_nodeattr_txt, /**< Dump node attributes to be shown in the label. */ + dump_node_info_txt /**< Dump node attributes into info1. */ } dump_reason_t; /** @@ -349,19 +350,19 @@ typedef struct { } ir_op_ops; /** - * Creates a new ir operation. + * Creates a new IR operation. * * @param code the opcode, one of type \c opcode * @param name the printable name of this opcode * @param p whether operations of this opcode are op_pin_state_pinned or floating - * @param flags a bitmask of irop_flags describing the behavior of the ir operation - * @param opar the parity of this ir operation + * @param flags a bitmask of irop_flags describing the behavior of the IR operation + * @param opar the parity of this IR operation * @param op_index if the parity is oparity_unary, oparity_binary or oparity_trinary the index * of the left operand * @param ops operations for this opcode, iff NULL default operations are used - * @param attr_size attribute size for this ir operation + * @param attr_size attribute size for this IR operation * - * @return The generated ir operation. + * @return The generated IR operation. * * This function can create all standard Firm opcode as well as new ones. * The behavior of new opcode depends on the operations \c ops and the \c flags. diff --git a/ir/be/benode.c b/ir/be/benode.c index eb1b4087d..0646ebfba 100644 --- a/ir/be/benode.c +++ b/ir/be/benode.c @@ -146,8 +146,7 @@ static const ir_op_ops be_node_op_ops; #define H irop_flag_highlevel #define c irop_flag_constlike #define K irop_flag_keep -#define M irop_flag_machine -#define E irop_flag_side_effect +#define M irop_flag_uses_memory /** @@ -265,21 +264,21 @@ void be_node_init(void) { /* Acquire all needed opcodes. */ beo_base = get_next_ir_opcodes(beo_Last); - op_be_Spill = new_ir_op(beo_base + beo_Spill, "be_Spill", op_pin_state_pinned, N, oparity_unary, 0, sizeof(be_frame_attr_t), &be_node_op_ops); - op_be_Reload = new_ir_op(beo_base + beo_Reload, "be_Reload", op_pin_state_pinned, N, oparity_zero, 0, sizeof(be_frame_attr_t), &be_node_op_ops); - op_be_Perm = new_ir_op(beo_base + beo_Perm, "be_Perm", op_pin_state_pinned, N, oparity_variable, 0, sizeof(be_node_attr_t), &be_node_op_ops); - op_be_MemPerm = new_ir_op(beo_base + beo_MemPerm, "be_MemPerm", op_pin_state_pinned, N, oparity_variable, 0, sizeof(be_memperm_attr_t), &be_node_op_ops); - op_be_Copy = new_ir_op(beo_base + beo_Copy, "be_Copy", op_pin_state_floats, N, oparity_unary, 0, sizeof(be_node_attr_t), &be_node_op_ops); - op_be_Keep = new_ir_op(beo_base + beo_Keep, "be_Keep", op_pin_state_pinned, K, oparity_dynamic, 0, sizeof(be_node_attr_t), &be_node_op_ops); - op_be_CopyKeep = new_ir_op(beo_base + beo_CopyKeep, "be_CopyKeep", op_pin_state_pinned, K, oparity_variable, 0, sizeof(be_node_attr_t), &be_node_op_ops); - op_be_Call = new_ir_op(beo_base + beo_Call, "be_Call", op_pin_state_pinned, F|E, oparity_variable, 0, sizeof(be_call_attr_t), &be_node_op_ops); - op_be_Return = new_ir_op(beo_base + beo_Return, "be_Return", op_pin_state_pinned, X, oparity_dynamic, 0, sizeof(be_return_attr_t), &be_node_op_ops); - op_be_AddSP = new_ir_op(beo_base + beo_AddSP, "be_AddSP", op_pin_state_pinned, N, oparity_unary, 0, sizeof(be_node_attr_t), &be_node_op_ops); - op_be_SubSP = new_ir_op(beo_base + beo_SubSP, "be_SubSP", op_pin_state_pinned, N, oparity_unary, 0, sizeof(be_node_attr_t), &be_node_op_ops); - op_be_IncSP = new_ir_op(beo_base + beo_IncSP, "be_IncSP", op_pin_state_pinned, N, oparity_unary, 0, sizeof(be_stack_attr_t), &be_node_op_ops); - op_be_RegParams = new_ir_op(beo_base + beo_RegParams, "be_RegParams", op_pin_state_pinned, N, oparity_zero, 0, sizeof(be_node_attr_t), &be_node_op_ops); - op_be_FrameAddr = new_ir_op(beo_base + beo_FrameAddr, "be_FrameAddr", op_pin_state_floats, N, oparity_unary, 0, sizeof(be_frame_attr_t), &be_node_op_ops); - op_be_Barrier = new_ir_op(beo_base + beo_Barrier, "be_Barrier", op_pin_state_pinned, N, oparity_dynamic, 0, sizeof(be_node_attr_t), &be_node_op_ops); + op_be_Spill = new_ir_op(beo_base + beo_Spill, "be_Spill", op_pin_state_pinned, N, oparity_unary, 0, sizeof(be_frame_attr_t), &be_node_op_ops); + op_be_Reload = new_ir_op(beo_base + beo_Reload, "be_Reload", op_pin_state_pinned, N, oparity_zero, 0, sizeof(be_frame_attr_t), &be_node_op_ops); + op_be_Perm = new_ir_op(beo_base + beo_Perm, "be_Perm", op_pin_state_pinned, N, oparity_variable, 0, sizeof(be_node_attr_t), &be_node_op_ops); + op_be_MemPerm = new_ir_op(beo_base + beo_MemPerm, "be_MemPerm", op_pin_state_pinned, N, oparity_variable, 0, sizeof(be_memperm_attr_t), &be_node_op_ops); + op_be_Copy = new_ir_op(beo_base + beo_Copy, "be_Copy", op_pin_state_floats, N, oparity_unary, 0, sizeof(be_node_attr_t), &be_node_op_ops); + op_be_Keep = new_ir_op(beo_base + beo_Keep, "be_Keep", op_pin_state_pinned, K, oparity_dynamic, 0, sizeof(be_node_attr_t), &be_node_op_ops); + op_be_CopyKeep = new_ir_op(beo_base + beo_CopyKeep, "be_CopyKeep", op_pin_state_pinned, K, oparity_variable, 0, sizeof(be_node_attr_t), &be_node_op_ops); + op_be_Call = new_ir_op(beo_base + beo_Call, "be_Call", op_pin_state_pinned, F|M, oparity_variable, 0, sizeof(be_call_attr_t), &be_node_op_ops); + op_be_Return = new_ir_op(beo_base + beo_Return, "be_Return", op_pin_state_pinned, X, oparity_dynamic, 0, sizeof(be_return_attr_t), &be_node_op_ops); + op_be_AddSP = new_ir_op(beo_base + beo_AddSP, "be_AddSP", op_pin_state_pinned, N, oparity_unary, 0, sizeof(be_node_attr_t), &be_node_op_ops); + op_be_SubSP = new_ir_op(beo_base + beo_SubSP, "be_SubSP", op_pin_state_pinned, N, oparity_unary, 0, sizeof(be_node_attr_t), &be_node_op_ops); + op_be_IncSP = new_ir_op(beo_base + beo_IncSP, "be_IncSP", op_pin_state_pinned, N, oparity_unary, 0, sizeof(be_stack_attr_t), &be_node_op_ops); + op_be_RegParams = new_ir_op(beo_base + beo_RegParams, "be_RegParams", op_pin_state_pinned, N, oparity_zero, 0, sizeof(be_node_attr_t), &be_node_op_ops); + op_be_FrameAddr = new_ir_op(beo_base + beo_FrameAddr, "be_FrameAddr", op_pin_state_floats, N, oparity_unary, 0, sizeof(be_frame_attr_t), &be_node_op_ops); + op_be_Barrier = new_ir_op(beo_base + beo_Barrier, "be_Barrier", op_pin_state_pinned, N, oparity_dynamic, 0, sizeof(be_node_attr_t), &be_node_op_ops); set_op_tag(op_be_Spill, &be_node_tag); op_be_Spill->ops.node_cmp_attr = FrameAddr_cmp_attr; diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index 9e878286a..3f4fffc5d 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -1261,7 +1261,7 @@ static void dump_node_vcgattr(FILE *F, ir_node *node, ir_node *local, int bad) if(is_op_constlike(op)) { print_vcg_color(F, ird_color_const); - } else if(is_op_side_effects(op)) { + } else if(is_op_uses_memory(op)) { print_vcg_color(F, ird_color_side_effects); } else if(is_op_cfopcode(op) || is_op_forking(op)) { print_vcg_color(F, ird_color_controlflow); diff --git a/ir/ir/irop.c b/ir/ir/irop.c index 67351de3f..33bd41a56 100644 --- a/ir/ir/irop.c +++ b/ir/ir/irop.c @@ -239,7 +239,7 @@ new_ir_op(unsigned code, const char *name, op_pin_state p, res->code = code; res->name = new_id_from_chars(name, strlen(name)); - res->op_pin_state_pinned = p; + res->pin_state = p; res->attr_size = attr_size; res->flags = flags; res->opar = opar; @@ -283,7 +283,7 @@ init_op(void) #define c irop_flag_constlike #define K irop_flag_keep #define S irop_flag_start_block -#define E irop_flag_side_effect +#define M irop_flag_uses_memory /* Caution: A great deal of Firm optimizations depend an right operations flags. */ op_Block = new_ir_op(iro_Block, "Block", op_pin_state_pinned, L, oparity_variable, -1, sizeof(block_attr), NULL); @@ -300,16 +300,16 @@ init_op(void) op_Sel = new_ir_op(iro_Sel, "Sel", op_pin_state_floats, H, oparity_any, -1, sizeof(sel_attr), NULL); - op_Call = new_ir_op(iro_Call, "Call", op_pin_state_mem_pinned, F|E, oparity_variable, -1, sizeof(call_attr), NULL); + op_Call = new_ir_op(iro_Call, "Call", op_pin_state_mem_pinned, F|M, oparity_variable, -1, sizeof(call_attr), NULL); op_Add = new_ir_op(iro_Add, "Add", op_pin_state_floats, C, oparity_binary, 0, 0, NULL); op_Sub = new_ir_op(iro_Sub, "Sub", op_pin_state_floats, N, oparity_binary, 0, 0, NULL); op_Minus = new_ir_op(iro_Minus, "Minus", op_pin_state_floats, N, oparity_unary, 0, 0, NULL); op_Mul = new_ir_op(iro_Mul, "Mul", op_pin_state_floats, C, oparity_binary, 0, 0, NULL); op_Mulh = new_ir_op(iro_Mulh, "Mulh", op_pin_state_floats, C, oparity_binary, 0, 0, NULL); - op_Quot = new_ir_op(iro_Quot, "Quot", op_pin_state_exc_pinned, F, oparity_binary, 1, sizeof(divmod_attr), NULL); - op_DivMod = new_ir_op(iro_DivMod, "DivMod", op_pin_state_exc_pinned, F, oparity_binary, 1, sizeof(divmod_attr), NULL); - op_Div = new_ir_op(iro_Div, "Div", op_pin_state_exc_pinned, F, oparity_binary, 1, sizeof(divmod_attr), NULL); - op_Mod = new_ir_op(iro_Mod, "Mod", op_pin_state_exc_pinned, F, oparity_binary, 1, sizeof(divmod_attr), NULL); + op_Quot = new_ir_op(iro_Quot, "Quot", op_pin_state_exc_pinned, F|M, oparity_binary, 1, sizeof(divmod_attr), NULL); + op_DivMod = new_ir_op(iro_DivMod, "DivMod", op_pin_state_exc_pinned, F|M, oparity_binary, 1, sizeof(divmod_attr), NULL); + op_Div = new_ir_op(iro_Div, "Div", op_pin_state_exc_pinned, F|M, oparity_binary, 1, sizeof(divmod_attr), NULL); + op_Mod = new_ir_op(iro_Mod, "Mod", op_pin_state_exc_pinned, F|M, oparity_binary, 1, sizeof(divmod_attr), NULL); op_Abs = new_ir_op(iro_Abs, "Abs", op_pin_state_floats, N, oparity_unary, 0, 0, NULL); op_And = new_ir_op(iro_And, "And", op_pin_state_floats, C, oparity_binary, 0, 0, NULL); op_Or = new_ir_op(iro_Or, "Or", op_pin_state_floats, C, oparity_binary, 0, 0, NULL); @@ -327,10 +327,10 @@ init_op(void) op_Phi = new_ir_op(iro_Phi, "Phi", op_pin_state_pinned, N, oparity_variable, -1, sizeof(phi0_attr), NULL); - op_Load = new_ir_op(iro_Load, "Load", op_pin_state_exc_pinned, F|E, oparity_any, -1, sizeof(load_attr), NULL); - op_Store = new_ir_op(iro_Store, "Store", op_pin_state_exc_pinned, F|E, oparity_any, -1, sizeof(store_attr), NULL); - op_Alloc = new_ir_op(iro_Alloc, "Alloc", op_pin_state_pinned, F|E, oparity_any, -1, sizeof(alloc_attr), NULL); - op_Free = new_ir_op(iro_Free, "Free", op_pin_state_pinned, N|E, oparity_any, -1, sizeof(free_attr), NULL); + op_Load = new_ir_op(iro_Load, "Load", op_pin_state_exc_pinned, F|M, oparity_any, -1, sizeof(load_attr), NULL); + op_Store = new_ir_op(iro_Store, "Store", op_pin_state_exc_pinned, F|M, oparity_any, -1, sizeof(store_attr), NULL); + op_Alloc = new_ir_op(iro_Alloc, "Alloc", op_pin_state_pinned, F|M, oparity_any, -1, sizeof(alloc_attr), NULL); + op_Free = new_ir_op(iro_Free, "Free", op_pin_state_pinned, N|M, oparity_any, -1, sizeof(free_attr), NULL); op_Sync = new_ir_op(iro_Sync, "Sync", op_pin_state_pinned, N, oparity_dynamic, -1, 0, NULL); op_Proj = new_ir_op(iro_Proj, "Proj", op_pin_state_floats, N, oparity_unary, -1, sizeof(long), NULL); @@ -349,7 +349,7 @@ init_op(void) op_NoMem = new_ir_op(iro_NoMem, "NoMem", op_pin_state_pinned, N, oparity_zero, -1, 0, NULL); op_Mux = new_ir_op(iro_Mux, "Mux", op_pin_state_floats, N, oparity_trinary, -1, 0, NULL); op_Psi = new_ir_op(iro_Psi, "Psi", op_pin_state_floats, N, oparity_variable, -1, 0, NULL); - op_CopyB = new_ir_op(iro_CopyB, "CopyB", op_pin_state_mem_pinned, F|H|E, oparity_trinary, -1, sizeof(copyb_attr), NULL); + op_CopyB = new_ir_op(iro_CopyB, "CopyB", op_pin_state_mem_pinned, F|H|M, oparity_trinary, -1, sizeof(copyb_attr), NULL); op_InstOf = new_ir_op(iro_InstOf, "InstOf", op_pin_state_mem_pinned, H, oparity_unary, -1, sizeof(io_attr), NULL); op_Raise = new_ir_op(iro_Raise, "Raise", op_pin_state_pinned, H|X, oparity_any, -1, 0, NULL); @@ -357,7 +357,7 @@ init_op(void) op_Pin = new_ir_op(iro_Pin, "Pin", op_pin_state_pinned, H, oparity_unary, -1, 0, NULL); - op_ASM = new_ir_op(iro_ASM, "ASM", op_pin_state_mem_pinned, K|E, oparity_variable, -1, sizeof(asm_attr), NULL); + op_ASM = new_ir_op(iro_ASM, "ASM", op_pin_state_mem_pinned, K|M, oparity_variable, -1, sizeof(asm_attr), NULL); op_Anchor = new_ir_op(iro_Anchor, "Anchor", op_pin_state_pinned, N, oparity_variable, -1, 0, NULL); @@ -479,9 +479,9 @@ op_pin_state (get_op_pinned)(const ir_op *op) { /* Sets op_pin_state_pinned in the opcode. Setting it to floating has no effect for Phi, Block and control flow nodes. */ -void set_op_pinned(ir_op *op, op_pin_state op_pin_state_pinned) { +void set_op_pinned(ir_op *op, op_pin_state pinned) { if (op == op_Block || op == op_Phi || is_op_cfopcode(op)) return; - op->op_pin_state_pinned = op_pin_state_pinned; + op->pin_state = pinned; } /* set_op_pinned */ /* retrieve the next free opcode */ diff --git a/ir/ir/irop_t.h b/ir/ir/irop_t.h index 04dbb862c..ec310cb03 100644 --- a/ir/ir/irop_t.h +++ b/ir/ir/irop_t.h @@ -100,8 +100,8 @@ static INLINE int is_op_constlike(const ir_op *op) { return op->flags & irop_flag_constlike; } -static INLINE int is_op_side_effects(const ir_op *op) { - return op->flags & irop_flag_side_effect; +static INLINE int is_op_uses_memory(const ir_op *op) { + return op->flags & irop_flag_uses_memory; } /** Returns non-zero if operation must always be optimized */ @@ -143,7 +143,7 @@ static INLINE ident *_get_op_ident(const ir_op *op){ } static INLINE op_pin_state _get_op_pinned(const ir_op *op) { - return op->op_pin_state_pinned; + return op->pin_state; } static INLINE void _set_generic_function_ptr(ir_op *op, op_func func) { diff --git a/ir/ir/irtypes.h b/ir/ir/irtypes.h index 461300a01..5155d926f 100644 --- a/ir/ir/irtypes.h +++ b/ir/ir/irtypes.h @@ -51,7 +51,7 @@ struct ir_op { unsigned code; /**< The unique opcode of the op. */ ident *name; /**< The name of the op. */ size_t attr_size; /**< Space needed in memory for private attributes. */ - op_pin_state op_pin_state_pinned; /**< How to deal with the node in CSE, PRE. */ + op_pin_state pin_state; /**< How to deal with the node in CSE, PRE. */ op_arity opar; /**< The arity of operator. */ int op_index; /**< The index of the first data operand, 0 for most cases, 1 for Div etc. */ unsigned flags; /**< Flags describing the behavior of the ir_op, a bitmasks of irop_flags. */