Commit 386963de authored by Christian Würdig's avatar Christian Würdig
Browse files

fixed some bugs concerning am_offs

parent a425171f
......@@ -325,6 +325,8 @@ static void ia32_prepare_graph(void *self) {
irg_walk_blkwise_graph(cg->irg, ia32_place_consts, ia32_transform_node, cg);
dump_ir_block_graph_sched(cg->irg, "-transformed");
edges_deactivate(cg->irg);
edges_activate(cg->irg);
irg_walk_blkwise_graph(cg->irg, NULL, ia32_optimize_am, cg);
dump_ir_block_graph_sched(cg->irg, "-am");
}
......
......@@ -128,14 +128,7 @@ char *ia32_emit_am(const ir_node *n) {
}
if (am_flav & ia32_O) {
s = get_ia32_am_offs(n);
if (! had_output) {
/* skip the first 3 characters which are " <op> " */
s += 3;
}
obstack_printf(obst, "%s", s);
obstack_printf(obst, get_ia32_am_offs(n));
}
obstack_printf(obst, "] ");
......
......@@ -469,11 +469,12 @@ char *get_ia32_am_offs(const ir_node *node) {
size = obstack_object_size(attr->am_offs);
if (size > 0) {
res = xcalloc(1, size + 1);
memcpy(res, obstack_base(attr->am_offs), size);
res = xcalloc(1, size + 2);
res[0] = attr->offs_sign;
memcpy(&res[1], obstack_base(attr->am_offs), size);
}
res[size] = '\0';
res[size + 1] = '\0';
return res;
}
......@@ -483,13 +484,28 @@ char *get_ia32_am_offs(const ir_node *node) {
static void extend_ia32_am_offs(ir_node *node, char *offset, char op) {
ia32_attr_t *attr = get_ia32_attr(node);
if (! offset)
return;
/* offset could already have an explicit sign */
/* -> supersede op if necessary */
if (offset[0] == '-' || offset[0] == '+') {
op = offset[0];
offset++;
}
if (!attr->am_offs) {
/* obstack is not initialized */
attr->am_offs = xcalloc(1, sizeof(*(attr->am_offs)));
obstack_init(attr->am_offs);
attr->offs_sign = op;
}
else {
/* If obstack is initialized, connect the new offset with op */
obstack_printf(attr->am_offs, "%c", op);
}
obstack_printf(attr->am_offs, "%c%s", op, offset);
obstack_printf(attr->am_offs, "%s", offset);
}
/**
......
......@@ -54,8 +54,9 @@ typedef struct _ia32_attr_t {
ia32_am_type_t am_support; /**<< indicates addrmode type supported by this node */
ia32_am_flavour_t am_flavour; /**<< the concrete addrmode characteristics */
struct obstack *am_offs; /**<< offsets for AddrMode */
int am_scale; /**<< addrmode scale for index register */
struct obstack *am_offs; /**<< offsets for AddrMode */
char offs_sign; /**<< the sign of the first offset */
int am_scale; /**<< addrmode scale for index register */
tarval *tv; /**<< tarval for immediate operations */
char *sc; /**<< symconst name */
......
......@@ -234,6 +234,17 @@ static int node_is_comm(const ir_node *irn) {
return 0;
}
static int ia32_get_irn_n_edges(const ir_node *irn) {
const ir_edge_t *edge;
int cnt = 0;
foreach_out_edge(irn, edge) {
cnt++;
}
return cnt;
}
/**
* Returns the first mode_M Proj connected to irn.
*/
......@@ -578,7 +589,7 @@ void ia32_optimize_am(ir_node *irn, void *env) {
store = NULL;
/* now check for users and Store */
if (get_irn_n_edges(succ) == 1) {
if (ia32_get_irn_n_edges(succ) == 1) {
succ = get_edge_src_irn(get_irn_out_edge_first(succ));
if (is_ia32_fStore(succ) || is_ia32_Store(succ)) {
......@@ -675,7 +686,7 @@ void ia32_optimize_am(ir_node *irn, void *env) {
if (check_am_src) {
left = get_irn_n(irn, 2);
if (get_irn_n_edges(left) == 1) {
if (ia32_get_irn_n_edges(left) == 1) {
left = get_Proj_pred(left);
addr_b = get_irn_n(left, 0);
......
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