bugfix in ircgcons and some additional features
[libfirm] / ir / ir / ircons.c
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ir/ircons.c
4  * Purpose:     Various irnode constructors.  Automatic construction
5  *              of SSA representation.
6  * Author:      Martin Trapp, Christian Schaefer
7  * Modified by: Goetz Lindenmaier, Boris Boesler
8  * Created:
9  * CVS-ID:      $Id$
10  * Copyright:   (c) 1998-2003 Universität Karlsruhe
11  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
12  */
13
14
15 #ifdef HAVE_CONFIG_H
16 # include <config.h>
17 #endif
18
19 # include "irgraph_t.h"
20 # include "irnode_t.h"
21 # include "irmode_t.h"
22 # include "ircons.h"
23 # include "firm_common_t.h"
24 # include "irvrfy.h"
25 # include "irop.h"
26 # include "iropt_t.h"
27 # include "irgmod.h"
28 # include "array.h"
29 /* memset belongs to string.h */
30 # include "string.h"
31 # include "irbackedge_t.h"
32
33 #if USE_EXPLICIT_PHI_IN_STACK
34 /* A stack needed for the automatic Phi node construction in constructor
35    Phi_in. Redefinition in irgraph.c!! */
36 struct Phi_in_stack {
37   ir_node **stack;
38   int       pos;
39 };
40 typedef struct Phi_in_stack Phi_in_stack;
41 #endif
42
43 /*
44  * language dependant initialization variable
45  */
46 static default_initialize_local_variable_func_t *default_initialize_local_variable = NULL;
47
48 /*** ******************************************** */
49 /** privat interfaces, for professional use only */
50
51 /* Constructs a Block with a fixed number of predecessors.
52    Does not set current_block.  Can not be used with automatic
53    Phi node construction. */
54 INLINE ir_node *
55 new_rd_Block (dbg_info* db, ir_graph *irg,  int arity, ir_node **in)
56 {
57   ir_node *res;
58
59   res = new_ir_node (db, irg, NULL, op_Block, mode_BB, arity, in);
60   set_Block_matured(res, 1);
61   set_Block_block_visited(res, 0);
62
63   //res->attr.block.exc = exc_normal;
64   //res->attr.block.handler_entry = 0;
65   res->attr.block.irg = irg;
66   res->attr.block.backedge = new_backedge_arr(irg->obst, arity);
67   res->attr.block.in_cg = NULL;
68   res->attr.block.cg_backedge = NULL;
69
70   irn_vrfy_irg (res, irg);
71   return res;
72 }
73
74 INLINE ir_node *
75 new_rd_Start (dbg_info* db, ir_graph *irg, ir_node *block)
76 {
77   ir_node *res;
78
79   res = new_ir_node (db, irg, block, op_Start, mode_T, 0, NULL);
80   //res->attr.start.irg = irg;
81
82   irn_vrfy_irg (res, irg);
83   return res;
84 }
85
86 INLINE ir_node *
87 new_rd_End (dbg_info* db, ir_graph *irg, ir_node *block)
88 {
89   ir_node *res;
90
91   res = new_ir_node (db, irg, block, op_End, mode_X, -1, NULL);
92
93   irn_vrfy_irg (res, irg);
94   return res;
95 }
96
97 /* Creates a Phi node with all predecessors.  Calling this constructor
98    is only allowed if the corresponding block is mature.  */
99 INLINE ir_node *
100 new_rd_Phi (dbg_info* db, ir_graph *irg, ir_node *block, int arity, ir_node **in, ir_mode *mode)
101 {
102   ir_node *res;
103   int i;
104   bool has_unknown = false;
105
106   assert( get_Block_matured(block) );
107   assert( get_irn_arity(block) == arity );
108
109   res = new_ir_node (db, irg, block, op_Phi, mode, arity, in);
110
111   res->attr.phi_backedge = new_backedge_arr(irg->obst, arity);
112
113   for (i = arity-1; i >= 0; i--) if (get_irn_op(in[i]) == op_Unknown) has_unknown = true;
114   if (!has_unknown) res = optimize_node (res);
115   irn_vrfy_irg (res, irg);
116
117   /* Memory Phis in endless loops must be kept alive.
118      As we can't distinguish these easily we keep all of them alive. */
119   if ((res->op == op_Phi) && (mode == mode_M))
120     add_End_keepalive(irg->end, res);
121   return res;
122 }
123
124 INLINE ir_node *
125 new_rd_Const_type (dbg_info* db, ir_graph *irg, ir_node *block, ir_mode *mode, tarval *con, type *tp)
126 {
127   ir_node *res;
128   res = new_ir_node (db, irg, block, op_Const, mode, 0, NULL);
129   res->attr.con.tv = con;
130   set_Const_type(res, tp);  /* Call method because of complex assertion. */
131   res = optimize_node (res);
132   assert(get_Const_type(res) == tp);
133   irn_vrfy_irg (res, irg);
134
135 #if 0
136   res = local_optimize_newby (res);
137 # endif
138
139   return res;
140 }
141
142 INLINE ir_node *
143 new_rd_Const (dbg_info* db, ir_graph *irg, ir_node *block, ir_mode *mode, tarval *con)
144 {
145   type *tp = unknown_type;
146   if (tarval_is_entity(con))
147     tp = find_pointer_type_to_type(get_entity_type(get_tarval_entity(con)));
148   return new_rd_Const_type (db, irg, block, mode, con, tp);
149 }
150
151 INLINE ir_node *
152 new_rd_Id (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *val, ir_mode *mode)
153 {
154   ir_node *in[1];
155   ir_node *res;
156   in[0]=val;
157   res = new_ir_node (db, irg, block, op_Id, mode, 1, in);
158   res = optimize_node (res);
159   irn_vrfy_irg (res, irg);
160   return res;
161 }
162
163 INLINE ir_node *
164 new_rd_Proj (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *arg, ir_mode *mode,
165             long proj)
166 {
167   ir_node *in[1];
168   ir_node *res;
169   in[0]=arg;
170   res = new_ir_node (db, irg, block, op_Proj, mode, 1, in);
171   res->attr.proj = proj;
172
173   assert(res);
174   assert(get_Proj_pred(res));
175   assert(get_nodes_Block(get_Proj_pred(res)));
176
177   res = optimize_node (res);
178
179   irn_vrfy_irg (res, irg);
180   return res;
181
182 }
183
184 INLINE ir_node *
185 new_rd_defaultProj (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *arg,
186                    long max_proj)
187 {
188   ir_node *res;
189   assert((arg->op==op_Cond) && (get_irn_mode(arg->in[1]) == mode_Iu));
190   arg->attr.c.kind = fragmentary;
191   arg->attr.c.default_proj = max_proj;
192   res = new_rd_Proj (db, irg, block, arg, mode_X, max_proj);
193   return res;
194 }
195
196 INLINE ir_node *
197 new_rd_Conv (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op, ir_mode *mode)
198 {
199   ir_node *in[1];
200   ir_node *res;
201   in[0]=op;
202   res = new_ir_node (db, irg, block, op_Conv, mode, 1, in);
203   res = optimize_node (res);
204   irn_vrfy_irg (res, irg);
205   return res;
206 }
207
208 INLINE ir_node *
209 new_rd_Cast (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op, type *to_tp)
210 {
211   ir_node *res;
212   res = new_ir_node (db, irg, block, op_Cast, get_irn_mode(op), 1, &op);
213   res->attr.cast.totype = to_tp;
214   res = optimize_node (res);
215   irn_vrfy_irg (res, irg);
216   return res;
217 }
218
219 INLINE ir_node *
220 new_rd_Tuple (dbg_info* db, ir_graph *irg, ir_node *block, int arity, ir_node **in)
221 {
222   ir_node *res;
223
224   res = new_ir_node (db, irg, block, op_Tuple, mode_T, arity, in);
225   res = optimize_node (res);
226   irn_vrfy_irg (res, irg);
227   return res;
228 }
229
230 INLINE ir_node *
231 new_rd_Add (dbg_info* db, ir_graph *irg, ir_node *block,
232            ir_node *op1, ir_node *op2, ir_mode *mode)
233 {
234   ir_node *in[2];
235   ir_node *res;
236   in[0] = op1;
237   in[1] = op2;
238   res = new_ir_node (db, irg, block, op_Add, mode, 2, in);
239   res = optimize_node (res);
240   irn_vrfy_irg (res, irg);
241   return res;
242 }
243
244 INLINE ir_node *
245 new_rd_Sub (dbg_info* db, ir_graph *irg, ir_node *block,
246            ir_node *op1, ir_node *op2, ir_mode *mode)
247 {
248   ir_node *in[2];
249   ir_node *res;
250   in[0] = op1;
251   in[1] = op2;
252   res = new_ir_node (db, irg, block, op_Sub, mode, 2, in);
253   res = optimize_node (res);
254   irn_vrfy_irg (res, irg);
255   return res;
256 }
257
258 INLINE ir_node *
259 new_rd_Minus (dbg_info* db, ir_graph *irg, ir_node *block,
260              ir_node *op,  ir_mode *mode)
261 {
262   ir_node *in[1];
263   ir_node *res;
264   in[0]=op;
265   res = new_ir_node (db, irg, block, op_Minus, mode, 1, in);
266   res = optimize_node (res);
267   irn_vrfy_irg (res, irg);
268   return res;
269 }
270
271 INLINE ir_node *
272 new_rd_Mul (dbg_info* db, ir_graph *irg, ir_node *block,
273            ir_node *op1, ir_node *op2, ir_mode *mode)
274 {
275   ir_node *in[2];
276   ir_node *res;
277   in[0] = op1;
278   in[1] = op2;
279   res = new_ir_node (db, irg, block, op_Mul, mode, 2, in);
280   res = optimize_node (res);
281   irn_vrfy_irg (res, irg);
282   return res;
283 }
284
285 INLINE ir_node *
286 new_rd_Quot (dbg_info* db, ir_graph *irg, ir_node *block,
287             ir_node *memop, ir_node *op1, ir_node *op2)
288 {
289   ir_node *in[3] ;
290   ir_node *res;
291   in[0] = memop;
292   in[1] = op1;
293   in[2] = op2;
294   res = new_ir_node (db, irg, block, op_Quot, mode_T, 3, in);
295   res = optimize_node (res);
296   irn_vrfy_irg (res, irg);
297   return res;
298 }
299
300 INLINE ir_node *
301 new_rd_DivMod (dbg_info* db, ir_graph *irg, ir_node *block,
302               ir_node *memop, ir_node *op1, ir_node *op2)
303 {
304   ir_node *in[3];
305   ir_node *res;
306   in[0] = memop;
307   in[1] = op1;
308   in[2] = op2;
309   res = new_ir_node (db, irg, block, op_DivMod, mode_T, 3, in);
310   res = optimize_node (res);
311   irn_vrfy_irg (res, irg);
312   return res;
313 }
314
315 INLINE ir_node *
316 new_rd_Div (dbg_info* db, ir_graph *irg, ir_node *block,
317            ir_node *memop, ir_node *op1, ir_node *op2)
318 {
319   ir_node *in[3];
320   ir_node *res;
321   in[0] = memop;
322   in[1] = op1;
323   in[2] = op2;
324   res = new_ir_node (db, irg, block, op_Div, mode_T, 3, in);
325   res = optimize_node (res);
326   irn_vrfy_irg (res, irg);
327   return res;
328 }
329
330 INLINE ir_node *
331 new_rd_Mod (dbg_info* db, ir_graph *irg, ir_node *block,
332            ir_node *memop, ir_node *op1, ir_node *op2)
333 {
334   ir_node *in[3];
335   ir_node *res;
336   in[0] = memop;
337   in[1] = op1;
338   in[2] = op2;
339   res = new_ir_node (db, irg, block, op_Mod, mode_T, 3, in);
340   res = optimize_node (res);
341   irn_vrfy_irg (res, irg);
342   return res;
343 }
344
345 INLINE ir_node *
346 new_rd_And (dbg_info* db, ir_graph *irg, ir_node *block,
347            ir_node *op1, ir_node *op2, ir_mode *mode)
348 {
349   ir_node *in[2];
350   ir_node *res;
351   in[0] = op1;
352   in[1] = op2;
353   res = new_ir_node (db, irg, block, op_And, mode, 2, in);
354   res = optimize_node (res);
355   irn_vrfy_irg (res, irg);
356   return res;
357 }
358
359 INLINE ir_node *
360 new_rd_Or (dbg_info* db, ir_graph *irg, ir_node *block,
361           ir_node *op1, ir_node *op2, ir_mode *mode)
362 {
363   ir_node *in[2];
364   ir_node *res;
365   in[0] = op1;
366   in[1] = op2;
367   res = new_ir_node (db, irg, block, op_Or, mode, 2, in);
368   res = optimize_node (res);
369   irn_vrfy_irg (res, irg);
370   return res;
371 }
372
373 INLINE ir_node *
374 new_rd_Eor (dbg_info* db, ir_graph *irg, ir_node *block,
375           ir_node *op1, ir_node *op2, ir_mode *mode)
376 {
377   ir_node *in[2];
378   ir_node *res;
379   in[0] = op1;
380   in[1] = op2;
381   res = new_ir_node (db, irg, block, op_Eor, mode, 2, in);
382   res = optimize_node (res);
383   irn_vrfy_irg (res, irg);
384   return res;
385 }
386
387 INLINE ir_node *
388 new_rd_Not    (dbg_info* db, ir_graph *irg, ir_node *block,
389               ir_node *op, ir_mode *mode)
390 {
391   ir_node *in[1];
392   ir_node *res;
393   in[0] = op;
394   res = new_ir_node (db, irg, block, op_Not, mode, 1, in);
395   res = optimize_node (res);
396   irn_vrfy_irg (res, irg);
397   return res;
398 }
399
400 INLINE ir_node *
401 new_rd_Shl (dbg_info* db, ir_graph *irg, ir_node *block,
402           ir_node *op, ir_node *k, ir_mode *mode)
403 {
404   ir_node *in[2];
405   ir_node *res;
406   in[0] = op;
407   in[1] = k;
408   res = new_ir_node (db, irg, block, op_Shl, mode, 2, in);
409   res = optimize_node (res);
410   irn_vrfy_irg (res, irg);
411   return res;
412 }
413
414 INLINE ir_node *
415 new_rd_Shr (dbg_info* db, ir_graph *irg, ir_node *block,
416            ir_node *op, ir_node *k, ir_mode *mode)
417 {
418   ir_node *in[2];
419   ir_node *res;
420   in[0] = op;
421   in[1] = k;
422   res = new_ir_node (db, irg, block, op_Shr, mode, 2, in);
423   res = optimize_node (res);
424   irn_vrfy_irg (res, irg);
425   return res;
426 }
427
428 INLINE ir_node *
429 new_rd_Shrs (dbg_info* db, ir_graph *irg, ir_node *block,
430            ir_node *op, ir_node *k, ir_mode *mode)
431 {
432   ir_node *in[2];
433   ir_node *res;
434   in[0] = op;
435   in[1] = k;
436   res = new_ir_node (db, irg, block, op_Shrs, mode, 2, in);
437   res = optimize_node (res);
438   irn_vrfy_irg (res, irg);
439   return res;
440 }
441
442 INLINE ir_node *
443 new_rd_Rot (dbg_info* db, ir_graph *irg, ir_node *block,
444            ir_node *op, ir_node *k, ir_mode *mode)
445 {
446   ir_node *in[2];
447   ir_node *res;
448   in[0] = op;
449   in[1] = k;
450   res = new_ir_node (db, irg, block, op_Rot, mode, 2, in);
451   res = optimize_node (res);
452   irn_vrfy_irg (res, irg);
453   return res;
454 }
455
456 INLINE ir_node *
457 new_rd_Abs (dbg_info* db, ir_graph *irg, ir_node *block,
458            ir_node *op, ir_mode *mode)
459 {
460   ir_node *in[1];
461   ir_node *res;
462   in[0] = op;
463   res = new_ir_node (db, irg, block, op_Abs, mode, 1, in);
464   res = optimize_node (res);
465   irn_vrfy_irg (res, irg);
466   return res;
467 }
468
469 INLINE ir_node *
470 new_rd_Cmp (dbg_info* db, ir_graph *irg, ir_node *block,
471            ir_node *op1, ir_node *op2)
472 {
473   ir_node *in[2];
474   ir_node *res;
475   in[0] = op1;
476   in[1] = op2;
477   res = new_ir_node (db, irg, block, op_Cmp, mode_T, 2, in);
478   res = optimize_node (res);
479   irn_vrfy_irg (res, irg);
480   return res;
481 }
482
483 INLINE ir_node *
484 new_rd_Jmp (dbg_info* db, ir_graph *irg, ir_node *block)
485 {
486   ir_node *res;
487   res = new_ir_node (db, irg, block, op_Jmp, mode_X, 0, NULL);
488   res = optimize_node (res);
489   irn_vrfy_irg (res, irg);
490   return res;
491 }
492
493 INLINE ir_node *
494 new_rd_Cond (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *c)
495 {
496   ir_node *in[1];
497   ir_node *res;
498   in[0] = c;
499   res = new_ir_node (db, irg, block, op_Cond, mode_T, 1, in);
500   res->attr.c.kind = dense;
501   res->attr.c.default_proj = 0;
502   res = optimize_node (res);
503   irn_vrfy_irg (res, irg);
504   return res;
505 }
506
507 ir_node *
508 new_rd_Call (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *store,
509             ir_node *callee, int arity, ir_node **in, type *tp)
510 {
511   ir_node **r_in;
512   ir_node *res;
513   int r_arity;
514
515   r_arity = arity+2;
516   NEW_ARR_A (ir_node *, r_in, r_arity);
517   r_in[0] = store;
518   r_in[1] = callee;
519   memcpy (&r_in[2], in, sizeof (ir_node *) * arity);
520
521   res = new_ir_node (db, irg, block, op_Call, mode_T, r_arity, r_in);
522
523   assert(is_method_type(tp));
524   set_Call_type(res, tp);
525   res->attr.call.callee_arr = NULL;
526   res = optimize_node (res);
527   irn_vrfy_irg (res, irg);
528   return res;
529 }
530
531 ir_node *
532 new_rd_Return (dbg_info* db, ir_graph *irg, ir_node *block,
533               ir_node *store, int arity, ir_node **in)
534 {
535   ir_node **r_in;
536   ir_node *res;
537   int r_arity;
538
539   r_arity = arity+1;
540   NEW_ARR_A (ir_node *, r_in, r_arity);
541   r_in[0] = store;
542   memcpy (&r_in[1], in, sizeof (ir_node *) * arity);
543   res = new_ir_node (db, irg, block, op_Return, mode_X, r_arity, r_in);
544   res = optimize_node (res);
545   irn_vrfy_irg (res, irg);
546   return res;
547 }
548
549 INLINE ir_node *
550 new_rd_Raise (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *store, ir_node *obj)
551 {
552   ir_node *in[2];
553   ir_node *res;
554   in[0] = store;
555   in[1] = obj;
556   res = new_ir_node (db, irg, block, op_Raise, mode_T, 2, in);
557   res = optimize_node (res);
558   irn_vrfy_irg (res, irg);
559   return res;
560 }
561
562 INLINE ir_node *
563 new_rd_Load (dbg_info* db, ir_graph *irg, ir_node *block,
564             ir_node *store, ir_node *adr)
565 {
566   ir_node *in[2];
567   ir_node *res;
568   in[0] = store;
569   in[1] = adr;
570   res = new_ir_node (db, irg, block, op_Load, mode_T, 2, in);
571
572   res = optimize_node (res);
573   irn_vrfy_irg (res, irg);
574   return res;
575 }
576
577 INLINE ir_node *
578 new_rd_Store (dbg_info* db, ir_graph *irg, ir_node *block,
579              ir_node *store, ir_node *adr, ir_node *val)
580 {
581   ir_node *in[3];
582   ir_node *res;
583   in[0] = store;
584   in[1] = adr;
585   in[2] = val;
586   res = new_ir_node (db, irg, block, op_Store, mode_T, 3, in);
587
588   res = optimize_node (res);
589
590   irn_vrfy_irg (res, irg);
591   return res;
592 }
593
594 INLINE ir_node *
595 new_rd_Alloc (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *store,
596             ir_node *size, type *alloc_type, where_alloc where)
597 {
598   ir_node *in[2];
599   ir_node *res;
600   in[0] = store;
601   in[1] = size;
602   res = new_ir_node (db, irg, block, op_Alloc, mode_T, 2, in);
603
604   res->attr.a.where = where;
605   res->attr.a.type = alloc_type;
606
607   res = optimize_node (res);
608   irn_vrfy_irg (res, irg);
609   return res;
610 }
611
612 INLINE ir_node *
613 new_rd_Free (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *store,
614             ir_node *ptr, ir_node *size, type *free_type)
615 {
616   ir_node *in[3];
617   ir_node *res;
618   in[0] = store;
619   in[1] = ptr;
620   in[2] = size;
621   res = new_ir_node (db, irg, block, op_Free, mode_T, 3, in);
622
623   res->attr.f = free_type;
624
625   res = optimize_node (res);
626   irn_vrfy_irg (res, irg);
627   return res;
628 }
629
630 ir_node *
631 new_rd_Sel (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *store, ir_node *objptr,
632            int arity, ir_node **in, entity *ent)
633 {
634   ir_node **r_in;
635   ir_node *res;
636   int r_arity;
637
638   r_arity = arity + 2;
639   NEW_ARR_A (ir_node *, r_in, r_arity);  /* uses alloca */
640   r_in[0] = store;
641   r_in[1] = objptr;
642   memcpy (&r_in[2], in, sizeof (ir_node *) * arity);
643   res = new_ir_node (db, irg, block, op_Sel, mode_P_mach, r_arity, r_in);
644
645   res->attr.s.ent = ent;
646
647   res = optimize_node (res);
648   irn_vrfy_irg (res, irg);
649   return res;
650 }
651
652 ir_node *
653 new_rd_InstOf (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
654                ir_node *objptr, type *ent)
655 {
656   ir_node **r_in;
657   ir_node *res;
658   int r_arity;
659
660   r_arity = 2;
661   NEW_ARR_A (ir_node *, r_in, r_arity);
662   r_in [0] = store;
663   r_in [1] = objptr;
664
665   res = new_ir_node (db, irg, block, op_Sel, mode_T, r_arity, r_in);
666
667   res->attr.io.ent = ent;
668
669   /* res = optimize (res);
670   * irn_vrfy_irg (res, irg); */
671   return (res);
672 }
673
674 INLINE ir_node *
675 new_rd_SymConst (dbg_info* db, ir_graph *irg, ir_node *block, type_or_id_p value,
676                 symconst_kind symkind)
677 {
678   ir_node *res;
679   ir_mode *mode;
680   if (symkind == linkage_ptr_info)
681     mode = mode_P_mach;
682   else
683     mode = mode_Iu;
684   res = new_ir_node (db, irg, block, op_SymConst, mode, 0, NULL);
685
686   res->attr.i.num = symkind;
687   if (symkind == linkage_ptr_info) {
688     res->attr.i.tori.ptrinfo = (ident *)value;
689   } else {
690     assert (   (   (symkind == type_tag)
691                 || (symkind == size))
692             && (is_type(value)));
693     res->attr.i.tori.typ = (type *)value;
694   }
695   res = optimize_node (res);
696   irn_vrfy_irg (res, irg);
697   return res;
698 }
699
700 INLINE ir_node *
701 new_rd_Sync (dbg_info* db, ir_graph *irg, ir_node *block, int arity, ir_node **in)
702 {
703   ir_node *res;
704
705   res = new_ir_node (db, irg, block, op_Sync, mode_M, arity, in);
706
707   res = optimize_node (res);
708   irn_vrfy_irg (res, irg);
709   return res;
710 }
711
712 INLINE ir_node *
713 new_rd_Bad (ir_graph *irg)
714 {
715   return irg->bad;
716 }
717
718 INLINE ir_node *
719 new_rd_Confirm (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *val, ir_node *bound, pn_Cmp cmp)
720 {
721   ir_node *in[2], *res;
722   in[0] = val;
723   in[1] = bound;
724
725   res = new_ir_node (db, irg, block, op_Confirm, get_irn_mode(val), 2, in);
726
727   res->attr.confirm_cmp = cmp;
728
729   res = optimize_node (res);
730   irn_vrfy_irg(res, irg);
731   return res;
732 }
733
734 INLINE ir_node *
735 new_rd_Unknown (ir_graph *irg)
736 {
737   return irg->unknown;
738 }
739
740 INLINE ir_node *
741 new_rd_CallBegin (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *call)
742 {
743   ir_node *in[1];
744   ir_node *res;
745   in[0] = get_Call_ptr(call);
746   res = new_ir_node (db, irg, block, op_CallBegin, mode_T, 1, in);
747   //res->attr.callbegin.irg = irg;
748   res->attr.callbegin.call = call;
749   res = optimize_node (res);
750   irn_vrfy_irg (res, irg);
751   return res;
752 }
753
754 INLINE ir_node *
755 new_rd_EndReg (dbg_info *db, ir_graph *irg, ir_node *block)
756 {
757   ir_node *res;
758
759   res = new_ir_node (db, irg, block, op_EndReg, mode_T, -1, NULL);
760   //res->attr.end.irg = irg;
761
762   irn_vrfy_irg (res, irg);
763   return res;
764 }
765
766 INLINE ir_node *
767 new_rd_EndExcept (dbg_info *db, ir_graph *irg, ir_node *block)
768 {
769   ir_node *res;
770
771   res = new_ir_node (db, irg, block, op_EndExcept, mode_T, -1, NULL);
772   //res->attr.end.irg = irg;
773
774   irn_vrfy_irg (res, irg);
775   return res;
776 }
777
778 INLINE ir_node *
779 new_rd_Break (dbg_info *db, ir_graph *irg, ir_node *block)
780 {
781   ir_node *res;
782   res = new_ir_node (db, irg, block, op_Break, mode_X, 0, NULL);
783   res = optimize_node (res);
784   irn_vrfy_irg (res, irg);
785   return res;
786 }
787
788 INLINE ir_node *
789 new_rd_Filter (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg, ir_mode *mode,
790                long proj)
791 {
792   ir_node *in[1];
793   ir_node *res;
794   in[0] = arg;
795   res = new_ir_node (db, irg, block, op_Filter, mode, 1, in);
796   res->attr.filter.proj = proj;
797   res->attr.filter.in_cg = NULL;
798   res->attr.filter.backedge = NULL;
799
800   assert(res);
801   assert(get_Proj_pred(res));
802   assert(get_nodes_Block(get_Proj_pred(res)));
803
804   res = optimize_node (res);
805
806   irn_vrfy_irg (res, irg);
807   return res;
808
809 }
810
811 INLINE ir_node *new_r_Block  (ir_graph *irg,  int arity, ir_node **in) {
812   return new_rd_Block(NULL, irg, arity, in);
813 }
814 INLINE ir_node *new_r_Start  (ir_graph *irg, ir_node *block) {
815   return new_rd_Start(NULL, irg, block);
816 }
817 INLINE ir_node *new_r_End    (ir_graph *irg, ir_node *block) {
818   return new_rd_End(NULL, irg, block);
819 }
820 INLINE ir_node *new_r_Jmp    (ir_graph *irg, ir_node *block) {
821   return new_rd_Jmp(NULL, irg, block);
822 }
823 INLINE ir_node *new_r_Cond   (ir_graph *irg, ir_node *block, ir_node *c) {
824   return new_rd_Cond(NULL, irg, block, c);
825 }
826 INLINE ir_node *new_r_Return (ir_graph *irg, ir_node *block,
827                        ir_node *store, int arity, ir_node **in) {
828   return new_rd_Return(NULL, irg, block, store, arity, in);
829 }
830 INLINE ir_node *new_r_Raise  (ir_graph *irg, ir_node *block,
831                        ir_node *store, ir_node *obj) {
832   return new_rd_Raise(NULL, irg, block, store, obj);
833 }
834 INLINE ir_node *new_r_Const  (ir_graph *irg, ir_node *block,
835                        ir_mode *mode, tarval *con) {
836   return new_rd_Const(NULL, irg, block, mode, con);
837 }
838 INLINE ir_node *new_r_SymConst (ir_graph *irg, ir_node *block,
839                        type_or_id_p value, symconst_kind symkind) {
840   return new_rd_SymConst(NULL, irg, block, value, symkind);
841 }
842 INLINE ir_node *new_r_Sel    (ir_graph *irg, ir_node *block, ir_node *store,
843                               ir_node *objptr, int n_index, ir_node **index,
844                               entity *ent) {
845   return new_rd_Sel(NULL, irg, block, store, objptr, n_index, index, ent);
846 }
847 INLINE ir_node *new_r_InstOf (ir_graph *irg, ir_node *block, ir_node *store, ir_node *objptr,
848                               type *ent) {
849   return (new_rd_InstOf (NULL, irg, block, store, objptr, ent));
850 }
851 INLINE ir_node *new_r_Call   (ir_graph *irg, ir_node *block, ir_node *store,
852                               ir_node *callee, int arity, ir_node **in,
853                               type *tp) {
854   return new_rd_Call(NULL, irg, block, store, callee, arity, in, tp);
855 }
856 INLINE ir_node *new_r_Add    (ir_graph *irg, ir_node *block,
857                               ir_node *op1, ir_node *op2, ir_mode *mode) {
858   return new_rd_Add(NULL, irg, block, op1, op2, mode);
859 }
860 INLINE ir_node *new_r_Sub    (ir_graph *irg, ir_node *block,
861                               ir_node *op1, ir_node *op2, ir_mode *mode) {
862   return new_rd_Sub(NULL, irg, block, op1, op2, mode);
863 }
864 INLINE ir_node *new_r_Minus  (ir_graph *irg, ir_node *block,
865                               ir_node *op,  ir_mode *mode) {
866   return new_rd_Minus(NULL, irg, block,  op, mode);
867 }
868 INLINE ir_node *new_r_Mul    (ir_graph *irg, ir_node *block,
869                               ir_node *op1, ir_node *op2, ir_mode *mode) {
870   return new_rd_Mul(NULL, irg, block, op1, op2, mode);
871 }
872 INLINE ir_node *new_r_Quot   (ir_graph *irg, ir_node *block,
873                               ir_node *memop, ir_node *op1, ir_node *op2) {
874   return new_rd_Quot(NULL, irg, block, memop, op1, op2);
875 }
876 INLINE ir_node *new_r_DivMod (ir_graph *irg, ir_node *block,
877                               ir_node *memop, ir_node *op1, ir_node *op2) {
878   return new_rd_DivMod(NULL, irg, block, memop, op1, op2);
879 }
880 INLINE ir_node *new_r_Div    (ir_graph *irg, ir_node *block,
881                               ir_node *memop, ir_node *op1, ir_node *op2) {
882   return new_rd_Div(NULL, irg, block, memop, op1, op2);
883 }
884 INLINE ir_node *new_r_Mod    (ir_graph *irg, ir_node *block,
885                               ir_node *memop, ir_node *op1, ir_node *op2) {
886   return new_rd_Mod(NULL, irg, block, memop, op1, op2);
887 }
888 INLINE ir_node *new_r_Abs    (ir_graph *irg, ir_node *block,
889                               ir_node *op, ir_mode *mode) {
890   return new_rd_Abs(NULL, irg, block, op, mode);
891 }
892 INLINE ir_node *new_r_And    (ir_graph *irg, ir_node *block,
893                               ir_node *op1, ir_node *op2, ir_mode *mode) {
894   return new_rd_And(NULL, irg, block,  op1, op2, mode);
895 }
896 INLINE ir_node *new_r_Or     (ir_graph *irg, ir_node *block,
897                               ir_node *op1, ir_node *op2, ir_mode *mode) {
898   return new_rd_Or(NULL, irg, block,  op1, op2, mode);
899 }
900 INLINE ir_node *new_r_Eor    (ir_graph *irg, ir_node *block,
901                               ir_node *op1, ir_node *op2, ir_mode *mode) {
902   return new_rd_Eor(NULL, irg, block,  op1, op2, mode);
903 }
904 INLINE ir_node *new_r_Not    (ir_graph *irg, ir_node *block,
905                        ir_node *op, ir_mode *mode) {
906   return new_rd_Not(NULL, irg, block, op, mode);
907 }
908 INLINE ir_node *new_r_Cmp    (ir_graph *irg, ir_node *block,
909                        ir_node *op1, ir_node *op2) {
910   return new_rd_Cmp(NULL, irg, block, op1, op2);
911 }
912 INLINE ir_node *new_r_Shl    (ir_graph *irg, ir_node *block,
913                        ir_node *op, ir_node *k, ir_mode *mode) {
914   return new_rd_Shl(NULL, irg, block, op, k, mode);
915 }
916 INLINE ir_node *new_r_Shr    (ir_graph *irg, ir_node *block,
917                        ir_node *op, ir_node *k, ir_mode *mode) {
918   return new_rd_Shr(NULL, irg, block, op, k, mode);
919 }
920 INLINE ir_node *new_r_Shrs   (ir_graph *irg, ir_node *block,
921                        ir_node *op, ir_node *k, ir_mode *mode) {
922   return new_rd_Shrs(NULL, irg, block, op, k, mode);
923 }
924 INLINE ir_node *new_r_Rot    (ir_graph *irg, ir_node *block,
925                        ir_node *op, ir_node *k, ir_mode *mode) {
926   return new_rd_Rot(NULL, irg, block, op, k, mode);
927 }
928 INLINE ir_node *new_r_Conv   (ir_graph *irg, ir_node *block,
929                        ir_node *op, ir_mode *mode) {
930   return new_rd_Conv(NULL, irg, block, op, mode);
931 }
932 INLINE ir_node *new_r_Cast   (ir_graph *irg, ir_node *block, ir_node *op, type *to_tp) {
933   return new_rd_Cast(NULL, irg, block, op, to_tp);
934 }
935 INLINE ir_node *new_r_Phi    (ir_graph *irg, ir_node *block, int arity,
936                        ir_node **in, ir_mode *mode) {
937   return new_rd_Phi(NULL, irg, block, arity, in, mode);
938 }
939 INLINE ir_node *new_r_Load   (ir_graph *irg, ir_node *block,
940                        ir_node *store, ir_node *adr) {
941   return new_rd_Load(NULL, irg, block, store, adr);
942 }
943 INLINE ir_node *new_r_Store  (ir_graph *irg, ir_node *block,
944                        ir_node *store, ir_node *adr, ir_node *val) {
945   return new_rd_Store(NULL, irg, block, store, adr, val);
946 }
947 INLINE ir_node *new_r_Alloc  (ir_graph *irg, ir_node *block, ir_node *store,
948                        ir_node *size, type *alloc_type, where_alloc where) {
949   return new_rd_Alloc(NULL, irg, block, store, size, alloc_type, where);
950 }
951 INLINE ir_node *new_r_Free   (ir_graph *irg, ir_node *block, ir_node *store,
952                        ir_node *ptr, ir_node *size, type *free_type) {
953   return new_rd_Free(NULL, irg, block, store, ptr, size, free_type);
954 }
955 INLINE ir_node *new_r_Sync   (ir_graph *irg, ir_node *block, int arity, ir_node **in) {
956   return new_rd_Sync(NULL, irg, block, arity, in);
957 }
958 INLINE ir_node *new_r_Proj   (ir_graph *irg, ir_node *block, ir_node *arg,
959                        ir_mode *mode, long proj) {
960   return new_rd_Proj(NULL, irg, block, arg, mode, proj);
961 }
962 INLINE ir_node *new_r_defaultProj (ir_graph *irg, ir_node *block, ir_node *arg,
963                             long max_proj) {
964   return new_rd_defaultProj(NULL, irg, block, arg, max_proj);
965 }
966 INLINE ir_node *new_r_Tuple  (ir_graph *irg, ir_node *block,
967                        int arity, ir_node **in) {
968   return new_rd_Tuple(NULL, irg, block, arity, in );
969 }
970 INLINE ir_node *new_r_Id     (ir_graph *irg, ir_node *block,
971                        ir_node *val, ir_mode *mode) {
972   return new_rd_Id(NULL, irg, block, val, mode);
973 }
974 INLINE ir_node *new_r_Bad    (ir_graph *irg) {
975   return new_rd_Bad(irg);
976 }
977 INLINE ir_node *new_r_Confirm (ir_graph *irg, ir_node *block, ir_node *val, ir_node *bound, pn_Cmp cmp) {
978   return new_rd_Confirm (NULL, irg, block, val, bound, cmp);
979 }
980 INLINE ir_node *new_r_Unknown (ir_graph *irg) {
981   return new_rd_Unknown(irg);
982 }
983 INLINE ir_node *new_r_CallBegin (ir_graph *irg, ir_node *block, ir_node *callee) {
984   return new_rd_CallBegin(NULL, irg, block, callee);
985 }
986 INLINE ir_node *new_r_EndReg (ir_graph *irg, ir_node *block) {
987   return new_rd_EndReg(NULL, irg, block);
988 }
989 INLINE ir_node *new_r_EndExcept (ir_graph *irg, ir_node *block) {
990   return new_rd_EndExcept(NULL, irg, block);
991 }
992 INLINE ir_node *new_r_Break  (ir_graph *irg, ir_node *block) {
993   return new_rd_Break(NULL, irg, block);
994 }
995 INLINE ir_node *new_r_Filter (ir_graph *irg, ir_node *block, ir_node *arg,
996                        ir_mode *mode, long proj) {
997   return new_rd_Filter(NULL, irg, block, arg, mode, proj);
998 }
999
1000
1001 /** ********************/
1002 /** public interfaces  */
1003 /** construction tools */
1004
1005 /**
1006  *
1007  *   - create a new Start node in the current block
1008  *
1009  *   @return s - pointer to the created Start node
1010  *
1011  *
1012  */
1013 ir_node *
1014 new_d_Start (dbg_info* db)
1015 {
1016   ir_node *res;
1017
1018   res = new_ir_node (db, current_ir_graph, current_ir_graph->current_block,
1019                      op_Start, mode_T, 0, NULL);
1020   //res->attr.start.irg = current_ir_graph;
1021
1022   res = optimize_node (res);
1023   irn_vrfy_irg (res, current_ir_graph);
1024   return res;
1025 }
1026
1027 ir_node *
1028 new_d_End (dbg_info* db)
1029 {
1030   ir_node *res;
1031   res = new_ir_node (db, current_ir_graph,  current_ir_graph->current_block,
1032                      op_End, mode_X, -1, NULL);
1033   res = optimize_node (res);
1034   irn_vrfy_irg (res, current_ir_graph);
1035
1036   return res;
1037 }
1038
1039 /* Constructs a Block with a fixed number of predecessors.
1040    Does set current_block.  Can be used with automatic Phi
1041    node construction. */
1042 ir_node *
1043 new_d_Block (dbg_info* db, int arity, ir_node **in)
1044 {
1045   ir_node *res;
1046   int i;
1047   bool has_unknown = false;
1048
1049   res = new_rd_Block (db, current_ir_graph, arity, in);
1050
1051   /* Create and initialize array for Phi-node construction. */
1052   res->attr.block.graph_arr = NEW_ARR_D (ir_node *, current_ir_graph->obst,
1053                                          current_ir_graph->n_loc);
1054   memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->n_loc);
1055
1056   for (i = arity-1; i >= 0; i--) if (get_irn_op(in[i]) == op_Unknown) has_unknown = true;
1057
1058   if (!has_unknown) res = optimize_node (res);
1059   current_ir_graph->current_block = res;
1060
1061   irn_vrfy_irg (res, current_ir_graph);
1062
1063   return res;
1064 }
1065
1066 /* ***********************************************************************/
1067 /* Methods necessary for automatic Phi node creation                     */
1068 /*
1069   ir_node *phi_merge            (ir_node *block, int pos, ir_mode *mode, ir_node **nin, int ins)
1070   ir_node *get_r_value_internal (ir_node *block, int pos, ir_mode *mode);
1071   ir_node *new_rd_Phi0           (ir_graph *irg, ir_node *block, ir_mode *mode)
1072   ir_node *new_rd_Phi_in         (ir_graph *irg, ir_node *block, ir_mode *mode,  ir_node **in, int ins)
1073
1074   Call Graph:   ( A ---> B == A "calls" B)
1075
1076        get_value         mature_block
1077           |                   |
1078           |                   |
1079           |                   |
1080           |          ---> phi_merge
1081           |         /       /   \
1082           |        /       /     \
1083          \|/      /      |/_      \
1084        get_r_value_internal        |
1085                 |                  |
1086                 |                  |
1087                \|/                \|/
1088             new_rd_Phi0          new_rd_Phi_in
1089
1090 * *************************************************************************** */
1091
1092 /* Creates a Phi node with 0 predecessors */
1093 static INLINE ir_node *
1094 new_rd_Phi0 (ir_graph *irg, ir_node *block, ir_mode *mode)
1095 {
1096   ir_node *res;
1097   res = new_ir_node (NULL, irg, block, op_Phi, mode, 0, NULL);
1098   irn_vrfy_irg (res, irg);
1099   return res;
1100 }
1101
1102 /* There are two implementations of the Phi node construction.  The first
1103    is faster, but does not work for blocks with more than 2 predecessors.
1104    The second works always but is slower and causes more unnecessary Phi
1105    nodes.
1106    Select the implementations by the following preprocessor flag set in
1107    common/common.h: */
1108 #if USE_FAST_PHI_CONSTRUCTION
1109
1110 /* This is a stack used for allocating and deallocating nodes in
1111    new_rd_Phi_in.  The original implementation used the obstack
1112    to model this stack, now it is explicit.  This reduces side effects.
1113 */
1114 #if USE_EXPLICIT_PHI_IN_STACK
1115 INLINE Phi_in_stack *
1116 new_Phi_in_stack() {
1117   Phi_in_stack *res;
1118
1119   res = (Phi_in_stack *) malloc ( sizeof (Phi_in_stack));
1120
1121   res->stack = NEW_ARR_F (ir_node *, 1);
1122   res->pos = 0;
1123
1124   return res;
1125 }
1126
1127 INLINE void
1128 free_Phi_in_stack(Phi_in_stack *s) {
1129   DEL_ARR_F(s->stack);
1130   free(s);
1131 }
1132 static INLINE void
1133 free_to_Phi_in_stack(ir_node *phi) {
1134   assert(get_irn_opcode(phi) == iro_Phi);
1135
1136   if (ARR_LEN(current_ir_graph->Phi_in_stack->stack) ==
1137       current_ir_graph->Phi_in_stack->pos)
1138     ARR_APP1 (ir_node *, current_ir_graph->Phi_in_stack->stack, phi);
1139   else
1140     current_ir_graph->Phi_in_stack->stack[current_ir_graph->Phi_in_stack->pos] = phi;
1141
1142   (current_ir_graph->Phi_in_stack->pos)++;
1143 }
1144
1145 static INLINE ir_node *
1146 alloc_or_pop_from_Phi_in_stack(ir_graph *irg, ir_node *block, ir_mode *mode,
1147              int arity, ir_node **in) {
1148   ir_node *res;
1149   ir_node **stack = current_ir_graph->Phi_in_stack->stack;
1150   int pos = current_ir_graph->Phi_in_stack->pos;
1151
1152
1153   if (pos == 0) {
1154     /* We need to allocate a new node */
1155     res = new_ir_node (db, irg, block, op_Phi, mode, arity, in);
1156     res->attr.phi_backedge = new_backedge_arr(irg->obst, arity);
1157   } else {
1158     /* reuse the old node and initialize it again. */
1159     res = stack[pos-1];
1160
1161     assert (res->kind == k_ir_node);
1162     assert (res->op == op_Phi);
1163     res->mode = mode;
1164     res->visited = 0;
1165     res->link = NULL;
1166     assert (arity >= 0);
1167     /* ???!!! How to free the old in array??  Not at all: on obstack ?!! */
1168     res->in = NEW_ARR_D (ir_node *, irg->obst, (arity+1));
1169     res->in[0] = block;
1170     memcpy (&res->in[1], in, sizeof (ir_node *) * arity);
1171
1172     (current_ir_graph->Phi_in_stack->pos)--;
1173   }
1174   return res;
1175 }
1176 #endif /* USE_EXPLICIT_PHI_IN_STACK */
1177
1178 /* Creates a Phi node with a given, fixed array **in of predecessors.
1179    If the Phi node is unnecessary, as the same value reaches the block
1180    through all control flow paths, it is eliminated and the value
1181    returned directly.  This constructor is only intended for use in
1182    the automatic Phi node generation triggered by get_value or mature.
1183    The implementation is quite tricky and depends on the fact, that
1184    the nodes are allocated on a stack:
1185    The in array contains predecessors and NULLs.  The NULLs appear,
1186    if get_r_value_internal, that computed the predecessors, reached
1187    the same block on two paths.  In this case the same value reaches
1188    this block on both paths, there is no definition in between.  We need
1189    not allocate a Phi where these path's merge, but we have to communicate
1190    this fact to the caller.  This happens by returning a pointer to the
1191    node the caller _will_ allocate.  (Yes, we predict the address. We can
1192    do so because the nodes are allocated on the obstack.)  The caller then
1193    finds a pointer to itself and, when this routine is called again,
1194    eliminates itself.
1195    */
1196 static INLINE ir_node *
1197 new_rd_Phi_in (ir_graph *irg, ir_node *block, ir_mode *mode,
1198               ir_node **in, int ins)
1199 {
1200   int i;
1201   ir_node *res, *known;
1202
1203   /* allocate a new node on the obstack.
1204      This can return a node to which some of the pointers in the in-array
1205      already point.
1206      Attention: the constructor copies the in array, i.e., the later changes
1207      to the array in this routine do not affect the constructed node!  If
1208      the in array contains NULLs, there will be missing predecessors in the
1209      returned node.
1210      Is this a possible internal state of the Phi node generation? */
1211 #if USE_EXPLICIT_PHI_IN_STACK
1212   res = known = alloc_or_pop_from_Phi_in_stack(irg, block, mode, ins, in);
1213 #else
1214   res = known = new_ir_node (NULL, irg, block, op_Phi, mode, ins, in);
1215   res->attr.phi_backedge = new_backedge_arr(irg->obst, ins);
1216 #endif
1217   /* The in-array can contain NULLs.  These were returned by
1218      get_r_value_internal if it reached the same block/definition on a
1219      second path.
1220      The NULLs are replaced by the node itself to simplify the test in the
1221      next loop. */
1222   for (i=0;  i < ins;  ++i)
1223     if (in[i] == NULL) in[i] = res;
1224
1225   /* This loop checks whether the Phi has more than one predecessor.
1226      If so, it is a real Phi node and we break the loop.  Else the
1227      Phi node merges the same definition on several paths and therefore
1228      is not needed. */
1229   for (i=0;  i < ins;  ++i)
1230   {
1231     if (in[i]==res || in[i]==known) continue;
1232
1233     if (known==res)
1234       known = in[i];
1235     else
1236       break;
1237   }
1238
1239   /* i==ins: there is at most one predecessor, we don't need a phi node. */
1240   if (i==ins) {
1241 #if USE_EXPLICIT_PHI_IN_STACK
1242     free_to_Phi_in_stack(res);
1243 #else
1244     obstack_free (current_ir_graph->obst, res);
1245 #endif
1246     res = known;
1247   } else {
1248     res = optimize_node (res);
1249     irn_vrfy_irg (res, irg);
1250   }
1251
1252   /* return the pointer to the Phi node.  This node might be deallocated! */
1253   return res;
1254 }
1255
1256 static ir_node *
1257 get_r_value_internal (ir_node *block, int pos, ir_mode *mode);
1258
1259 /**
1260     allocates and returns this node.  The routine called to allocate the
1261     node might optimize it away and return a real value, or even a pointer
1262     to a deallocated Phi node on top of the obstack!
1263     This function is called with an in-array of proper size. **/
1264 static ir_node *
1265 phi_merge (ir_node *block, int pos, ir_mode *mode, ir_node **nin, int ins)
1266 {
1267   ir_node *prevBlock, *res;
1268   int i;
1269
1270   /* This loop goes to all predecessor blocks of the block the Phi node is in
1271      and there finds the operands of the Phi node by calling
1272      get_r_value_internal. */
1273   for (i = 1;  i <= ins;  ++i) {
1274     assert (block->in[i]);
1275     prevBlock = block->in[i]->in[0]; /* go past control flow op to prev block */
1276     assert (prevBlock);
1277     nin[i-1] = get_r_value_internal (prevBlock, pos, mode);
1278   }
1279
1280   /* After collecting all predecessors into the array nin a new Phi node
1281      with these predecessors is created.  This constructor contains an
1282      optimization: If all predecessors of the Phi node are identical it
1283      returns the only operand instead of a new Phi node.  If the value
1284      passes two different control flow edges without being defined, and
1285      this is the second path treated, a pointer to the node that will be
1286      allocated for the first path (recursion) is returned.  We already
1287      know the address of this node, as it is the next node to be allocated
1288      and will be placed on top of the obstack. (The obstack is a _stack_!) */
1289   res = new_rd_Phi_in (current_ir_graph, block, mode, nin, ins);
1290
1291   /* Now we now the value for "pos" and can enter it in the array with
1292      all known local variables.  Attention: this might be a pointer to
1293      a node, that later will be allocated!!! See new_rd_Phi_in.
1294      If this is called in mature, after some set_value in the same block,
1295      the proper value must not be overwritten:
1296      The call order
1297        get_value    (makes Phi0, put's it into graph_arr)
1298        set_value    (overwrites Phi0 in graph_arr)
1299        mature_block (upgrades Phi0, puts it again into graph_arr, overwriting
1300                      the proper value.)
1301      fails. */
1302   if (!block->attr.block.graph_arr[pos]) {
1303     block->attr.block.graph_arr[pos] = res;
1304   } else {
1305     /*  printf(" value already computed by %s\n",
1306         get_id_str(block->attr.block.graph_arr[pos]->op->name));  */
1307   }
1308
1309   return res;
1310 }
1311
1312 /* This function returns the last definition of a variable.  In case
1313    this variable was last defined in a previous block, Phi nodes are
1314    inserted.  If the part of the firm graph containing the definition
1315    is not yet constructed, a dummy Phi node is returned. */
1316 static ir_node *
1317 get_r_value_internal (ir_node *block, int pos, ir_mode *mode)
1318 {
1319   ir_node *res;
1320   /* There are 4 cases to treat.
1321
1322      1. The block is not mature and we visit it the first time.  We can not
1323         create a proper Phi node, therefore a Phi0, i.e., a Phi without
1324         predecessors is returned.  This node is added to the linked list (field
1325         "link") of the containing block to be completed when this block is
1326         matured. (Completion will add a new Phi and turn the Phi0 into an Id
1327         node.)
1328
1329      2. The value is already known in this block, graph_arr[pos] is set and we
1330         visit the block the first time.  We can return the value without
1331         creating any new nodes.
1332
1333      3. The block is mature and we visit it the first time.  A Phi node needs
1334         to be created (phi_merge).  If the Phi is not needed, as all it's
1335         operands are the same value reaching the block through different
1336         paths, it's optimized away and the value itself is returned.
1337
1338      4. The block is mature, and we visit it the second time.  Now two
1339         subcases are possible:
1340         * The value was computed completely the last time we were here. This
1341           is the case if there is no loop.  We can return the proper value.
1342         * The recursion that visited this node and set the flag did not
1343           return yet.  We are computing a value in a loop and need to
1344           break the recursion without knowing the result yet.
1345           @@@ strange case.  Straight forward we would create a Phi before
1346           starting the computation of it's predecessors.  In this case we will
1347           find a Phi here in any case.  The problem is that this implementation
1348           only creates a Phi after computing the predecessors, so that it is
1349           hard to compute self references of this Phi.  @@@
1350         There is no simple check for the second subcase.  Therefore we check
1351         for a second visit and treat all such cases as the second subcase.
1352         Anyways, the basic situation is the same:  we reached a block
1353         on two paths without finding a definition of the value:  No Phi
1354         nodes are needed on both paths.
1355         We return this information "Two paths, no Phi needed" by a very tricky
1356         implementation that relies on the fact that an obstack is a stack and
1357         will return a node with the same address on different allocations.
1358         Look also at phi_merge and new_rd_phi_in to understand this.
1359         @@@ Unfortunately this does not work, see testprogram
1360         three_cfpred_example.
1361
1362   */
1363
1364   /* case 4 -- already visited. */
1365   if (get_irn_visited(block) == get_irg_visited(current_ir_graph)) return NULL;
1366
1367   /* visited the first time */
1368   set_irn_visited(block, get_irg_visited(current_ir_graph));
1369
1370   /* Get the local valid value */
1371   res = block->attr.block.graph_arr[pos];
1372
1373   /* case 2 -- If the value is actually computed, return it. */
1374   if (res) { return res;};
1375
1376   if (block->attr.block.matured) { /* case 3 */
1377
1378     /* The Phi has the same amount of ins as the corresponding block. */
1379     int ins = get_irn_arity(block);
1380     ir_node **nin;
1381     NEW_ARR_A (ir_node *, nin, ins);
1382
1383     /* Phi merge collects the predecessors and then creates a node. */
1384     res = phi_merge (block, pos, mode, nin, ins);
1385
1386   } else {  /* case 1 */
1387     /* The block is not mature, we don't know how many in's are needed.  A Phi
1388        with zero predecessors is created.  Such a Phi node is called Phi0
1389        node.  (There is also an obsolete Phi0 opcode.) The Phi0 is then added
1390        to the list of Phi0 nodes in this block to be matured by mature_block
1391        later.
1392        The Phi0 has to remember the pos of it's internal value.  If the real
1393        Phi is computed, pos is used to update the array with the local
1394        values. */
1395
1396     res = new_rd_Phi0 (current_ir_graph, block, mode);
1397     res->attr.phi0_pos = pos;
1398     res->link = block->link;
1399     block->link = res;
1400   }
1401
1402   /* If we get here, the frontend missed a use-before-definition error */
1403   if (!res) {
1404     /* Error Message */
1405     printf("Error: no value set.  Use of undefined variable.  Initializing to zero.\n");
1406     assert (mode->code >= irm_F && mode->code <= irm_P);
1407     res = new_rd_Const (NULL, current_ir_graph, block, mode,
1408                        tarval_mode_null[mode->code]);
1409   }
1410
1411   /* The local valid value is available now. */
1412   block->attr.block.graph_arr[pos] = res;
1413
1414   return res;
1415 }
1416
1417 #else /* if 0 */
1418
1419 /**
1420     it starts the recursion.  This causes an Id at the entry of
1421     every block that has no definition of the value! **/
1422
1423 #if USE_EXPLICIT_PHI_IN_STACK
1424 /* Just dummies */
1425 INLINE Phi_in_stack * new_Phi_in_stack() {  return NULL; }
1426 INLINE void free_Phi_in_stack(Phi_in_stack *s) { }
1427 #endif
1428
1429 static INLINE ir_node *
1430 new_rd_Phi_in (ir_graph *irg, ir_node *block, ir_mode *mode,
1431               ir_node **in, int ins)
1432 {
1433   int i;
1434   ir_node *res, *known;
1435
1436   /* Allocate a new node on the obstack.  The allocation copies the in
1437      array. */
1438   res = new_ir_node (NULL, irg, block, op_Phi, mode, ins, in);
1439   res->attr.phi_backedge = new_backedge_arr(irg->obst, ins);
1440
1441   /* This loop checks whether the Phi has more than one predecessor.
1442      If so, it is a real Phi node and we break the loop.  Else the
1443      Phi node merges the same definition on several paths and therefore
1444      is not needed. Don't consider Bad nodes! */
1445   known = res;
1446   for (i=0;  i < ins;  ++i)
1447   {
1448         assert(in[i]);
1449
1450     if (in[i]==res || in[i]==known || is_Bad(in[i])) continue;
1451
1452     if (known==res)
1453       known = in[i];
1454     else
1455       break;
1456   }
1457
1458   /* i==ins: there is at most one predecessor, we don't need a phi node. */
1459   if (i==ins) {
1460     if (res != known) {
1461       obstack_free (current_ir_graph->obst, res);
1462       res = known;
1463     } else {
1464       /* A undefined value, e.g., in unreachable code. */
1465       res = new_Bad();
1466     }
1467   } else {
1468     res = optimize_node (res);
1469     irn_vrfy_irg (res, irg);
1470     /* Memory Phis in endless loops must be kept alive.
1471        As we can't distinguish these easily we keep all of the alive. */
1472     if ((res->op == op_Phi) && (mode == mode_M))
1473       add_End_keepalive(irg->end, res);
1474   }
1475
1476   return res;
1477 }
1478
1479 static ir_node *
1480 get_r_value_internal (ir_node *block, int pos, ir_mode *mode);
1481
1482 #if PRECISE_EXC_CONTEXT
1483 static ir_node *
1484 phi_merge (ir_node *block, int pos, ir_mode *mode, ir_node **nin, int ins);
1485
1486 static INLINE ir_node **
1487 new_frag_arr (ir_node *n) {
1488   ir_node **arr;
1489   int opt;
1490   arr = NEW_ARR_D (ir_node *, current_ir_graph->obst, current_ir_graph->n_loc);
1491   memcpy(arr, current_ir_graph->current_block->attr.block.graph_arr,
1492          sizeof(ir_node *)*current_ir_graph->n_loc);
1493   /* turn off optimization before allocating Proj nodes, as res isn't
1494      finished yet. */
1495   opt = get_optimize(); set_optimize(0);
1496   /* Here we rely on the fact that all frag ops have Memory as first result! */
1497   if (get_irn_op(n) == op_Call)
1498     arr[0] = new_Proj(n, mode_M, 3);
1499   else
1500     arr[0] = new_Proj(n, mode_M, 0);
1501   set_optimize(opt);
1502   current_ir_graph->current_block->attr.block.graph_arr[current_ir_graph->n_loc-1] = n;
1503   return arr;
1504 }
1505
1506 static INLINE ir_node **
1507 get_frag_arr (ir_node *n) {
1508   if (get_irn_op(n) == op_Call) {
1509     return n->attr.call.frag_arr;
1510   } else if (get_irn_op(n) == op_Alloc) {
1511     return n->attr.a.frag_arr;
1512   } else {
1513     return n->attr.frag_arr;
1514   }
1515 }
1516
1517 static void
1518 set_frag_value(ir_node **frag_arr, int pos, ir_node *val) {
1519   if (!frag_arr[pos]) frag_arr[pos] = val;
1520   if (frag_arr[current_ir_graph->n_loc - 1])
1521     set_frag_value (get_frag_arr(frag_arr[current_ir_graph->n_loc - 1]), pos, val);
1522 }
1523
1524 static ir_node *
1525 get_r_frag_value_internal (ir_node *block, ir_node *cfOp, int pos, ir_mode *mode) {
1526   ir_node *res;
1527   ir_node **frag_arr;
1528
1529   assert(is_fragile_op(cfOp) && (get_irn_op(cfOp) != op_Bad));
1530
1531   frag_arr = get_frag_arr(cfOp);
1532   res = frag_arr[pos];
1533   if (!res) {
1534     if (block->attr.block.graph_arr[pos]) {
1535       /* There was a set_value after the cfOp and no get_value before that
1536                  set_value.  We must build a Phi node now. */
1537       if (block->attr.block.matured) {
1538                 int ins = get_irn_arity(block);
1539                 ir_node **nin;
1540                 NEW_ARR_A (ir_node *, nin, ins);
1541                 res = phi_merge(block, pos, mode, nin, ins);
1542       } else {
1543                 res = new_rd_Phi0 (current_ir_graph, block, mode);
1544                 res->attr.phi0_pos = pos;
1545                 res->link = block->link;
1546                 block->link = res;
1547       }
1548       assert(res);
1549       /* @@@ tested by Flo: set_frag_value(frag_arr, pos, res);
1550                  but this should be better: (remove comment if this works) */
1551       /* It's a Phi, we can write this into all graph_arrs with NULL */
1552       set_frag_value(block->attr.block.graph_arr, pos, res);
1553     } else {
1554       res = get_r_value_internal(block, pos, mode);
1555       set_frag_value(block->attr.block.graph_arr, pos, res);
1556     }
1557   }
1558   return res;
1559 }
1560 #endif
1561
1562 /**
1563     computes the predecessors for the real phi node, and then
1564     allocates and returns this node.  The routine called to allocate the
1565     node might optimize it away and return a real value.
1566     This function must be called with an in-array of proper size. **/
1567 static ir_node *
1568 phi_merge (ir_node *block, int pos, ir_mode *mode, ir_node **nin, int ins)
1569 {
1570   ir_node *prevBlock, *prevCfOp, *res, *phi0;
1571   int i;
1572
1573   /* If this block has no value at pos create a Phi0 and remember it
1574      in graph_arr to break recursions.
1575      Else we may not set graph_arr as there a later value is remembered. */
1576   phi0 = NULL;
1577   if (!block->attr.block.graph_arr[pos]) {
1578     if (block == get_irg_start_block(current_ir_graph)) {
1579       /* Collapsing to Bad tarvals is no good idea.
1580          So we call a user-supplied routine here that deals with this case as
1581          appropriate for the given language. Sorryly the only help we can give
1582          here is the position.
1583
1584          Even if all variables are defined before use, it can happen that
1585          we get to the start block, if a cond has been replaced by a tuple
1586          (bad, jmp).  In this case we call the function needlessly, eventually
1587          generating an non existant error.
1588          However, this SHOULD NOT HAPPEN, as bad control flow nodes are intercepted
1589          before recuring.
1590       */
1591       if (default_initialize_local_variable)
1592         block->attr.block.graph_arr[pos] = default_initialize_local_variable(mode, pos);
1593       else
1594         block->attr.block.graph_arr[pos] = new_Const(mode, tarval_bad);
1595       /* We don't need to care about exception ops in the start block.
1596          There are none by definition. */
1597       return block->attr.block.graph_arr[pos];
1598     } else {
1599       phi0 = new_rd_Phi0(current_ir_graph, block, mode);
1600       block->attr.block.graph_arr[pos] = phi0;
1601 #if PRECISE_EXC_CONTEXT
1602       /* Set graph_arr for fragile ops.  Also here we should break recursion.
1603          We could choose a cyclic path through an cfop.  But the recursion would
1604          break at some point. */
1605       set_frag_value(block->attr.block.graph_arr, pos, phi0);
1606 #endif
1607     }
1608   }
1609
1610   /* This loop goes to all predecessor blocks of the block the Phi node
1611      is in and there finds the operands of the Phi node by calling
1612      get_r_value_internal.  */
1613   for (i = 1;  i <= ins;  ++i) {
1614     prevCfOp = skip_Proj(block->in[i]);
1615     assert (prevCfOp);
1616     if (is_Bad(prevCfOp)) {
1617       /* In case a Cond has been optimized we would get right to the start block
1618          with an invalid definition. */
1619       nin[i-1] = new_Bad();
1620       continue;
1621     }
1622     prevBlock = block->in[i]->in[0]; /* go past control flow op to prev block */
1623     assert (prevBlock);
1624     if (!is_Bad(prevBlock)) {
1625 #if PRECISE_EXC_CONTEXT
1626       if (is_fragile_op(prevCfOp) && (get_irn_op (prevCfOp) != op_Bad)) {
1627         assert(get_r_frag_value_internal (prevBlock, prevCfOp, pos, mode));
1628         nin[i-1] = get_r_frag_value_internal (prevBlock, prevCfOp, pos, mode);
1629       } else
1630 #endif
1631         nin[i-1] = get_r_value_internal (prevBlock, pos, mode);
1632     } else {
1633       nin[i-1] = new_Bad();
1634     }
1635   }
1636
1637   /* After collecting all predecessors into the array nin a new Phi node
1638      with these predecessors is created.  This constructor contains an
1639      optimization: If all predecessors of the Phi node are identical it
1640      returns the only operand instead of a new Phi node.  */
1641   res = new_rd_Phi_in (current_ir_graph, block, mode, nin, ins);
1642
1643   /* In case we allocated a Phi0 node at the beginning of this procedure,
1644      we need to exchange this Phi0 with the real Phi. */
1645   if (phi0) {
1646     exchange(phi0, res);
1647     block->attr.block.graph_arr[pos] = res;
1648     /* Don't set_frag_value as it does not overwrite.  Doesn't matter, is
1649        only an optimization. */
1650   }
1651
1652   return res;
1653 }
1654
1655 /* This function returns the last definition of a variable.  In case
1656    this variable was last defined in a previous block, Phi nodes are
1657    inserted.  If the part of the firm graph containing the definition
1658    is not yet constructed, a dummy Phi node is returned. */
1659 static ir_node *
1660 get_r_value_internal (ir_node *block, int pos, ir_mode *mode)
1661 {
1662   ir_node *res;
1663   /* There are 4 cases to treat.
1664
1665      1. The block is not mature and we visit it the first time.  We can not
1666         create a proper Phi node, therefore a Phi0, i.e., a Phi without
1667         predecessors is returned.  This node is added to the linked list (field
1668         "link") of the containing block to be completed when this block is
1669         matured. (Comlpletion will add a new Phi and turn the Phi0 into an Id
1670         node.)
1671
1672      2. The value is already known in this block, graph_arr[pos] is set and we
1673         visit the block the first time.  We can return the value without
1674         creating any new nodes.
1675
1676      3. The block is mature and we visit it the first time.  A Phi node needs
1677         to be created (phi_merge).  If the Phi is not needed, as all it's
1678         operands are the same value reaching the block through different
1679         paths, it's optimized away and the value itself is returned.
1680
1681      4. The block is mature, and we visit it the second time.  Now two
1682         subcases are possible:
1683         * The value was computed completely the last time we were here. This
1684           is the case if there is no loop.  We can return the proper value.
1685         * The recursion that visited this node and set the flag did not
1686           return yet.  We are computing a value in a loop and need to
1687           break the recursion.  This case only happens if we visited
1688           the same block with phi_merge before, which inserted a Phi0.
1689           So we return the Phi0.
1690   */
1691
1692   /* case 4 -- already visited. */
1693   if (get_irn_visited(block) == get_irg_visited(current_ir_graph)) {
1694     /* As phi_merge allocates a Phi0 this value is always defined. Here
1695      is the critical difference of the two algorithms. */
1696     assert(block->attr.block.graph_arr[pos]);
1697     return block->attr.block.graph_arr[pos];
1698   }
1699
1700   /* visited the first time */
1701   set_irn_visited(block, get_irg_visited(current_ir_graph));
1702
1703   /* Get the local valid value */
1704   res = block->attr.block.graph_arr[pos];
1705
1706   /* case 2 -- If the value is actually computed, return it. */
1707   if (res) { return res; };
1708
1709   if (block->attr.block.matured) { /* case 3 */
1710
1711     /* The Phi has the same amount of ins as the corresponding block. */
1712     int ins = get_irn_arity(block);
1713     ir_node **nin;
1714     NEW_ARR_A (ir_node *, nin, ins);
1715
1716     /* Phi merge collects the predecessors and then creates a node. */
1717     res = phi_merge (block, pos, mode, nin, ins);
1718
1719   } else {  /* case 1 */
1720     /* The block is not mature, we don't know how many in's are needed.  A Phi
1721        with zero predecessors is created.  Such a Phi node is called Phi0
1722        node.  The Phi0 is then added to the list of Phi0 nodes in this block
1723        to be matured by mature_block later.
1724        The Phi0 has to remember the pos of it's internal value.  If the real
1725        Phi is computed, pos is used to update the array with the local
1726        values. */
1727     res = new_rd_Phi0 (current_ir_graph, block, mode);
1728     res->attr.phi0_pos = pos;
1729     res->link = block->link;
1730     block->link = res;
1731   }
1732
1733   /* If we get here, the frontend missed a use-before-definition error */
1734   if (!res) {
1735     /* Error Message */
1736     printf("Error: no value set.  Use of undefined variable.  Initializing to zero.\n");
1737     assert (mode->code >= irm_F && mode->code <= irm_P);
1738     res = new_rd_Const (NULL, current_ir_graph, block, mode,
1739                        get_mode_null(mode));
1740   }
1741
1742   /* The local valid value is available now. */
1743   block->attr.block.graph_arr[pos] = res;
1744
1745   return res;
1746 }
1747
1748 #endif /* USE_FAST_PHI_CONSTRUCTION */
1749
1750 /* ************************************************************************** */
1751
1752 /** Finalize a Block node, when all control flows are known.  */
1753 /** Acceptable parameters are only Block nodes.               */
1754 void
1755 mature_block (ir_node *block)
1756 {
1757
1758   int ins;
1759   ir_node *n, **nin;
1760   ir_node *next;
1761
1762   assert (get_irn_opcode(block) == iro_Block);
1763   /* @@@ should be commented in
1764      assert (!get_Block_matured(block) && "Block already matured"); */
1765
1766   if (!get_Block_matured(block)) {
1767     ins = ARR_LEN (block->in)-1;
1768     /* Fix block parameters */
1769     block->attr.block.backedge = new_backedge_arr(current_ir_graph->obst, ins);
1770
1771     /* An array for building the Phi nodes. */
1772     NEW_ARR_A (ir_node *, nin, ins);
1773
1774     /* Traverse a chain of Phi nodes attached to this block and mature
1775        these, too. **/
1776     for (n = block->link;  n;  n=next) {
1777       inc_irg_visited(current_ir_graph);
1778       next = n->link;
1779       exchange (n, phi_merge (block, n->attr.phi0_pos, n->mode, nin, ins));
1780     }
1781
1782     block->attr.block.matured = 1;
1783
1784     /* Now, as the block is a finished firm node, we can optimize it.
1785        Since other nodes have been allocated since the block was created
1786        we can not free the node on the obstack.  Therefore we have to call
1787        optimize_in_place.
1788        Unfortunately the optimization does not change a lot, as all allocated
1789        nodes refer to the unoptimized node.
1790        We can call _2, as global cse has no effect on blocks. */
1791     block = optimize_in_place_2(block);
1792     irn_vrfy_irg(block, current_ir_graph);
1793   }
1794 }
1795
1796 ir_node *
1797 new_d_Phi (dbg_info* db, int arity, ir_node **in, ir_mode *mode)
1798 {
1799   return new_rd_Phi (db, current_ir_graph, current_ir_graph->current_block,
1800                     arity, in, mode);
1801 }
1802
1803 ir_node *
1804 new_d_Const (dbg_info* db, ir_mode *mode, tarval *con)
1805 {
1806   return new_rd_Const (db, current_ir_graph, current_ir_graph->start_block,
1807                       mode, con);
1808 }
1809
1810 ir_node *
1811 new_d_Const_type (dbg_info* db, ir_mode *mode, tarval *con, type *tp)
1812 {
1813   return new_rd_Const_type (db, current_ir_graph, current_ir_graph->start_block,
1814                             mode, con, tp);
1815 }
1816
1817
1818 ir_node *
1819 new_d_Id (dbg_info* db, ir_node *val, ir_mode *mode)
1820 {
1821   return new_rd_Id (db, current_ir_graph, current_ir_graph->current_block,
1822                    val, mode);
1823 }
1824
1825 ir_node *
1826 new_d_Proj (dbg_info* db, ir_node *arg, ir_mode *mode, long proj)
1827 {
1828   return new_rd_Proj (db, current_ir_graph, current_ir_graph->current_block,
1829                      arg, mode, proj);
1830 }
1831
1832 ir_node *
1833 new_d_defaultProj (dbg_info* db, ir_node *arg, long max_proj)
1834 {
1835   ir_node *res;
1836   assert((arg->op==op_Cond) && (get_irn_mode(arg->in[1]) == mode_Iu));
1837   arg->attr.c.kind = fragmentary;
1838   arg->attr.c.default_proj = max_proj;
1839   res = new_Proj (arg, mode_X, max_proj);
1840   return res;
1841 }
1842
1843 ir_node *
1844 new_d_Conv (dbg_info* db, ir_node *op, ir_mode *mode)
1845 {
1846   return new_rd_Conv (db, current_ir_graph, current_ir_graph->current_block,
1847                      op, mode);
1848 }
1849
1850 ir_node *
1851 new_d_Cast (dbg_info* db, ir_node *op, type *to_tp)
1852 {
1853   return new_rd_Cast (db, current_ir_graph, current_ir_graph->current_block, op, to_tp);
1854 }
1855
1856 ir_node *
1857 new_d_Tuple (dbg_info* db, int arity, ir_node **in)
1858 {
1859   return new_rd_Tuple (db, current_ir_graph, current_ir_graph->current_block,
1860                       arity, in);
1861 }
1862
1863 ir_node *
1864 new_d_Add (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode)
1865 {
1866   return new_rd_Add (db, current_ir_graph, current_ir_graph->current_block,
1867                     op1, op2, mode);
1868 }
1869
1870 ir_node *
1871 new_d_Sub (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode)
1872 {
1873   return new_rd_Sub (db, current_ir_graph, current_ir_graph->current_block,
1874                     op1, op2, mode);
1875 }
1876
1877
1878 ir_node *
1879 new_d_Minus  (dbg_info* db, ir_node *op,  ir_mode *mode)
1880 {
1881   return new_rd_Minus (db, current_ir_graph, current_ir_graph->current_block,
1882                       op, mode);
1883 }
1884
1885 ir_node *
1886 new_d_Mul (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode)
1887 {
1888   return new_rd_Mul (db, current_ir_graph, current_ir_graph->current_block,
1889                     op1, op2, mode);
1890 }
1891
1892 ir_node *
1893 new_d_Quot (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2)
1894 {
1895   ir_node *res;
1896   res = new_rd_Quot (db, current_ir_graph, current_ir_graph->current_block,
1897                      memop, op1, op2);
1898 #if PRECISE_EXC_CONTEXT
1899   if ((current_ir_graph->phase_state == phase_building) &&
1900       (get_irn_op(res) == op_Quot))  /* Could be optimized away. */
1901     res->attr.frag_arr = new_frag_arr(res);
1902 #endif
1903
1904   return res;
1905 }
1906
1907 ir_node *
1908 new_d_DivMod (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2)
1909 {
1910   ir_node *res;
1911   res = new_rd_DivMod (db, current_ir_graph, current_ir_graph->current_block,
1912                        memop, op1, op2);
1913 #if PRECISE_EXC_CONTEXT
1914   if ((current_ir_graph->phase_state == phase_building) &&
1915       (get_irn_op(res) == op_DivMod))   /* Could be optimized away. */
1916     res->attr.frag_arr = new_frag_arr(res);
1917 #endif
1918
1919   return res;
1920 }
1921
1922 ir_node *
1923 new_d_Div (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2)
1924 {
1925   ir_node *res;
1926   res = new_rd_Div (db, current_ir_graph, current_ir_graph->current_block,
1927                     memop, op1, op2);
1928 #if PRECISE_EXC_CONTEXT
1929   if ((current_ir_graph->phase_state == phase_building) &&
1930       (get_irn_op(res) == op_Div))  /* Could be optimized away. */
1931     res->attr.frag_arr = new_frag_arr(res);
1932 #endif
1933
1934   return res;
1935 }
1936
1937 ir_node *
1938 new_d_Mod (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2)
1939 {
1940   ir_node *res;
1941   res = new_rd_Mod (db, current_ir_graph, current_ir_graph->current_block,
1942                     memop, op1, op2);
1943 #if PRECISE_EXC_CONTEXT
1944   if ((current_ir_graph->phase_state == phase_building) &&
1945       (get_irn_op(res) == op_Mod))  /* Could be optimized away. */
1946     res->attr.frag_arr = new_frag_arr(res);
1947 #endif
1948
1949   return res;
1950 }
1951
1952 ir_node *
1953 new_d_And (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode)
1954 {
1955   return new_rd_And (db, current_ir_graph, current_ir_graph->current_block,
1956                     op1, op2, mode);
1957 }
1958
1959 ir_node *
1960 new_d_Or (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode)
1961 {
1962   return new_rd_Or (db, current_ir_graph, current_ir_graph->current_block,
1963                    op1, op2, mode);
1964 }
1965
1966 ir_node *
1967 new_d_Eor (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode)
1968 {
1969   return new_rd_Eor (db, current_ir_graph, current_ir_graph->current_block,
1970                     op1, op2, mode);
1971 }
1972
1973 ir_node *
1974 new_d_Not (dbg_info* db, ir_node *op, ir_mode *mode)
1975 {
1976   return new_rd_Not (db, current_ir_graph, current_ir_graph->current_block,
1977                     op, mode);
1978 }
1979
1980 ir_node *
1981 new_d_Shl (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode)
1982 {
1983   return new_rd_Shl (db, current_ir_graph, current_ir_graph->current_block,
1984                     op, k, mode);
1985 }
1986
1987 ir_node *
1988 new_d_Shr (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode)
1989 {
1990   return new_rd_Shr (db, current_ir_graph, current_ir_graph->current_block,
1991                     op, k, mode);
1992 }
1993
1994 ir_node *
1995 new_d_Shrs (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode)
1996 {
1997   return new_rd_Shrs (db, current_ir_graph, current_ir_graph->current_block,
1998                      op, k, mode);
1999 }
2000
2001 ir_node *
2002 new_d_Rot (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode)
2003 {
2004   return new_rd_Rot (db, current_ir_graph, current_ir_graph->current_block,
2005                      op, k, mode);
2006 }
2007
2008 ir_node *
2009 new_d_Abs (dbg_info* db, ir_node *op, ir_mode *mode)
2010 {
2011   return new_rd_Abs (db, current_ir_graph, current_ir_graph->current_block,
2012                     op, mode);
2013 }
2014
2015 ir_node *
2016 new_d_Cmp (dbg_info* db, ir_node *op1, ir_node *op2)
2017 {
2018   return new_rd_Cmp (db, current_ir_graph, current_ir_graph->current_block,
2019                     op1, op2);
2020 }
2021
2022 ir_node *
2023 new_d_Jmp (dbg_info* db)
2024 {
2025   return new_rd_Jmp (db, current_ir_graph, current_ir_graph->current_block);
2026 }
2027
2028 ir_node *
2029 new_d_Cond (dbg_info* db, ir_node *c)
2030 {
2031   return new_rd_Cond (db, current_ir_graph, current_ir_graph->current_block, c);
2032 }
2033
2034 ir_node *
2035 new_d_Call (dbg_info* db, ir_node *store, ir_node *callee, int arity, ir_node **in,
2036           type *tp)
2037 {
2038   ir_node *res;
2039   res = new_rd_Call (db, current_ir_graph, current_ir_graph->current_block,
2040                      store, callee, arity, in, tp);
2041 #if PRECISE_EXC_CONTEXT
2042   if ((current_ir_graph->phase_state == phase_building) &&
2043       (get_irn_op(res) == op_Call))  /* Could be optimized away. */
2044     res->attr.call.frag_arr = new_frag_arr(res);
2045 #endif
2046
2047   return res;
2048 }
2049
2050 ir_node *
2051 new_d_Return (dbg_info* db, ir_node* store, int arity, ir_node **in)
2052 {
2053   return new_rd_Return (db, current_ir_graph, current_ir_graph->current_block,
2054                        store, arity, in);
2055 }
2056
2057 ir_node *
2058 new_d_Raise (dbg_info* db, ir_node *store, ir_node *obj)
2059 {
2060   return new_rd_Raise (db, current_ir_graph, current_ir_graph->current_block,
2061                       store, obj);
2062 }
2063
2064 ir_node *
2065 new_d_Load (dbg_info* db, ir_node *store, ir_node *addr)
2066 {
2067   ir_node *res;
2068   res = new_rd_Load (db, current_ir_graph, current_ir_graph->current_block,
2069                      store, addr);
2070 #if PRECISE_EXC_CONTEXT
2071   if ((current_ir_graph->phase_state == phase_building) &&
2072       (get_irn_op(res) == op_Load))  /* Could be optimized away. */
2073     res->attr.frag_arr = new_frag_arr(res);
2074 #endif
2075
2076   return res;
2077 }
2078
2079 ir_node *
2080 new_d_Store (dbg_info* db, ir_node *store, ir_node *addr, ir_node *val)
2081 {
2082   ir_node *res;
2083   res = new_rd_Store (db, current_ir_graph, current_ir_graph->current_block,
2084                       store, addr, val);
2085 #if PRECISE_EXC_CONTEXT
2086   if ((current_ir_graph->phase_state == phase_building) &&
2087       (get_irn_op(res) == op_Store))  /* Could be optimized away. */
2088     res->attr.frag_arr = new_frag_arr(res);
2089 #endif
2090
2091   return res;
2092 }
2093
2094 ir_node *
2095 new_d_Alloc (dbg_info* db, ir_node *store, ir_node *size, type *alloc_type,
2096            where_alloc where)
2097 {
2098   ir_node *res;
2099   res = new_rd_Alloc (db, current_ir_graph, current_ir_graph->current_block,
2100                       store, size, alloc_type, where);
2101 #if PRECISE_EXC_CONTEXT
2102   if ((current_ir_graph->phase_state == phase_building) &&
2103       (get_irn_op(res) == op_Alloc))  /* Could be optimized away. */
2104     res->attr.a.frag_arr = new_frag_arr(res);
2105 #endif
2106
2107   return res;
2108 }
2109
2110 ir_node *
2111 new_d_Free (dbg_info* db, ir_node *store, ir_node *ptr, ir_node *size, type *free_type)
2112 {
2113   return new_rd_Free (db, current_ir_graph, current_ir_graph->current_block,
2114                      store, ptr, size, free_type);
2115 }
2116
2117 ir_node *
2118 new_d_simpleSel (dbg_info* db, ir_node *store, ir_node *objptr, entity *ent)
2119 /* GL: objptr was called frame before.  Frame was a bad choice for the name
2120    as the operand could as well be a pointer to a dynamic object. */
2121 {
2122   return new_rd_Sel (db, current_ir_graph, current_ir_graph->current_block,
2123                     store, objptr, 0, NULL, ent);
2124 }
2125
2126 ir_node *
2127 new_d_Sel (dbg_info* db, ir_node *store, ir_node *objptr, int n_index, ir_node **index, entity *sel)
2128 {
2129   return new_rd_Sel (db, current_ir_graph, current_ir_graph->current_block,
2130                     store, objptr, n_index, index, sel);
2131 }
2132
2133 ir_node *
2134 new_d_InstOf (dbg_info *db, ir_node *store, ir_node *objptr, type *ent)
2135 {
2136   return (new_rd_InstOf (db, current_ir_graph, current_ir_graph->current_block,
2137                                                  store, objptr, ent));
2138 }
2139
2140 ir_node *
2141 new_d_SymConst (dbg_info* db, type_or_id_p value, symconst_kind kind)
2142 {
2143   return new_rd_SymConst (db, current_ir_graph, current_ir_graph->start_block,
2144                          value, kind);
2145 }
2146
2147 ir_node *
2148 new_d_Sync (dbg_info* db, int arity, ir_node** in)
2149 {
2150   return new_rd_Sync (db, current_ir_graph, current_ir_graph->current_block,
2151                       arity, in);
2152 }
2153
2154
2155 ir_node *
2156 new_d_Bad (void)
2157 {
2158   return current_ir_graph->bad;
2159 }
2160
2161 ir_node *
2162 new_d_Confirm (dbg_info *db, ir_node *val, ir_node *bound, pn_Cmp cmp)
2163 {
2164   return new_rd_Confirm (db, current_ir_graph, current_ir_graph->current_block,
2165                          val, bound, cmp);
2166 }
2167
2168 ir_node *
2169 new_d_Unknown (void)
2170 {
2171   return current_ir_graph->unknown;
2172 }
2173
2174 ir_node *
2175 new_d_CallBegin (dbg_info *db, ir_node *call)
2176 {
2177   ir_node *res;
2178   res = new_rd_CallBegin (db, current_ir_graph, current_ir_graph->current_block, call);
2179   return res;
2180 }
2181
2182 ir_node *
2183 new_d_EndReg (dbg_info *db)
2184 {
2185   ir_node *res;
2186   res = new_rd_EndReg(db, current_ir_graph, current_ir_graph->current_block);
2187   return res;
2188 }
2189
2190 ir_node *
2191 new_d_EndExcept (dbg_info *db)
2192 {
2193   ir_node *res;
2194   res = new_rd_EndExcept(db, current_ir_graph, current_ir_graph->current_block);
2195   return res;
2196 }
2197
2198 ir_node *
2199 new_d_Break (dbg_info *db)
2200 {
2201   return new_rd_Break (db, current_ir_graph, current_ir_graph->current_block);
2202 }
2203
2204 ir_node *
2205 new_d_Filter (dbg_info *db, ir_node *arg, ir_mode *mode, long proj)
2206 {
2207   return new_rd_Filter (db, current_ir_graph, current_ir_graph->current_block,
2208                         arg, mode, proj);
2209 }
2210
2211 /* ********************************************************************* */
2212 /* Comfortable interface with automatic Phi node construction.           */
2213 /* (Uses also constructors of ?? interface, except new_Block.            */
2214 /* ********************************************************************* */
2215
2216 /** Block construction **/
2217 /* immature Block without predecessors */
2218 ir_node *new_d_immBlock (dbg_info* db) {
2219   ir_node *res;
2220
2221   assert(get_irg_phase_state (current_ir_graph) == phase_building);
2222   /* creates a new dynamic in-array as length of in is -1 */
2223   res = new_ir_node (db, current_ir_graph, NULL, op_Block, mode_BB, -1, NULL);
2224   current_ir_graph->current_block = res;
2225   res->attr.block.matured = 0;
2226   //res->attr.block.exc = exc_normal;
2227   //res->attr.block.handler_entry = 0;
2228   res->attr.block.irg = current_ir_graph;
2229   res->attr.block.backedge = NULL;
2230   res->attr.block.in_cg = NULL;
2231   res->attr.block.cg_backedge = NULL;
2232   set_Block_block_visited(res, 0);
2233
2234   /* Create and initialize array for Phi-node construction. */
2235   res->attr.block.graph_arr = NEW_ARR_D (ir_node *, current_ir_graph->obst,
2236                                          current_ir_graph->n_loc);
2237   memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->n_loc);
2238
2239   /* Immature block may not be optimized! */
2240   irn_vrfy_irg (res, current_ir_graph);
2241
2242   return res;
2243 }
2244
2245 INLINE ir_node *
2246 new_immBlock () {
2247   return new_d_immBlock(NULL);
2248 }
2249
2250 /* add an adge to a jmp/control flow node */
2251 void
2252 add_in_edge (ir_node *block, ir_node *jmp)
2253 {
2254   if (block->attr.block.matured) {
2255     assert(0 && "Error: Block already matured!\n");
2256   }
2257   else {
2258     assert (jmp != NULL);
2259     ARR_APP1 (ir_node *, block->in, jmp);
2260   }
2261 }
2262
2263 /* changing the current block */
2264 void
2265 switch_block (ir_node *target)
2266 {
2267   current_ir_graph->current_block = target;
2268 }
2269
2270 /* ************************ */
2271 /* parameter administration */
2272
2273 /* get a value from the parameter array from the current block by its index */
2274 ir_node *
2275 get_d_value (dbg_info* db, int pos, ir_mode *mode)
2276 {
2277   assert(get_irg_phase_state (current_ir_graph) == phase_building);
2278   inc_irg_visited(current_ir_graph);
2279
2280   return get_r_value_internal (current_ir_graph->current_block, pos + 1, mode);
2281 }
2282 /* get a value from the parameter array from the current block by its index */
2283 INLINE ir_node *
2284 get_value (int pos, ir_mode *mode)
2285 {
2286   return get_d_value(NULL, pos, mode);
2287 }
2288
2289 /* set a value at position pos in the parameter array from the current block */
2290 INLINE void
2291 set_value (int pos, ir_node *value)
2292 {
2293   assert(get_irg_phase_state (current_ir_graph) == phase_building);
2294   assert(pos+1 < current_ir_graph->n_loc);
2295   current_ir_graph->current_block->attr.block.graph_arr[pos + 1] = value;
2296 }
2297
2298 /* get the current store */
2299 INLINE ir_node *
2300 get_store (void)
2301 {
2302   assert(get_irg_phase_state (current_ir_graph) == phase_building);
2303   /* GL: one could call get_value instead */
2304   inc_irg_visited(current_ir_graph);
2305   return get_r_value_internal (current_ir_graph->current_block, 0, mode_M);
2306 }
2307
2308 /* set the current store */
2309 INLINE void
2310 set_store (ir_node *store)
2311 {
2312   /* GL: one could call set_value instead */
2313   assert(get_irg_phase_state (current_ir_graph) == phase_building);
2314   current_ir_graph->current_block->attr.block.graph_arr[0] = store;
2315 }
2316
2317 void
2318 keep_alive (ir_node *ka)
2319 {
2320   add_End_keepalive(current_ir_graph->end, ka);
2321 }
2322
2323 /** Useful access routines **/
2324 /* Returns the current block of the current graph.  To set the current
2325    block use switch_block(). */
2326 ir_node *get_cur_block() {
2327   return get_irg_current_block(current_ir_graph);
2328 }
2329
2330 /* Returns the frame type of the current graph */
2331 type *get_cur_frame_type() {
2332   return get_irg_frame_type(current_ir_graph);
2333 }
2334
2335
2336 /* ********************************************************************* */
2337 /* initialize */
2338
2339 /* call once for each run of the library */
2340 void
2341 init_cons (default_initialize_local_variable_func_t *func)
2342 {
2343   default_initialize_local_variable = func;
2344 }
2345
2346 /* call for each graph */
2347 void
2348 finalize_cons (ir_graph *irg) {
2349   irg->phase_state = phase_high;
2350 }
2351
2352
2353 ir_node *new_Block(int arity, ir_node **in) {
2354   return new_d_Block(NULL, arity, in);
2355 }
2356 ir_node *new_Start  (void) {
2357   return new_d_Start(NULL);
2358 }
2359 ir_node *new_End    (void) {
2360   return new_d_End(NULL);
2361 }
2362 ir_node *new_Jmp    (void) {
2363   return new_d_Jmp(NULL);
2364 }
2365 ir_node *new_Cond   (ir_node *c) {
2366   return new_d_Cond(NULL, c);
2367 }
2368 ir_node *new_Return (ir_node *store, int arity, ir_node *in[]) {
2369   return new_d_Return(NULL, store, arity, in);
2370 }
2371 ir_node *new_Raise  (ir_node *store, ir_node *obj) {
2372   return new_d_Raise(NULL, store, obj);
2373 }
2374 ir_node *new_Const  (ir_mode *mode, tarval *con) {
2375   return new_d_Const(NULL, mode, con);
2376 }
2377 ir_node *new_SymConst (type_or_id_p value, symconst_kind kind) {
2378   return new_d_SymConst(NULL, value, kind);
2379 }
2380 ir_node *new_simpleSel(ir_node *store, ir_node *objptr, entity *ent) {
2381   return new_d_simpleSel(NULL, store, objptr, ent);
2382 }
2383 ir_node *new_Sel    (ir_node *store, ir_node *objptr, int arity, ir_node **in,
2384                      entity *ent) {
2385   return new_d_Sel(NULL, store, objptr, arity, in, ent);
2386 }
2387 ir_node *new_InstOf (ir_node *store, ir_node *objptr, type *ent) {
2388   return new_d_InstOf (NULL, store, objptr, ent);
2389 }
2390 ir_node *new_Call   (ir_node *store, ir_node *callee, int arity, ir_node **in,
2391                      type *tp) {
2392   return new_d_Call(NULL, store, callee, arity, in, tp);
2393 }
2394 ir_node *new_Add    (ir_node *op1, ir_node *op2, ir_mode *mode) {
2395   return new_d_Add(NULL, op1, op2, mode);
2396 }
2397 ir_node *new_Sub    (ir_node *op1, ir_node *op2, ir_mode *mode) {
2398   return new_d_Sub(NULL, op1, op2, mode);
2399 }
2400 ir_node *new_Minus  (ir_node *op,  ir_mode *mode) {
2401   return new_d_Minus(NULL, op, mode);
2402 }
2403 ir_node *new_Mul    (ir_node *op1, ir_node *op2, ir_mode *mode) {
2404   return new_d_Mul(NULL, op1, op2, mode);
2405 }
2406 ir_node *new_Quot   (ir_node *memop, ir_node *op1, ir_node *op2) {
2407   return new_d_Quot(NULL, memop, op1, op2);
2408 }
2409 ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2) {
2410   return new_d_DivMod(NULL, memop, op1, op2);
2411 }
2412 ir_node *new_Div    (ir_node *memop, ir_node *op1, ir_node *op2) {
2413   return new_d_Div(NULL, memop, op1, op2);
2414 }
2415 ir_node *new_Mod    (ir_node *memop, ir_node *op1, ir_node *op2) {
2416   return new_d_Mod(NULL, memop, op1, op2);
2417 }
2418 ir_node *new_Abs    (ir_node *op, ir_mode *mode) {
2419   return new_d_Abs(NULL, op, mode);
2420 }
2421 ir_node *new_And    (ir_node *op1, ir_node *op2, ir_mode *mode) {
2422   return new_d_And(NULL, op1, op2, mode);
2423 }
2424 ir_node *new_Or     (ir_node *op1, ir_node *op2, ir_mode *mode) {
2425   return new_d_Or(NULL, op1, op2, mode);
2426 }
2427 ir_node *new_Eor    (ir_node *op1, ir_node *op2, ir_mode *mode) {
2428   return new_d_Eor(NULL, op1, op2, mode);
2429 }
2430 ir_node *new_Not    (ir_node *op,                ir_mode *mode) {
2431   return new_d_Not(NULL, op, mode);
2432 }
2433 ir_node *new_Shl    (ir_node *op,  ir_node *k,   ir_mode *mode) {
2434   return new_d_Shl(NULL, op, k, mode);
2435 }
2436 ir_node *new_Shr    (ir_node *op,  ir_node *k,   ir_mode *mode) {
2437   return new_d_Shr(NULL, op, k, mode);
2438 }
2439 ir_node *new_Shrs   (ir_node *op,  ir_node *k,   ir_mode *mode) {
2440   return new_d_Shrs(NULL, op, k, mode);
2441 }
2442 #define new_Rotate new_Rot
2443 ir_node *new_Rot    (ir_node *op,  ir_node *k,   ir_mode *mode) {
2444   return new_d_Rot(NULL, op, k, mode);
2445 }
2446 ir_node *new_Cmp    (ir_node *op1, ir_node *op2) {
2447   return new_d_Cmp(NULL, op1, op2);
2448 }
2449 ir_node *new_Conv   (ir_node *op, ir_mode *mode) {
2450   return new_d_Conv(NULL, op, mode);
2451 }
2452 ir_node *new_Cast   (ir_node *op, type *to_tp) {
2453   return new_d_Cast(NULL, op, to_tp);
2454 }
2455 ir_node *new_Phi    (int arity, ir_node **in, ir_mode *mode) {
2456   return new_d_Phi(NULL, arity, in, mode);
2457 }
2458 ir_node *new_Load   (ir_node *store, ir_node *addr) {
2459   return new_d_Load(NULL, store, addr);
2460 }
2461 ir_node *new_Store  (ir_node *store, ir_node *addr, ir_node *val) {
2462   return new_d_Store(NULL, store, addr, val);
2463 }
2464 ir_node *new_Alloc  (ir_node *store, ir_node *size, type *alloc_type,
2465                      where_alloc where) {
2466   return new_d_Alloc(NULL, store, size, alloc_type, where);
2467 }
2468 ir_node *new_Free   (ir_node *store, ir_node *ptr, ir_node *size,
2469                      type *free_type) {
2470   return new_d_Free(NULL, store, ptr, size, free_type);
2471 }
2472 ir_node *new_Sync   (int arity, ir_node **in) {
2473   return new_d_Sync(NULL, arity, in);
2474 }
2475 ir_node *new_Proj   (ir_node *arg, ir_mode *mode, long proj) {
2476   return new_d_Proj(NULL, arg, mode, proj);
2477 }
2478 ir_node *new_defaultProj (ir_node *arg, long max_proj) {
2479   return new_d_defaultProj(NULL, arg, max_proj);
2480 }
2481 ir_node *new_Tuple  (int arity, ir_node **in) {
2482   return new_d_Tuple(NULL, arity, in);
2483 }
2484 ir_node *new_Id     (ir_node *val, ir_mode *mode) {
2485   return new_d_Id(NULL, val, mode);
2486 }
2487 ir_node *new_Bad    (void) {
2488   return new_d_Bad();
2489 }
2490 ir_node *new_Confirm (ir_node *val, ir_node *bound, pn_Cmp cmp) {
2491   return new_d_Confirm (NULL, val, bound, cmp);
2492 }
2493 ir_node *new_Unknown(void) {
2494   return new_d_Unknown();
2495 }
2496 ir_node *new_CallBegin (ir_node *callee) {
2497   return new_d_CallBegin(NULL, callee);
2498 }
2499 ir_node *new_EndReg (void) {
2500   return new_d_EndReg(NULL);
2501 }
2502 ir_node *new_EndExcept (void) {
2503   return new_d_EndExcept(NULL);
2504 }
2505 ir_node *new_Break  (void) {
2506   return new_d_Break(NULL);
2507 }
2508 ir_node *new_Filter (ir_node *arg, ir_mode *mode, long proj) {
2509   return new_d_Filter(NULL, arg, mode, proj);
2510 }