- for (i = dims - 1; i >= 0; i--) {
- int dim = map[i];
- ir_node *lb, *ub, *elms, *n, *ind;
-
- elms = NULL;
- lb = get_array_lower_bound(arr_ty, dim);
- ub = get_array_upper_bound(arr_ty, dim);
-
- assert(irg == current_ir_graph);
- if (get_irn_op(lb) != op_Unknown)
- lb = new_rd_Conv(dbg, irg, bl, copy_const_value(get_irn_dbg_info(sel), lb), mode_Int);
- else
- lb = NULL;
-
- if (get_irn_op(ub) != op_Unknown)
- ub = new_rd_Conv(dbg, irg, bl, copy_const_value(get_irn_dbg_info(sel), ub), mode_Int);
- else
- ub = NULL;
-
- /*
- * If the array has more than one dimension, lower and upper
- * bounds have to be set in the non-last dimension.
- */
- if (i > 0) {
- assert(lb && "lower bound has to be set in multi-dim array");
- assert(lb && "upper bound has to be set in multi-dim array");
-
- /* Elements in one Dimension */
- elms = new_rd_Sub(dbg, irg, bl, ub, lb, mode_Int);
- }
-
- ind = new_rd_Conv(dbg, irg, bl, get_Sel_index(sel, dim), mode_Int);
-
- /*
- * Normalize index, id lower bound is set, also assume
- * lower bound == 0
- */
- if (lb)
- ind = new_rd_Sub(dbg, irg, bl, ind, lb, mode_Int);
-
- n = new_rd_Mul(dbg, irg, bl, ind, last_size, mode_Int);
-
- /*
- * see comment above.
- */
- if (i > 0)
- last_size = new_rd_Mul(dbg, irg, bl, last_size, elms, mode_Int);
-
- newn = new_rd_Add(dbg, irg, bl, newn, n, mode);
- }
- } else {
- /* no array type */
- ir_mode *idx_mode = get_irn_mode(index);
- tarval *tv = new_tarval_from_long(get_mode_size_bytes(basemode), idx_mode);
-
- newn = new_rd_Add(dbg, irg, bl, get_Sel_ptr(sel),
- new_rd_Mul(dbg, irg, bl, index,
- new_r_Const(irg, get_irg_start_block(irg), idx_mode, tv),
- idx_mode),
- mode);