BugFix:
[libfirm] / ir / be / belower.c
1 /**
2  * Author:      Christian Wuerdig
3  * Date:        2005/12/14
4  * Copyright:   (c) Universitaet Karlsruhe
5  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
6  * CVS-Id:      $Id$
7  *
8  * Performs lowering of perm nodes and spill/reload optimization.
9  */
10 #ifdef HAVE_CONFIG_H
11 #include "config.h"
12 #endif
13
14 #include <stdlib.h>
15
16 #include "ircons.h"
17 #include "debug.h"
18 #include "irhooks.h"
19
20 #include "bearch.h"
21 #include "belower.h"
22 #include "benode_t.h"
23 #include "bechordal_t.h"
24 #include "besched_t.h"
25 #include "bestat.h"
26
27 #include "irgmod.h"
28 #include "iredges_t.h"
29 #include "irgwalk.h"
30
31 #ifdef HAVE_MALLOC_H
32  #include <malloc.h>
33 #endif
34 #ifdef HAVE_ALLOCA_H
35  #include <alloca.h>
36 #endif
37
38 #undef is_Perm
39 #define is_Perm(arch_env, irn) (arch_irn_classify(arch_env, irn) == arch_irn_class_perm)
40
41 /* lowering walker environment */
42 typedef struct _lower_env_t {
43         be_chordal_env_t  *chord_env;
44         unsigned           do_copy:1;
45         DEBUG_ONLY(firm_dbg_module_t *dbg_module;)
46 } lower_env_t;
47
48 /* holds a perm register pair */
49 typedef struct _reg_pair_t {
50         const arch_register_t *in_reg;    /**< a perm IN register */
51         ir_node               *in_node;   /**< the in node to which the register belongs */
52
53         const arch_register_t *out_reg;   /**< a perm OUT register */
54         ir_node               *out_node;  /**< the out node to which the register belongs */
55
56         int                    checked;   /**< indicates whether the pair was check for cycle or not */
57 } reg_pair_t;
58
59 typedef enum _perm_type_t {
60         PERM_CYCLE,
61         PERM_CHAIN,
62         PERM_SWAP,
63         PERM_COPY
64 } perm_type_t;
65
66 /* structure to represent cycles or chains in a perm */
67 typedef struct _perm_cycle_t {
68         const arch_register_t **elems;       /**< the registers in the cycle */
69         int                     n_elems;     /**< number of elements in the cycle */
70         perm_type_t             type;        /**< type (CHAIN or CYCLE) */
71 } perm_cycle_t;
72
73 /* Compare the in registers of two register pairs */
74 static int compare_reg_pair(const void *a, const void *b) {
75         const reg_pair_t *pair_a = a;
76         const reg_pair_t *pair_b = b;
77
78         if (pair_a->in_reg->index > pair_b->in_reg->index)
79                 return 1;
80         else
81                 return -1;
82 }
83
84 /* returns the number register pairs marked as checked */
85 static int get_n_checked_pairs(reg_pair_t *pairs, int n) {
86         int i, n_checked = 0;
87
88         for (i = 0; i < n; i++) {
89                 if (pairs[i].checked)
90                         n_checked++;
91         }
92
93         return n_checked;
94 }
95
96 /**
97  * Gets the node corresponding to a register from an array of register pairs.
98  * NOTE: The given registers pairs and the register to look for must belong
99  *       to the same register class.
100  *
101  * @param pairs  The array of register pairs
102  * @param n      The number of pairs
103  * @param reg    The register to look for
104  * @param in_out 0 == look for IN register, 1 == look for OUT register
105  * @return The corresponding node or NULL if not found
106  */
107 static ir_node *get_node_for_register(reg_pair_t *pairs, int n, const arch_register_t *reg, int in_out) {
108         int i;
109
110         if (in_out) {
111                 for (i = 0; i < n; i++) {
112                         /* out register matches */
113                         if (pairs[i].out_reg->index == reg->index)
114                                 return pairs[i].out_node;
115                 }
116         }
117         else {
118                 for (i = 0; i < n; i++) {
119                         /* in register matches */
120                         if (pairs[i].in_reg->index == reg->index)
121                                 return pairs[i].in_node;
122                 }
123         }
124
125         return NULL;
126 }
127
128 /**
129  * Gets the index in the register pair array where the in/out register
130  * corresponds to reg_idx.
131  *
132  * @param pairs  The array of register pairs
133  * @param n      The number of pairs
134  * @param reg    The register index to look for
135  * @param in_out 0 == look for IN register, 1 == look for OUT register
136  * @return The corresponding index in pairs or -1 if not found
137  */
138 static int get_pairidx_for_regidx(reg_pair_t *pairs, int n, int reg_idx, int in_out) {
139         int i;
140
141         if (in_out) {
142                 for (i = 0; i < n; i++) {
143                         /* out register matches */
144                         if (pairs[i].out_reg->index == reg_idx)
145                                 return i;
146                 }
147         }
148         else {
149                 for (i = 0; i < n; i++) {
150                         /* in register matches */
151                         if (pairs[i].in_reg->index == reg_idx)
152                                 return i;
153                 }
154         }
155
156         return -1;
157 }
158
159 /**
160  * Gets an array of register pairs and tries to identify a cycle or chain starting
161  * at position start.
162  *
163  * @param cycle Variable to hold the cycle
164  * @param pairs Array of register pairs
165  * @param start Index to start
166  * @return The cycle or chain
167  */
168 static perm_cycle_t *get_perm_cycle(perm_cycle_t *cycle, reg_pair_t *pairs, int n, int start) {
169         int head         = pairs[start].in_reg->index;
170         int cur_idx      = pairs[start].out_reg->index;
171         int cur_pair_idx = start;
172         int n_pairs_done = get_n_checked_pairs(pairs, n);
173         int idx;
174         perm_type_t cycle_tp = PERM_CYCLE;
175
176         /* We could be right in the middle of a chain, so we need to find the start */
177         while (head != cur_idx) {
178                 /* goto previous register in cycle or chain */
179                 cur_pair_idx = get_pairidx_for_regidx(pairs, n, head, 1);
180
181                 if (cur_pair_idx < 0) {
182                         cycle_tp = PERM_CHAIN;
183                         break;
184                 }
185                 else {
186                         head  = pairs[cur_pair_idx].in_reg->index;
187                         start = cur_pair_idx;
188                 }
189         }
190
191         /* assume worst case: all remaining pairs build a cycle or chain */
192         cycle->elems    = xcalloc((n - n_pairs_done) * 2, sizeof(cycle->elems[0]));
193         cycle->n_elems  = 2;  /* initial number of elements is 2 */
194         cycle->elems[0] = pairs[start].in_reg;
195         cycle->elems[1] = pairs[start].out_reg;
196         cycle->type     = cycle_tp;
197         cur_idx         = pairs[start].out_reg->index;
198
199         idx = 2;
200         /* check for cycle or end of a chain */
201         while (cur_idx != head) {
202                 /* goto next register in cycle or chain */
203                 cur_pair_idx = get_pairidx_for_regidx(pairs, n, cur_idx, 0);
204
205                 if (cur_pair_idx < 0)
206                         break;
207
208                 cur_idx = pairs[cur_pair_idx].out_reg->index;
209
210                 /* it's not the first element: insert it */
211                 if (cur_idx != head) {
212                         cycle->elems[idx++] = pairs[cur_pair_idx].out_reg;
213                         cycle->n_elems++;
214                 }
215                 else {
216                         /* we are there where we started -> CYCLE */
217                         cycle->type = PERM_CYCLE;
218                 }
219         }
220
221         /* mark all pairs having one in/out register with cycle in common as checked */
222         for (idx = 0; idx < cycle->n_elems; idx++) {
223                 cur_pair_idx = get_pairidx_for_regidx(pairs, n, cycle->elems[idx]->index, 0);
224
225                 if (cur_pair_idx >= 0)
226                         pairs[cur_pair_idx].checked = 1;
227
228                 cur_pair_idx = get_pairidx_for_regidx(pairs, n, cycle->elems[idx]->index, 1);
229
230                 if (cur_pair_idx >= 0)
231                         pairs[cur_pair_idx].checked = 1;
232         }
233
234         return cycle;
235 }
236
237 /**
238  * Lowers a perm node.  Resolves cycles and creates a bunch of
239  * copy and swap operations to permute registers.
240  * Note: The caller of this function has to make sure, that irn
241  *       is a Perm node.
242  *
243  * @param irn      The perm node
244  * @param block    The block the perm node belongs to
245  * @param walk_env The environment
246  */
247 static void lower_perm_node(ir_node *irn, void *walk_env) {
248         const arch_register_class_t *reg_class;
249         const arch_env_t            *arch_env;
250         lower_env_t     *env         = walk_env;
251         int              real_size   = 0;
252         int              n, i, pn, do_copy, j, n_ops;
253         reg_pair_t      *pairs;
254         const ir_edge_t *edge;
255         perm_cycle_t    *cycle;
256         ir_node         *sched_point, *block, *in[2];
257         ir_node         *arg1, *arg2, *res1, *res2;
258         ir_node         *cpyxchg = NULL;
259         DEBUG_ONLY(firm_dbg_module_t *mod;)
260
261         arch_env = env->chord_env->birg->main_env->arch_env;
262         do_copy  = env->do_copy;
263         DEBUG_ONLY(mod = env->dbg_module;)
264         block    = get_nodes_block(irn);
265
266         /*
267                 Get the schedule predecessor node to the perm
268                 NOTE: This works with auto-magic. If we insert the
269                         new copy/exchange nodes after this node, everything
270                         should be ok.
271         */
272         sched_point = sched_prev(irn);
273         DBG((mod, LEVEL_1, "sched point is %+F\n", sched_point));
274         assert(sched_point && "Perm is not scheduled or has no predecessor");
275
276         n = get_irn_arity(irn);
277         assert(n == get_irn_n_edges(irn) && "perm's in and out numbers different");
278
279         reg_class = arch_get_irn_register(arch_env, get_irn_n(irn, 0))->reg_class;
280         pairs     = alloca(n * sizeof(pairs[0]));
281
282         /* build the list of register pairs (in, out) */
283         i = 0;
284         foreach_out_edge(irn, edge) {
285                 pairs[i].out_node = get_edge_src_irn(edge);
286                 pn                = get_Proj_proj(pairs[i].out_node);
287                 pairs[i].in_node  = get_irn_n(irn, pn);
288
289                 pairs[i].in_reg  = arch_get_irn_register(arch_env, pairs[i].in_node);
290                 pairs[i].out_reg = arch_get_irn_register(arch_env, pairs[i].out_node);
291
292                 pairs[i].checked = 0;
293                 i++;
294         }
295
296         /* sort the register pairs by the indices of the in registers */
297         qsort(pairs, n, sizeof(pairs[0]), compare_reg_pair);
298
299         /* Mark all equal pairs as checked, and exchange the OUT proj with
300                 the IN node. */
301         for (i = 0; i < n; i++) {
302                 if (pairs[i].in_reg->index == pairs[i].out_reg->index) {
303                         DBG((mod, LEVEL_1, "%+F removing equal perm register pair (%+F, %+F, %s)\n",
304                                 irn, pairs[i].in_node, pairs[i].out_node, pairs[i].out_reg->name));
305
306                         /* We have to check for a special case:
307                                 The in-node could be a Proj from a Perm. In this case,
308                                 we need to correct the projnum */
309                         if (is_Perm(arch_env, pairs[i].in_node) && is_Proj(pairs[i].in_node)) {
310                                 set_Proj_proj(pairs[i].out_node, get_Proj_proj(pairs[i].in_node));
311                         }
312
313                         /* remove the proj from the schedule */
314                         sched_remove(pairs[i].out_node);
315
316                         /* reroute the edges from the proj to the argument */
317                         edges_reroute(pairs[i].out_node, pairs[i].in_node, env->chord_env->irg);
318
319                         pairs[i].checked = 1;
320                 }
321         }
322
323         /* Set do_copy to 0 if it's on but we have no free register */
324         if (do_copy) {
325                 do_copy = 0;
326         }
327
328         real_size = n - get_n_checked_pairs(pairs, n);
329
330         be_do_stat_perm(reg_class->name, reg_class->n_regs, irn, block, n, real_size);
331
332         /* check for cycles and chains */
333         while (get_n_checked_pairs(pairs, n) < n) {
334                 i = n_ops = 0;
335
336                 /* go to the first not-checked pair */
337                 while (pairs[i].checked) i++;
338                 cycle = xcalloc(1, sizeof(*cycle));
339                 cycle = get_perm_cycle(cycle, pairs, n, i);
340
341                 DB((mod, LEVEL_1, "%+F: following %s created:\n  ", irn, cycle->type == PERM_CHAIN ? "chain" : "cycle"));
342                 for (j = 0; j < cycle->n_elems; j++) {
343                         DB((mod, LEVEL_1, " %s", cycle->elems[j]->name));
344                 }
345                 DB((mod, LEVEL_1, "\n"));
346
347                 /* We don't need to do anything if we have a Perm with two
348                         elements which represents a cycle, because those nodes
349                         already represent exchange nodes */
350                 if (n == 2 && cycle->type == PERM_CYCLE) {
351                         free(cycle);
352                         continue;
353                 }
354
355 //TODO: - iff PERM_CYCLE && do_copy -> determine free temp reg and insert copy to/from it before/after
356 //        the copy cascade (this reduces the cycle into a chain)
357
358                 /* build copy/swap nodes from back to front */
359                 for (i = cycle->n_elems - 2; i >= 0; i--) {
360                         arg1 = get_node_for_register(pairs, n, cycle->elems[i], 0);
361                         arg2 = get_node_for_register(pairs, n, cycle->elems[i + 1], 0);
362
363                         res1 = get_node_for_register(pairs, n, cycle->elems[i], 1);
364                         res2 = get_node_for_register(pairs, n, cycle->elems[i + 1], 1);
365                         /*
366                                 If we have a cycle and don't copy: we need to create exchange nodes
367                                 NOTE: An exchange node is a perm node with 2 INs and 2 OUTs
368                                 IN_1  = in node with register i
369                                 IN_2  = in node with register i + 1
370                                 OUT_1 = out node with register i + 1
371                                 OUT_2 = out node with register i
372                         */
373                         if (cycle->type == PERM_CYCLE && !do_copy) {
374                                 in[0] = arg1;
375                                 in[1] = arg2;
376
377                                 /* At this point we have to handle the following problem:     */
378                                 /*                                                            */
379                                 /* If we have a cycle with more than two elements, then       */
380                                 /* this could correspond to the following Perm node:          */
381                                 /*                                                            */
382                                 /*   +----+   +----+   +----+                                 */
383                                 /*   | r1 |   | r2 |   | r3 |                                 */
384                                 /*   +-+--+   +-+--+   +--+-+                                 */
385                                 /*     |        |         |                                   */
386                                 /*     |        |         |                                   */
387                                 /*   +-+--------+---------+-+                                 */
388                                 /*   |         Perm         |                                 */
389                                 /*   +-+--------+---------+-+                                 */
390                                 /*     |        |         |                                   */
391                                 /*     |        |         |                                   */
392                                 /*   +-+--+   +-+--+   +--+-+                                 */
393                                 /*   |Proj|   |Proj|   |Proj|                                 */
394                                 /*   | r2 |   | r3 |   | r1 |                                 */
395                                 /*   +----+   +----+   +----+                                 */
396                                 /*                                                            */
397                                 /* This node is about to be split up into two 2x Perm's       */
398                                 /* for which we need 4 Proj's and the one additional Proj     */
399                                 /* of the first Perm has to be one IN of the second. So in    */
400                                 /* general we need to create one additional Proj for each     */
401                                 /* "middle" Perm and set this to one in node of the successor */
402                                 /* Perm.                                                      */
403
404                                 DBG((mod, LEVEL_1, "%+F creating exchange node (%+F, %s) and (%+F, %s) with\n",
405                                         irn, arg1, cycle->elems[i]->name, arg2, cycle->elems[i + 1]->name));
406                                 DBG((mod, LEVEL_1, "%+F                        (%+F, %s) and (%+F, %s)\n",
407                                         irn, res1, cycle->elems[i]->name, res2, cycle->elems[i + 1]->name));
408
409                                 cpyxchg = be_new_Perm(reg_class, env->chord_env->irg, block, 2, in);
410                                 n_ops++;
411
412                                 if (i > 0) {
413                                         /* cycle is not done yet */
414                                         int pidx = get_pairidx_for_regidx(pairs, n, cycle->elems[i]->index, 0);
415
416                                         /* create intermediate proj */
417                                         res1 = new_r_Proj(get_irn_irg(irn), block, cpyxchg, get_irn_mode(res1), 0);
418
419                                         /* set as in for next Perm */
420                                         pairs[pidx].in_node = res1;
421                                 }
422                                 else {
423                                         sched_remove(res1);
424                                 }
425
426                                 sched_remove(res2);
427
428                                 set_Proj_pred(res2, cpyxchg);
429                                 set_Proj_proj(res2, 0);
430                                 set_Proj_pred(res1, cpyxchg);
431                                 set_Proj_proj(res1, 1);
432
433                                 sched_add_after(sched_point, res1);
434                                 sched_add_after(sched_point, res2);
435
436                                 arch_set_irn_register(arch_env, res2, cycle->elems[i + 1]);
437                                 arch_set_irn_register(arch_env, res1, cycle->elems[i]);
438
439                                 /* insert the copy/exchange node in schedule after the magic schedule node (see above) */
440                                 sched_add_after(sched_point, cpyxchg);
441
442                                 DBG((mod, LEVEL_1, "replacing %+F with %+F, placed new node after %+F\n", irn, cpyxchg, sched_point));
443
444                                 /* set the new scheduling point */
445                                 sched_point = res1;
446                         }
447                         else {
448                                 DBG((mod, LEVEL_1, "%+F creating copy node (%+F, %s) -> (%+F, %s)\n",
449                                         irn, arg1, cycle->elems[i]->name, res2, cycle->elems[i + 1]->name));
450
451                                 cpyxchg = be_new_Copy(reg_class, env->chord_env->irg, block, arg1);
452                                 arch_set_irn_register(arch_env, cpyxchg, cycle->elems[i + 1]);
453                                 n_ops++;
454
455                                 /* remove the proj from the schedule */
456                                 sched_remove(res2);
457
458                                 /* exchange copy node and proj */
459                                 exchange(res2, cpyxchg);
460
461                                 /* insert the copy/exchange node in schedule after the magic schedule node (see above) */
462                                 sched_add_after(sched_point, cpyxchg);
463
464                                 /* set the new scheduling point */
465                                 sched_point = cpyxchg;
466                         }
467                 }
468
469                 be_do_stat_permcycle(reg_class->name, irn, block, cycle->type == PERM_CHAIN, cycle->n_elems, n_ops);
470
471                 free((void *) cycle->elems);
472                 free(cycle);
473         }
474
475
476
477         /* remove the perm from schedule */
478         sched_remove(irn);
479 }
480
481
482
483 static int get_n_out_edges(const ir_node *irn) {
484         const ir_edge_t *edge;
485         int cnt = 0;
486
487         foreach_out_edge(irn, edge) {
488                 cnt++;
489         }
490
491         return cnt;
492 }
493
494 static ir_node *belower_skip_proj(ir_node *irn) {
495         while(is_Proj(irn))
496                 irn = get_Proj_pred(irn);
497         return irn;
498 }
499
500 static void fix_in(ir_node *irn, ir_node *old, ir_node *nw) {
501         int i, n;
502
503         irn = belower_skip_proj(irn);
504         n   = get_irn_arity(irn);
505
506         for (i = 0; i < n; i++) {
507                 if (get_irn_n(irn, i) == old) {
508                         set_irn_n(irn, i, nw);
509                         break;
510                 }
511         }
512 }
513
514 static void gen_assure_different_pattern(ir_node *irn, be_irg_t *birg, ir_node *other_different) {
515         const arch_env_t          *arch_env = birg->main_env->arch_env;
516         ir_node                   *in[2], *keep, *cpy, *temp;
517         ir_node                   *block = get_nodes_block(irn);
518         const arch_register_class_t *cls = arch_get_irn_reg_class(arch_env, other_different, -1);
519         FIRM_DBG_REGISTER(firm_dbg_module_t *mod, "firm.be.lower");
520
521         if (arch_irn_is(arch_env, other_different, ignore) || ! mode_is_datab(get_irn_mode(other_different))) {
522                 DBG((mod, LEVEL_1, "ignore constraint for %+F because other_irn is ignore or not a datab node\n", irn));
523                 return;
524         }
525
526         /* Make a not spillable copy of the different node   */
527         /* this is needed because the different irn could be */
528         /* in block far far away                             */
529         /* The copy is optimized later if not needed         */
530
531         temp = new_rd_Unknown(birg->irg, get_irn_mode(other_different));
532         cpy = be_new_Copy(cls, birg->irg, block, temp);
533         be_node_set_flags(cpy, BE_OUT_POS(0), arch_irn_flags_dont_spill);
534
535         in[0] = irn;
536         in[1] = cpy;
537
538         /* Let the irn use the copy instead of the old other_different */
539         fix_in(irn, other_different, cpy);
540
541         /* Add the Keep resp. CopyKeep and reroute the users */
542         /* of the other_different irn in case of CopyKeep.   */
543         if (get_n_out_edges(other_different) == 0) {
544                 keep = be_new_Keep(cls, birg->irg, block, 2, in);
545         }
546         else {
547                 keep = be_new_CopyKeep_single(cls, birg->irg, block, cpy, irn, get_irn_mode(other_different));
548                 be_node_set_reg_class(keep, 1, cls);
549                 edges_reroute(other_different, keep, birg->irg);
550         }
551
552         /* after rerouting: let the copy point to the other_different irn */
553         set_irn_n(cpy, 0, other_different);
554
555         DBG((mod, LEVEL_1, "created %+F for %+F to assure should_be_different\n", keep, irn));
556 }
557
558 /**
559  * Checks if node has a should_be_different constraint in output
560  * and adds a Keep then to assure the constraint.
561  */
562 static void assure_different_constraints(ir_node *irn, be_irg_t *birg) {
563         const arch_env_t          *arch_env = birg->main_env->arch_env;
564         const arch_register_req_t *req;
565         arch_register_req_t        req_temp;
566         int i, n;
567
568         req = arch_get_register_req(arch_env, &req_temp, irn, -1);
569
570         if (req) {
571                 if (arch_register_req_is(req, should_be_different)) {
572                         gen_assure_different_pattern(irn, birg, req->other_different);
573                 }
574                 else if (arch_register_req_is(req, should_be_different_from_all)) {
575                         n = get_irn_arity(belower_skip_proj(irn));
576                         for (i = 0; i < n; i++) {
577                                 gen_assure_different_pattern(irn, birg, get_irn_n(belower_skip_proj(irn), i));
578                         }
579                 }
580         }
581 }
582
583
584
585 /**
586  * Calls the functions to assure register constraints.
587  *
588  * @param irn      The node to be checked for lowering
589  * @param walk_env The walker environment
590  */
591 static void assure_constraints_walker(ir_node *irn, void *walk_env) {
592         if (is_Block(irn))
593                 return;
594
595         if (mode_is_datab(get_irn_mode(irn)))
596                 assure_different_constraints(irn, walk_env);
597
598         return;
599 }
600
601
602
603 /**
604  * Walks over all nodes to assure register constraints.
605  *
606  * @param birg  The birg structure containing the irg
607  */
608 void assure_constraints(be_irg_t *birg) {
609         irg_walk_blkwise_graph(birg->irg, NULL, assure_constraints_walker, birg);
610 }
611
612
613
614 /**
615  * Calls the corresponding lowering function for the node.
616  *
617  * @param irn      The node to be checked for lowering
618  * @param walk_env The walker environment
619  */
620 static void lower_nodes_after_ra_walker(ir_node *irn, void *walk_env) {
621         lower_env_t      *env      = walk_env;
622         const arch_env_t *arch_env = env->chord_env->birg->main_env->arch_env;
623
624         if (!is_Block(irn) && !is_Proj(irn)) {
625                 if (is_Perm(arch_env, irn)) {
626                         lower_perm_node(irn, walk_env);
627                 }
628         }
629
630         return;
631 }
632
633 /**
634  * Walks over all blocks in an irg and performs lowering need to be
635  * done after register allocation (e.g. perm lowering).
636  *
637  * @param chord_env The chordal environment containing the irg
638  * @param do_copy   1 == resolve cycles with a free reg if available
639  */
640 void lower_nodes_after_ra(be_chordal_env_t *chord_env, int do_copy) {
641         lower_env_t env;
642
643         env.chord_env  = chord_env;
644         env.do_copy    = do_copy;
645         FIRM_DBG_REGISTER(env.dbg_module, "firm.be.lower");
646
647         irg_walk_blkwise_graph(chord_env->irg, NULL, lower_nodes_after_ra_walker, &env);
648 }
649
650 #undef is_Perm