/*
- * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
- *
* This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
+ * Copyright (C) 2012 University of Karlsruhe.
*/
/**
*/
#include "config.h"
+#include "irnode_t.h"
#include "irprog.h"
#include "irop_t.h"
#include "irgraph_t.h"
if (ent) {
ir_type *ent_type = get_entity_owner(ent);
-
- if (ent_type) {
- ir_fprintf(stderr, "\nFIRM: irn_verify_irg() %+F::%s failed\n",
- ent_type, get_entity_name(ent));
- } else {
- fprintf(stderr, "\nFIRM: irn_verify_irg() <NULL>::%s failed\n", get_entity_name(ent));
- }
+ ir_fprintf(stderr, "\nFIRM: irn_verify_irg() %+F::%s failed\n", ent_type, get_entity_name(ent));
} else {
fprintf(stderr, "\nFIRM: irn_verify_irg() <IRG %p> failed\n", (void *)irg);
}
*/
static int verify_node_Proj_Proj(const ir_node *p)
{
- ir_mode *mode = get_irn_mode(p);
- ir_node *pred = get_Proj_pred(p);
- long proj = get_Proj_proj(p);
- long nr = get_Proj_proj(pred);
- ir_type *mt; /* A method type */
+ ir_mode *mode = get_irn_mode(p);
+ ir_node *pred = get_Proj_pred(p);
+ ir_node *predpred = get_Proj_pred(pred);
+ long proj = get_Proj_proj(p);
+ long nr = get_Proj_proj(pred);
- pred = skip_Id(get_Proj_pred(pred));
- ASSERT_AND_RET((get_irn_mode(pred) == mode_T), "Proj from something not a tuple", 0);
-
- switch (get_irn_opcode(pred)) {
- case iro_Start:
- mt = get_entity_type(get_irg_entity(get_irn_irg(pred)));
+ switch (get_irn_opcode(predpred)) {
+ case iro_Start: {
+ ir_graph *irg = get_irn_irg(p);
+ ir_type *mt = get_entity_type(get_irg_entity(irg));
if (nr == pn_Start_T_args) {
ASSERT_AND_RET(
(proj < (int)get_method_n_params(mt)),
"More Projs for args than args in type", 0
);
- if ((mode_is_reference(mode)) && is_compound_type(get_method_param_type(mt, proj)))
- /* value argument */ break;
-
- if (!irg_is_constrained(get_irn_irg(pred), IR_GRAPH_CONSTRAINT_BACKEND)) {
+ ir_type *param_type = get_method_param_type(mt, proj);
+ if (!irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_BACKEND)) {
ASSERT_AND_RET_DBG(
- (mode == get_type_mode(get_method_param_type(mt, proj))),
+ (mode == get_type_mode(param_type)),
"Mode of Proj from Start doesn't match mode of param type.", 0,
show_proj_mode_failure(p, get_method_param_type(mt, proj));
);
}
}
break;
+ }
- case iro_Call:
- {
- ASSERT_AND_RET(
- (proj >= 0 && mode_is_datab(mode)),
- "wrong Proj from Proj from Call", 0);
- mt = get_Call_type(pred);
- ASSERT_AND_RET(is_unknown_type(mt) || is_Method_type(mt),
- "wrong call type on call", 0);
- ASSERT_AND_RET(
- (proj < (int)get_method_n_ress(mt)),
- "More Projs for results than results in type.", 0);
- if ((mode_is_reference(mode)) && is_compound_type(get_method_res_type(mt, proj)))
- /* value result */ break;
-
- ASSERT_AND_RET(
- (mode == get_type_mode(get_method_res_type(mt, proj))),
- "Mode of Proj from Call doesn't match mode of result type.", 0);
- }
+ case iro_Call: {
+ ASSERT_AND_RET(
+ (proj >= 0 && mode_is_datab(mode)),
+ "wrong Proj from Proj from Call", 0);
+ ir_type *mt = get_Call_type(predpred);
+ ASSERT_AND_RET(is_unknown_type(mt) || is_Method_type(mt),
+ "wrong call type on call", 0);
+ ASSERT_AND_RET(
+ (proj < (int)get_method_n_ress(mt)),
+ "More Projs for results than results in type.", 0);
+ ir_type *res_type = get_method_res_type(mt, proj);
+ /* value result */
+ if ((mode_is_reference(mode)) &&
+ (is_compound_type(res_type) || is_Array_type(res_type)))
+ break;
+
+ ASSERT_AND_RET(
+ (mode == get_type_mode(get_method_res_type(mt, proj))),
+ "Mode of Proj from Call doesn't match mode of result type.", 0);
break;
+ }
case iro_Tuple:
/* We don't test */
return 1;
}
-/**
- * verify a Proj(Bound) node
- */
-static int verify_node_Proj_Bound(const ir_node *p)
-{
- ir_mode *mode = get_irn_mode(p);
- ir_node *n = get_Proj_pred(p);
- long proj = get_Proj_proj(p);
-
- ASSERT_AND_RET_DBG(
- (
- (proj == pn_Bound_M && mode == mode_M) ||
- (proj == pn_Bound_X_regular && mode == mode_X) ||
- (proj == pn_Bound_X_except && mode == mode_X) ||
- (proj == pn_Bound_res && mode == get_irn_mode(get_Bound_index(n)))
- ),
- "wrong Proj from Bound", 0,
- show_proj_failure(p);
- );
- return 1;
-}
-
static int verify_node_Proj_fragile(const ir_node *node)
{
ir_node *pred = get_Proj_pred(node);
ASSERT_AND_RET( mymode == mode_X, "Result X", 0 ); /* result X */
/* Compare returned results with result types of method type */
mt = get_entity_type(get_irg_entity(irg));
- ASSERT_AND_RET_DBG(get_Return_n_ress(n) == get_method_n_ress(mt),
+ ASSERT_AND_RET_DBG((size_t)get_Return_n_ress(n) == get_method_n_ress(mt),
"Number of results for Return doesn't match number of results in type.", 0,
show_return_nres(irg, n, mt););
for (i = get_Return_n_ress(n) - 1; i >= 0; --i) {
/* SymConst: BB --> ref */
mode_is_reference(mymode))
,"SymConst node", 0);
+ if (SYMCONST_HAS_ENT(get_SymConst_kind(n))) {
+ ir_entity *ent = get_SymConst_entity(n);
+ /* the is_method_entity(ent) exception is for nested functions... */
+ ASSERT_AND_RET_DBG((get_entity_owner(ent)->flags & tf_segment)
+ || is_method_entity(ent),
+ "SymConst node with non-segment entity", 0,
+ show_node_failure(n););
+ }
return 1;
}
}
ent = get_Sel_entity(n);
ASSERT_AND_RET_DBG(ent, "Sel node with empty entity", 0, show_node_failure(n););
+ ASSERT_AND_RET_DBG(!(get_entity_owner(ent)->flags & tf_segment),
+ "Sel node with global entity", 0, show_node_failure(n););
return 1;
}
return 1;
}
-/**
- * verify a Cast node
- */
-static int verify_node_Cast(const ir_node *n)
-{
- ir_mode *mymode = get_irn_mode(n);
- ir_mode *op1mode = get_irn_mode(get_Cast_op(n));
-
- ASSERT_AND_RET_DBG(
- /* Conv: BB x datab1 --> datab2 */
- mode_is_data(op1mode) && op1mode == mymode,
- "Cast node", 0,
- show_unop_failure(n, "/* Conv: BB x datab1 --> datab2 */");
- );
- return 1;
-}
-
/**
* verify a Phi node
*/
return 1;
}
-/**
- * verify a Bound node
- */
-static int verify_node_Bound(const ir_node *n)
-{
- ir_mode *mymode = get_irn_mode(n);
- ir_mode *op1mode = get_irn_mode(get_Bound_mem(n));
- ir_mode *op2mode = get_irn_mode(get_Bound_index(n));
- ir_mode *op3mode = get_irn_mode(get_Bound_lower(n));
- ir_mode *op4mode = get_irn_mode(get_Bound_upper(n));
-
- /* Bound: BB x M x int x int x int --> M x X */
- ASSERT_AND_RET(
- mymode == mode_T &&
- op1mode == mode_M &&
- op2mode == op3mode &&
- op3mode == op4mode &&
- mode_is_int(op3mode),
- "Bound node", 0 );
- return 1;
-}
-
/**
* Check dominance.
* For each usage of a node, it is checked, if the block of the
);
}
+ ASSERT_AND_RET_DBG(
+ !is_irn_start_block_placed(n) || get_nodes_block(n) == get_irg_start_block(irg),
+ "node should be in start block", 0,
+ ir_printf("node %+F", n);
+ );
+
if (op->ops.verify_node)
return op->ops.verify_node(n);
register_verify_node_func(op_Alloc, verify_node_Alloc);
register_verify_node_func(op_And, verify_node_And);
register_verify_node_func(op_Block, verify_node_Block);
- register_verify_node_func(op_Bound, verify_node_Bound);
register_verify_node_func(op_Call, verify_node_Call);
- register_verify_node_func(op_Cast, verify_node_Cast);
register_verify_node_func(op_Cmp, verify_node_Cmp);
register_verify_node_func(op_Cond, verify_node_Cond);
register_verify_node_func(op_Confirm, verify_node_Confirm);
register_verify_node_func(op_Sync, verify_node_Sync);
register_verify_node_func_proj(op_Alloc, verify_node_Proj_Alloc);
- register_verify_node_func_proj(op_Bound, verify_node_Proj_Bound);
register_verify_node_func_proj(op_Call, verify_node_Proj_Call);
register_verify_node_func_proj(op_Cond, verify_node_Proj_Cond);
register_verify_node_func_proj(op_CopyB, verify_node_Proj_CopyB);