-static ir_node *build_copy_graph(dbg_info *dbg, ir_node *blk, ir_node *mem, ir_node *src, ir_node *tgt, ir_type *tp) {
- int i, n;
-
- if (is_Array_type(tp)) {
- assert(0);
- } else {
- for (i = 0, n = get_compound_n_members(tp); i < n; ++i) {
- ir_entity *ent = get_compound_member(tp, i);
- ir_node *s = new_d_simpleSel(dbg, mem, src, ent);
- ir_node *d = new_d_simpleSel(dbg, mem, tgt, ent);
- ir_type *ent_tp = get_entity_type(ent);
-
- if (is_atomic_type(ent_tp)) {
- ir_mode *mode = get_type_mode(ent_tp);
- ir_node *irn = new_rd_Load(dbg, current_ir_graph, blk, mem, s, mode);
- ir_node *res = new_r_Proj(current_ir_graph, blk, irn, mode, pn_Load_res);
-
- mem = new_r_Proj(current_ir_graph, blk, irn, mode_M, pn_Load_M);
- irn = new_rd_Store(dbg, current_ir_graph, blk, mem, d, res);
- mem = new_r_Proj(current_ir_graph, blk, irn, mode_M, pn_Store_M);
- } else {
- mem = build_copy_graph(dbg, blk, mem, s, d, ent_tp);
- }
+static void lower_copyb_nodes(ir_node *irn, unsigned mode_bytes)
+{
+ ir_graph *irg = get_irn_irg(irn);
+ unsigned size;
+ unsigned offset;
+ ir_mode *mode;
+ ir_mode *addr_mode;
+ ir_node *mem;
+ ir_node *addr_src;
+ ir_node *addr_dst;
+ ir_node *block;
+ ir_type *tp;
+
+ addr_src = get_CopyB_src(irn);
+ addr_dst = get_CopyB_dst(irn);
+ mem = get_CopyB_mem(irn);
+ addr_mode = get_irn_mode(addr_src);
+ block = get_nodes_block(irn);
+
+ tp = get_CopyB_type(irn);
+ size = get_type_size_bytes(tp);
+
+ offset = 0;
+ while (offset < size) {
+ mode = get_ir_mode(mode_bytes);
+ for (; offset + mode_bytes <= size; offset += mode_bytes) {
+ /* construct offset */
+ ir_node *addr_const;
+ ir_node *add;
+ ir_node *load;
+ ir_node *load_res;
+ ir_node *load_mem;
+ ir_node *store;
+ ir_node *store_mem;
+
+ addr_const = new_r_Const_long(irg, mode_Iu, offset);
+ add = new_r_Add(block, addr_src, addr_const, addr_mode);
+
+ load = new_r_Load(block, mem, add, mode, cons_none);
+ load_res = new_r_Proj(load, mode, pn_Load_res);
+ load_mem = new_r_Proj(load, mode_M, pn_Load_M);
+
+ addr_const = new_r_Const_long(irg, mode_Iu, offset);
+ add = new_r_Add(block, addr_dst, addr_const, addr_mode);
+
+ store = new_r_Store(block, load_mem, add, load_res, cons_none);
+ store_mem = new_r_Proj(store, mode_M, pn_Store_M);
+
+ mem = store_mem;