Commit 1783354d authored by Christoph Mallon's avatar Christoph Mallon
Browse files

irnode: Add and use get_Const_long().

parent e05b47f9
......@@ -428,10 +428,8 @@ check_classes:;
ir_entity *entity2 = get_Member_entity(base2);
return entity1 != entity2 ? ir_no_alias : ir_may_alias;
} else if (class1 == ir_sc_globaladdr) {
ir_tarval *tv = get_Const_tarval(base1);
offset1 += get_tarval_long(tv);
tv = get_Const_tarval(base2);
offset2 += get_tarval_long(tv);
offset1 += get_Const_long(base1);
offset2 += get_Const_long(base2);
unsigned type_size = MAX(size1, size2);
if ((unsigned long)labs(offset2 - offset1) >= type_size)
......
......@@ -859,7 +859,7 @@ static ir_node *gen_shift_binop(ir_node *node, ir_node *op1, ir_node *op2,
attr.base.op_mode = AMD64_OP_SHIFT_IMM;
reqs = reg_reqs;
out_req0 = &amd64_requirement_gp_same_0;
attr.immediate = get_tarval_long(get_Const_tarval(op2));
attr.immediate = get_Const_long(op2);
} else {
attr.base.op_mode = AMD64_OP_SHIFT_REG;
in[arity++] = be_transform_node(op2);
......
......@@ -307,7 +307,7 @@ static bool try_encode_as_immediate(const ir_node *node, arm_immediate_t *res)
if (!is_Const(node))
return false;
uint32_t val = get_tarval_long(get_Const_tarval(node));
uint32_t val = get_Const_long(node);
if (val == 0) {
res->imm_8 = 0;
......@@ -1031,9 +1031,7 @@ static ir_node *make_shift(ir_node *node, match_flags_t flags,
ir_node *new_op1 = be_transform_node(op1);
if (is_Const(op2)) {
ir_tarval *tv = get_Const_tarval(op2);
unsigned int val = get_tarval_long(tv);
assert(tarval_is_long(tv));
unsigned int const val = get_Const_long(op2);
if (can_use_shift_constant(val, shift_modifier)) {
switch (shift_modifier) {
case ARM_SHF_LSL_REG: shift_modifier = ARM_SHF_LSL_IMM; break;
......
......@@ -162,9 +162,8 @@ static void link_ops_in_block_walker(ir_node *node, void *data)
break;
case iro_Builtin:
if (get_Builtin_kind(node) == ir_bk_return_address) {
ir_node *param = get_Builtin_param(node, 0);
ir_tarval *tv = get_Const_tarval(param); /* must be Const */
long value = get_tarval_long(tv);
ir_node *const param = get_Builtin_param(node, 0);
long const value = get_Const_long(param); /* must be Const */
if (value > 0) {
/* not the return address of the current function:
* we need the stack pointer for the frame climbing */
......
......@@ -428,8 +428,7 @@ static bool shr_upper_bits_clean(const ir_node *node, ir_mode *mode)
} else {
const ir_node *right = get_Shr_right(node);
if (is_Const(right)) {
ir_tarval *tv = get_Const_tarval(right);
long val = get_tarval_long(tv);
long const val = get_Const_long(right);
if (val >= 32 - (long)get_mode_size_bits(mode))
return true;
}
......@@ -444,8 +443,7 @@ static bool shrs_upper_bits_clean(const ir_node *node, ir_mode *mode)
static bool const_upper_bits_clean(const ir_node *node, ir_mode *mode)
{
ir_tarval *tv = get_Const_tarval(node);
long val = get_tarval_long(tv);
long const val = get_Const_long(node);
if (mode_is_signed(mode)) {
long shifted = val >> (get_mode_size_bits(mode)-1);
return shifted == 0 || shifted == -1;
......
......@@ -1332,13 +1332,9 @@ static ir_node *gen_64bit_shifts(dbg_info *dbgi, ir_node *block,
static bool is_complementary_shifts(ir_node *value1, ir_node *value2)
{
if (is_Const(value1) && is_Const(value2)) {
ir_tarval *tv1 = get_Const_tarval(value1);
ir_tarval *tv2 = get_Const_tarval(value2);
if (tarval_is_long(tv1) && tarval_is_long(tv2)) {
long v1 = get_tarval_long(tv1);
long v2 = get_tarval_long(tv2);
return v1 <= v2 && v2 == 32-v1;
}
long const v1 = get_Const_long(value1);
long const v2 = get_Const_long(value2);
return v1 <= v2 && v2 == 32 - v1;
}
return false;
}
......@@ -1582,9 +1578,7 @@ static ir_node *gen_And(ir_node *node)
/* is it a zero extension? */
if (is_Const(op2)) {
ir_tarval *tv = get_Const_tarval(op2);
long v = get_tarval_long(tv);
long const v = get_Const_long(op2);
if (v == 0xFF || v == 0xFFFF) {
ir_mode *src_mode;
if (v == 0xFF) {
......@@ -1905,8 +1899,7 @@ static ir_node *gen_Shrs(ir_node *node)
ir_node *right = get_Shrs_right(node);
if (is_Const(right)) {
ir_tarval *tv = get_Const_tarval(right);
long val = get_tarval_long(tv);
long const val = get_Const_long(right);
if (val == 31 && get_irn_n_edges(left) > 1) {
/* this is a sign extension */
dbg_info *dbgi = get_irn_dbg_info(node);
......@@ -5169,8 +5162,7 @@ static ir_node *gen_return_address(ir_node *node)
ir_node *block = be_transform_node(get_nodes_block(node));
ir_graph *irg = get_irn_irg(node);
ir_node *ptr = get_irg_frame(irg);
ir_tarval *tv = get_Const_tarval(param);
unsigned long value = get_tarval_long(tv);
unsigned long value = get_Const_long(param);
if (value > 0) {
ir_node *const cfr = new_bd_ia32_ClimbFrame(dbgi, block, ptr, value);
ptr = new_r_Proj(cfr, ia32_mode_gp, pn_ia32_ClimbFrame_res);
......@@ -5205,11 +5197,10 @@ static ir_node *gen_frame_address(ir_node *node)
{
ir_node *param = get_Builtin_param(node, 0);
dbg_info *dbgi = get_irn_dbg_info(node);
ir_tarval *tv = get_Const_tarval(param);
ir_graph *irg = get_irn_irg(node);
ir_node *block = be_transform_node(get_nodes_block(node));
ir_node *ptr = get_irg_frame(irg);
unsigned long value = get_tarval_long(tv);
unsigned long value = get_Const_long(param);
if (value > 0) {
ir_node *const cfr = new_bd_ia32_ClimbFrame(dbgi, block, ptr, value);
ptr = new_r_Proj(cfr, ia32_mode_gp, pn_ia32_ClimbFrame_res);
......@@ -5253,9 +5244,8 @@ static ir_node *gen_prefetch(ir_node *node)
return be_transform_node(get_Builtin_mem(node));
}
ir_node *param = get_Builtin_param(node, 1);
ir_tarval *tv = get_Const_tarval(param);
long rw = get_tarval_long(tv);
ir_node *const param = get_Builtin_param(node, 1);
long const rw = get_Const_long(param);
/* construct load address */
ir_node *ptr = get_Builtin_param(node, 0);
......@@ -5273,9 +5263,8 @@ static ir_node *gen_prefetch(ir_node *node)
new_node = new_bd_ia32_PrefetchW(dbgi, block, base, idx, mem);
} else if (ia32_cg_config.use_sse_prefetch) {
/* note: rw == 1 is IGNORED in that case */
ir_node *param = get_Builtin_param(node, 2);
ir_tarval *tv = get_Const_tarval(param);
long locality = get_tarval_long(tv);
ir_node *const param = get_Builtin_param(node, 2);
long const locality = get_Const_long(param);
/* SSE style prefetch */
switch (locality) {
......
......@@ -115,8 +115,7 @@ static void eat_immediate(x86_address_t *addr, ir_node *node, bool negate)
switch (get_irn_opcode(node)) {
case iro_Const: {
/* simply add the value to the offset */
ir_tarval *tv = get_Const_tarval(node);
long val = get_tarval_long(tv);
long const val = get_Const_long(node);
if (negate) {
addr->offset -= val;
} else {
......
......@@ -175,7 +175,7 @@ static bool is_imm_encodeable(const ir_node *node)
if (!is_Const(node))
return false;
long value = get_tarval_long(get_Const_tarval(node));
long const value = get_Const_long(node);
return sparc_is_value_imm_encodeable(value);
}
......@@ -495,7 +495,7 @@ static ir_node *gen_ASM(ir_node *node)
if (imm_type == 'I') {
if (is_imm_encodeable(pred)) {
operand->kind = ASM_OPERAND_IMMEDIATE;
operand->immediate_value = get_tarval_long(get_Const_tarval(pred));
operand->immediate_value = get_Const_long(pred);
continue;
}
} else if (imm_type == 'A') {
......@@ -506,7 +506,7 @@ static ir_node *gen_ASM(ir_node *node)
continue;
} else if (is_Const(pred)) {
operand->kind = ASM_OPERAND_IMMEDIATE;
operand->immediate_value = get_tarval_long(get_Const_tarval(pred));
operand->immediate_value = get_Const_long(pred);
continue;
}
}
......@@ -635,8 +635,8 @@ static ir_node *gen_helper_binop_args(ir_node *node,
assert(get_mode_size_bits(mode2) <= 32);
if (is_imm_encodeable(op2)) {
int32_t immediate = get_tarval_long(get_Const_tarval(op2));
ir_node *new_op1 = gen_helper_binop_left(op1, dbgi, block, flags);
int32_t const immediate = get_Const_long(op2);
ir_node *const new_op1 = gen_helper_binop_left(op1, dbgi, block, flags);
return new_imm(dbgi, block, new_op1, NULL, immediate);
}
ir_node *new_op2 = be_transform_node(op2);
......@@ -645,7 +645,7 @@ static ir_node *gen_helper_binop_args(ir_node *node,
}
if ((flags & MATCH_COMMUTATIVE) && is_imm_encodeable(op1)) {
int32_t immediate = get_tarval_long(get_Const_tarval(op1));
int32_t const immediate = get_Const_long(op1);
return new_imm(dbgi, block, new_op2, NULL, immediate);
}
......@@ -714,13 +714,13 @@ static ir_node *gen_helper_binopx(ir_node *node, match_flags_t match_flags,
assert(match_flags & MATCH_MODE_NEUTRAL);
if (is_imm_encodeable(op2)) {
int32_t immediate = get_tarval_long(get_Const_tarval(op2));
ir_node *new_op1 = be_transform_node(op1);
int32_t const immediate = get_Const_long(op2);
ir_node *const new_op1 = be_transform_node(op1);
return new_binopx_imm(dbgi, block, new_op1, new_flags, NULL, immediate);
}
ir_node *new_op2 = be_transform_node(op2);
if ((match_flags & MATCH_COMMUTATIVE) && is_imm_encodeable(op1)) {
int32_t immediate = get_tarval_long(get_Const_tarval(op1));
int32_t const immediate = get_Const_long(op1);
return new_binopx_imm(dbgi, block, new_op2, new_flags, NULL, immediate);
}
ir_node *new_op1 = be_transform_node(op1);
......@@ -781,7 +781,7 @@ static void match_address(ir_node *ptr, address_t *address, bool use_ptr2)
ir_node *add_right = get_Add_right(base);
if (is_Const(add_right)) {
base = get_Add_left(base);
offset += get_tarval_long(get_Const_tarval(add_right));
offset += get_Const_long(add_right);
}
}
/* Note that we don't match sub(x, Const) or chains of adds/subs
......@@ -879,8 +879,7 @@ static ir_node *gen_Add(ir_node *node)
address.entity, address.offset);
}
ir_tarval *tv = get_Const_tarval(right);
uint32_t val = get_tarval_long(tv);
uint32_t const val = get_Const_long(right);
if (val == 0x1000) {
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *block = be_transform_node(get_nodes_block(node));
......@@ -1192,7 +1191,7 @@ static ir_node *gen_Div(ir_node *node)
ir_node *left_high = gen_sign_extension_value(left);
if (is_imm_encodeable(right)) {
int32_t immediate = get_tarval_long(get_Const_tarval(right));
int32_t const immediate = get_Const_long(right);
res = new_bd_sparc_SDiv_imm(dbgi, new_block, new_mem, left_high, left_low,
NULL, immediate);
} else {
......@@ -1204,7 +1203,7 @@ static ir_node *gen_Div(ir_node *node)
ir_graph *irg = get_irn_irg(node);
ir_node *left_high = get_g0(irg);
if (is_imm_encodeable(right)) {
int32_t immediate = get_tarval_long(get_Const_tarval(right));
int32_t const immediate = get_Const_long(right);
res = new_bd_sparc_UDiv_imm(dbgi, new_block, new_mem, left_high, left_low,
NULL, immediate);
} else {
......@@ -1258,8 +1257,7 @@ static ir_node *gen_helper_bitop(ir_node *node,
new_not_reg, new_not_imm);
}
if (is_Const(op2) && get_irn_n_edges(op2) == 1) {
ir_tarval *tv = get_Const_tarval(op2);
long value = get_tarval_long(tv);
long const value = get_Const_long(op2);
if (!sparc_is_value_imm_encodeable(value)) {
long notvalue = ~value;
if ((notvalue & 0x3ff) == 0) {
......@@ -2223,9 +2221,7 @@ static ir_node *gen_Alloc(ir_node *node)
ir_node *subsp;
if (is_Const(size)) {
ir_tarval *tv = get_Const_tarval(size);
long sizel = get_tarval_long(tv);
long const sizel = get_Const_long(size);
assert((sizel & (SPARC_STACK_ALIGNMENT - 1)) == 0 && "Found Alloc with misaligned constant");
subsp = new_bd_sparc_SubSP_imm(dbgi, new_block, stack_pred, new_mem, NULL, sizel);
} else {
......
......@@ -709,7 +709,7 @@ void dump_type_to_file(FILE *const F, const ir_type *const tp)
fprintf(F, "[");
const ir_node *size = get_array_size(tp);
if (is_Const(size)) {
fprintf(F, "%ld", get_tarval_long(get_Const_tarval(size)));
fprintf(F, "%ld", get_Const_long(size));
} else {
dump_node_opcode(F, size);
fprintf(F, " %ld", get_irn_node_nr(size));
......
......@@ -612,7 +612,7 @@ static void write_type_array(write_env_t *env, ir_type *tp)
write_type_ref(env, element_type);
ir_node *size = get_array_size(tp);
if (is_Const(size))
write_long(env, get_tarval_long(get_Const_tarval(size)));
write_long(env, get_Const_long(size));
else if (is_Unknown(size))
write_symbol(env, "unknown");
else
......
......@@ -359,6 +359,11 @@ static inline int Block_block_visited_(const ir_node *node)
return node->attr.block.block_visited >= get_irg_block_visited(node->irg);
}
static inline long get_Const_long(ir_node const *const node)
{
return get_tarval_long(get_Const_tarval_(node));
}
static inline int is_Const_null_(const ir_node *node)
{
return tarval_is_null(get_Const_tarval_(node));
......
......@@ -319,7 +319,7 @@ static void get_base_and_offset(ir_node *ptr, base_offset_t *base_offset)
if (get_irn_mode(l) != mode || !is_Const(r))
break;
offset += get_tarval_long(get_Const_tarval(r));
offset += get_Const_long(r);
ptr = l;
} else if (is_Sub(ptr)) {
ir_node *l = get_Sub_left(ptr);
......@@ -328,7 +328,7 @@ static void get_base_and_offset(ir_node *ptr, base_offset_t *base_offset)
if (get_irn_mode(l) != mode || !is_Const(r))
break;
offset -= get_tarval_long(get_Const_tarval(r));
offset -= get_Const_long(r);
ptr = l;
} else if (is_Sel(ptr)) {
ir_node *index = get_Sel_index(ptr);
......@@ -342,7 +342,7 @@ static void get_base_and_offset(ir_node *ptr, base_offset_t *base_offset)
/* TODO: may overflow here */
int size = get_type_size_bytes(element_type);
offset += size * get_tarval_long(get_Const_tarval(index));
offset += size * get_Const_long(index);
ptr = get_Sel_ptr(ptr);
} else if (is_Member(ptr)) {
ir_entity *entity = get_Member_entity(ptr);
......
......@@ -32,6 +32,7 @@
#include <stddef.h>
#include <stdbool.h>
#include "irnode_t.h"
#include "type_t.h"
#include "xmalloc.h"
......@@ -962,7 +963,7 @@ unsigned get_array_size_int(const ir_type *array)
{
assert(is_Array_type(array));
ir_node *node = array->attr.aa.size;
return get_tarval_long(get_Const_tarval(node));
return get_Const_long(node);
}
void set_array_element_type(ir_type *array, ir_type *tp)
......
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