Commit 413b6b9c authored by Michael Beck's avatar Michael Beck
Browse files

- More restructureation:

 - add new operations computed_value_Proj() and equivalent_node_Proj()
 - computed_value_func() uses now const ir_node *
 - removed some old code

[r20950]
parent a6a29ed6
......@@ -578,7 +578,7 @@ symconst_kind get_SymConst_kind(const ir_node *node);
void set_SymConst_kind(ir_node *node, symconst_kind num);
/** Only to access SymConst of kind type_tag or size. Else assertion: */
ir_type *get_SymConst_type(ir_node *node);
ir_type *get_SymConst_type(const ir_node *node);
void set_SymConst_type(ir_node *node, ir_type *tp);
/** Only to access SymConst of kind addr_name. Else assertion: */
......@@ -1244,6 +1244,7 @@ ir_node *skip_Id(ir_node *node); /* Old name is skip_nop(). */
ir_node *skip_Tuple(ir_node *node);
/** returns operand of node if node is a Cast. */
ir_node *skip_Cast(ir_node *node);
const ir_node *skip_Cast_const(const ir_node *node);
/** Returns operand of node if node is a Confirm */
ir_node *skip_Confirm(ir_node *node);
/** Skip all high-level Operations (including Cast, Confirm). */
......
......@@ -268,7 +268,7 @@ typedef unsigned (*hash_func)(const ir_node *self);
* This operation evaluates an IR node into a tarval if possible,
* returning tarval_bad otherwise.
*/
typedef tarval *(*computed_value_func)(ir_node *self);
typedef tarval *(*computed_value_func)(const ir_node *self);
/**
* The equivalent node operation.
......@@ -371,21 +371,24 @@ typedef int (*dump_node_func)(ir_node *self, FILE *F, dump_reason_t reason);
* io_op Operations.
*/
typedef struct {
hash_func hash; /**< Calculate a hash value for an IR node. */
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. */
reassociate_func reassociate; /**< Reassociate a tree. */
copy_attr_func copy_attr; /**< Copy node attributes. */
get_type_func get_type; /**< Return the type of a node. */
get_type_attr_func get_type_attr; /**< Return the type attribute of a node. */
get_entity_attr_func get_entity_attr; /**< Return the entity attribute of a node. */
verify_node_func verify_node; /**< Verify the node. */
verify_proj_node_func verify_proj_node; /**< Verify the Proj node. */
dump_node_func dump_node; /**< Dump a node. */
op_func generic; /**< A generic function pointer. */
const arch_irn_ops_t *be_ops; /**< callbacks used by the backend. */
hash_func hash; /**< Calculate a hash value for an IR node. */
computed_value_func computed_value; /**< Evaluates a node into a tarval if possible. */
computed_value_func computed_value_Proj; /**< Evaluates a Proj node into a tarval if possible. */
equivalent_node_func equivalent_node; /**< Optimizes the node by returning an equivalent one. */
equivalent_node_func equivalent_node_Proj; /**< Optimizes the Proj node by returning an equivalent one. */
transform_node_func transform_node; /**< Optimizes the node by transforming it. */
equivalent_node_func transform_node_Proj; /**< Optimizes the Proj node by transforming it. */
node_cmp_attr_func node_cmp_attr; /**< Compares two node attributes. */
reassociate_func reassociate; /**< Reassociate a tree. */
copy_attr_func copy_attr; /**< Copy node attributes. */
get_type_func get_type; /**< Return the type of a node. */
get_type_attr_func get_type_attr; /**< Return the type attribute of a node. */
get_entity_attr_func get_entity_attr; /**< Return the entity attribute of a node. */
verify_node_func verify_node; /**< Verify the node. */
verify_proj_node_func verify_proj_node; /**< Verify the Proj node. */
dump_node_func dump_node; /**< Dump a node. */
op_func generic; /**< A generic function pointer. */
const arch_irn_ops_t *be_ops; /**< callbacks used by the backend. */
} ir_op_ops;
/**
......
......@@ -78,7 +78,7 @@ typedef enum _fp_model_t {
/** If the expression referenced can be evaluated statically
* computed_value returns a tarval representing the result.
* Else returns tarval_bad. */
tarval *computed_value(ir_node *n);
tarval *computed_value(const ir_node *n);
/** Applies all optimizations to n that are expressible as a pattern
* in Firm, i.e., they need not a walk of the graph.
......
......@@ -1684,6 +1684,9 @@ static const ir_op_ops be_node_op_ops = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
copy_attr,
NULL,
NULL,
......
......@@ -1146,10 +1146,13 @@ set_SymConst_kind(ir_node *node, symconst_kind kind) {
}
ir_type *
get_SymConst_type(ir_node *node) {
get_SymConst_type(const ir_node *node) {
/* the cast here is annoying, but we have to compensate for
the skip_tip() */
ir_node *irn = (ir_node *)node;
assert(is_SymConst(node) &&
(SYMCONST_HAS_TYPE(get_SymConst_kind(node))));
return node->attr.symc.sym.type_p = skip_tid(node->attr.symc.sym.type_p);
return irn->attr.symc.sym.type_p = skip_tid(irn->attr.symc.sym.type_p);
}
void
......@@ -2582,7 +2585,14 @@ restart:
/* returns operand of node if node is a Cast */
ir_node *skip_Cast(ir_node *node) {
if (get_irn_op(node) == op_Cast)
if (is_Cast(node))
return get_Cast_op(node);
return node;
}
/* returns operand of node if node is a Cast */
const ir_node *skip_Cast_const(const ir_node *node) {
if (is_Cast(node))
return get_Cast_op(node);
return node;
}
......
This diff is collapsed.
......@@ -97,7 +97,7 @@ static tarval *compare_iv_dbg(const interval_t *l_iv, const interval_t *r_iv, pn
* This is a often needed case, so we handle here Confirm
* nodes too.
*/
int value_not_zero(ir_node *n, ir_node **confirm) {
int value_not_zero(const ir_node *n, ir_node_cnst_ptr *confirm) {
#define RET_ON(x) if (x) { *confirm = n; return 1; }; break
tarval *tv;
......@@ -175,11 +175,11 @@ int value_not_zero(ir_node *n, ir_node **confirm) {
* - A SymConst(entity) is NEVER a NULL pointer
* - Confirms are evaluated
*/
int value_not_null(ir_node *n, ir_node **confirm) {
int value_not_null(const ir_node *n, ir_node_cnst_ptr *confirm) {
tarval *tv;
*confirm = NULL;
n = skip_Cast(n);
n = skip_Cast_const(n);
tv = value_of(n);
if (tarval_is_constant(tv) && ! tarval_is_null(tv))
......
......@@ -32,6 +32,9 @@
#include "firm_types.h"
/** Needed for MSVC to suporess warnings because it doest NOT handle const right. */
typedef const ir_node *ir_node_cnst_ptr;
/**
* Check, if the value of a node is != 0.
*
......@@ -42,7 +45,7 @@
* @param confirm if n is confirmed to be != 0, returns
* the the Confirm-node, else NULL
*/
int value_not_zero(ir_node *n, ir_node **confirm);
int value_not_zero(const ir_node *n, ir_node_cnst_ptr *confirm);
/**
* Check, if the value of a node cannot represent a NULL pointer.
......@@ -57,7 +60,7 @@ int value_not_zero(ir_node *n, ir_node **confirm);
* @param confirm if n is confirmed to be != NULL, returns
* the the Confirm-node, else NULL
*/
int value_not_null(ir_node *n, ir_node **confirm);
int value_not_null(const ir_node *n, ir_node_cnst_ptr *confirm);
/**
* Possible return values of value_classify().
......
Markdown is supported
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