X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firnode.c;h=f9957859d1491af88f50956342b7e1faeaff7b49;hb=4f92e524762e0febc361676111b3b5b79addd03a;hp=02e3e26e50c213a46ce356a7a7069f53bb4bc385;hpb=270f2356557d43d3e7ea36dacac46cd1e54a902d;p=libfirm diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index 02e3e26e5..f9957859d 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -43,6 +43,7 @@ #include "irhooks.h" #include "irtools.h" +#include "util.h" #include "beinfo.h" @@ -54,47 +55,43 @@ #define RETURN_RESULT_OFFSET 1 /* mem is not a result */ #define END_KEEPALIVE_OFFSET 0 -static const char *pnc_name_arr [] = { - "pn_Cmp_False", "pn_Cmp_Eq", "pn_Cmp_Lt", "pn_Cmp_Le", - "pn_Cmp_Gt", "pn_Cmp_Ge", "pn_Cmp_Lg", "pn_Cmp_Leg", - "pn_Cmp_Uo", "pn_Cmp_Ue", "pn_Cmp_Ul", "pn_Cmp_Ule", - "pn_Cmp_Ug", "pn_Cmp_Uge", "pn_Cmp_Ne", "pn_Cmp_True" +static const char *relation_names [] = { + "false", + "equal", + "less", + "less_equal", + "greater", + "greater_equal", + "less_greater", + "less_equal_greater", + "unordered", + "unordered_equal", + "unordered_less", + "unordered_less_equal", + "unordered_greater", + "unordered_greater_equal", + "not_equal", + "true" }; -/** - * returns the pnc name from an pnc constant - */ -const char *get_pnc_string(int pnc) +const char *get_relation_string(ir_relation relation) { - assert(pnc >= 0 && pnc < - (int) (sizeof(pnc_name_arr)/sizeof(pnc_name_arr[0]))); - return pnc_name_arr[pnc]; + assert(relation < (ir_relation)ARRAY_SIZE(relation_names)); + return relation_names[relation]; } -/* - * Calculates the negated (Complement(R)) pnc condition. - */ -pn_Cmp get_negated_pnc(long pnc, ir_mode *mode) +ir_relation get_negated_relation(ir_relation relation) { - pnc ^= pn_Cmp_True; - - /* do NOT add the Uo bit for non-floating point values */ - if (! mode_is_float(mode)) - pnc &= ~pn_Cmp_Uo; - - return (pn_Cmp) pnc; + return relation ^ ir_relation_true; } -/* Calculates the inversed (R^-1) pnc condition, i.e., "<" --> ">" */ -pn_Cmp get_inversed_pnc(long pnc) +ir_relation get_inversed_relation(ir_relation relation) { - long code = pnc & ~(pn_Cmp_Lt|pn_Cmp_Gt); - long lesser = pnc & pn_Cmp_Lt; - long greater = pnc & pn_Cmp_Gt; - - code |= (lesser ? pn_Cmp_Gt : 0) | (greater ? pn_Cmp_Lt : 0); - - return (pn_Cmp) code; + ir_relation code = relation & ~(ir_relation_less|ir_relation_greater); + bool less = relation & ir_relation_less; + bool greater = relation & ir_relation_greater; + code |= (less ? ir_relation_greater : 0) | (greater ? ir_relation_less : 0); + return code; } /** @@ -519,19 +516,6 @@ ir_type *is_frame_pointer(const ir_node *n) return NULL; } -/* Test whether arbitrary node is tls pointer, i.e. Proj(pn_Start_P_tls) - * from Start. If so returns tls type, else Null. */ -ir_type *is_tls_pointer(const ir_node *n) -{ - if (is_Proj(n) && (get_Proj_proj(n) == pn_Start_P_tls)) { - ir_node *start = get_Proj_pred(n); - if (is_Start(start)) { - return get_tls_type(); - } - } - return NULL; -} - ir_node **get_Block_cfgpred_arr(ir_node *node) { assert(is_Block(node)); @@ -968,15 +952,6 @@ void set_Sel_index(ir_node *node, int pos, ir_node *index) set_irn_n(node, pos + SEL_INDEX_OFFSET, index); } - -/* For unary and binary arithmetic operations the access to the - operands can be factored out. Left is the first, right the - second arithmetic value as listed in tech report 0999-33. - unops are: Minus, Abs, Not, Conv, Cast - binops are: Add, Sub, Mul, Quot, DivMod, Div, Mod, And, Or, Eor, Shl, - Shr, Shrs, Rotate, Cmp */ - - ir_node **get_Call_param_arr(ir_node *node) { assert(is_Call(node)); @@ -1057,19 +1032,19 @@ int Call_has_callees(const ir_node *node) (node->attr.call.callee_arr != NULL)); } -int get_Call_n_callees(const ir_node *node) +size_t get_Call_n_callees(const ir_node *node) { assert(is_Call(node) && node->attr.call.callee_arr); return ARR_LEN(node->attr.call.callee_arr); } -ir_entity *get_Call_callee(const ir_node *node, int pos) +ir_entity *get_Call_callee(const ir_node *node, size_t pos) { - assert(pos >= 0 && pos < get_Call_n_callees(node)); + assert(pos < get_Call_n_callees(node)); return node->attr.call.callee_arr[pos]; } -void set_Call_callee_arr(ir_node *node, const int n, ir_entity ** arr) +void set_Call_callee_arr(ir_node *node, size_t n, ir_entity ** arr) { ir_graph *irg = get_irn_irg(node); @@ -1273,55 +1248,6 @@ void set_memop_ptr(ir_node *node, ir_node *ptr) set_irn_n(node, 1, ptr); } -ir_volatility get_Load_volatility(const ir_node *node) -{ - assert(is_Load(node)); - return (ir_volatility)node->attr.load.volatility; -} - -void set_Load_volatility(ir_node *node, ir_volatility volatility) -{ - assert(is_Load(node)); - node->attr.load.volatility = volatility; -} - -ir_align get_Load_align(const ir_node *node) -{ - assert(is_Load(node)); - return (ir_align)node->attr.load.aligned; -} - -void set_Load_align(ir_node *node, ir_align align) -{ - assert(is_Load(node)); - node->attr.load.aligned = align; -} - - -ir_volatility get_Store_volatility(const ir_node *node) -{ - assert(is_Store(node)); - return (ir_volatility)node->attr.store.volatility; -} - -void set_Store_volatility(ir_node *node, ir_volatility volatility) -{ - assert(is_Store(node)); - node->attr.store.volatility = volatility; -} - -ir_align get_Store_align(const ir_node *node) -{ - assert(is_Store(node)); - return (ir_align)node->attr.store.aligned; -} - -void set_Store_align(ir_node *node, ir_align align) -{ - assert(is_Store(node)); - node->attr.store.aligned = align; -} - ir_node **get_Sync_preds_arr(ir_node *node) { @@ -1366,11 +1292,6 @@ int (is_arg_Proj)(const ir_node *node) return _is_arg_Proj(node); } -pn_Cmp (get_Proj_pn_cmp)(const ir_node *node) -{ - return _get_Proj_pn_cmp(node); -} - ir_node **get_Tuple_preds_arr(ir_node *node) { assert(is_Tuple(node)); @@ -1584,8 +1505,6 @@ ir_node *get_fragile_op_mem(ir_node *node) switch (get_irn_opcode(node)) { case iro_Call : - case iro_Quot : - case iro_DivMod: case iro_Div : case iro_Mod : case iro_Load : @@ -1602,19 +1521,6 @@ ir_node *get_fragile_op_mem(ir_node *node) } } -/* Returns the result mode of a Div operation. */ -ir_mode *get_divop_resmod(const ir_node *node) -{ - switch (get_irn_opcode(node)) { - case iro_Quot : return get_Quot_resmode(node); - case iro_DivMod: return get_DivMod_resmode(node); - case iro_Div : return get_Div_resmode(node); - case iro_Mod : return get_Mod_resmode(node); - default: - panic("should not be reached"); - } -} - /* Returns true if the operation is a forking control flow operation. */ int (is_irn_forking)(const ir_node *node) { @@ -1725,7 +1631,7 @@ static ir_type *get_Null_type(const ir_node *n) } /* Sets the get_type operation for an ir_op_ops. */ -ir_op_ops *firm_set_default_get_type_attr(ir_opcode code, ir_op_ops *ops) +ir_op_ops *firm_set_default_get_type_attr(unsigned code, ir_op_ops *ops) { switch (code) { case iro_SymConst: ops->get_type_attr = get_SymConst_attr_type; break; @@ -1750,7 +1656,7 @@ static ir_entity *get_Null_ent(const ir_node *n) } /* Sets the get_type operation for an ir_op_ops. */ -ir_op_ops *firm_set_default_get_entity_attr(ir_opcode code, ir_op_ops *ops) +ir_op_ops *firm_set_default_get_entity_attr(unsigned code, ir_op_ops *ops) { switch (code) { case iro_SymConst: ops->get_entity_attr = get_SymConst_attr_entity; break;