2 * Author: Christian Wuerdig
4 * Copyright: (c) Universitaet Karlsruhe
5 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
8 * Performs lowering of perm nodes and spill/reload optimization.
22 #include "bechordal_t.h"
23 #include "besched_t.h"
26 #include "iredges_t.h"
37 #define is_Perm(arch_env, irn) (arch_irn_classify(arch_env, irn) == arch_irn_class_perm)
39 /* collect static data about perms */
40 typedef struct _perm_stat_t {
41 const arch_register_class_t *cls; /**< the current register class */
42 int *perm_size_ar; /**< the sizes of all perms in an irg */
43 int *real_perm_size_ar; /**< the sizes of all perms in an irg */
44 int *chain_len_ar; /**< the sizes of all chains for all perms */
45 int *cycle_len_ar; /**< the siyes of all cycles for all perms */
46 int num_perms; /**< number of all perms */
47 int num_real_perms; /**< number of all perms */
48 int num_chains; /**< the number of all chains */
49 int num_cycles; /**< the number of all cycles */
52 /* lowering walker environment */
53 typedef struct _lower_env_t {
54 be_chordal_env_t *chord_env;
59 DEBUG_ONLY(firm_dbg_module_t *dbg_module;)
62 /* holds a perm register pair */
63 typedef struct _reg_pair_t {
64 const arch_register_t *in_reg; /**< a perm IN register */
65 ir_node *in_node; /**< the in node to which the register belongs */
67 const arch_register_t *out_reg; /**< a perm OUT register */
68 ir_node *out_node; /**< the out node to which the register belongs */
70 int checked; /**< indicates whether the pair was check for cycle or not */
73 typedef enum _perm_type_t {
80 /* structure to represent cycles or chains in a perm */
81 typedef struct _perm_cycle_t {
82 const arch_register_t **elems; /**< the registers in the cycle */
83 int n_elems; /**< number of elements in the cycle */
84 perm_type_t type; /**< type (CHAIN or CYCLE) */
87 /* Compare the in registers of two register pairs */
88 static int compare_reg_pair(const void *a, const void *b) {
89 const reg_pair_t *pair_a = a;
90 const reg_pair_t *pair_b = b;
92 if (pair_a->in_reg->index > pair_b->in_reg->index)
98 /* returns the number register pairs marked as checked */
99 static int get_n_checked_pairs(reg_pair_t *pairs, int n) {
100 int i, n_checked = 0;
102 for (i = 0; i < n; i++) {
103 if (pairs[i].checked)
111 * Gets the node corresponding to a register from an array of register pairs.
112 * NOTE: The given registers pairs and the register to look for must belong
113 * to the same register class.
115 * @param pairs The array of register pairs
116 * @param n The number of pairs
117 * @param reg The register to look for
118 * @param in_out 0 == look for IN register, 1 == look for OUT register
119 * @return The corresponding node or NULL if not found
121 static ir_node *get_node_for_register(reg_pair_t *pairs, int n, const arch_register_t *reg, int in_out) {
125 for (i = 0; i < n; i++) {
126 /* out register matches */
127 if (pairs[i].out_reg->index == reg->index)
128 return pairs[i].out_node;
132 for (i = 0; i < n; i++) {
133 /* in register matches */
134 if (pairs[i].in_reg->index == reg->index)
135 return pairs[i].in_node;
143 * Gets the index in the register pair array where the in/out register
144 * corresponds to reg_idx.
146 * @param pairs The array of register pairs
147 * @param n The number of pairs
148 * @param reg The register index to look for
149 * @param in_out 0 == look for IN register, 1 == look for OUT register
150 * @return The corresponding index in pairs or -1 if not found
152 static int get_pairidx_for_regidx(reg_pair_t *pairs, int n, int reg_idx, int in_out) {
156 for (i = 0; i < n; i++) {
157 /* out register matches */
158 if (pairs[i].out_reg->index == reg_idx)
163 for (i = 0; i < n; i++) {
164 /* in register matches */
165 if (pairs[i].in_reg->index == reg_idx)
174 * Gets an array of register pairs and tries to identify a cycle or chain starting
177 * @param cycle Variable to hold the cycle
178 * @param pairs Array of register pairs
179 * @param start Index to start
180 * @return The cycle or chain
182 static perm_cycle_t *get_perm_cycle(perm_cycle_t *cycle, reg_pair_t *pairs, int n, int start) {
183 int head = pairs[start].in_reg->index;
184 int cur_idx = pairs[start].out_reg->index;
185 int cur_pair_idx = start;
186 int n_pairs_done = get_n_checked_pairs(pairs, n);
188 perm_type_t cycle_tp = PERM_CYCLE;
190 /* We could be right in the middle of a chain, so we need to find the start */
191 while (head != cur_idx) {
192 /* goto previous register in cycle or chain */
193 cur_pair_idx = get_pairidx_for_regidx(pairs, n, head, 1);
195 if (cur_pair_idx < 0) {
196 cycle_tp = PERM_CHAIN;
200 head = pairs[cur_pair_idx].in_reg->index;
201 start = cur_pair_idx;
205 /* assume worst case: all remaining pairs build a cycle or chain */
206 cycle->elems = xcalloc((n - n_pairs_done) * 2, sizeof(cycle->elems[0]));
207 cycle->n_elems = 2; /* initial number of elements is 2 */
208 cycle->elems[0] = pairs[start].in_reg;
209 cycle->elems[1] = pairs[start].out_reg;
210 cycle->type = cycle_tp;
211 cur_idx = pairs[start].out_reg->index;
214 /* check for cycle or end of a chain */
215 while (cur_idx != head) {
216 /* goto next register in cycle or chain */
217 cur_pair_idx = get_pairidx_for_regidx(pairs, n, cur_idx, 0);
219 if (cur_pair_idx < 0)
222 cur_idx = pairs[cur_pair_idx].out_reg->index;
224 /* it's not the first element: insert it */
225 if (cur_idx != head) {
226 cycle->elems[idx++] = pairs[cur_pair_idx].out_reg;
230 /* we are there where we started -> CYCLE */
231 cycle->type = PERM_CYCLE;
235 /* mark all pairs having one in/out register with cycle in common as checked */
236 for (idx = 0; idx < cycle->n_elems; idx++) {
237 cur_pair_idx = get_pairidx_for_regidx(pairs, n, cycle->elems[idx]->index, 0);
239 if (cur_pair_idx >= 0)
240 pairs[cur_pair_idx].checked = 1;
242 cur_pair_idx = get_pairidx_for_regidx(pairs, n, cycle->elems[idx]->index, 1);
244 if (cur_pair_idx >= 0)
245 pairs[cur_pair_idx].checked = 1;
252 * Lowers a perm node. Resolves cycles and creates a bunch of
253 * copy and swap operations to permute registers.
254 * Note: The caller of this function has to make sure, that irn
257 * @param irn The perm node
258 * @param block The block the perm node belongs to
259 * @param walk_env The environment
261 static void lower_perm_node(ir_node *irn, void *walk_env) {
262 const arch_register_class_t *reg_class;
263 const arch_env_t *arch_env;
264 lower_env_t *env = walk_env;
265 perm_stat_t **pstat = env->pstat;
267 const ir_edge_t *edge;
269 int n, i, pn, do_copy, j, pstat_idx = -1;
270 ir_node *sched_point, *block, *in[2];
271 ir_node *arg1, *arg2, *res1, *res2;
272 ir_node *cpyxchg = NULL;
273 DEBUG_ONLY(firm_dbg_module_t *mod;)
275 arch_env = env->chord_env->birg->main_env->arch_env;
276 do_copy = env->do_copy;
277 DEBUG_ONLY(mod = env->dbg_module;)
278 block = get_nodes_block(irn);
281 Get the schedule predecessor node to the perm
282 NOTE: This works with auto-magic. If we insert the
283 new copy/exchange nodes after this node, everything
286 sched_point = sched_prev(irn);
287 DBG((mod, LEVEL_1, "sched point is %+F\n", sched_point));
288 assert(sched_point && "Perm is not scheduled or has no predecessor");
290 n = get_irn_arity(irn);
291 assert(n == get_irn_n_edges(irn) && "perm's in and out numbers different");
293 reg_class = arch_get_irn_register(arch_env, get_irn_n(irn, 0))->reg_class;
294 pairs = alloca(n * sizeof(pairs[0]));
297 /* determine index in statistics */
298 for (i = 0; i < env->pstat_n; i++) {
299 if (strcmp(pstat[i]->cls->name, reg_class->name) == 0) {
304 assert(pstat_idx >= 0 && "could not determine class index for statistics");
306 pstat[pstat_idx]->num_perms++;
307 pstat[pstat_idx]->perm_size_ar[n - 1]++;
310 /* build the list of register pairs (in, out) */
312 foreach_out_edge(irn, edge) {
313 pairs[i].out_node = get_edge_src_irn(edge);
314 pn = get_Proj_proj(pairs[i].out_node);
315 pairs[i].in_node = get_irn_n(irn, pn);
317 pairs[i].in_reg = arch_get_irn_register(arch_env, pairs[i].in_node);
318 pairs[i].out_reg = arch_get_irn_register(arch_env, pairs[i].out_node);
320 pairs[i].checked = 0;
324 /* sort the register pairs by the indices of the in registers */
325 qsort(pairs, n, sizeof(pairs[0]), compare_reg_pair);
327 /* Mark all equal pairs as checked, and exchange the OUT proj with
329 for (i = 0; i < n; i++) {
330 if (pairs[i].in_reg->index == pairs[i].out_reg->index) {
331 DBG((mod, LEVEL_1, "%+F removing equal perm register pair (%+F, %+F, %s)\n",
332 irn, pairs[i].in_node, pairs[i].out_node, pairs[i].out_reg->name));
334 /* We have to check for a special case:
335 The in-node could be a Proj from a Perm. In this case,
336 we need to correct the projnum */
337 if (is_Perm(arch_env, pairs[i].in_node) && is_Proj(pairs[i].in_node)) {
338 set_Proj_proj(pairs[i].out_node, get_Proj_proj(pairs[i].in_node));
341 /* remove the proj from the schedule */
342 sched_remove(pairs[i].out_node);
344 /* reroute the edges from the proj to the argument */
345 edges_reroute(pairs[i].out_node, pairs[i].in_node, env->chord_env->irg);
347 pairs[i].checked = 1;
351 /* Set do_copy to 0 if it's on but we have no free register */
356 if (env->do_stat && get_n_checked_pairs(pairs, n) < n) {
357 pstat[pstat_idx]->num_real_perms++;
358 pstat[pstat_idx]->real_perm_size_ar[n - 1]++;
361 /* check for cycles and chains */
362 while (get_n_checked_pairs(pairs, n) < n) {
365 /* go to the first not-checked pair */
366 while (pairs[i].checked) i++;
367 cycle = xcalloc(1, sizeof(*cycle));
368 cycle = get_perm_cycle(cycle, pairs, n, i);
370 DB((mod, LEVEL_1, "%+F: following %s created:\n ", irn, cycle->type == PERM_CHAIN ? "chain" : "cycle"));
371 for (j = 0; j < cycle->n_elems; j++) {
372 DB((mod, LEVEL_1, " %s", cycle->elems[j]->name));
374 DB((mod, LEVEL_1, "\n"));
378 int n_idx = cycle->n_elems - 1;
379 if (cycle->type == PERM_CHAIN) {
380 pstat[pstat_idx]->num_chains++;
381 pstat[pstat_idx]->chain_len_ar[n_idx]++;
384 pstat[pstat_idx]->num_cycles++;
385 pstat[pstat_idx]->cycle_len_ar[n_idx]++;
389 /* We don't need to do anything if we have a Perm with two
390 elements which represents a cycle, because those nodes
391 already represent exchange nodes */
392 if (n == 2 && cycle->type == PERM_CYCLE) {
397 //TODO: - iff PERM_CYCLE && do_copy -> determine free temp reg and insert copy to/from it before/after
398 // the copy cascade (this reduces the cycle into a chain)
400 /* build copy/swap nodes from back to front */
401 for (i = cycle->n_elems - 2; i >= 0; i--) {
402 arg1 = get_node_for_register(pairs, n, cycle->elems[i], 0);
403 arg2 = get_node_for_register(pairs, n, cycle->elems[i + 1], 0);
405 res1 = get_node_for_register(pairs, n, cycle->elems[i], 1);
406 res2 = get_node_for_register(pairs, n, cycle->elems[i + 1], 1);
409 If we have a cycle and don't copy: we need to create exchange nodes
410 NOTE: An exchange node is a perm node with 2 INs and 2 OUTs
411 IN_1 = in node with register i
412 IN_2 = in node with register i + 1
413 OUT_1 = out node with register i + 1
414 OUT_2 = out node with register i
416 if (cycle->type == PERM_CYCLE && !do_copy) {
420 /* At this point we have to handle the following problem: */
422 /* If we have a cycle with more than two elements, then */
423 /* this could correspond to the following Perm node: */
425 /* +----+ +----+ +----+ */
426 /* | r1 | | r2 | | r3 | */
427 /* +-+--+ +-+--+ +--+-+ */
430 /* +-+--------+---------+-+ */
432 /* +-+--------+---------+-+ */
435 /* +-+--+ +-+--+ +--+-+ */
436 /* |Proj| |Proj| |Proj| */
437 /* | r2 | | r3 | | r1 | */
438 /* +----+ +----+ +----+ */
440 /* This node is about to be split up into two 2x Perm's */
441 /* for which we need 4 Proj's and the one additional Proj */
442 /* of the first Perm has to be one IN of the second. So in */
443 /* general we need to create one additional Proj for each */
444 /* "middle" Perm and set this to one in node of the successor */
447 DBG((mod, LEVEL_1, "%+F creating exchange node (%+F, %s) and (%+F, %s) with\n",
448 irn, arg1, cycle->elems[i]->name, arg2, cycle->elems[i + 1]->name));
449 DBG((mod, LEVEL_1, "%+F (%+F, %s) and (%+F, %s)\n",
450 irn, res1, cycle->elems[i]->name, res2, cycle->elems[i + 1]->name));
452 cpyxchg = be_new_Perm(reg_class, env->chord_env->irg, block, 2, in);
455 /* cycle is not done yet */
456 int pidx = get_pairidx_for_regidx(pairs, n, cycle->elems[i]->index, 0);
458 /* create intermediate proj */
459 res1 = new_r_Proj(get_irn_irg(irn), block, cpyxchg, get_irn_mode(res1), 0);
461 /* set as in for next Perm */
462 pairs[pidx].in_node = res1;
470 set_Proj_pred(res2, cpyxchg);
471 set_Proj_proj(res2, 0);
472 set_Proj_pred(res1, cpyxchg);
473 set_Proj_proj(res1, 1);
475 sched_add_after(sched_point, res1);
476 sched_add_after(sched_point, res2);
478 arch_set_irn_register(arch_env, res2, cycle->elems[i + 1]);
479 arch_set_irn_register(arch_env, res1, cycle->elems[i]);
481 /* insert the copy/exchange node in schedule after the magic schedule node (see above) */
482 sched_add_after(sched_point, cpyxchg);
484 DBG((mod, LEVEL_1, "replacing %+F with %+F, placed new node after %+F\n", irn, cpyxchg, sched_point));
486 /* set the new scheduling point */
490 DBG((mod, LEVEL_1, "%+F creating copy node (%+F, %s) -> (%+F, %s)\n",
491 irn, arg1, cycle->elems[i]->name, res2, cycle->elems[i + 1]->name));
493 cpyxchg = be_new_Copy(reg_class, env->chord_env->irg, block, arg1);
494 arch_set_irn_register(arch_env, cpyxchg, cycle->elems[i + 1]);
496 /* remove the proj from the schedule */
499 /* exchange copy node and proj */
500 exchange(res2, cpyxchg);
502 /* insert the copy/exchange node in schedule after the magic schedule node (see above) */
503 sched_add_after(sched_point, cpyxchg);
505 /* set the new scheduling point */
506 sched_point = cpyxchg;
510 free((void *) cycle->elems);
514 /* remove the perm from schedule */
520 static int get_n_out_edges(const ir_node *irn) {
521 const ir_edge_t *edge;
524 foreach_out_edge(irn, edge) {
531 static ir_node *belower_skip_proj(ir_node *irn) {
533 irn = get_Proj_pred(irn);
537 static void fix_in(ir_node *irn, ir_node *old, ir_node *nw) {
540 irn = belower_skip_proj(irn);
541 n = get_irn_arity(irn);
543 for (i = 0; i < n; i++) {
544 if (get_irn_n(irn, i) == old) {
545 set_irn_n(irn, i, nw);
551 static void gen_assure_different_pattern(ir_node *irn, be_irg_t *birg, ir_node *other_different) {
552 const arch_env_t *arch_env = birg->main_env->arch_env;
553 ir_node *in[2], *keep, *cpy, *temp;
554 ir_node *block = get_nodes_block(irn);
555 const arch_register_class_t *cls = arch_get_irn_reg_class(arch_env, other_different, -1);
556 FIRM_DBG_REGISTER(firm_dbg_module_t *mod, "firm.be.lower");
558 if (arch_irn_is(arch_env, other_different, ignore) || ! mode_is_datab(get_irn_mode(other_different))) {
559 DBG((mod, LEVEL_1, "ignore constraint for %+F because other_irn is ignore or not a datab node\n", irn));
563 /* Make a not spillable copy of the different node */
564 /* this is needed because the different irn could be */
565 /* in block far far away */
566 /* The copy is optimized later if not needed */
568 temp = new_rd_Unknown(birg->irg, get_irn_mode(other_different));
569 cpy = be_new_Copy(cls, birg->irg, block, temp);
570 be_node_set_flags(cpy, BE_OUT_POS(0), arch_irn_flags_dont_spill);
575 /* Let the irn use the copy instead of the old other_different */
576 fix_in(irn, other_different, cpy);
578 /* Add the Keep resp. CopyKeep and reroute the users */
579 /* of the other_different irn in case of CopyKeep. */
580 if (get_n_out_edges(other_different) == 0) {
581 keep = be_new_Keep(cls, birg->irg, block, 2, in);
584 keep = be_new_CopyKeep_single(cls, birg->irg, block, cpy, irn, get_irn_mode(other_different));
585 be_node_set_reg_class(keep, 1, cls);
586 edges_reroute(other_different, keep, birg->irg);
589 /* after rerouting: let the copy point to the other_different irn */
590 set_irn_n(cpy, 0, other_different);
592 DBG((mod, LEVEL_1, "created %+F for %+F to assure should_be_different\n", keep, irn));
596 * Checks if node has a should_be_different constraint in output
597 * and adds a Keep then to assure the constraint.
599 static void assure_different_constraints(ir_node *irn, be_irg_t *birg) {
600 const arch_env_t *arch_env = birg->main_env->arch_env;
601 const arch_register_req_t *req;
602 arch_register_req_t req_temp;
605 req = arch_get_register_req(arch_env, &req_temp, irn, -1);
608 if (arch_register_req_is(req, should_be_different)) {
609 gen_assure_different_pattern(irn, birg, req->other_different);
611 else if (arch_register_req_is(req, should_be_different_from_all)) {
612 n = get_irn_arity(belower_skip_proj(irn));
613 for (i = 0; i < n; i++) {
614 gen_assure_different_pattern(irn, birg, get_irn_n(belower_skip_proj(irn), i));
623 * Calls the functions to assure register constraints.
625 * @param irn The node to be checked for lowering
626 * @param walk_env The walker environment
628 static void assure_constraints_walker(ir_node *irn, void *walk_env) {
632 if (mode_is_datab(get_irn_mode(irn)))
633 assure_different_constraints(irn, walk_env);
641 * Walks over all nodes to assure register constraints.
643 * @param birg The birg structure containing the irg
645 void assure_constraints(be_irg_t *birg) {
646 irg_walk_blkwise_graph(birg->irg, NULL, assure_constraints_walker, birg);
652 * Calls the corresponding lowering function for the node.
654 * @param irn The node to be checked for lowering
655 * @param walk_env The walker environment
657 static void lower_nodes_after_ra_walker(ir_node *irn, void *walk_env) {
658 lower_env_t *env = walk_env;
659 const arch_env_t *arch_env = env->chord_env->birg->main_env->arch_env;
661 if (!is_Block(irn) && !is_Proj(irn)) {
662 if (is_Perm(arch_env, irn)) {
663 lower_perm_node(irn, walk_env);
670 static void lower_print_perm_stat(lower_env_t *env) {
671 int i, j, total_len_chain, total_len_cycle, total_size_perm, total_size_real_perm;
673 printf("=== IRG: %s ===\n", get_entity_name(get_irg_entity(env->chord_env->irg)));
674 for (i = 0; i < env->pstat_n; i++) {
675 if (env->pstat[i]->num_perms == 0)
678 printf("CLASS: %s\n", env->pstat[i]->cls->name);
679 printf("# total perms: %d (size:num -> 1:%d", env->pstat[i]->num_perms, env->pstat[i]->perm_size_ar[0]);
681 total_size_perm = env->pstat[i]->perm_size_ar[0];
682 for (j = 1; j < env->pstat[i]->cls->n_regs; j++) {
683 total_size_perm += (j + 1) * env->pstat[i]->perm_size_ar[j];
684 printf(", %d:%d", j + 1, env->pstat[i]->perm_size_ar[j]);
687 printf("avg perm size: %.2f\n", env->pstat[i]->num_perms ? (float)total_size_perm / (float)env->pstat[i]->num_perms : 0);
689 printf("# real perms: %d (size:num -> 1:%d", env->pstat[i]->num_real_perms, env->pstat[i]->real_perm_size_ar[0]);
691 total_size_real_perm = env->pstat[i]->real_perm_size_ar[0];
692 for (j = 1; j < env->pstat[i]->cls->n_regs; j++) {
693 total_size_real_perm += (j + 1) * env->pstat[i]->real_perm_size_ar[j];
694 printf(", %d:%d", j + 1, env->pstat[i]->real_perm_size_ar[j]);
697 printf("avg real perm size: %.2f\n", env->pstat[i]->num_real_perms ? (float)total_size_real_perm / (float)env->pstat[i]->num_real_perms : 0);
699 printf("# total chains: %d (lenght:num -> 1:%d", env->pstat[i]->num_chains, env->pstat[i]->chain_len_ar[0]);
701 total_len_chain = env->pstat[i]->chain_len_ar[0];
703 for (j = 1; j < env->pstat[i]->cls->n_regs; j++) {
704 total_len_chain += (j + 1) * env->pstat[i]->chain_len_ar[j];
705 printf(", %d:%d", j + 1, env->pstat[i]->chain_len_ar[j]);
708 printf("avg chain length: %.2f\n", env->pstat[i]->num_chains ? (float)total_len_chain / (float)env->pstat[i]->num_chains : 0);
709 printf("avg chains/perm: %.2f\n", env->pstat[i]->num_real_perms ? (float)env->pstat[i]->num_chains / (float)env->pstat[i]->num_real_perms : 0);
711 printf("# total cycles: %d (length:num -> 1:%d", env->pstat[i]->num_cycles, env->pstat[i]->cycle_len_ar[0]);
713 total_len_cycle = env->pstat[i]->cycle_len_ar[0];
714 for (j = 1; j < env->pstat[i]->cls->n_regs; j++) {
715 total_len_cycle += (j + 1) * env->pstat[i]->cycle_len_ar[j];
716 printf(", %d:%d", j + 1, env->pstat[i]->cycle_len_ar[j]);
719 printf("avg cycle length: %.2f\n", env->pstat[i]->num_cycles ? (float)total_len_cycle / (float)env->pstat[i]->num_cycles : 0);
720 printf("avg cycles/perm: %.2f\n", env->pstat[i]->num_real_perms ? (float)env->pstat[i]->num_cycles / (float)env->pstat[i]->num_real_perms : 0);
725 * Walks over all blocks in an irg and performs lowering need to be
726 * done after register allocation (e.g. perm lowering).
728 * @param chord_env The chordal environment containing the irg
729 * @param do_copy 1 == resolve cycles with a free reg if available
731 void lower_nodes_after_ra(be_chordal_env_t *chord_env, int do_copy, int do_stat) {
734 env.chord_env = chord_env;
735 env.do_copy = do_copy;
736 env.do_stat = do_stat;
737 FIRM_DBG_REGISTER(env.dbg_module, "firm.be.lower");
739 /* if we want statistics: allocate memory for the data and initialize with 0 */
741 const arch_isa_t *isa = chord_env->birg->main_env->arch_env->isa;
742 int i, n = arch_isa_get_n_reg_class(isa);
744 env.pstat = alloca(n * sizeof(env.pstat[0]));
747 for (i = 0; i < n; i++) {
748 const arch_register_class_t *cls = arch_isa_get_reg_class(isa, i);
749 int n_regs = cls->n_regs;
751 env.pstat[i] = alloca(sizeof(*(env.pstat[0])));
752 memset(env.pstat[i], 0, sizeof(*(env.pstat[0])));
754 env.pstat[i]->perm_size_ar = alloca(n_regs * sizeof(env.pstat[i]->perm_size_ar[0]));
755 env.pstat[i]->real_perm_size_ar = alloca(n_regs * sizeof(env.pstat[i]->real_perm_size_ar[0]));
756 env.pstat[i]->chain_len_ar = alloca(n_regs * sizeof(env.pstat[i]->chain_len_ar[0]));
757 env.pstat[i]->cycle_len_ar = alloca(n_regs * sizeof(env.pstat[i]->cycle_len_ar[0]));
759 memset(env.pstat[i]->perm_size_ar, 0, n_regs * sizeof(env.pstat[i]->perm_size_ar[0]));
760 memset(env.pstat[i]->real_perm_size_ar, 0, n_regs * sizeof(env.pstat[i]->real_perm_size_ar[0]));
761 memset(env.pstat[i]->chain_len_ar, 0, n_regs * sizeof(env.pstat[i]->chain_len_ar[0]));
762 memset(env.pstat[i]->cycle_len_ar, 0, n_regs * sizeof(env.pstat[i]->cycle_len_ar[0]));
764 env.pstat[i]->cls = cls;
768 irg_walk_blkwise_graph(chord_env->irg, NULL, lower_nodes_after_ra_walker, &env);
771 lower_print_perm_stat(&env);