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

some cleanups

parent 9e445b9b
...@@ -45,7 +45,7 @@ static bool tarval_possible(ir_tarval *tv) ...@@ -45,7 +45,7 @@ static bool tarval_possible(ir_tarval *tv)
* *
* @return true if the DAG represents an immediate, false else * @return true if the DAG represents an immediate, false else
*/ */
static bool do_is_immediate(const ir_node *node, bool *symconst_allowed, static bool do_is_immediate(const ir_node *node, bool *entity_allowed,
bool negate) bool negate)
{ {
switch (get_irn_opcode(node)) { switch (get_irn_opcode(node)) {
...@@ -56,11 +56,10 @@ static bool do_is_immediate(const ir_node *node, bool *symconst_allowed, ...@@ -56,11 +56,10 @@ static bool do_is_immediate(const ir_node *node, bool *symconst_allowed,
/* unfortunately the assembler/linker doesn't support -symconst */ /* unfortunately the assembler/linker doesn't support -symconst */
if (negate) if (negate)
return false; return false;
if (!*symconst_allowed) if (!*entity_allowed)
return false; return false;
/* only 1 symconst allowed */ /* only 1 symconst allowed */
*symconst_allowed = false; *entity_allowed = false;
return true; return true;
case iro_Unknown: case iro_Unknown:
...@@ -74,10 +73,10 @@ static bool do_is_immediate(const ir_node *node, bool *symconst_allowed, ...@@ -74,10 +73,10 @@ static bool do_is_immediate(const ir_node *node, bool *symconst_allowed,
return false; return false;
ir_node *left = get_binop_left(node); ir_node *left = get_binop_left(node);
if (!do_is_immediate(left, symconst_allowed, negate)) if (!do_is_immediate(left, entity_allowed, negate))
return false; return false;
ir_node *right = get_binop_right(node); ir_node *right = get_binop_right(node);
if (!do_is_immediate(right, symconst_allowed, if (!do_is_immediate(right, entity_allowed,
is_Sub(node) ? !negate : negate)) is_Sub(node) ? !negate : negate))
return false; return false;
...@@ -91,16 +90,12 @@ static bool do_is_immediate(const ir_node *node, bool *symconst_allowed, ...@@ -91,16 +90,12 @@ static bool do_is_immediate(const ir_node *node, bool *symconst_allowed,
/** /**
* Check if a DAG starting with root node can be folded into an address mode * Check if a DAG starting with root node can be folded into an address mode
* as an immediate. * as an immediate.
*
* @param addr the address mode data so far
* @param node the node
* @param negate if set, the immediate must be negated
*/ */
static int is_immediate(const ir_node *node, bool negate, static int is_immediate(const ir_node *node, bool negate,
bool init_symconst_allowed) bool init_entity_allowed)
{ {
bool symconst_allowed = init_symconst_allowed; bool entity_allowed = init_entity_allowed;
return do_is_immediate(node, &symconst_allowed, negate); return do_is_immediate(node, &entity_allowed, negate);
} }
/** /**
...@@ -177,28 +172,26 @@ static ir_node *eat_immediates(x86_address_t *addr, ir_node *node, ...@@ -177,28 +172,26 @@ static ir_node *eat_immediates(x86_address_t *addr, ir_node *node,
if (is_Add(node)) { if (is_Add(node)) {
ir_node *left = get_Add_left(node); ir_node *left = get_Add_left(node);
ir_node *right = get_Add_right(node); ir_node *right = get_Add_right(node);
bool symconst_ok = bool entity_ok = addr->entity != NULL &&
addr->entity != NULL &&
((flags & x86_create_am_entities_ip_relative) == 0 ((flags & x86_create_am_entities_ip_relative) == 0
|| (addr->base == NULL)); || (addr->base == NULL));
if (is_immediate(left, false, symconst_ok)) { if (is_immediate(left, false, entity_ok)) {
eat_immediate(addr, left, false); eat_immediate(addr, left, false);
return eat_immediates(addr, right, x86_create_am_normal); return eat_immediates(addr, right, x86_create_am_normal);
} }
if (is_immediate(right, false, symconst_ok)) { if (is_immediate(right, false, entity_ok)) {
eat_immediate(addr, right, false); eat_immediate(addr, right, false);
return eat_immediates(addr, left, x86_create_am_normal); return eat_immediates(addr, left, x86_create_am_normal);
} }
} else if (is_Sub(node)) { } else if (is_Sub(node)) {
ir_node *left = get_Sub_left(node); ir_node *left = get_Sub_left(node);
ir_node *right = get_Sub_right(node); ir_node *right = get_Sub_right(node);
bool symconst_ok = bool entity_ok = addr->entity != NULL &&
addr->entity != NULL &&
((flags & x86_create_am_entities_ip_relative) == 0 ((flags & x86_create_am_entities_ip_relative) == 0
|| (addr->base == NULL)); || (addr->base == NULL));
if (is_immediate(right, true, symconst_ok)) { if (is_immediate(right, true, entity_ok)) {
eat_immediate(addr, right, true); eat_immediate(addr, right, true);
return eat_immediates(addr, left, x86_create_am_normal); return eat_immediates(addr, left, x86_create_am_normal);
} }
......
Supports Markdown
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