Commit d652537f authored by Moritz Kroll's avatar Moritz Kroll
Browse files

Renamed get_Cond_defaultProj() to get_Cond_default_proj() for consistency....

Renamed get_Cond_defaultProj() to get_Cond_default_proj() for consistency. Added set_Cond_default_proj() and get_cond_kind_name(). Made get_cond_jmp_predicate_name() consistent with other enum name functions.

[r25545]
parent 4ff92a60
......@@ -474,11 +474,15 @@ typedef enum {
Proj nodes mean default control flow, i.e., Proj(n). */
} cond_kind;
/** Gets the string representation of the Cond node kind. */
const char *get_cond_kind_name(cond_kind kind);
ir_node *get_Cond_selector(const ir_node *node);
void set_Cond_selector(ir_node *node, ir_node *selector);
cond_kind get_Cond_kind(const ir_node *node);
void set_Cond_kind(ir_node *node, cond_kind kind);
long get_Cond_defaultProj(const ir_node *node);
long get_Cond_default_proj(const ir_node *node);
void set_Cond_default_proj(ir_node *node, long defproj);
/**
* Projection numbers for conditions.
......@@ -1381,7 +1385,7 @@ typedef enum {
COND_JMP_PRED_FALSE /**< The False case is predicted. */
} cond_jmp_predicate;
/** Gets the string representation of the jump prediction .*/
/** Gets the string representation of the jump prediction. */
const char *get_cond_jmp_predicate_name(cond_jmp_predicate pred);
/** Returns the conditional jump prediction of a Cond node. */
......
......@@ -443,7 +443,7 @@ static void insert_Confirm_in_block(ir_node *block, void *env) {
long proj_nr = get_Proj_proj(proj);
/* this is a CASE, but we cannot handle the default case */
if (proj_nr == get_Cond_defaultProj(cond))
if (proj_nr == get_Cond_default_proj(cond))
return;
handle_case(block, get_Cond_selector(cond), proj_nr, env);
......
......@@ -977,7 +977,7 @@ static ir_node *gen_Cond(ir_node *node) {
const_graph = create_const_graph_value(dbg, block, translation);
sub = new_bd_arm_Sub(dbg, block, new_op, const_graph, mode, ARM_SHF_NONE, 0);
return new_bd_arm_SwitchJmp(dbg, block, sub, n_projs, get_Cond_defaultProj(node) - translation);
return new_bd_arm_SwitchJmp(dbg, block, sub, n_projs, get_Cond_default_proj(node) - translation);
}
}
......
......@@ -2600,7 +2600,7 @@ static ir_node *create_Switch(ir_node *node)
ir_node *new_sel = be_transform_node(sel);
long switch_min = LONG_MAX;
long switch_max = LONG_MIN;
long default_pn = get_Cond_defaultProj(node);
long default_pn = get_Cond_default_proj(node);
ir_node *new_node;
const ir_edge_t *edge;
......
......@@ -585,7 +585,7 @@ ir_node *gen_node_for_SwitchCond(mips_transform_env_t *env)
assert(get_mode_size_bits(selector_mode) == 32);
defaultproj = NULL;
defaultprojn = get_Cond_defaultProj(node);
defaultprojn = get_Cond_default_proj(node);
// go over all projs to find min-&maxval of the switch
minval = INT_MAX;
......
......@@ -921,7 +921,7 @@ static ir_node *gen_Cond(ppc32_transform_env_t *env) {
ir_node *switch_node = new_bd_ppc32_Switch(env->dbg, env->block, selector,
unknown_gpr, unknown_cond, env->mode);
set_ppc32_proj_nr(switch_node, get_Cond_defaultProj(env->irn));
set_ppc32_proj_nr(switch_node, get_Cond_default_proj(env->irn));
return switch_node;
}
......
......@@ -769,7 +769,7 @@ int dump_node_opcode(FILE *F, ir_node *n)
ir_node *pred = get_Proj_pred(n);
if (get_irn_opcode(pred) == iro_Cond
&& get_Proj_proj(n) == get_Cond_defaultProj(pred)
&& get_Proj_proj(n) == get_Cond_default_proj(pred)
&& get_irn_mode(get_Cond_selector(pred)) != mode_b)
fprintf(F, "defProj");
else
......
......@@ -244,7 +244,7 @@ int dump_irnode_to_file(FILE *F, ir_node *n) {
} break;
case iro_Cond: {
fprintf(F, " condition kind: %s\n", get_Cond_kind(n) == dense ? "dense" : "fragmentary");
fprintf(F, " default ProjNr: %ld\n", get_Cond_defaultProj(n));
fprintf(F, " default ProjNr: %ld\n", get_Cond_default_proj(n));
if (get_Cond_jmp_pred(n) != COND_JMP_PRED_NONE)
fprintf(F, " jump prediction: %s\n", get_cond_jmp_predicate_name(get_Cond_jmp_pred(n)));
} break;
......
......@@ -1006,6 +1006,18 @@ I don't want to choose 3) as 2a) seems to have advantages for
dataflow analysis and 3) does not allow to convert the representation to
2a).
*/
const char *get_cond_kind_name(cond_kind kind)
{
#define X(a) case a: return #a;
switch (kind) {
X(dense);
X(fragmentary);
}
return "<unknown>";
#undef X
}
ir_node *
get_Cond_selector(const ir_node *node) {
assert(is_Cond(node));
......@@ -1031,11 +1043,16 @@ set_Cond_kind(ir_node *node, cond_kind kind) {
}
long
get_Cond_defaultProj(const ir_node *node) {
get_Cond_default_proj(const ir_node *node) {
assert(is_Cond(node));
return node->attr.cond.default_proj;
}
void set_Cond_default_proj(ir_node *node, long defproj) {
assert(is_Cond(node));
node->attr.cond.default_proj = defproj;
}
ir_node *
get_Return_mem(const ir_node *node) {
assert(is_Return(node));
......@@ -3089,12 +3106,14 @@ int (is_irn_machine_user)(const ir_node *node, unsigned n) {
/* Gets the string representation of the jump prediction .*/
const char *get_cond_jmp_predicate_name(cond_jmp_predicate pred) {
#define X(a) case a: return #a;
switch (pred) {
default:
case COND_JMP_PRED_NONE: return "no prediction";
case COND_JMP_PRED_TRUE: return "true taken";
case COND_JMP_PRED_FALSE: return "false taken";
X(COND_JMP_PRED_NONE);
X(COND_JMP_PRED_TRUE);
X(COND_JMP_PRED_FALSE);
}
return "<unknown>";
#undef X
}
/* Returns the conditional jump prediction of a Cond node. */
......
......@@ -3954,7 +3954,7 @@ static ir_node *transform_node_Proj_Cond(ir_node *proj) {
/* we have a constant switch */
long num = get_Proj_proj(proj);
if (num != get_Cond_defaultProj(n)) { /* we cannot optimize default Proj's yet */
if (num != get_Cond_default_proj(n)) { /* we cannot optimize default Proj's yet */
if (get_tarval_long(tb) == num) {
/* Do NOT create a jump here, or we will have 2 control flow ops
* in a block. This case is optimized away in optimize_cf(). */
......
......@@ -73,7 +73,7 @@ static int should_do_table_switch(ir_node *cond, unsigned spare_size)
if (get_irn_n_outs(cond) <= 4)
return 0;
default_pn = get_Cond_defaultProj(cond);
default_pn = get_Cond_default_proj(cond);
foreach_out_irn(cond, i, proj) {
long pn = get_Proj_proj(proj);
......@@ -216,7 +216,7 @@ static void find_cond_nodes(ir_node *block, void *ctx)
numcases = get_irn_n_outs(cond) - 1; // does not contain default case
NEW_ARR_A(case_data_t, cases, numcases);
default_pn = get_Cond_defaultProj(cond);
default_pn = get_Cond_default_proj(cond);
ifcas_env.sel = sel;
ifcas_env.defindex = 0;
NEW_ARR_A(ir_node*, ifcas_env.defusers, numcases);
......
......@@ -625,7 +625,7 @@ static int handle_switch_cond(ir_node *cond) {
if (proj2 == NULL) {
/* this Cond has only one Proj: must be the defProj */
assert(get_Cond_defaultProj(cond) == get_Proj_proj(proj1));
assert(get_Cond_default_proj(cond) == get_Proj_proj(proj1));
/* convert it into a Jmp */
jmp = new_r_Jmp(current_ir_graph, blk);
exchange(proj1, jmp);
......@@ -638,7 +638,7 @@ static int handle_switch_cond(ir_node *cond) {
if (tv != tarval_bad) {
/* we have a constant switch */
long num = get_tarval_long(tv);
long def_num = get_Cond_defaultProj(cond);
long def_num = get_Cond_default_proj(cond);
if (def_num == get_Proj_proj(proj1)) {
/* first one is the defProj */
......
......@@ -2376,7 +2376,7 @@ static void compute_Proj_Cond(node_t *node, ir_node *cond) {
node->type.tv = tarval_reachable;
} else if (selector->type.tv == tarval_top) {
if (tarval_UNKNOWN == tarval_top &&
pnc == get_Cond_defaultProj(cond)) {
pnc == get_Cond_default_proj(cond)) {
/* a switch based of Top is always "default" */
node->type.tv = tarval_reachable;
} else {
......@@ -2384,7 +2384,7 @@ static void compute_Proj_Cond(node_t *node, ir_node *cond) {
}
} else {
long value = get_tarval_long(selector->type.tv);
if (pnc == get_Cond_defaultProj(cond)) {
if (pnc == get_Cond_default_proj(cond)) {
/* default switch, have to check ALL other cases */
int i;
......
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