ir_spec.py 17.2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from spec_util import abstract, setnodedefaults

class Op(object):
	"Base class for firm nodes"
abstract(Op)

class Unop(Op):
	"Unary nodes have exactly 1 input"
	name     = "unop"
	ins      = [ "op" ]
	op_index = 0
	pinned   = "no"
abstract(Unop)

class Binop(Op):
	"Binary nodes have exactly 2 inputs"
	name     = "binop"
	ins      = [ "left", "right" ]
	op_index = 0
	pinned   = "no"
abstract(Binop)

class Add(Binop):
	flags = ["commutative"]

class Alloc(Op):
27
	ins   = [ "mem", "count" ]
28
29
30
31
32
33
	outs  = [
		("M",         "memory result",                         "pn_Generic_M"),
		("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
		("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
		("res",       "pointer to newly allocated memory",     "pn_Generic_other"),
	]
34
	flags = [ "fragile", "uses_memory" ]
35
36
37
38
39
40
41
42
43
	attrs = [
		dict(
			name = "type",
			type = "ir_type*"
		),
		dict(
			name = "where",
			type = "ir_where_alloc"
		)
44
45
46
47
48
49
50
51
52
	]
	pinned      = "yes"
	attr_struct = "alloc_attr"

class Anchor(Op):
	mode        = "mode_ANY"
	arity       = "variable"
	flags       = [ "dump_noblock" ]
	pinned      = "yes"
53
	attr_struct = "irg_attr"
54
55
56
57
58
59
60
61
62
63
64
65
	knownBlock  = True
	singleton   = True

class And(Binop):
	flags    = [ "commutative" ]

class ASM(Op):
	mode          = "mode_T"
	arity         = "variable"
	flags         = [ "keep", "uses_memory" ]
	pinned        = "memory"
	pinned_init   = "op_pin_state_pinned"
66
67
	attr_struct   = "asm_attr"
	attrs_name    = "assem"
68
69
70
71
72
73
74
75
	attrs = [
		dict(
			name = "input_constraints",
			type = "ir_asm_constraint*",
		),
		dict(
			name = "n_output_constraints",
			type = "int",
76
			noprop = True,
77
78
79
80
81
82
83
84
		),
		dict(
			name = "output_constraints",
			type = "ir_asm_constraint*",
		),
		dict(
			name = "n_clobbers",
			type = "int",
85
			noprop = True,
86
87
88
89
90
91
92
93
94
		),
		dict(
			name = "clobbers",
			type = "ident**",
		),
		dict(
			name = "text",
			type = "ident*",
		),
95
96
97
98
	]
	java_noconstr = True

class Bad(Op):
Matthias Braun's avatar
Matthias Braun committed
99
	mode        = "mode_Bad"
100
	flags       = [ "cfopcode", "start_block", "dump_noblock" ]
Matthias Braun's avatar
Matthias Braun committed
101
102
103
104
	pinned      = "yes"
	knownBlock  = True
	singleton   = True
	attr_struct = "irg_attr"
105
106
	init = '''
	res->attr.irg.irg = irg;
107
108
109
110
111
112
113
114
115
116
117
118
	'''

class Block(Op):
	mode        = "mode_BB"
	knownBlock  = True
	block       = "NULL"
	pinned      = "yes"
	optimize    = False
	arity       = "variable"
	flags       = [ "labeled" ]
	attr_struct = "block_attr"
	java_noconstr = True
Moritz Kroll's avatar
Moritz Kroll committed
119
120
121
122
123
124
125

	init = '''
	/* macroblock header */
	res->in[0] = res;

	res->attr.block.is_dead     = 0;
	res->attr.block.is_mb_head  = 1;
126
	res->attr.block.irg.irg     = irg;
Moritz Kroll's avatar
Moritz Kroll committed
127
128
129
130
131
	res->attr.block.backedge    = new_backedge_arr(irg->obst, arity);
	res->attr.block.in_cg       = NULL;
	res->attr.block.cg_backedge = NULL;
	res->attr.block.extblk      = NULL;
	res->attr.block.mb_depth    = 0;
132
	res->attr.block.entity      = NULL;
Moritz Kroll's avatar
Moritz Kroll committed
133
134
135

	set_Block_matured(res, 1);
	set_Block_block_visited(res, 0);
136
137

	/* Create and initialize array for Phi-node construction. */
138
139
140
	if (get_irg_phase_state(irg) == phase_building) {
		res->attr.block.graph_arr = NEW_ARR_D(ir_node *, irg->obst, irg->n_loc);
		memset(res->attr.block.graph_arr, 0, irg->n_loc * sizeof(ir_node*));
141
	}
142
	'''
143

144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
	java_add   = '''
	public void addPred(Node node) {
		binding_cons.add_immBlock_pred(ptr, node.ptr);
	}

	public void mature() {
		binding_cons.mature_immBlock(ptr);
	}

	@Override
	public Block getBlock() {
		return null;
	}

	public boolean blockVisited() {
		return 0 != binding.Block_block_visited(ptr);
	}

	public void markBlockVisited() {
		binding.mark_Block_block_visited(ptr);
164
165
166
167
168
	}

	public boolean isBad() {
		return binding.is_Bad(ptr) != 0;
	}
169
170
	'''

171
172
173
class Borrow(Binop):
	flags = []

174
175
class Bound(Op):
	ins    = [ "mem", "index", "lower", "upper" ]
176
177
178
179
180
181
	outs  = [
		("M",         "memory result",                         "pn_Generic_M"),
		("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
		("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
		("res",       "the checked index",                     "pn_Generic_other"),
	]
182
183
184
185
 	flags  = [ "fragile", "highlevel" ]
	pinned = "exception"
	pinned_init = "op_pin_state_pinned"
	attr_struct = "bound_attr"
186
	attrs_name  = "bound"
187
188
189
190

class Builtin(Op):
	ins      = [ "mem" ]
	arity    = "variable"
191
192
193
194
	outs     = [
		("M",        "memory result", "pn_Generic_M"),
		("1_result", "first result",  "pn_Generic_other"),
	]
195
	flags    = [ "uses_memory" ]
196
	attrs    = [
197
198
199
200
		dict(
			type = "ir_builtin_kind",
			name = "kind"
		),
201
		dict(
202
203
204
			type = "ir_type*",
			name = "type"
		)
205
206
207
208
	]
	pinned      = "memory"
	pinned_init = "op_pin_state_pinned"
	attr_struct = "builtin_attr"
209
	init   = '''
210
211
212
	assert((get_unknown_type() == type) || is_Method_type(type));
	'''

213
214
215
class Call(Op):
	ins      = [ "mem", "ptr" ]
	arity    = "variable"
216
217
218
219
220
221
222
	outs     = [
		("M",                "memory result",                         "pn_Generic_M"),
		("X_regular",        "control flow when no exception occurs", "pn_Generic_X_regular"),
		("X_except",         "control flow when exception occured",   "pn_Generic_X_except"),
		("T_result",         "tuple containing all results",          "pn_Generic_other"),
		("P_value_res_base", "pointer to memory register containing copied results passed by value"),
	]
223
	flags    = [ "fragile", "uses_memory" ]
224
	attrs    = [
225
226
227
		dict(
			type = "ir_type*",
			name = "type"
228
229
230
231
232
233
		),
		dict(
			type = "unsigned",
			name = "tail_call",
			# the tail call attribute can only be set by analysis
			init = "0"
234
		)
235
236
237
238
	]
	attr_struct = "call_attr"
	pinned      = "memory"
	pinned_init = "op_pin_state_pinned"
239
240
	init = '''
	assert((get_unknown_type() == type) || is_Method_type(type));
241
	'''
242

243
244
245
class Carry(Binop):
	flags = [ "commutative" ]

Michael Beck's avatar
Michael Beck committed
246
class Cast(Unop):
247
248
	mode     = "get_irn_mode(irn_op)"
	flags    = [ "highlevel" ]
249
250
251
252
253
	attrs    = [
		dict(
			type = "ir_type*",
			name = "type"
		)
254
255
	]
	attr_struct = "cast_attr"
256
	init     = "assert(is_atomic_type(type));"
257
258

class Cmp(Binop):
259
	outs  = [
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
		("False", "always false",                            "0"),
		("Eq",    "equal",                                   "1"),
		("Lt",    "less",                                    "2"),
		("Le",    "less or equal",                           "pn_Cmp_Eq|pn_Cmp_Lt"),
		("Gt",    "greater",                                 "4"),
		("Ge",    "greater or equal",                        "pn_Cmp_Eq|pn_Cmp_Gt"),
		("Lg",    "less or greater ('not equal' for integer numbers)", "pn_Cmp_Lt|pn_Cmp_Gt"),
		("Leg",   "less, equal or greater ('not unordered')", "pn_Cmp_Lt|pn_Cmp_Eq|pn_Cmp_Gt"),
		("Uo",    "unordered",                               "8"),
		("Ue",    "unordered or equal",                      "pn_Cmp_Uo|pn_Cmp_Eq"),
		("Ul",    "unordered or less",                       "pn_Cmp_Uo|pn_Cmp_Lt"),
		("Ule",   "unordered, less or equal",                "pn_Cmp_Uo|pn_Cmp_Lt|pn_Cmp_Eq"),
		("Ug",    "unordered or greater",                    "pn_Cmp_Uo|pn_Cmp_Gt"),
		("Uge",   "onordered, greater or equal",             "pn_Cmp_Uo|pn_Cmp_Gt|pn_Cmp_Eq"),
		("Ne",    "unordered, less or greater ('not equal' for floatingpoint numbers)", "pn_Cmp_Uo|pn_Cmp_Lt|pn_Cmp_Gt"),
		("True",  "always true",                             "15"),
276
	]
277
278
279
280
	flags = []

class Cond(Op):
	ins      = [ "selector" ]
281
282
283
284
	outs     = [
		("false", "control flow if operand is \"false\""),
		("true",  "control flow if operand is \"true\""),
	]
285
286
	flags    = [ "cfopcode", "forking" ]
	pinned   = "yes"
287
288
289
290
291
292
293
294
295
296
297
	attrs    = [
		dict(
			name = "default_proj",
			type = "long",
			init = "0"
		),
		dict(
			name = "jmp_pred",
			type = "cond_jmp_predicate",
			init = "COND_JMP_PRED_NONE"
		)
298
	]
299
	attr_struct = "cond_attr"
300

301
302
303
304
305
class Confirm(Op):
	ins      = [ "value", "bound" ]
	mode     = "get_irn_mode(irn_value)"
	flags    = [ "highlevel" ]
	pinned   = "yes"
306
307
308
309
310
	attrs    = [
		dict(
			name = "cmp",
			type = "pn_Cmp"
		),
311
312
	]
	attr_struct = "confirm_attr"
313
	attrs_name  = "confirm"
314
315
316
317
318
319
320

class Const(Op):
	mode       = ""
	flags      = [ "constlike", "start_block" ]
	knownBlock = True
	pinned     = "no"
	attrs_name = "con"
321
322
323
324
325
	attrs      = [
		dict(
			type = "tarval*",
			name = "tarval",
		)
326
327
	]
	attr_struct = "const_attr"
328

329
330
class Conv(Unop):
	flags = []
331
332
333
334
335
336
337
338
339
340
	attrs = [
		dict(
			name = "strict",
			type = "int",
			init = "0",
			special = dict(
				prefix = "strict",
				init = "1"
			)
		)
341
342
	]
	attr_struct = "conv_attr"
343
	attrs_name  = "conv"
344
345
346

class CopyB(Op):
	ins   = [ "mem", "dst", "src" ]
347
348
349
350
351
	outs  = [
		("M",         "memory result",                         "pn_Generic_M"),
		("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
		("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
	]
352
	flags = [ "fragile", "highlevel", "uses_memory" ]
353
354
	attrs = [
		dict(
355
356
			name = "type",
			type = "ir_type*"
357
		)
358
359
	]
	attr_struct = "copyb_attr"
360
	attrs_name  = "copyb"
361
362
	pinned      = "memory"
	pinned_init = "op_pin_state_pinned"
363

364
365
class Div(Op):
	ins   = [ "mem", "left", "right" ]
366
367
368
369
370
371
	outs  = [
		("M",         "memory result",                         "pn_Generic_M"),
		("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
		("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
		("res",       "result of computation",                 "pn_Generic_other"),
	]
372
373
	flags = [ "fragile", "uses_memory" ]
	attrs_name = "divmod"
374
375
376
377
378
	attrs = [
		dict(
			type = "ir_mode*",
			name = "resmode"
		),
Moritz Kroll's avatar
Moritz Kroll committed
379
380
381
382
383
384
385
386
		dict(
			name = "no_remainder",
			type = "int",
			init = "0",
			special = dict(
				suffix = "RL",
				init = "1"
			)
387
		)
388
389
390
391
392
	]
	attr_struct = "divmod_attr"
	pinned      = "exception"
	op_index    = 1
	arity_override = "oparity_binary"
393

394
395
class DivMod(Op):
	ins   = [ "mem", "left", "right" ]
396
397
398
399
400
401
402
	outs  = [
		("M",         "memory result",                         "pn_Generic_M"),
		("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
		("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
		("res_div",   "result of computation a/b",             "pn_Generic_other"),
		("res_mod",   "result of computation a%b"),
	]
403
404
	flags = [ "fragile", "uses_memory" ]
	attrs_name = "divmod"
405
406
407
408
409
	attrs = [
		dict(
			type = "ir_mode*",
			name = "resmode"
		),
410
411
412
413
414
415
416
417
	]
	attr_struct = "divmod_attr"
	pinned      = "exception"
	op_index    = 1
	arity_override = "oparity_binary"

class Dummy(Op):
	ins   = []
418
	flags = [ "cfopcode", "start_block", "constlike", "dump_noblock" ]
419
420
421
422
423
424
425
426
427
428
429
430
431
	knownBlock = True
	pinned     = "yes"
	block      = "get_irg_start_block(irg)"

class End(Op):
	mode       = "mode_X"
	pinned     = "yes"
	arity      = "dynamic"
	flags      = [ "cfopcode" ]
	singleton  = True

class Eor(Binop):
	flags    = [ "commutative" ]
432

433
434
435
436
437
class Free(Op):
	ins    = [ "mem", "ptr", "size" ]
	mode   = "mode_M"
	flags  = [ "uses_memory" ]
	pinned = "yes"
438
	attrs  = [
439
		dict(
440
441
			name = "type",
			type = "ir_type*"
442
443
		),
		dict(
444
445
			name = "where",
			type = "ir_where_alloc"
446
		)
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
	]
	attr_struct = "free_attr"

class Id(Op):
	ins    = [ "pred" ]
	pinned = "no"
	flags  = []

class IJmp(Op):
	mode     = "mode_X"
	pinned   = "yes"
	ins      = [ "target" ]
	flags    = [ "cfopcode", "forking", "keep" ]

class InstOf(Op):
	ins   = [ "store", "obj" ]
463
464
465
466
467
468
	outs  = [
		("M",         "memory result",                         "pn_Generic_M"),
		("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
		("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
		("res",       "checked object pointer",                "pn_Generic_other"),
	]
469
	flags = [ "highlevel" ]
470
471
472
473
474
	attrs = [
		dict(
			name = "type",
			type = "ir_type*"
		)
475
476
477
478
479
480
481
482
483
484
485
486
487
	]
	attr_struct = "io_attr"
	pinned      = "memory"
	pinned_init = "op_pin_state_floats"

class Jmp(Op):
	mode     = "mode_X"
	pinned   = "yes"
	ins      = []
	flags    = [ "cfopcode" ]

class Load(Op):
	ins      = [ "mem", "ptr" ]
488
489
490
491
492
493
	outs  = [
		("M",         "memory result",                         "pn_Generic_M"),
		("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
		("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
		("res",       "result of load operation",              "pn_Generic_other"),
	]
494
495
496
	flags    = [ "fragile", "uses_memory" ]
	pinned   = "exception"
	pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
497
498
499
500
501
502
	attrs    = [
		dict(
			type = "ir_mode*",
			name = "mode",
			java_name = "load_mode"
		),
503
504
	]
	attr_struct = "load_attr"
505
506
	constructor_args = [
		dict(
Moritz Kroll's avatar
Moritz Kroll committed
507
			type = "ir_cons_flags",
508
509
			name = "flags",
		),
510
511
512
513
514
515
516
	]

class Minus(Unop):
	flags = []

class Mod(Op):
	ins   = [ "mem", "left", "right" ]
517
518
519
520
521
522
	outs  = [
		("M",         "memory result",                         "pn_Generic_M"),
		("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
		("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
		("res",       "result of computation",                 "pn_Generic_other"),
	]
523
524
	flags = [ "fragile", "uses_memory" ]
	attrs_name = "divmod"
525
	attrs = [
526
		dict(
527
528
			type = "ir_mode*",
			name = "resmode"
529
		),
530
531
532
533
534
	]
	attr_struct = "divmod_attr"
	pinned      = "exception"
	op_index    = 1
	arity_override = "oparity_binary"
Matthias Braun's avatar
Matthias Braun committed
535

536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
class Mul(Binop):
	flags = [ "commutative" ]

class Mulh(Binop):
	flags = [ "commutative" ]

class Mux(Op):
	ins    = [ "sel", "false", "true" ]
	flags  = []
	pinned = "no"

class NoMem(Op):
	mode       = "mode_M"
	flags      = [ "dump_noblock", "dump_noinput" ]
	pinned     = "yes"
	knownBlock = True
	singleton  = True

class Not(Unop):
	flags = []

class Or(Binop):
	flags = [ "commutative" ]

class Phi(Op):
561
562
563
564
	pinned        = "yes"
	arity         = "variable"
	flags         = []
	attr_struct   = "phi_attr"
565
	java_noconstr = True
Matthias Braun's avatar
Matthias Braun committed
566
567
568
569
570
571
	init = '''
	/* Memory Phis in endless loops must be kept alive.
	   As we can't distinguish these easily we keep all of them alive. */
   	if (is_Phi(res) && mode == mode_M)
		add_End_keepalive(get_irg_end(irg), res);
	'''
572
573
574
575
576
577
578
579

class Pin(Op):
	ins      = [ "op" ]
	mode     = "get_irn_mode(irn_op)"
	flags    = [ "highlevel" ]
	pinned   = "yes"

class Proj(Op):
580
581
582
583
584
585
586
587
	ins        = [ "pred" ]
	flags      = []
	pinned     = "no"
	knownBlock = True
	knownGraph = True
	block      = "get_nodes_block(irn_pred)"
	graph      = "get_irn_irg(irn_pred)"
	attrs      = [
588
589
		dict(
			type = "long",
590
			name = "proj",
591
592
			initname = "",
			noprop = False,
593
		)
594
595
596
597
598
	]
	attr_struct = "long"

class Quot(Op):
	ins   = [ "mem", "left", "right" ]
599
600
601
602
603
604
	outs  = [
		("M",         "memory result",                         "pn_Generic_M"),
		("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
		("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
		("res",       "result of computation",                 "pn_Generic_other"),
	]
605
606
	flags = [ "fragile", "uses_memory" ]
	attrs_name = "divmod"
607
	attrs = [
608
		dict(
609
610
611
			type = "ir_mode*",
			name = "resmode"
		),
612
613
614
615
616
617
618
619
	]
	attr_struct = "divmod_attr"
	pinned      = "exception"
	op_index    = 1
	arity_override = "oparity_binary"

class Raise(Op):
	ins    = [ "mem", "exo_ptr" ]
620
621
622
623
	outs  = [
		("M", "memory result",                     "pn_Generic_M"),
		("X", "control flow to exception handler", "pn_Generic_X_regular"),
	]
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
	flags  = [ "highlevel", "cfopcode" ]
	pinned = "yes"

class Return(Op):
	ins      = [ "mem" ]
	arity    = "variable"
	mode     = "mode_X"
	flags    = [ "cfopcode" ]
	pinned   = "yes"

class Rotl(Binop):
	flags    = []

class Sel(Op):
	ins    = [ "mem", "ptr" ]
	arity  = "variable"
	flags  = []
	mode   = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data"
	pinned = "no"
643
	attrs  = [
644
		dict(
645
646
647
			type = "ir_entity*",
			name = "entity"
		)
648
649
650
651
652
653
654
655
656
657
658
659
660
	]
	attr_struct = "sel_attr"

class Shl(Binop):
	flags = []

class Shr(Binop):
	flags = []

class Shrs(Binop):
	flags = []

class Start(Op):
661
662
663
664
665
666
667
	outs       = [
		("X_initial_exec", "control flow"),
		("M",              "initial memory"),
		("P_frame_base",   "frame base pointer"),
		("P_tls",          "pointer to thread local storage segment"),
		("T_args",         "function arguments")
	]
668
669
670
671
672
673
674
	mode       = "mode_T"
	pinned     = "yes"
	flags      = [ "cfopcode" ]
	singleton  = True

class Store(Op):
	ins      = [ "mem", "ptr", "value" ]
675
676
677
678
679
	outs  = [
		("M",         "memory result",                         "pn_Generic_M"),
		("X_regular", "control flow when no exception occurs", "pn_Generic_X_regular"),
		("X_except",  "control flow when exception occured",   "pn_Generic_X_except"),
	]
680
681
682
683
	flags    = [ "fragile", "uses_memory" ]
	pinned   = "exception"
	attr_struct = "store_attr"
	pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
684
	constructor_args = [
685
		dict(
686
687
			type = "ir_cons_flags",
			name = "flags",
688
		),
689
690
691
692
693
694
695
696
697
698
	]

class Sub(Binop):
	flags = []

class SymConst(Op):
	mode       = "mode_P"
	flags      = [ "constlike", "start_block" ]
	knownBlock = True
	pinned     = "no"
699
	attrs      = [
700
		dict(
701
			type = "ir_entity*",
702
703
			name = "entity",
			noprop = True
704
		)
705
706
707
708
709
710
711
712
713
	]
	attr_struct = "symconst_attr"
	java_noconstr = True

class Sync(Op):
	mode     = "mode_M"
	flags    = []
	pinned   = "no"
	optimize = False
714
	arity    = "dynamic"
715

716
717
718
719
720
class Tuple(Op):
	arity  = "variable"
	mode   = "mode_T"
	pinned = "no"
	flags  = [ "labeled" ]
721
	java_noconstr = True
722
723
724
725
726

class Unknown(Op):
	knownBlock = True
	pinned     = "yes"
	block      = "get_irg_start_block(irg)"
727
	flags      = [ "cfopcode", "start_block", "constlike", "dump_noblock" ]
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743

# Prepare node list

def getOpList(namespace):
	nodes = []
	for t in namespace.values():
		if type(t) != type:
			continue

		if issubclass(t, Op):
			setnodedefaults(t)
			nodes.append(t)
	return nodes

nodes = getOpList(globals())
nodes = sorted(nodes, lambda x,y: cmp(x.name, y.name))