Commit efa9475a authored by Matthias Braun's avatar Matthias Braun
Browse files

sparc: rewrite address mode matching, we now use offsets for load/store nodes...

sparc: rewrite address mode matching, we now use offsets for load/store nodes and need less special nodes

[r27951]
parent 1a7fa9fb
......@@ -66,23 +66,24 @@
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
static arch_irn_class_t sparc_classify(const ir_node *irn)
static arch_irn_class_t sparc_classify(const ir_node *node)
{
(void) irn;
(void) node;
return 0;
}
static ir_entity *sparc_get_frame_entity(const ir_node *irn)
static ir_entity *sparc_get_frame_entity(const ir_node *node)
{
if (is_sparc_FrameAddr(irn)) {
const sparc_symconst_attr_t *attr = get_irn_generic_attr_const(irn);
return attr->entity;
if (is_sparc_FrameAddr(node)) {
const sparc_attr_t *attr = get_sparc_attr_const(node);
return attr->immediate_value_entity;
}
if (sparc_has_load_store_attr(irn)) {
const sparc_load_store_attr_t *load_store_attr = get_sparc_load_store_attr_const(irn);
if (sparc_has_load_store_attr(node)) {
const sparc_load_store_attr_t *load_store_attr
= get_sparc_load_store_attr_const(node);
if (load_store_attr->is_frame_entity) {
return load_store_attr->entity;
return load_store_attr->base.immediate_value_entity;
}
}
......@@ -93,16 +94,14 @@ static ir_entity *sparc_get_frame_entity(const ir_node *irn)
* This function is called by the generic backend to correct offsets for
* nodes accessing the stack.
*/
static void sparc_set_frame_offset(ir_node *irn, int offset)
static void sparc_set_frame_offset(ir_node *node, int offset)
{
if (is_sparc_FrameAddr(irn)) {
sparc_symconst_attr_t *attr = get_irn_generic_attr(irn);
attr->fp_offset += offset;
} else {
sparc_load_store_attr_t *attr = get_sparc_load_store_attr(irn);
assert(sparc_has_load_store_attr(irn));
attr->offset += offset;
}
sparc_attr_t *attr = get_sparc_attr(node);
attr->immediate_value += offset;
/* must be a FrameAddr or a load/store node with frame_entity */
assert(is_sparc_FrameAddr(node) ||
get_sparc_load_store_attr_const(node)->is_frame_entity);
}
static int sparc_get_sp_bias(const ir_node *node)
......@@ -259,7 +258,7 @@ static void sparc_collect_frame_entity_nodes(ir_node *node, void *data)
return;
attr = get_sparc_load_store_attr_const(node);
entity = attr->entity;
entity = attr->base.immediate_value_entity;
mode = attr->load_store_mode;
if (entity != NULL)
return;
......@@ -279,7 +278,9 @@ static void sparc_set_frame_entity(ir_node *node, ir_entity *entity)
/* we only say be_node_needs_frame_entity on nodes with load_store
* attributes, so this should be fine */
sparc_load_store_attr_t *attr = get_sparc_load_store_attr(node);
attr->entity = entity;
assert(attr->is_frame_entity);
assert(attr->base.immediate_value_entity == NULL);
attr->base.immediate_value_entity = entity;
}
}
......
......@@ -109,17 +109,46 @@ static const arch_register_t *get_out_reg(const ir_node *node, int pos)
return reg;
}
static bool is_valid_immediate(int32_t value)
{
return -4096 <= value && value < 4096;
}
void sparc_emit_immediate(const ir_node *node)
{
int32_t value = get_sparc_attr_const(node)->immediate_value;
assert(-4096 <= value && value < 4096);
be_emit_irprintf("%d", value);
const sparc_attr_t *attr = get_sparc_attr_const(node);
ir_entity *entity = attr->immediate_value_entity;
if (entity == NULL) {
int32_t value = attr->immediate_value;
assert(is_valid_immediate(value));
be_emit_irprintf("%d", value);
} else {
be_emit_cstring("%lo(");
be_gas_emit_entity(entity);
if (attr->immediate_value != 0) {
be_emit_irprintf("%+d", attr->immediate_value);
}
be_emit_char(')');
}
}
void sparc_emit_high_immediate(const ir_node *node)
{
uint32_t value = (uint32_t) get_sparc_attr_const(node)->immediate_value;
be_emit_irprintf("%%hi(0x%X)", value);
const sparc_attr_t *attr = get_sparc_attr_const(node);
ir_entity *entity = attr->immediate_value_entity;
be_emit_cstring("%hi(");
if (entity == NULL) {
uint32_t value = (uint32_t) attr->immediate_value;
be_emit_irprintf("0x%X", value);
} else {
be_gas_emit_entity(entity);
if (attr->immediate_value != 0) {
be_emit_irprintf("%+d", attr->immediate_value);
}
}
be_emit_char(')');
}
void sparc_emit_source_register(const ir_node *node, int pos)
......@@ -165,14 +194,20 @@ static bool is_stack_pointer_relative(const ir_node *node)
void sparc_emit_offset(const ir_node *node)
{
const sparc_load_store_attr_t *attr = get_sparc_load_store_attr_const(node);
long offset = attr->offset;
/* bad hack: the real stack stuff is behind the always-there spill
* space for the register window and stack */
if (is_stack_pointer_relative(node))
offset += SPARC_MIN_STACKSIZE;
if (offset != 0) {
be_emit_irprintf("%+ld", offset);
if (attr->is_frame_entity) {
int32_t offset = attr->base.immediate_value;
/* bad hack: the real stack stuff is behind the always-there spill
* space for the register window and stack */
if (is_stack_pointer_relative(node))
offset += SPARC_MIN_STACKSIZE;
if (offset != 0) {
assert(is_valid_immediate(offset));
be_emit_irprintf("%+ld", offset);
}
} else {
be_emit_char('+');
sparc_emit_immediate(node);
}
}
......@@ -420,6 +455,9 @@ static void emit_sparc_Call(const ir_node *node)
be_emit_cstring("\tcall ");
if (entity != NULL) {
sparc_emit_entity(entity);
if (attr->immediate_value != 0) {
be_emit_irprintf("%+d", attr->immediate_value);
}
be_emit_cstring(", 0");
} else {
int last = get_irn_arity(node);
......@@ -521,55 +559,29 @@ static void emit_be_MemPerm(const ir_node *node)
assert(sp_change == 0);
}
/**
* Emit a SymConst.
*/
static void emit_sparc_SymConst(const ir_node *irn)
{
const sparc_symconst_attr_t *attr = get_sparc_symconst_attr_const(irn);
//sethi %hi(const32),%reg
//or %reg,%lo(const32),%reg
be_emit_cstring("\tsethi %hi(");
be_gas_emit_entity(attr->entity);
be_emit_cstring("), ");
sparc_emit_dest_register(irn, 0);
be_emit_cstring("\n ");
// TODO: could be combined with the following load/store instruction
be_emit_cstring("\tor ");
sparc_emit_dest_register(irn, 0);
be_emit_cstring(", %lo(");
be_gas_emit_entity(attr->entity);
be_emit_cstring("), ");
sparc_emit_dest_register(irn, 0);
be_emit_finish_line_gas(irn);
}
/**
* Emits code for FrameAddr fix
*/
static void emit_sparc_FrameAddr(const ir_node *irn)
static void emit_sparc_FrameAddr(const ir_node *node)
{
const sparc_symconst_attr_t *attr = get_irn_generic_attr_const(irn);
const sparc_attr_t *attr = get_sparc_attr_const(node);
// no need to fix offset as we are adressing via the framepointer
if (attr->fp_offset >= 0) {
if (attr->immediate_value >= 0) {
be_emit_cstring("\tadd ");
sparc_emit_source_register(irn, 0);
sparc_emit_source_register(node, 0);
be_emit_cstring(", ");
be_emit_irprintf("%ld", attr->fp_offset);
be_emit_irprintf("%ld", attr->immediate_value);
} else {
be_emit_cstring("\tsub ");
sparc_emit_source_register(irn, 0);
sparc_emit_source_register(node, 0);
be_emit_cstring(", ");
be_emit_irprintf("%ld", -attr->fp_offset);
be_emit_irprintf("%ld", -attr->immediate_value);
}
be_emit_cstring(", ");
sparc_emit_dest_register(irn, 0);
be_emit_finish_line_gas(irn);
sparc_emit_dest_register(node, 0);
be_emit_finish_line_gas(node);
}
static const char *get_icc_unsigned(pn_Cmp pnc)
......@@ -833,7 +845,6 @@ static void sparc_register_emitters(void)
set_emitter(op_sparc_Mulh, emit_sparc_Mulh);
set_emitter(op_sparc_Save, emit_sparc_Save);
set_emitter(op_sparc_SDiv, emit_sparc_SDiv);
set_emitter(op_sparc_SymConst, emit_sparc_SymConst);
set_emitter(op_sparc_UDiv, emit_sparc_UDiv);
/* no need to emit anything for the following nodes */
......
......@@ -44,11 +44,6 @@
#include "sparc_new_nodes.h"
#include "gen_sparc_regalloc_if.h"
static bool has_symconst_attr(const ir_node *node)
{
return is_sparc_SymConst(node) || is_sparc_FrameAddr(node);
}
bool sparc_has_load_store_attr(const ir_node *node)
{
return is_sparc_Ld(node) || is_sparc_St(node) || is_sparc_Ldf(node)
......@@ -91,6 +86,8 @@ static bool has_fp_conv_attr(const ir_node *node)
*/
static void sparc_dump_node(FILE *F, ir_node *n, dump_reason_t reason)
{
const sparc_attr_t *attr;
switch (reason) {
case dump_node_opcode_txt:
fprintf(F, "%s", get_irn_opname(n));
......@@ -101,20 +98,20 @@ static void sparc_dump_node(FILE *F, ir_node *n, dump_reason_t reason)
case dump_node_info_txt:
arch_dump_reqs_and_registers(F, n);
attr = get_sparc_attr_const(n);
if (attr->immediate_value_entity) {
ir_fprintf(F, "entity: %+F (offset %d)\n",
attr->immediate_value_entity, attr->immediate_value);
} else {
ir_fprintf(F, "immediate value: %d\n", attr->immediate_value);
}
if (has_save_attr(n)) {
const sparc_save_attr_t *attr = get_sparc_save_attr_const(n);
fprintf(F, "initial stacksize: %d\n", attr->initial_stacksize);
}
if (has_symconst_attr(n)) {
const sparc_symconst_attr_t *attr = get_sparc_symconst_attr_const(n);
ir_fprintf(F, "entity: %+F\n", attr->entity);
fprintf(F, "fp_offset: %d\n", attr->fp_offset);
}
if (sparc_has_load_store_attr(n)) {
const sparc_load_store_attr_t *attr = get_sparc_load_store_attr_const(n);
ir_fprintf(F, "load store mode: %+F\n", attr->load_store_mode);
ir_fprintf(F, "entity: %+F\n", attr->entity);
fprintf(F, "offset: %ld\n", attr->offset);
fprintf(F, "is frame entity: %s\n",
attr->is_frame_entity ? "true" : "false");
}
......@@ -146,10 +143,12 @@ static void sparc_dump_node(FILE *F, ir_node *n, dump_reason_t reason)
}
}
static void sparc_set_attr_imm(ir_node *res, int32_t immediate_value)
static void sparc_set_attr_imm(ir_node *res, ir_entity *entity,
int32_t immediate_value)
{
sparc_attr_t *attr = get_irn_generic_attr(res);
attr->immediate_value = immediate_value;
sparc_attr_t *attr = get_irn_generic_attr(res);
attr->immediate_value_entity = entity;
attr->immediate_value = immediate_value;
}
static void init_sparc_jmp_cond_attr(ir_node *node, int pnc, bool is_unsigned)
......@@ -209,18 +208,6 @@ const sparc_load_store_attr_t *get_sparc_load_store_attr_const(const ir_node *no
return (const sparc_load_store_attr_t*) get_irn_generic_attr_const(node);
}
sparc_symconst_attr_t *get_sparc_symconst_attr(ir_node *node)
{
assert(has_symconst_attr(node));
return (sparc_symconst_attr_t*) get_irn_generic_attr_const(node);
}
const sparc_symconst_attr_t *get_sparc_symconst_attr_const(const ir_node *node)
{
assert(has_symconst_attr(node));
return (const sparc_symconst_attr_t*) get_irn_generic_attr_const(node);
}
sparc_jmp_cond_attr_t *get_sparc_jmp_cond_attr(ir_node *node)
{
assert(has_jmp_cond_attr(node));
......@@ -337,21 +324,14 @@ static void init_sparc_attributes(ir_node *node, arch_irn_flags_t flags,
}
static void init_sparc_load_store_attributes(ir_node *res, ir_mode *ls_mode,
ir_entity *entity,
long offset, bool is_frame_entity)
{
sparc_load_store_attr_t *attr = get_sparc_load_store_attr(res);
attr->load_store_mode = ls_mode;
attr->entity = entity;
attr->is_frame_entity = is_frame_entity;
attr->offset = offset;
}
static void init_sparc_symconst_attributes(ir_node *res, ir_entity *entity)
ir_entity *entity, int32_t offset,
bool is_frame_entity)
{
sparc_symconst_attr_t *attr = get_sparc_symconst_attr(res);
attr->entity = entity;
attr->fp_offset = 0;
sparc_load_store_attr_t *attr = get_sparc_load_store_attr(res);
attr->base.immediate_value_entity = entity;
attr->base.immediate_value = offset;
attr->load_store_mode = ls_mode;
attr->is_frame_entity = is_frame_entity;
}
static void init_sparc_save_attributes(ir_node *res, int initial_stacksize)
......@@ -413,22 +393,8 @@ static int cmp_attr_sparc_load_store(ir_node *a, ir_node *b)
if (cmp_attr_sparc(a, b))
return 1;
return attr_a->entity != attr_b->entity
|| attr_a->is_frame_entity != attr_b->is_frame_entity
|| attr_a->load_store_mode != attr_b->load_store_mode
|| attr_a->offset != attr_b->offset;
}
static int cmp_attr_sparc_symconst(ir_node *a, ir_node *b)
{
const sparc_symconst_attr_t *attr_a = get_sparc_symconst_attr_const(a);
const sparc_symconst_attr_t *attr_b = get_sparc_symconst_attr_const(b);
if (cmp_attr_sparc(a, b))
return 1;
return attr_a->entity != attr_b->entity
|| attr_a->fp_offset != attr_b->fp_offset;
return attr_a->is_frame_entity != attr_b->is_frame_entity
|| attr_a->load_store_mode != attr_b->load_store_mode;
}
static int cmp_attr_sparc_jmp_cond(ir_node *a, ir_node *b)
......
......@@ -38,9 +38,6 @@ bool sparc_has_load_store_attr(const ir_node *node);
sparc_load_store_attr_t *get_sparc_load_store_attr(ir_node *node);
const sparc_load_store_attr_t *get_sparc_load_store_attr_const(const ir_node *node);
sparc_symconst_attr_t *get_sparc_symconst_attr(ir_node *node);
const sparc_symconst_attr_t *get_sparc_symconst_attr_const(const ir_node *node);
sparc_jmp_cond_attr_t *get_sparc_jmp_cond_attr(ir_node *node);
const sparc_jmp_cond_attr_t *get_sparc_jmp_cond_attr_const(const ir_node *node);
......
......@@ -38,7 +38,7 @@ struct sparc_attr_t
except_attr exc; /**< the exception attribute. MUST be the first one. */
const arch_register_req_t **in_req; /**< register requirements for arguments */
int32_t immediate_value; /* immediate values */
ir_entity *immediate_value_entity; /* hack for now */
ir_entity *immediate_value_entity;
};
enum sparc_arch_irn_flags_t {
......@@ -79,21 +79,9 @@ typedef struct sparc_load_store_attr_t sparc_load_store_attr_t;
struct sparc_load_store_attr_t {
sparc_attr_t base; /**< generic attribute */
ir_mode *load_store_mode;
ir_entity *entity;
long offset;
bool is_frame_entity;
};
/**
* attributes for SymConsts
*/
typedef struct sparc_symconst_attr_t sparc_symconst_attr_t;
struct sparc_symconst_attr_t {
sparc_attr_t base; /**< generic attribute */
ir_entity *entity;
int fp_offset;
};
/**
* attributes for conditional jumps
*/
......
......@@ -148,8 +148,6 @@ $default_copy_attr = "sparc_copy_attr";
sparc_attr_t => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);",
sparc_load_store_attr_t => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);\n".
"\tinit_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity);",
sparc_symconst_attr_t => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);\n".
"\tinit_sparc_symconst_attributes(res, entity);",
sparc_jmp_cond_attr_t => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);",
sparc_jmp_switch_attr_t => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);",
sparc_save_attr_t => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);",
......@@ -162,7 +160,6 @@ $default_copy_attr = "sparc_copy_attr";
%compare_attr = (
sparc_attr_t => "cmp_attr_sparc",
sparc_load_store_attr_t => "cmp_attr_sparc_load_store",
sparc_symconst_attr_t => "cmp_attr_sparc_symconst",
sparc_jmp_cond_attr_t => "cmp_attr_sparc_jmp_cond",
sparc_jmp_switch_attr_t => "cmp_attr_sparc_jmp_switch",
sparc_save_attr_t => "cmp_attr_sparc_save",
......@@ -180,8 +177,8 @@ $default_copy_attr = "sparc_copy_attr";
my %cmp_operand_constructors = (
imm => {
attr => "int32_t immediate_value",
custominit => "sparc_set_attr_imm(res, immediate_value);",
attr => "ir_entity *immediate_entity, int32_t immediate_value",
custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
reg_req => { in => [ "gp" ], out => [ "flags" ] },
ins => [ "left" ],
},
......@@ -193,8 +190,8 @@ my %cmp_operand_constructors = (
my %unop_operand_constructors = (
imm => {
attr => "int32_t immediate_value",
custominit => "sparc_set_attr_imm(res, immediate_value);",
attr => "ir_entity *immediate_entity, int32_t immediate_value",
custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
reg_req => { in => [], out => [ "gp" ] },
},
reg => {
......@@ -204,8 +201,8 @@ my %unop_operand_constructors = (
my %binop_operand_constructors = (
imm => {
attr => "int32_t immediate_value",
custominit => "sparc_set_attr_imm(res, immediate_value);",
attr => "ir_entity *immediate_entity, int32_t immediate_value",
custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
reg_req => { in => [ "gp" ], out => [ "gp" ] },
ins => [ "left" ],
},
......@@ -283,7 +280,7 @@ Ld => {
outs => [ "res", "M" ],
ins => [ "ptr", "mem" ],
attr_type => "sparc_load_store_attr_t",
attr => "ir_mode *ls_mode, ir_entity *entity, long offset, bool is_frame_entity",
attr => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
emit => '. ld%LM [%S1%O], %D1'
},
......@@ -292,8 +289,8 @@ SetHi => {
outs => [ "res" ],
mode => $mode_gp,
reg_req => { in => [], out => [ "gp" ] },
attr => "int32_t immediate_value",
custominit => "sparc_set_attr_imm(res, immediate_value);",
attr => "ir_entity *entity, int32_t immediate_value",
custominit => "sparc_set_attr_imm(res, entity, immediate_value);",
emit => '. sethi %HIM, %D1'
},
......@@ -312,7 +309,7 @@ St => {
ins => [ "ptr", "val", "mem" ],
outs => [ "M" ],
attr_type => "sparc_load_store_attr_t",
attr => "ir_mode *ls_mode, ir_entity *entity, long offset, bool is_frame_entity",
attr => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
emit => '. st%SM %S2, [%S1%O]'
},
......@@ -342,23 +339,15 @@ AddSP => {
emit => ". add %S1, %S2, %D1\n",
},
SymConst => {
op_flags => [ "constlike" ],
irn_flags => [ "rematerializable" ],
attr => "ir_entity *entity",
reg_req => { out => [ "gp" ] },
attr_type => "sparc_symconst_attr_t",
mode => $mode_gp,
},
FrameAddr => {
op_flags => [ "constlike" ],
irn_flags => [ "rematerializable" ],
attr => "ir_entity *entity",
reg_req => { in => [ "gp" ], out => [ "gp" ] },
ins => [ "base" ],
attr_type => "sparc_symconst_attr_t",
mode => $mode_gp,
op_flags => [ "constlike" ],
irn_flags => [ "rematerializable" ],
attr => "ir_entity *entity, int32_t offset",
reg_req => { in => [ "gp" ], out => [ "gp" ] },
ins => [ "base" ],
attr_type => "sparc_attr_t",
custominit => "sparc_set_attr_imm(res, entity, offset);",
mode => $mode_gp,
},
Bicc => {
......@@ -396,8 +385,8 @@ Call => {
out_arity => "variable",
constructors => {
imm => {
attr => "ir_entity *entity, long offset",
custominit => "get_sparc_attr(res)->immediate_value_entity = entity;",
attr => "ir_entity *entity, int32_t offset",
custominit => "\tsparc_set_attr_imm(res, entity, offset);",
arity => "variable",
out_arity => "variable",
},
......@@ -697,7 +686,7 @@ Ldf => {
ins => [ "ptr", "mem" ],
outs => [ "res", "M" ],
attr_type => "sparc_load_store_attr_t",
attr => "ir_mode *ls_mode, ir_entity *entity, long offset, bool is_frame_entity",
attr => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
emit => '. ld%FLSM [%S1%O], %D1'
},
......@@ -718,7 +707,7 @@ Stf => {
ins => [ "ptr", "val", "mem" ],
outs => [ "M" ],
attr_type => "sparc_load_store_attr_t",
attr => "ir_mode *ls_mode, ir_entity *entity, long offset, bool is_frame_entity",
attr => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
emit => '. st%FLSM %S2, [%S1%O]',
mode => 'mode_M',
},
......
......@@ -69,9 +69,6 @@ static ir_mode *mode_fp2;
//static ir_mode *mode_fp4;
static pmap *node_to_stack;
static ir_node *gen_SymConst(ir_node *node);
static inline int mode_needs_gp_reg(ir_mode *mode)
{
return mode_is_int(mode) || mode_is_reference(mode);
......@@ -89,10 +86,10 @@ static ir_node *gen_zero_extension(dbg_info *dbgi, ir_node *block, ir_node *op,
int src_bits)
{
if (src_bits == 8) {
return new_bd_sparc_And_imm(dbgi, block, op, 0xFF);
return new_bd_sparc_And_imm(dbgi, block, op, NULL, 0xFF);
} else if (src_bits == 16) {
ir_node *lshift = new_bd_sparc_Sll_imm(dbgi, block, op, 16);
ir_node *rshift = new_bd_sparc_Slr_imm(dbgi, block, lshift, 16);
ir_node *lshift = new_bd_sparc_Sll_imm(dbgi, block, op, NULL, 16);
ir_node *rshift = new_bd_sparc_Slr_imm(dbgi, block, lshift, NULL, 16);
return rshift;
} else {
panic("zero extension only supported for 8 and 16 bits");
......@@ -111,8 +108,8 @@ static ir_node *gen_sign_extension(dbg_info *dbgi, ir_node *block, ir_node *op,
int src_bits)
{
int shift_width = 32 - src_bits;
ir_node *lshift_node = new_bd_sparc_Sll_imm(dbgi, block, op, shift_width);
ir_node *rshift_node = new_bd_sparc_Sra_imm(dbgi, block, lshift_node, shift_width);
ir_node *lshift_node = new_bd_sparc_Sll_imm(dbgi, block, op, NULL, shift_width);
ir_node *rshift_node = new_bd_sparc_Sra_imm(dbgi, block, lshift_node, NULL, shift_width);
return rshift_node;
}
......@@ -159,12 +156,16 @@ typedef enum {
typedef ir_node* (*new_binop_reg_func) (dbg_info *dbgi, ir_node *block, ir_node *op1, ir_node *op2);
typedef ir_node* (*new_binop_fp_func) (dbg_info *dbgi, ir_node *block, ir_node *op1, ir_node *op2, ir_mode *mode);
typedef ir_node* (*new_binop_imm_func) (dbg_info *dbgi, ir_node *block, ir_node *op1, int32_t immediate);
typedef ir_node* (*new_binop_imm_func) (dbg_info *dbgi, ir_node *block, ir_node *op1, ir_entity *entity, int32_t immediate);
typedef ir_node* (*new_unop_fp_func) (dbg_info *dbgi, ir_node *block, ir_node *op1, ir_mode *mode);
static bool is_value_imm_encodeable(int32_t value)
{
return -4096 <= value && value <= 4095;
}
/**
* checks if a node's value can be encoded as a immediate
*
*/
static bool is_imm_encodeable(const ir_node *node)
{
......@@ -173,7 +174,7 @@ static bool is_imm_encodeable(const ir_node *node)
return false;
value = get_tarval_long(get_Const_tarval(node));
return -4096 <= value && value <= 4095;
return is_value_imm_encodeable(value);
}