automatically generate opcode declarations from ir_spec
[libfirm] / scripts / ir_spec.py
1 from spec_util import abstract, setnodedefaults
2
3 class Op(object):
4         "Base class for firm nodes"
5 abstract(Op)
6
7 class Unop(Op):
8         "Unary nodes have exactly 1 input"
9         name     = "unop"
10         ins      = [ "op" ]
11         op_index = 0
12         pinned   = "no"
13 abstract(Unop)
14
15 class Binop(Op):
16         "Binary nodes have exactly 2 inputs"
17         name     = "binop"
18         ins      = [ "left", "right" ]
19         op_index = 0
20         pinned   = "no"
21 abstract(Binop)
22
23 class Abs(Unop):
24         flags = []
25
26 class Add(Binop):
27         flags = ["commutative"]
28
29 class Alloc(Op):
30         ins   = [ "mem", "count" ]
31         outs  = [
32                 ("M",         "memory result",                         "pn_Generic_M"),
33                 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
34                 ("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
35                 ("res",       "pointer to newly allocated memory",     "pn_Generic_other"),
36         ]
37         flags = [ "fragile", "uses_memory" ]
38         attrs = [
39                 dict(
40                         name = "type",
41                         type = "ir_type*"
42                 ),
43                 dict(
44                         name = "where",
45                         type = "ir_where_alloc"
46                 )
47         ]
48         pinned      = "yes"
49         attr_struct = "alloc_attr"
50         d_post = '''
51         firm_alloc_frag_arr(res, op_Alloc, &res->attr.alloc.exc.frag_arr);
52         '''
53
54 class Anchor(Op):
55         mode        = "mode_ANY"
56         arity       = "variable"
57         flags       = [ "dump_noblock" ]
58         pinned      = "yes"
59         knownBlock  = True
60         singleton   = True
61
62 class And(Binop):
63         flags    = [ "commutative" ]
64
65 class ASM(Op):
66         mode          = "mode_T"
67         arity         = "variable"
68         flags         = [ "keep", "uses_memory" ]
69         pinned        = "memory"
70         pinned_init   = "op_pin_state_pinned"
71         attr_struct   = "asm_attr"
72         attrs_name    = "assem"
73         attrs = [
74                 dict(
75                         name = "input_constraints",
76                         type = "ir_asm_constraint*",
77                 ),
78                 dict(
79                         name = "n_output_constraints",
80                         type = "int",
81                         noprop = True,
82                 ),
83                 dict(
84                         name = "output_constraints",
85                         type = "ir_asm_constraint*",
86                 ),
87                 dict(
88                         name = "n_clobbers",
89                         type = "int",
90                         noprop = True,
91                 ),
92                 dict(
93                         name = "clobbers",
94                         type = "ident**",
95                 ),
96                 dict(
97                         name = "text",
98                         type = "ident*",
99                 ),
100         ]
101         java_noconstr = True
102
103 class Bad(Op):
104         mode        = "mode_Bad"
105         flags       = [ "cfopcode", "fragile", "start_block", "dump_noblock" ]
106         pinned      = "yes"
107         knownBlock  = True
108         singleton   = True
109         attr_struct = "irg_attr"
110         init = '''
111         res->attr.irg.irg = irg;
112         '''
113
114 class Block(Op):
115         mode        = "mode_BB"
116         knownBlock  = True
117         block       = "NULL"
118         pinned      = "yes"
119         optimize    = False
120         arity       = "variable"
121         flags       = [ "labeled" ]
122         attr_struct = "block_attr"
123         java_noconstr = True
124
125         init = '''
126         /* macroblock header */
127         res->in[0] = res;
128
129         res->attr.block.is_dead     = 0;
130         res->attr.block.is_mb_head  = 1;
131         res->attr.block.irg.irg     = irg;
132         res->attr.block.backedge    = new_backedge_arr(irg->obst, arity);
133         res->attr.block.in_cg       = NULL;
134         res->attr.block.cg_backedge = NULL;
135         res->attr.block.extblk      = NULL;
136         res->attr.block.mb_depth    = 0;
137         res->attr.block.entity      = NULL;
138
139         set_Block_matured(res, 1);
140         set_Block_block_visited(res, 0);
141
142         /* Create and initialize array for Phi-node construction. */
143         if (get_irg_phase_state(irg) == phase_building) {
144                 res->attr.block.graph_arr = NEW_ARR_D(ir_node *, irg->obst, irg->n_loc);
145                 memset(res->attr.block.graph_arr, 0, irg->n_loc * sizeof(ir_node*));
146         }
147         '''
148
149         java_add   = '''
150         public void addPred(Node node) {
151                 binding_cons.add_immBlock_pred(ptr, node.ptr);
152         }
153
154         public void mature() {
155                 binding_cons.mature_immBlock(ptr);
156         }
157
158         @Override
159         public Block getBlock() {
160                 return null;
161         }
162
163         public boolean blockVisited() {
164                 return 0 != binding.Block_block_visited(ptr);
165         }
166
167         public void markBlockVisited() {
168                 binding.mark_Block_block_visited(ptr);
169         }
170
171         public boolean isBad() {
172                 return binding.is_Bad(ptr) != 0;
173         }
174         '''
175
176 class Borrow(Binop):
177         flags = []
178
179 class Bound(Op):
180         ins    = [ "mem", "index", "lower", "upper" ]
181         outs  = [
182                 ("M",         "memory result",                         "pn_Generic_M"),
183                 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
184                 ("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
185                 ("res",       "the checked index",                     "pn_Generic_other"),
186         ]
187         flags  = [ "fragile", "highlevel" ]
188         pinned = "exception"
189         pinned_init = "op_pin_state_pinned"
190         attr_struct = "bound_attr"
191         attrs_name  = "bound"
192         d_post = '''
193         firm_alloc_frag_arr(res, op_Bound, &res->attr.bound.exc.frag_arr);
194         '''
195
196 class Builtin(Op):
197         ins      = [ "mem" ]
198         arity    = "variable"
199         outs     = [
200                 ("M",        "memory result", "pn_Generic_M"),
201                 ("1_result", "first result",  "pn_Generic_other"),
202         ]
203         flags    = [ "uses_memory" ]
204         attrs    = [
205                 dict(
206                         type = "ir_builtin_kind",
207                         name = "kind"
208                 ),
209                 dict(
210                         type = "ir_type*",
211                         name = "type"
212                 )
213         ]
214         pinned      = "memory"
215         pinned_init = "op_pin_state_pinned"
216         attr_struct = "builtin_attr"
217         init   = '''
218         assert((get_unknown_type() == type) || is_Method_type(type));
219         '''
220
221 class Call(Op):
222         ins      = [ "mem", "ptr" ]
223         arity    = "variable"
224         outs     = [
225                 ("M",                "memory result",                         "pn_Generic_M"),
226                 ("X_regular",        "control flow when no exception occurs", "pn_Generic_X_regular"),
227                 ("X_except",         "control flow when exception occured",   "pn_Generic_X_except"),
228                 ("T_result",         "tuple containing all results",          "pn_Generic_other"),
229                 ("P_value_res_base", "pointer to memory register containing copied results passed by value"),
230         ]
231         flags    = [ "fragile", "uses_memory" ]
232         attrs    = [
233                 dict(
234                         type = "ir_type*",
235                         name = "type"
236                 ),
237                 dict(
238                         type = "unsigned",
239                         name = "tail_call",
240                         # the tail call attribute can only be set by analysis
241                         init = "0"
242                 )
243         ]
244         attr_struct = "call_attr"
245         pinned      = "memory"
246         pinned_init = "op_pin_state_pinned"
247         init = '''
248         assert((get_unknown_type() == type) || is_Method_type(type));
249         '''
250         d_post = '''
251         firm_alloc_frag_arr(res, op_Call, &res->attr.call.exc.frag_arr);
252         '''
253
254 class Carry(Binop):
255         flags = [ "commutative" ]
256
257 class Cast(Unop):
258         mode     = "get_irn_mode(irn_op)"
259         flags    = [ "highlevel" ]
260         attrs    = [
261                 dict(
262                         type = "ir_type*",
263                         name = "type"
264                 )
265         ]
266         attr_struct = "cast_attr"
267         init     = "assert(is_atomic_type(type));"
268
269 class Cmp(Binop):
270         outs  = [
271                 ("False", "always false",                            "0"),
272                 ("Eq",    "equal",                                   "1"),
273                 ("Lt",    "less",                                    "2"),
274                 ("Le",    "less or equal",                           "pn_Cmp_Eq|pn_Cmp_Lt"),
275                 ("Gt",    "greater",                                 "4"),
276                 ("Ge",    "greater or equal",                        "pn_Cmp_Eq|pn_Cmp_Gt"),
277                 ("Lg",    "less or greater ('not equal' for integer numbers)", "pn_Cmp_Lt|pn_Cmp_Gt"),
278                 ("Leg",   "less, equal or greater ('not unordered')", "pn_Cmp_Lt|pn_Cmp_Eq|pn_Cmp_Gt"),
279                 ("Uo",    "unordered",                               "8"),
280                 ("Ue",    "unordered or equal",                      "pn_Cmp_Uo|pn_Cmp_Eq"),
281                 ("Ul",    "unordered or less",                       "pn_Cmp_Uo|pn_Cmp_Lt"),
282                 ("Ule",   "unordered, less or equal",                "pn_Cmp_Uo|pn_Cmp_Lt|pn_Cmp_Eq"),
283                 ("Ug",    "unordered or greater",                    "pn_Cmp_Uo|pn_Cmp_Gt"),
284                 ("Uge",   "onordered, greater or equal",             "pn_Cmp_Uo|pn_Cmp_Gt|pn_Cmp_Eq"),
285                 ("Ne",    "unordered, less or greater ('not equal' for floatingpoint numbers)", "pn_Cmp_Uo|pn_Cmp_Lt|pn_Cmp_Gt"),
286                 ("True",  "always true",                             "15"),
287         ]
288         flags = []
289
290 class Cond(Op):
291         ins      = [ "selector" ]
292         outs     = [
293                 ("false", "control flow if operand is \"false\""),
294                 ("true",  "control flow if operand is \"true\""),
295         ]
296         flags    = [ "cfopcode", "forking" ]
297         pinned   = "yes"
298         attrs    = [
299                 dict(
300                         name = "default_proj",
301                         type = "long",
302                         init = "0"
303                 ),
304                 dict(
305                         name = "jmp_pred",
306                         type = "cond_jmp_predicate",
307                         init = "COND_JMP_PRED_NONE"
308                 )
309         ]
310         attr_struct = "cond_attr"
311
312 class Confirm(Op):
313         ins      = [ "value", "bound" ]
314         mode     = "get_irn_mode(irn_value)"
315         flags    = [ "highlevel" ]
316         pinned   = "yes"
317         attrs    = [
318                 dict(
319                         name = "cmp",
320                         type = "pn_Cmp"
321                 ),
322         ]
323         attr_struct = "confirm_attr"
324         attrs_name  = "confirm"
325
326 class Const(Op):
327         mode       = ""
328         flags      = [ "constlike", "start_block" ]
329         knownBlock = True
330         pinned     = "no"
331         attrs_name = "con"
332         attrs      = [
333                 dict(
334                         type = "tarval*",
335                         name = "tarval",
336                 )
337         ]
338         attr_struct = "const_attr"
339
340 class Conv(Unop):
341         flags = []
342         attrs = [
343                 dict(
344                         name = "strict",
345                         type = "int",
346                         init = "0",
347                         special = dict(
348                                 prefix = "strict",
349                                 init = "1"
350                         )
351                 )
352         ]
353         attr_struct = "conv_attr"
354         attrs_name  = "conv"
355
356 class CopyB(Op):
357         ins   = [ "mem", "dst", "src" ]
358         outs  = [
359                 ("M",         "memory result",                         "pn_Generic_M"),
360                 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
361                 ("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
362         ]
363         flags = [ "fragile", "highlevel", "uses_memory" ]
364         attrs = [
365                 dict(
366                         name = "type",
367                         type = "ir_type*"
368                 )
369         ]
370         attr_struct = "copyb_attr"
371         attrs_name  = "copyb"
372         pinned      = "memory"
373         pinned_init = "op_pin_state_pinned"
374         d_post = '''
375         firm_alloc_frag_arr(res, op_CopyB, &res->attr.copyb.exc.frag_arr);
376         '''
377
378 class Div(Op):
379         ins   = [ "mem", "left", "right" ]
380         outs  = [
381                 ("M",         "memory result",                         "pn_Generic_M"),
382                 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
383                 ("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
384                 ("res",       "result of computation",                 "pn_Generic_other"),
385         ]
386         flags = [ "fragile", "uses_memory" ]
387         attrs_name = "divmod"
388         attrs = [
389                 dict(
390                         type = "ir_mode*",
391                         name = "resmode"
392                 ),
393                 dict(
394                         name = "no_remainder",
395                         type = "int",
396                         init = "0",
397                         special = dict(
398                                 suffix = "RL",
399                                 init = "1"
400                         )
401                 )
402         ]
403         attr_struct = "divmod_attr"
404         pinned      = "exception"
405         op_index    = 1
406         arity_override = "oparity_binary"
407         d_post = '''
408         firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr);
409         '''
410
411 class DivMod(Op):
412         ins   = [ "mem", "left", "right" ]
413         outs  = [
414                 ("M",         "memory result",                         "pn_Generic_M"),
415                 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
416                 ("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
417                 ("res_div",   "result of computation a/b",             "pn_Generic_other"),
418                 ("res_mod",   "result of computation a%b"),
419         ]
420         flags = [ "fragile", "uses_memory" ]
421         attrs_name = "divmod"
422         attrs = [
423                 dict(
424                         type = "ir_mode*",
425                         name = "resmode"
426                 ),
427         ]
428         attr_struct = "divmod_attr"
429         pinned      = "exception"
430         op_index    = 1
431         arity_override = "oparity_binary"
432         d_post = '''
433         firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr);
434         '''
435
436 class Dummy(Op):
437         ins   = []
438         flags = [ "cfopcode", "fragile", "start_block", "constlike",
439                   "dump_noblock" ]
440         knownBlock = True
441         pinned     = "yes"
442         block      = "get_irg_start_block(irg)"
443
444 class End(Op):
445         mode       = "mode_X"
446         pinned     = "yes"
447         arity      = "dynamic"
448         flags      = [ "cfopcode" ]
449         singleton  = True
450
451 class Eor(Binop):
452         flags    = [ "commutative" ]
453
454 class Free(Op):
455         ins    = [ "mem", "ptr", "size" ]
456         mode   = "mode_M"
457         flags  = [ "uses_memory" ]
458         pinned = "yes"
459         attrs  = [
460                 dict(
461                         name = "type",
462                         type = "ir_type*"
463                 ),
464                 dict(
465                         name = "where",
466                         type = "ir_where_alloc"
467                 )
468         ]
469         attr_struct = "free_attr"
470
471 class Id(Op):
472         ins    = [ "pred" ]
473         pinned = "no"
474         flags  = []
475
476 class IJmp(Op):
477         mode     = "mode_X"
478         pinned   = "yes"
479         ins      = [ "target" ]
480         flags    = [ "cfopcode", "forking", "keep" ]
481
482 class InstOf(Op):
483         ins   = [ "store", "obj" ]
484         outs  = [
485                 ("M",         "memory result",                         "pn_Generic_M"),
486                 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
487                 ("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
488                 ("res",       "checked object pointer",                "pn_Generic_other"),
489         ]
490         flags = [ "highlevel" ]
491         attrs = [
492                 dict(
493                         name = "type",
494                         type = "ir_type*"
495                 )
496         ]
497         attr_struct = "io_attr"
498         pinned      = "memory"
499         pinned_init = "op_pin_state_floats"
500
501 class Jmp(Op):
502         mode     = "mode_X"
503         pinned   = "yes"
504         ins      = []
505         flags    = [ "cfopcode" ]
506
507 class Load(Op):
508         ins      = [ "mem", "ptr" ]
509         outs  = [
510                 ("M",         "memory result",                         "pn_Generic_M"),
511                 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
512                 ("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
513                 ("res",       "result of load operation",              "pn_Generic_other"),
514         ]
515         flags    = [ "fragile", "uses_memory" ]
516         pinned   = "exception"
517         pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
518         attrs    = [
519                 dict(
520                         type = "ir_mode*",
521                         name = "mode",
522                         java_name = "load_mode"
523                 ),
524         ]
525         attr_struct = "load_attr"
526         constructor_args = [
527                 dict(
528                         type = "ir_cons_flags",
529                         name = "flags",
530                 ),
531         ]
532         d_post = '''
533         firm_alloc_frag_arr(res, op_Load, &res->attr.load.exc.frag_arr);
534         '''
535
536 class Minus(Unop):
537         flags = []
538
539 class Mod(Op):
540         ins   = [ "mem", "left", "right" ]
541         outs  = [
542                 ("M",         "memory result",                         "pn_Generic_M"),
543                 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
544                 ("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
545                 ("res",       "result of computation",                 "pn_Generic_other"),
546         ]
547         flags = [ "fragile", "uses_memory" ]
548         attrs_name = "divmod"
549         attrs = [
550                 dict(
551                         type = "ir_mode*",
552                         name = "resmode"
553                 ),
554         ]
555         attr_struct = "divmod_attr"
556         pinned      = "exception"
557         op_index    = 1
558         arity_override = "oparity_binary"
559         d_post = '''
560         firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr);
561         '''
562
563 class Mul(Binop):
564         flags = [ "commutative" ]
565
566 class Mulh(Binop):
567         flags = [ "commutative" ]
568
569 class Mux(Op):
570         ins    = [ "sel", "false", "true" ]
571         flags  = []
572         pinned = "no"
573
574 class NoMem(Op):
575         mode       = "mode_M"
576         flags      = [ "dump_noblock", "dump_noinput" ]
577         pinned     = "yes"
578         knownBlock = True
579         singleton  = True
580
581 class Not(Unop):
582         flags = []
583
584 class Or(Binop):
585         flags = [ "commutative" ]
586
587 class Phi(Op):
588         pinned        = "yes"
589         arity         = "variable"
590         flags         = []
591         attr_struct   = "phi_attr"
592         java_noconstr = True
593         init = '''
594         /* Memory Phis in endless loops must be kept alive.
595            As we can't distinguish these easily we keep all of them alive. */
596         if (is_Phi(res) && mode == mode_M)
597                 add_End_keepalive(get_irg_end(irg), res);
598         '''
599
600 class Pin(Op):
601         ins      = [ "op" ]
602         mode     = "get_irn_mode(irn_op)"
603         flags    = [ "highlevel" ]
604         pinned   = "yes"
605
606 class Proj(Op):
607         ins        = [ "pred" ]
608         flags      = []
609         pinned     = "no"
610         knownBlock = True
611         knownGraph = True
612         block      = "get_nodes_block(irn_pred)"
613         graph      = "get_irn_irg(irn_pred)"
614         attrs      = [
615                 dict(
616                         type = "long",
617                         name = "proj",
618                         initname = "",
619                         noprop = False,
620                 )
621         ]
622         attr_struct = "long"
623
624 class Quot(Op):
625         ins   = [ "mem", "left", "right" ]
626         outs  = [
627                 ("M",         "memory result",                         "pn_Generic_M"),
628                 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
629                 ("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
630                 ("res",       "result of computation",                 "pn_Generic_other"),
631         ]
632         flags = [ "fragile", "uses_memory" ]
633         attrs_name = "divmod"
634         attrs = [
635                 dict(
636                         type = "ir_mode*",
637                         name = "resmode"
638                 ),
639         ]
640         attr_struct = "divmod_attr"
641         pinned      = "exception"
642         op_index    = 1
643         arity_override = "oparity_binary"
644         d_post = '''
645         firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr);
646         '''
647
648 class Raise(Op):
649         ins    = [ "mem", "exo_ptr" ]
650         outs  = [
651                 ("M", "memory result",                     "pn_Generic_M"),
652                 ("X", "control flow to exception handler", "pn_Generic_X_regular"),
653         ]
654         flags  = [ "highlevel", "cfopcode" ]
655         pinned = "yes"
656
657 class Return(Op):
658         ins      = [ "mem" ]
659         arity    = "variable"
660         mode     = "mode_X"
661         flags    = [ "cfopcode" ]
662         pinned   = "yes"
663
664 class Rotl(Binop):
665         flags    = []
666
667 class Sel(Op):
668         ins    = [ "mem", "ptr" ]
669         arity  = "variable"
670         flags  = []
671         mode   = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data"
672         pinned = "no"
673         attrs  = [
674                 dict(
675                         type = "ir_entity*",
676                         name = "entity"
677                 )
678         ]
679         attr_struct = "sel_attr"
680
681 class Shl(Binop):
682         flags = []
683
684 class Shr(Binop):
685         flags = []
686
687 class Shrs(Binop):
688         flags = []
689
690 class Start(Op):
691         outs       = [
692                 ("X_initial_exec", "control flow"),
693                 ("M",              "initial memory"),
694                 ("P_frame_base",   "frame base pointer"),
695                 ("P_tls",          "pointer to thread local storage segment"),
696                 ("T_args",         "function arguments")
697         ]
698         mode       = "mode_T"
699         pinned     = "yes"
700         flags      = [ "cfopcode" ]
701         singleton  = True
702
703 class Store(Op):
704         ins      = [ "mem", "ptr", "value" ]
705         outs  = [
706                 ("M",         "memory result",                         "pn_Generic_M"),
707                 ("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
708                 ("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
709         ]
710         flags    = [ "fragile", "uses_memory" ]
711         pinned   = "exception"
712         attr_struct = "store_attr"
713         pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
714         constructor_args = [
715                 dict(
716                         type = "ir_cons_flags",
717                         name = "flags",
718                 ),
719         ]
720         d_post = '''
721         firm_alloc_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr);
722         '''
723
724 class Sub(Binop):
725         flags = []
726
727 class SymConst(Op):
728         mode       = "mode_P"
729         flags      = [ "constlike", "start_block" ]
730         knownBlock = True
731         pinned     = "no"
732         attrs      = [
733                 dict(
734                         type = "ir_entity*",
735                         name = "entity",
736                         noprop = True
737                 )
738         ]
739         attr_struct = "symconst_attr"
740         java_noconstr = True
741
742 class Sync(Op):
743         mode     = "mode_M"
744         flags    = []
745         pinned   = "no"
746         optimize = False
747         arity    = "dynamic"
748
749 class Tuple(Op):
750         arity  = "variable"
751         mode   = "mode_T"
752         pinned = "no"
753         flags  = [ "labeled" ]
754         java_noconstr = True
755
756 class Unknown(Op):
757         knownBlock = True
758         pinned     = "yes"
759         block      = "get_irg_start_block(irg)"
760         flags      = [ "cfopcode", "fragile", "start_block", "constlike",
761                        "dump_noblock" ]
762
763 # Prepare node list
764
765 def getOpList(namespace):
766         nodes = []
767         for t in namespace.values():
768                 if type(t) != type:
769                         continue
770
771                 if issubclass(t, Op):
772                         setnodedefaults(t)
773                         nodes.append(t)
774         return nodes
775
776 nodes = getOpList(globals())
777 nodes = sorted(nodes, lambda x,y: cmp(x.name, y.name))