Commit b22c964e authored by Michael Beck's avatar Michael Beck
Browse files

Add Pin Operation.

[r7998]
parent e2b4dc19
This diff is collapsed.
......@@ -296,6 +296,7 @@
* ir_node *new_InstOf (ir_node *store, ir_node obj, ir_type *ent);
* ir_node *new_Raise (ir_node *store, ir_node *obj);
* ir_node *new_Bound (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
* ir_node *new_Pin (ir_node *node);
*
* void add_immBlock_pred (ir_node *block, ir_node *jmp);
* void mature_immBlock (ir_node *block);
......@@ -1030,6 +1031,13 @@
* Describes a high level bounds check. Must be lowered to a Call to a runtime check
* function.
*
* ir_node *new_Pin (ir_node *node);
* -----------------------------------------------------------------------------------
*
* Pin the value of the node node in the current block No users of the Pin node can
* float above the Block of the Pin. The node cannot float behind this block. Often
* used to Pin the NoMem node.
*
*
* COPING WITH DATA OBJECTS
* ========================
......@@ -1044,7 +1052,7 @@
*
* All values known in a Block are listed in the block's attribute,
* block.**graph_arr which is used to automatically insert Phi nodes.
* The following two funcions can be used to add a newly computed value
* The following two functions can be used to add a newly computed value
* to the array, or to get the producer of a value, i.e., the current
* live value.
*
......@@ -1943,7 +1951,7 @@ ir_node *new_rd_Raise (dbg_info *db, ir_graph *irg, ir_node *block,
* @param *db A pointer for debug information.
* @param *irg The ir graph the node belong to.
* @param *block The block the node belong to.
* @param *store The current memory
* @param *store The current memory.
* @param *idx The ir_node that represents an index.
* @param *lower The ir_node that represents the lower bound for the index.
* @param *upper The ir_node that represents the upper bound for the index.
......@@ -1951,6 +1959,15 @@ ir_node *new_rd_Raise (dbg_info *db, ir_graph *irg, ir_node *block,
ir_node *new_rd_Bound(dbg_info *db, ir_graph *irg, ir_node *block,
ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
/** Constructor for a Pin node.
*
* @param *db A pointer for debug information.
* @param *irg The ir graph the node belong to.
* @param *block The block the node belong to.
* @param *node The node which value should be pinned.
*/
ir_node *new_rd_Pin(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *node);
/*-------------------------------------------------------------------------*/
/* The raw interface without debug support */
/*-------------------------------------------------------------------------*/
......@@ -2706,7 +2723,7 @@ ir_node *new_r_Raise (ir_graph *irg, ir_node *block,
*
* @param *irg The ir graph the node belong to.
* @param *block The block the node belong to.
* @param *store The current memory
* @param *store The current memory.
* @param *idx The ir_node that represents an index.
* @param *lower The ir_node that represents the lower bound for the index.
* @param *upper The ir_node that represents the upper bound for the index.
......@@ -2714,6 +2731,14 @@ ir_node *new_r_Raise (ir_graph *irg, ir_node *block,
ir_node *new_r_Bound(ir_graph *irg, ir_node *block,
ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
/** Constructor for a Pin node.
*
* @param *irg The ir graph the node belong to.
* @param *block The block the node belong to.
* @param *node The node which value should be pinned.
*/
ir_node *new_r_Pin(ir_graph *irg, ir_node *block, ir_node *node);
/*-----------------------------------------------------------------------*/
/* The block oriented interface */
/*-----------------------------------------------------------------------*/
......@@ -3468,6 +3493,13 @@ ir_node *new_d_Raise (dbg_info *db, ir_node *store, ir_node *obj);
*/
ir_node *new_d_Bound(dbg_info *db, ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
/** Constructor for a Pin node.
*
* @param *db A pointer for debug information.
* @param *node The node which value should be pinned.
*/
ir_node *new_d_Pin(dbg_info *db, ir_node *node);
/*-----------------------------------------------------------------------*/
/* The block oriented interface without debug support */
/*-----------------------------------------------------------------------*/
......@@ -4134,6 +4166,12 @@ ir_node *new_Raise (ir_node *store, ir_node *obj);
*/
ir_node *new_Bound(ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
/** Constructor for a Pin node.
*
* @param *node The node which value should be pinned.
*/
ir_node *new_Pin(ir_node *node);
/*---------------------------------------------------------------------*/
/* The comfortable interface. */
/* Supports automatic Phi node construction. */
......
......@@ -99,6 +99,8 @@ ir_op *op_CopyB; ir_op *get_op_CopyB (void) { return op_CopyB; }
ir_op *op_Raise; ir_op *get_op_Raise (void) { return op_Raise; }
ir_op *op_Bound; ir_op *get_op_Bound (void) { return op_Bound; }
ir_op *op_Pin; ir_op *get_op_Pin (void) { return op_Pin; }
/*
* Copies all attributes stored in the old node to the new node.
* Assumes both have the same opcode and sufficient size.
......@@ -113,25 +115,25 @@ void default_copy_attr(const ir_node *old_node, ir_node *new_node) {
/* copy additional node data */
memcpy(get_irn_data(new_node, void, size), get_irn_data(old_node, void, size), size);
}
}
} /* default_copy_attr */
/**
* Copies all attributes stored in the old node to the new node.
* Assumes both have the same opcode and sufficient size.
* Copies all Call attributes stored in the old node to the new node.
*/
static void
call_copy_attr(const ir_node *old_node, ir_node *new_node) {
default_copy_attr(old_node, new_node);
remove_Call_callee_arr(new_node);
}
} /* call_copy_attr */
/**
* Copies all Block attributes stored in the old node to the new node.
*/
static void
block_copy_attr(const ir_node *old_node, ir_node *new_node)
{
block_copy_attr(const ir_node *old_node, ir_node *new_node) {
default_copy_attr(old_node, new_node);
INIT_LIST_HEAD(&new_node->attr.block.succ_head);
}
} /* block_copy_attr */
/**
* Sets the default copy_attr operation for an ir_ops
......@@ -152,9 +154,8 @@ static ir_op_ops *firm_set_default_copy_attr(opcode code, ir_op_ops *ops) {
if (! ops->copy_attr)
ops->copy_attr = default_copy_attr;
}
return ops;
}
} /* firm_set_default_copy_attr */
/* Creates a new ir operation. */
ir_op *
......@@ -190,14 +191,14 @@ new_ir_op(opcode code, const char *name, op_pin_state p,
hook_new_ir_op(res);
return res;
}
} /* new_ir_op */
void free_ir_op(ir_op *code) {
hook_free_ir_op(code);
remove_irp_opcode(code);
free(code);
}
} /* free_ir_op */
void
init_op(void)
......@@ -281,6 +282,8 @@ init_op(void)
op_Raise = new_ir_op(iro_Raise, "Raise", op_pin_state_pinned, H|X, oparity_any, -1, 0, NULL);
op_Bound = new_ir_op(iro_Bound, "Bound", op_pin_state_exc_pinned, F|H, oparity_trinary, -1, sizeof(bound_attr), NULL);
op_Pin = new_ir_op(iro_Pin, "Pin", op_pin_state_pinned, H, oparity_unary, -1, 0, NULL);
#undef H
#undef Y
#undef F
......@@ -288,7 +291,7 @@ init_op(void)
#undef X
#undef C
#undef L
}
} /* init_op */
/* free memory used by irop module. */
......@@ -359,20 +362,22 @@ void finish_op(void) {
free_ir_op (op_InstOf ); op_InstOf = NULL;
free_ir_op (op_Raise ); op_Raise = NULL;
free_ir_op (op_Bound ); op_Bound = NULL;
free_ir_op (op_Pin ); op_Pin = NULL;
}
/* Returns the string for the opcode. */
const char *get_op_name (const ir_op *op) {
return get_id_str(op->name);
}
} /* get_op_name */
opcode (get_op_code)(const ir_op *op){
return _get_op_code(op);
}
} /* get_op_code */
ident *(get_op_ident)(const ir_op *op){
return _get_op_ident(op);
}
} /* get_op_ident */
const char *get_op_pin_state_name(op_pin_state s) {
switch(s) {
......@@ -383,43 +388,43 @@ const char *get_op_pin_state_name(op_pin_state s) {
XXX(op_pin_state_mem_pinned);
#undef XXX
}
return "<none>";
}
return "<none>";
} /* get_op_pin_state_name */
op_pin_state (get_op_pinned)(const ir_op *op) {
return _get_op_pinned(op);
}
} /* get_op_pinned */
/* 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 op_pin_state_pinned) {
if (op == op_Block || op == op_Phi || is_cfopcode(op)) return;
op->op_pin_state_pinned = op_pin_state_pinned;
}
} /* set_op_pinned */
/* retrieve the next free opcode */
unsigned get_next_ir_opcode(void) {
return next_iro++;
}
} /* get_next_ir_opcode */
/* Returns the next free n IR opcode number, allows to register a bunch of user ops */
unsigned get_next_ir_opcodes(unsigned num) {
unsigned base = next_iro;
next_iro += num;
return base;
}
} /* get_next_ir_opcodes */
/* 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);
}
} /* get_generic_function_ptr */
/* 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);
}
} /* set_generic_function_ptr */
/* Returns the ir_op_ops of an ir_op. */
const ir_op_ops *(get_op_ops)(const ir_op *op) {
return _get_op_ops(op);
}
} /* get_op_ops */
......@@ -53,16 +53,17 @@ typedef enum {
irop_flag_cfopcode = 0x00000004, /**< is a control flow operation */
irop_flag_ip_cfopcode = 0x00000008, /**< operation manipulates interprocedural control flow */
irop_flag_fragile = 0x00000010, /**< set if the operation can change the control flow because
of an exception */
of an exception */
irop_flag_forking = 0x00000020, /**< the operation is a forking control flow */
irop_flag_highlevel = 0x00000040, /**< the operation is a pure high-level one and can be
skipped in low-level optimizations */
irop_flag_constlike = 0x00000080, /**< the operation has no arguments and is some
kind of a constant */
irop_flag_keep = 0x00000100, /**< this operation can be kept in End's keep-alive list */
irop_flag_machine = 0x00000200, /**< this operation is a machine operation */
irop_flag_machine_op = 0x00000400, /**< this operation is a machine operand */
irop_flag_user = 0x00000800 /**< this flag and all higher one are free for machine user */
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_machine = 0x00000400, /**< this operation is a machine operation */
irop_flag_machine_op = 0x00000800, /**< this operation is a machine operand */
irop_flag_user = 0x00001000 /**< this flag and all higher one are free for machine user */
} irop_flags;
/** The opcodes of the libFirm predefined operations. */
......@@ -81,6 +82,7 @@ typedef enum {
iro_Unknown, iro_Filter, iro_Break, iro_CallBegin, iro_EndReg, iro_EndExcept,
iro_NoMem, iro_Mux, iro_Psi, iro_CopyB,
iro_InstOf, iro_Raise, iro_Bound,
iro_Pin,
iro_MaxOpcode
} opcode;
......@@ -157,6 +159,8 @@ extern ir_op *op_InstOf; ir_op *get_op_InstOf (void);
extern ir_op *op_Raise; ir_op *get_op_Raise (void);
extern ir_op *op_Bound; ir_op *get_op_Bound (void);
extern ir_op *op_Pin; ir_op *get_op_Pin (void);
/** Returns the ident for the opcode name */
ident *get_op_ident(const ir_op *op);
......
......@@ -101,6 +101,11 @@ static INLINE int is_op_constlike(const ir_op *op) {
return op->flags & irop_flag_constlike;
}
/** Returns non-zero if operation must always be optimized */
static INLINE int is_op_always_opt(const ir_op *op) {
return op->flags & irop_flag_always_opt;
}
/** Returns non-zero if operation is a keep-like op */
static INLINE int is_op_keep(const ir_op *op) {
return op->flags & irop_flag_keep;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment