8 #include "firm_types.h"
15 #include "../benode_t.h"
16 #include "../besched_t.h"
18 #include "ia32_new_nodes.h"
19 #include "bearch_ia32_t.h"
20 #include "gen_ia32_regalloc_if.h" /* the generated interface (register type and class defenitions) */
23 #define is_NoMem(irn) (get_irn_op(irn) == op_NoMem)
25 static int be_is_NoReg(be_abi_irg_t *babi, const ir_node *irn) {
26 if (be_abi_get_callee_save_irn(babi, &ia32_gp_regs[REG_XXX]) == irn ||
27 be_abi_get_callee_save_irn(babi, &ia32_fp_regs[REG_XXXX]) == irn)
36 * creates a unique ident by adding a number to a tag
38 * @param tag the tag string, must contain a %d if a number
41 static ident *unique_id(const char *tag)
43 static unsigned id = 0;
46 snprintf(str, sizeof(str), tag, ++id);
47 return new_id_from_str(str);
53 * Transforms a SymConst.
55 * @param mod the debug module
56 * @param block the block the new node should belong to
57 * @param node the ir SymConst node
58 * @param mode mode of the SymConst
59 * @return the created ia32 Const node
61 static ir_node *gen_SymConst(ia32_transform_env_t *env) {
63 dbg_info *dbg = env->dbg;
64 ir_mode *mode = env->mode;
65 ir_graph *irg = env->irg;
66 ir_node *block = env->block;
68 cnst = new_rd_ia32_Const(dbg, irg, block, mode);
69 set_ia32_Const_attr(cnst, env->irn);
74 * Get a primitive type for a mode.
76 static ir_type *get_prim_type(pmap *types, ir_mode *mode)
78 pmap_entry *e = pmap_find(types, mode);
83 snprintf(buf, sizeof(buf), "prim_type_%s", get_mode_name(mode));
84 res = new_type_primitive(new_id_from_str(buf), mode);
85 pmap_insert(types, mode, res);
93 * Get an entity that is initialized with a tarval
95 static entity *get_entity_for_tv(ia32_code_gen_t *cg, ir_node *cnst)
97 tarval *tv = get_Const_tarval(cnst);
98 pmap_entry *e = pmap_find(cg->tv_ent, tv);
103 ir_mode *mode = get_irn_mode(cnst);
104 ir_type *tp = get_Const_type(cnst);
105 if (tp == firm_unknown_type)
106 tp = get_prim_type(cg->types, mode);
108 res = new_entity(get_glob_type(), unique_id("ia32FloatCnst_%u"), tp);
110 set_entity_ld_ident(res, get_entity_ident(res));
111 set_entity_visibility(res, visibility_local);
112 set_entity_variability(res, variability_constant);
113 set_entity_allocation(res, allocation_static);
115 /* we create a new entity here: It's initialization must resist on the
117 rem = current_ir_graph;
118 current_ir_graph = get_const_code_irg();
119 set_atomic_ent_value(res, new_Const_type(tv, tp));
120 current_ir_graph = rem;
128 * Transforms a Const.
130 * @param mod the debug module
131 * @param block the block the new node should belong to
132 * @param node the ir Const node
133 * @param mode mode of the Const
134 * @return the created ia32 Const node
136 static ir_node *gen_Const(ia32_transform_env_t *env) {
139 ir_graph *irg = env->irg;
140 ir_node *block = env->block;
141 ir_node *node = env->irn;
142 dbg_info *dbg = env->dbg;
143 ir_mode *mode = env->mode;
145 if (mode_is_float(mode)) {
146 sym.entity_p = get_entity_for_tv(env->cg, node);
148 cnst = new_rd_SymConst(dbg, irg, block, sym, symconst_addr_ent);
150 cnst = gen_SymConst(env);
153 cnst = new_rd_ia32_Const(dbg, irg, block, get_irn_mode(node));
154 set_ia32_Const_attr(cnst, node);
162 * Transforms (all) Const's into ia32_Const and places them in the
163 * block where they are used (or in the cfg-pred Block in case of Phi's).
164 * Additionally all reference nodes are changed into mode_Is nodes.
166 void ia32_place_consts_set_modes(ir_node *irn, void *env) {
167 ia32_code_gen_t *cg = env;
168 ia32_transform_env_t tenv;
170 ir_node *pred, *cnst;
177 mode = get_irn_mode(irn);
179 /* transform all reference nodes into mode_Is nodes */
180 if (mode_is_reference(mode)) {
182 set_irn_mode(irn, mode);
185 tenv.block = get_nodes_block(irn);
190 /* Loop over all predecessors and check for Sym/Const nodes */
191 for (i = get_irn_arity(irn) - 1; i >= 0; --i) {
192 pred = get_irn_n(irn, i);
194 opc = get_irn_opcode(pred);
196 tenv.mode = get_irn_mode(pred);
197 tenv.dbg = get_irn_dbg_info(pred);
199 /* If it's a Phi, then we need to create the */
200 /* new Const in it's predecessor block */
202 tenv.block = get_Block_cfgpred_block(get_nodes_block(irn), i);
205 /* put the const into the block where the original const was */
206 if (! cg->opt.placecnst) {
207 tenv.block = get_nodes_block(pred);
212 cnst = gen_Const(&tenv);
215 cnst = gen_SymConst(&tenv);
221 /* if we found a const, then set it */
223 set_irn_n(irn, i, cnst);
229 /******************************************************************
231 * /\ | | | | | \/ | | |
232 * / \ __| | __| |_ __ ___ ___ ___| \ / | ___ __| | ___
233 * / /\ \ / _` |/ _` | '__/ _ \/ __/ __| |\/| |/ _ \ / _` |/ _ \
234 * / ____ \ (_| | (_| | | | __/\__ \__ \ | | | (_) | (_| | __/
235 * /_/ \_\__,_|\__,_|_| \___||___/___/_| |_|\___/ \__,_|\___|
237 ******************************************************************/
239 static int node_is_comm(const ir_node *irn) {
240 return is_ia32_irn(irn) ? is_ia32_commutative(irn) : 0;
243 static int ia32_get_irn_n_edges(const ir_node *irn) {
244 const ir_edge_t *edge;
247 foreach_out_edge(irn, edge) {
255 * Returns the first mode_M Proj connected to irn.
257 static ir_node *get_mem_proj(const ir_node *irn) {
258 const ir_edge_t *edge;
261 assert(get_irn_mode(irn) == mode_T && "expected mode_T node");
263 foreach_out_edge(irn, edge) {
264 src = get_edge_src_irn(edge);
266 assert(is_Proj(src) && "Proj expected");
268 if (get_irn_mode(src) == mode_M)
276 * Returns the first Proj with mode != mode_M connected to irn.
278 static ir_node *get_res_proj(const ir_node *irn) {
279 const ir_edge_t *edge;
282 assert(get_irn_mode(irn) == mode_T && "expected mode_T node");
284 foreach_out_edge(irn, edge) {
285 src = get_edge_src_irn(edge);
287 assert(is_Proj(src) && "Proj expected");
289 if (get_irn_mode(src) != mode_M)
297 * Determines if pred is a Proj and if is_op_func returns true for it's predecessor.
299 * @param pred The node to be checked
300 * @param is_op_func The check-function
301 * @return 1 if conditions are fulfilled, 0 otherwise
303 static int pred_is_specific_node(const ir_node *pred, int (*is_op_func)(const ir_node *n)) {
304 if (is_Proj(pred) && is_op_func(get_Proj_pred(pred))) {
312 * Determines if pred is a Proj and if is_op_func returns true for it's predecessor
313 * and if the predecessor is in block bl.
315 * @param bl The block
316 * @param pred The node to be checked
317 * @param is_op_func The check-function
318 * @return 1 if conditions are fulfilled, 0 otherwise
320 static int pred_is_specific_nodeblock(const ir_node *bl, const ir_node *pred,
321 int (*is_op_func)(const ir_node *n))
324 pred = get_Proj_pred(pred);
325 if ((bl == get_nodes_block(pred)) && is_op_func(pred)) {
336 * Checks if irn is a candidate for address calculation or address mode.
338 * address calculation (AC):
339 * - none of the operand must be a Load within the same block OR
340 * - all Loads must have more than one user OR
341 * - the irn has a frame entity (it's a former FrameAddr)
344 * - at least one operand has to be a Load within the same block AND
345 * - the load must not have other users than the irn AND
346 * - the irn must not have a frame entity set
348 * @param block The block the Loads must/not be in
349 * @param irn The irn to check
350 * @param check_addr 1 if to check for address calculation, 0 otherwise
351 * return 1 if irn is a candidate for AC or AM, 0 otherwise
353 static int is_candidate(const ir_node *block, const ir_node *irn, int check_addr) {
355 int n, is_cand = check_addr;
357 in = get_irn_n(irn, 2);
359 if (pred_is_specific_nodeblock(block, in, is_ia32_Ld)) {
360 n = ia32_get_irn_n_edges(in);
361 is_cand = check_addr ? (n == 1 ? 0 : is_cand) : (n == 1 ? 1 : is_cand);
364 in = get_irn_n(irn, 3);
366 if (pred_is_specific_nodeblock(block, in, is_ia32_Ld)) {
367 n = ia32_get_irn_n_edges(in);
368 is_cand = check_addr ? (n == 1 ? 0 : is_cand) : (n == 1 ? 1 : is_cand);
371 is_cand = get_ia32_frame_ent(irn) ? (check_addr ? 1 : 0) : is_cand;
377 * Compares the base and index addr and the load/store entities
378 * and returns 1 if they are equal.
380 static int load_store_addr_is_equal(const ir_node *load, const ir_node *store,
381 const ir_node *addr_b, const ir_node *addr_i)
383 int is_equal = (addr_b == get_irn_n(load, 0)) && (addr_i == get_irn_n(load, 1));
384 entity *lent = get_ia32_frame_ent(load);
385 entity *sent = get_ia32_frame_ent(store);
387 /* are both entities set and equal? */
388 is_equal = lent && sent && (lent == sent);
390 /* are the load and the store of the same mode? */
391 is_equal = get_ia32_ls_mode(load) == get_ia32_ls_mode(store);
399 * Folds Add or Sub to LEA if possible
401 static ir_node *fold_addr(be_abi_irg_t *babi, ir_node *irn, firm_dbg_module_t *mod, ir_node *noreg) {
402 ir_graph *irg = get_irn_irg(irn);
403 dbg_info *dbg = get_irn_dbg_info(irn);
404 ir_node *block = get_nodes_block(irn);
407 char *offs_cnst = NULL;
408 char *offs_lea = NULL;
412 ir_node *left, *right, *temp;
413 ir_node *base, *index;
414 ia32_am_flavour_t am_flav;
416 if (is_ia32_Add(irn))
419 left = get_irn_n(irn, 2);
420 right = get_irn_n(irn, 3);
422 /* "normalize" arguments in case of add with two operands */
423 if (isadd && ! be_is_NoReg(babi, right)) {
424 /* put LEA == ia32_am_O as right operand */
425 if (is_ia32_Lea(left) && get_ia32_am_flavour(left) == ia32_am_O) {
426 set_irn_n(irn, 2, right);
427 set_irn_n(irn, 3, left);
433 /* put LEA != ia32_am_O as left operand */
434 if (is_ia32_Lea(right) && get_ia32_am_flavour(right) != ia32_am_O) {
435 set_irn_n(irn, 2, right);
436 set_irn_n(irn, 3, left);
442 /* put SHL as left operand iff left is NOT a LEA */
443 if (! is_ia32_Lea(left) && pred_is_specific_node(right, is_ia32_Shl)) {
444 set_irn_n(irn, 2, right);
445 set_irn_n(irn, 3, left);
458 /* check if operand is either const */
459 if (get_ia32_cnst(irn)) {
460 DBG((mod, LEVEL_1, "\tfound op with imm"));
462 offs_cnst = get_ia32_cnst(irn);
466 /* determine the operand which needs to be checked */
467 if (be_is_NoReg(babi, right)) {
474 /* check if right operand is AMConst (LEA with ia32_am_O) */
475 if (is_ia32_Lea(temp) && get_ia32_am_flavour(temp) == ia32_am_O) {
476 DBG((mod, LEVEL_1, "\tgot op with LEA am_O"));
478 offs_lea = get_ia32_am_offs(temp);
483 /* default for add -> make right operand to index */
487 DBG((mod, LEVEL_1, "\tgot LEA candidate with index %+F\n", index));
489 /* determine the operand which needs to be checked */
491 if (is_ia32_Lea(left)) {
495 /* check for SHL 1,2,3 */
496 if (pred_is_specific_node(temp, is_ia32_Shl)) {
497 temp = get_Proj_pred(temp);
499 if (get_ia32_Immop_tarval(temp)) {
500 scale = get_tarval_long(get_ia32_Immop_tarval(temp));
503 index = get_irn_n(temp, 2);
505 DBG((mod, LEVEL_1, "\tgot scaled index %+F\n", index));
511 if (! be_is_NoReg(babi, index)) {
512 /* if we have index, but left == right -> no base */
516 else if (! is_ia32_Lea(left) && (index != right)) {
517 /* index != right -> we found a good Shl */
518 /* left != LEA -> this Shl was the left operand */
519 /* -> base is right operand */
525 /* Try to assimilate a LEA as left operand */
526 if (is_ia32_Lea(left) && (get_ia32_am_flavour(left) != ia32_am_O)) {
527 am_flav = get_ia32_am_flavour(left);
529 /* If we have an Add with a real right operand (not NoReg) and */
530 /* the LEA contains already an index calculation then we create */
532 /* If the LEA contains already a frame_entity then we also */
533 /* create a new one otherwise we would loose it. */
534 if ((isadd && !be_is_NoReg(babi, index) && (am_flav & ia32_am_I)) ||
535 get_ia32_frame_ent(left))
537 DBG((mod, LEVEL_1, "\tleave old LEA, creating new one\n"));
540 DBG((mod, LEVEL_1, "\tgot LEA as left operand ... assimilating\n"));
541 offs = get_ia32_am_offs(left);
542 base = get_irn_n(left, 0);
543 index = get_irn_n(left, 1);
544 scale = get_ia32_am_scale(left);
548 /* ok, we can create a new LEA */
550 res = new_rd_ia32_Lea(dbg, irg, block, base, index, mode_Is);
552 /* add the old offset of a previous LEA */
554 add_ia32_am_offs(res, offs);
557 /* add the new offset */
560 add_ia32_am_offs(res, offs_cnst);
563 add_ia32_am_offs(res, offs_lea);
567 /* either lea_O-cnst, -cnst or -lea_O */
570 add_ia32_am_offs(res, offs_lea);
573 sub_ia32_am_offs(res, offs_cnst);
576 sub_ia32_am_offs(res, offs_lea);
580 /* copy the frame entity (could be set in case of Add */
581 /* which was a FrameAddr) */
582 set_ia32_frame_ent(res, get_ia32_frame_ent(irn));
584 if (is_ia32_use_frame(irn))
585 set_ia32_use_frame(res);
588 set_ia32_am_scale(res, scale);
591 /* determine new am flavour */
592 if (offs || offs_cnst || offs_lea) {
595 if (! be_is_NoReg(babi, base)) {
598 if (! be_is_NoReg(babi, index)) {
604 set_ia32_am_flavour(res, am_flav);
606 set_ia32_op_type(res, ia32_AddrModeS);
608 DBG((mod, LEVEL_1, "\tLEA [%+F + %+F * %d + %s]\n", base, index, scale, get_ia32_am_offs(res)));
610 /* get the result Proj of the Add/Sub */
611 irn = get_res_proj(irn);
613 assert(irn && "Couldn't find result proj");
615 /* exchange the old op with the new LEA */
623 * Optimizes a pattern around irn to address mode if possible.
625 void ia32_optimize_am(ir_node *irn, void *env) {
626 ia32_code_gen_t *cg = env;
627 firm_dbg_module_t *mod = cg->mod;
629 be_abi_irg_t *babi = cg->birg->abi;
632 ir_node *block, *noreg_gp, *noreg_fp;
633 ir_node *left, *right, *temp;
634 ir_node *store, *load, *mem_proj;
635 ir_node *succ, *addr_b, *addr_i;
636 int check_am_src = 0;
638 if (! is_ia32_irn(irn))
641 dbg = get_irn_dbg_info(irn);
642 mode = get_irn_mode(irn);
643 block = get_nodes_block(irn);
644 noreg_gp = ia32_new_NoReg_gp(cg);
645 noreg_fp = ia32_new_NoReg_fp(cg);
647 DBG((mod, LEVEL_1, "checking for AM\n"));
649 /* 1st part: check for address calculations and transform the into Lea */
651 /* Following cases can occur: */
652 /* - Sub (l, imm) -> LEA [base - offset] */
653 /* - Sub (l, r == LEA with ia32_am_O) -> LEA [base - offset] */
654 /* - Add (l, imm) -> LEA [base + offset] */
655 /* - Add (l, r == LEA with ia32_am_O) -> LEA [base + offset] */
656 /* - Add (l == LEA with ia32_am_O, r) -> LEA [base + offset] */
657 /* - Add (l, r) -> LEA [base + index * scale] */
658 /* with scale > 1 iff l/r == shl (1,2,3) */
660 if (is_ia32_Sub(irn) || is_ia32_Add(irn)) {
661 left = get_irn_n(irn, 2);
662 right = get_irn_n(irn, 3);
664 /* Do not try to create a LEA if one of the operands is a Load. */
665 /* check is irn is a candidate for address calculation */
666 if (is_candidate(block, irn, 1)) {
667 DBG((mod, LEVEL_1, "\tfound address calculation candidate %+F ... ", irn));
668 res = fold_addr(babi, irn, mod, noreg_gp);
671 DB((mod, LEVEL_1, "transformed into %+F\n", res));
673 DB((mod, LEVEL_1, "not transformed\n"));
677 /* 2nd part: fold following patterns: */
678 /* - Load -> LEA into Load } TODO: If the LEA is used by more than one Load/Store */
679 /* - Store -> LEA into Store } it might be better to keep the LEA */
680 /* - op -> Load into AMop with am_Source */
682 /* - op is am_Source capable AND */
683 /* - the Load is only used by this op AND */
684 /* - the Load is in the same block */
685 /* - Store -> op -> Load into AMop with am_Dest */
687 /* - op is am_Dest capable AND */
688 /* - the Store uses the same address as the Load AND */
689 /* - the Load is only used by this op AND */
690 /* - the Load and Store are in the same block AND */
691 /* - nobody else uses the result of the op */
693 if ((res == irn) && (get_ia32_am_support(irn) != ia32_am_None) && !is_ia32_Lea(irn)) {
694 /* 1st: check for Load/Store -> LEA */
695 if (is_ia32_Ld(irn) || is_ia32_St(irn) || is_ia32_Store8Bit(irn)) {
696 left = get_irn_n(irn, 0);
698 if (is_ia32_Lea(left)) {
699 DBG((mod, LEVEL_1, "\nmerging %+F into %+F\n", left, irn));
701 /* get the AM attributes from the LEA */
702 add_ia32_am_offs(irn, get_ia32_am_offs(left));
703 set_ia32_am_scale(irn, get_ia32_am_scale(left));
704 set_ia32_am_flavour(irn, get_ia32_am_flavour(left));
706 set_ia32_op_type(irn, is_ia32_Ld(irn) ? ia32_AddrModeS : ia32_AddrModeD);
708 /* set base and index */
709 set_irn_n(irn, 0, get_irn_n(left, 0));
710 set_irn_n(irn, 1, get_irn_n(left, 1));
713 /* check if the node is an address mode candidate */
714 else if (is_candidate(block, irn, 0)) {
715 DBG((mod, LEVEL_1, "\tfound address mode candidate %+F ... ", irn));
717 left = get_irn_n(irn, 2);
718 if (get_irn_arity(irn) == 4) {
719 /* it's an "unary" operation */
723 right = get_irn_n(irn, 3);
726 /* normalize commutative ops */
727 if (node_is_comm(irn)) {
728 /* Assure that right operand is always a Load if there is one */
729 /* because non-commutative ops can only use Dest AM if the right */
730 /* operand is a load, so we only need to check right operand. */
731 if (pred_is_specific_nodeblock(block, left, is_ia32_Ld))
733 set_irn_n(irn, 2, right);
734 set_irn_n(irn, 3, left);
742 /* check for Store -> op -> Load */
744 /* Store -> op -> Load optimization is only possible if supported by op */
745 /* and if right operand is a Load */
746 if ((get_ia32_am_support(irn) & ia32_am_Dest) &&
747 pred_is_specific_nodeblock(block, right, is_ia32_Ld))
750 /* An address mode capable op always has a result Proj. */
751 /* If this Proj is used by more than one other node, we don't need to */
752 /* check further, otherwise we check for Store and remember the address, */
753 /* the Store points to. */
755 succ = get_res_proj(irn);
756 assert(succ && "Couldn't find result proj");
762 /* now check for users and Store */
763 if (ia32_get_irn_n_edges(succ) == 1) {
764 succ = get_edge_src_irn(get_irn_out_edge_first(succ));
766 if (is_ia32_fStore(succ) || is_ia32_Store(succ)) {
768 addr_b = get_irn_n(store, 0);
770 /* Could be that the Store is connected to the address */
771 /* calculating LEA while the Load is already transformed. */
772 if (is_ia32_Lea(addr_b)) {
774 addr_b = get_irn_n(succ, 0);
775 addr_i = get_irn_n(succ, 1);
784 /* we found a Store as single user: Now check for Load */
786 /* Extra check for commutative ops with two Loads */
787 /* -> put the interesting Load right */
788 if (node_is_comm(irn) &&
789 pred_is_specific_nodeblock(block, left, is_ia32_Ld))
791 if ((addr_b == get_irn_n(get_Proj_pred(left), 0)) &&
792 (addr_i == get_irn_n(get_Proj_pred(left), 1)))
794 /* We exchange left and right, so it's easier to kill */
795 /* the correct Load later and to handle unary operations. */
796 set_irn_n(irn, 2, right);
797 set_irn_n(irn, 3, left);
805 /* skip the Proj for easier access */
806 load = get_Proj_pred(right);
808 /* Compare Load and Store address */
809 if (load_store_addr_is_equal(load, store, addr_b, addr_i)) {
810 /* Right Load is from same address, so we can */
811 /* disconnect the Load and Store here */
813 /* set new base, index and attributes */
814 set_irn_n(irn, 0, addr_b);
815 set_irn_n(irn, 1, addr_i);
816 add_ia32_am_offs(irn, get_ia32_am_offs(load));
817 set_ia32_am_scale(irn, get_ia32_am_scale(load));
818 set_ia32_am_flavour(irn, get_ia32_am_flavour(load));
819 set_ia32_op_type(irn, ia32_AddrModeD);
820 set_ia32_frame_ent(irn, get_ia32_frame_ent(load));
821 set_ia32_ls_mode(irn, get_ia32_ls_mode(load));
823 if (is_ia32_use_frame(load))
824 set_ia32_use_frame(irn);
826 /* connect to Load memory and disconnect Load */
827 if (get_irn_arity(irn) == 5) {
829 set_irn_n(irn, 4, get_irn_n(load, 2));
830 set_irn_n(irn, 3, noreg_gp);
834 set_irn_n(irn, 3, get_irn_n(load, 2));
835 set_irn_n(irn, 2, noreg_gp);
838 /* connect the memory Proj of the Store to the op */
839 mem_proj = get_mem_proj(store);
840 set_Proj_pred(mem_proj, irn);
841 set_Proj_proj(mem_proj, 1);
843 DB((mod, LEVEL_1, "merged with %+F and %+F into dest AM\n", load, store));
846 else if (get_ia32_am_support(irn) & ia32_am_Source) {
847 /* There was no store, check if we still can optimize for source address mode */
850 } /* if (support AM Dest) */
851 else if (get_ia32_am_support(irn) & ia32_am_Source) {
852 /* op doesn't support am AM Dest -> check for AM Source */
856 /* normalize commutative ops */
857 if (node_is_comm(irn)) {
858 /* Assure that left operand is always a Load if there is one */
859 /* because non-commutative ops can only use Source AM if the */
860 /* left operand is a Load, so we only need to check the left */
861 /* operand afterwards. */
862 if (pred_is_specific_nodeblock(block, right, is_ia32_Ld)) {
863 set_irn_n(irn, 2, right);
864 set_irn_n(irn, 3, left);
872 /* optimize op -> Load iff Load is only used by this op */
873 /* and left operand is a Load which only used by this irn */
875 pred_is_specific_nodeblock(block, left, is_ia32_Ld) &&
876 (ia32_get_irn_n_edges(left) == 1))
878 left = get_Proj_pred(left);
880 addr_b = get_irn_n(left, 0);
881 addr_i = get_irn_n(left, 1);
883 /* set new base, index and attributes */
884 set_irn_n(irn, 0, addr_b);
885 set_irn_n(irn, 1, addr_i);
886 add_ia32_am_offs(irn, get_ia32_am_offs(left));
887 set_ia32_am_scale(irn, get_ia32_am_scale(left));
888 set_ia32_am_flavour(irn, get_ia32_am_flavour(left));
889 set_ia32_op_type(irn, ia32_AddrModeS);
890 set_ia32_frame_ent(irn, get_ia32_frame_ent(left));
891 set_ia32_ls_mode(irn, get_ia32_ls_mode(left));
893 if (is_ia32_use_frame(left))
894 set_ia32_use_frame(irn);
896 /* connect to Load memory */
897 if (get_irn_arity(irn) == 5) {
899 set_irn_n(irn, 4, get_irn_n(left, 2));
903 set_irn_n(irn, 3, get_irn_n(left, 2));
906 /* disconnect from Load */
907 set_irn_n(irn, 2, noreg_gp);
909 /* If Load has a memory Proj, connect it to the op */
910 mem_proj = get_mem_proj(left);
912 set_Proj_pred(mem_proj, irn);
913 set_Proj_proj(mem_proj, 1);
916 DB((mod, LEVEL_1, "merged with %+F into source AM\n", left));