-
- /* copy the frame entity (could be set in case of Add */
- /* which was a FrameAddr) */
- if (lea_ent)
- set_ia32_frame_ent(res, lea_ent);
- else
- set_ia32_frame_ent(res, get_ia32_frame_ent(irn));
-
- if (get_ia32_frame_ent(res))
- set_ia32_use_frame(res);
-
- /* set scale */
- set_ia32_am_scale(res, scale);
-
- am_flav = ia32_am_N;
- /* determine new am flavour */
- if (offs || offs_cnst || offs_lea || have_am_sc) {
- am_flav |= ia32_O;
- }
- if (! be_is_NoReg(cg, base)) {
- am_flav |= ia32_B;
- }
- if (! be_is_NoReg(cg, index)) {
- am_flav |= ia32_I;
- }
- if (scale > 0) {
- am_flav |= ia32_S;
- }
- set_ia32_am_flavour(res, am_flav);
-
- set_ia32_op_type(res, ia32_AddrModeS);
-
- SET_IA32_ORIG_NODE(res, ia32_get_old_node_name(cg, irn));
-
- DBG((mod, LEVEL_1, "\tLEA [%+F + %+F * %d + %s]\n", base, index, scale, get_ia32_am_offs(res)));
-
- /* we will exchange it, report here before the Proj is created */
- if (shift && lea && lea_o) {
- try_remove_from_sched(shift);
- try_remove_from_sched(lea);
- try_remove_from_sched(lea_o);
- DBG_OPT_LEA4(irn, lea_o, lea, shift, res);
- }
- else if (shift && lea) {
- try_remove_from_sched(shift);
- try_remove_from_sched(lea);
- DBG_OPT_LEA3(irn, lea, shift, res);
- }
- else if (shift && lea_o) {
- try_remove_from_sched(shift);
- try_remove_from_sched(lea_o);
- DBG_OPT_LEA3(irn, lea_o, shift, res);
- }
- else if (lea && lea_o) {
- try_remove_from_sched(lea);
- try_remove_from_sched(lea_o);
- DBG_OPT_LEA3(irn, lea_o, lea, res);
- }
- else if (shift) {
- try_remove_from_sched(shift);
- DBG_OPT_LEA2(irn, shift, res);
- }
- else if (lea) {
- try_remove_from_sched(lea);
- DBG_OPT_LEA2(irn, lea, res);
- }
- else if (lea_o) {
- try_remove_from_sched(lea_o);
- DBG_OPT_LEA2(irn, lea_o, res);
- }
- else
- DBG_OPT_LEA1(irn, res);
-
- /* get the result Proj of the Add/Sub */
- try_add_to_sched(irn, res);
- try_remove_from_sched(irn);
- irn = ia32_get_res_proj(irn);
-
- assert(irn && "Couldn't find result proj");
-
- /* exchange the old op with the new LEA */
- exchange(irn, res);