- 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 (! is_Unknown(lb))
- lb = new_rd_Conv(dbg, bl, copy_const_value(get_irn_dbg_info(sel), lb), mode_Int);
- else
- lb = NULL;
-
- if (! is_Unknown(ub))
- ub = new_rd_Conv(dbg, 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 != NULL && "lower bound has to be set in multi-dim array");
- assert(ub != NULL && "upper bound has to be set in multi-dim array");
-
- /* Elements in one Dimension */
- elms = new_rd_Sub(dbg, bl, ub, lb, mode_Int);
- }
-
- ind = new_rd_Conv(dbg, bl, get_Sel_index(sel, dim), mode_Int);
-
- /*
- * Normalize index, id lower bound is set, also assume
- * lower bound == 0
- */
- if (lb != NULL)
- ind = new_rd_Sub(dbg, bl, ind, lb, mode_Int);
-
- n = new_rd_Mul(dbg, bl, ind, last_size, mode_Int);
-
- /*
- * see comment above.
- */
- if (i > 0)
- last_size = new_rd_Mul(dbg, bl, last_size, elms, mode_Int);
-
- newn = new_rd_Add(dbg, 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, bl, get_Sel_ptr(sel),
- new_rd_Mul(dbg, bl, index,
- new_r_Const(irg, tv),
- idx_mode),
- mode);
- }
- } else if (is_Method_type(get_entity_type(ent)) &&
- is_Class_type(owner) &&
- (owner != get_glob_type()) &&
- (!is_frame_type(owner))) {
- ir_node *add;
- ir_mode *ent_mode = get_type_mode(get_entity_type(ent));
-
- /* We need an additional load when accessing methods from a dispatch table. */
- tv = new_tarval_from_long(get_entity_offset(ent), mode_Int);
- cnst = new_rd_Const(dbg, irg, tv);
- add = new_rd_Add(dbg, bl, get_Sel_ptr(sel), cnst, mode);
-#ifdef DO_CACHEOPT /* cacheopt version */
- newn = new_rd_Load(dbg, bl, get_Sel_mem(sel), sel, ent_mode, 0);
- cacheopt_map_addrs_register_node(newn);
- set_Load_ptr(newn, add);
-#else /* normal code */
- newn = new_rd_Load(dbg, bl, get_Sel_mem(sel), add, ent_mode, 0);
-#endif
- newn = new_r_Proj(newn, ent_mode, pn_Load_res);
-
- } else if (get_entity_owner(ent) != get_glob_type()) {
- int offset;
-
- /* replace Sel by add(obj, const(ent.offset)) */
- newn = get_Sel_ptr(sel);
- offset = get_entity_offset(ent);
- if (offset != 0) {
- ir_mode *mode_UInt = get_reference_mode_unsigned_eq(mode);
-
- tv = new_tarval_from_long(offset, mode_UInt);
- cnst = new_r_Const(irg, tv);
- newn = new_rd_Add(dbg, bl, newn, cnst, mode);