ircons.c 94.5 KB
Newer Older
Christian Würdig's avatar
Christian Würdig committed
1
/*
Michael Beck's avatar
Michael Beck committed
2
 * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
Christian Würdig's avatar
Christian Würdig committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 *
 * This file is part of libFirm.
 *
 * This file may be distributed and/or modified under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation and appearing in the file LICENSE.GPL included in the
 * packaging of this file.
 *
 * Licensees holding valid libFirm Professional Edition licenses may use
 * this file in accordance with the libFirm Commercial License.
 * Agreement provided with the Software.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE.
 */

Matthias Braun's avatar
Matthias Braun committed
20
21
22
23
24
25
26
/**
 * @file
 * @brief   Various irnode constructors. Automatic construction of SSA
 *          representation.
 * @author  Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Boris Boesler
            Michael Beck
 * @version $Id$
Götz Lindenmaier's avatar
Götz Lindenmaier committed
27
 */
Matthias Braun's avatar
Matthias Braun committed
28
#include "config.h"
Michael Beck's avatar
Michael Beck committed
29

30
31
32
33
34
35
36
37
38
39
#include "irprog_t.h"
#include "irgraph_t.h"
#include "irnode_t.h"
#include "irmode_t.h"
#include "ircons_t.h"
#include "firm_common_t.h"
#include "irvrfy.h"
#include "irop_t.h"
#include "iropt_t.h"
#include "irgmod.h"
40
#include "irhooks.h"
41
#include "array_t.h"
42
43
44
45
#include "irbackedge_t.h"
#include "irflag_t.h"
#include "iredges_t.h"
#include "irflag_t.h"
46

47
48
49
50
51
/* when we need verifying */
#ifdef NDEBUG
# define IRN_VRFY_IRG(res, irg)
#else
# define IRN_VRFY_IRG(res, irg)  irn_vrfy_irg(res, irg)
Michael Beck's avatar
Michael Beck committed
52
#endif /* NDEBUG */
53

Michael Beck's avatar
Michael Beck committed
54
55
/**
 * Language dependent variable initialization callback.
56
 */
57
static uninitialized_local_variable_func_t *default_initialize_local_variable = NULL;
58

59
/* creates a bd constructor for a binop */
60
#define NEW_BD_BINOP(instr)                                     \
61
static ir_node *                                                \
Michael Beck's avatar
Michael Beck committed
62
new_bd_##instr(dbg_info *db, ir_node *block,                    \
63
64
65
66
67
68
69
70
71
72
73
74
75
76
       ir_node *op1, ir_node *op2, ir_mode *mode)               \
{                                                               \
  ir_node  *in[2];                                              \
  ir_node  *res;                                                \
  ir_graph *irg = current_ir_graph;                             \
  in[0] = op1;                                                  \
  in[1] = op2;                                                  \
  res = new_ir_node(db, irg, block, op_##instr, mode, 2, in);   \
  res = optimize_node(res);                                     \
  IRN_VRFY_IRG(res, irg);                                       \
  return res;                                                   \
}

/* creates a bd constructor for an unop */
77
#define NEW_BD_UNOP(instr)                                      \
78
static ir_node *                                                \
Michael Beck's avatar
Michael Beck committed
79
new_bd_##instr(dbg_info *db, ir_node *block,                    \
80
81
82
83
84
85
86
87
88
89
90
              ir_node *op, ir_mode *mode)                       \
{                                                               \
  ir_node  *res;                                                \
  ir_graph *irg = current_ir_graph;                             \
  res = new_ir_node(db, irg, block, op_##instr, mode, 1, &op);  \
  res = optimize_node(res);                                     \
  IRN_VRFY_IRG(res, irg);                                       \
  return res;                                                   \
}

/* creates a bd constructor for an divop */
91
#define NEW_BD_DIVOP(instr)                                     \
92
static ir_node *                                                \
Michael Beck's avatar
Michael Beck committed
93
new_bd_##instr(dbg_info *db, ir_node *block,                    \
94
            ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state) \
95
96
97
98
99
100
101
102
{                                                               \
  ir_node  *in[3];                                              \
  ir_node  *res;                                                \
  ir_graph *irg = current_ir_graph;                             \
  in[0] = memop;                                                \
  in[1] = op1;                                                  \
  in[2] = op2;                                                  \
  res = new_ir_node(db, irg, block, op_##instr, mode_T, 3, in); \
103
  res->attr.divmod.exc.pin_state = state;                       \
104
  res->attr.divmod.res_mode = mode;                             \
105
  res->attr.divmod.no_remainder = 0;                            \
106
107
108
109
110
111
112
113
  res = optimize_node(res);                                     \
  IRN_VRFY_IRG(res, irg);                                       \
  return res;                                                   \
}

/* creates a rd constructor for a binop */
#define NEW_RD_BINOP(instr)                                     \
ir_node *                                                       \
Michael Beck's avatar
Michael Beck committed
114
new_rd_##instr(dbg_info *db, ir_graph *irg, ir_node *block,     \
115
116
117
118
119
120
121
122
123
124
125
126
127
       ir_node *op1, ir_node *op2, ir_mode *mode)               \
{                                                               \
  ir_node  *res;                                                \
  ir_graph *rem = current_ir_graph;                             \
  current_ir_graph = irg;                                       \
  res = new_bd_##instr(db, block, op1, op2, mode);              \
  current_ir_graph = rem;                                       \
  return res;                                                   \
}

/* creates a rd constructor for an unop */
#define NEW_RD_UNOP(instr)                                      \
ir_node *                                                       \
Michael Beck's avatar
Michael Beck committed
128
new_rd_##instr(dbg_info *db, ir_graph *irg, ir_node *block,     \
129
130
131
132
133
134
135
136
137
138
139
140
141
              ir_node *op, ir_mode *mode)                       \
{                                                               \
  ir_node  *res;                                                \
  ir_graph *rem = current_ir_graph;                             \
  current_ir_graph = irg;                                       \
  res = new_bd_##instr(db, block, op, mode);                    \
  current_ir_graph = rem;                                       \
  return res;                                                   \
}

/* creates a rd constructor for an divop */
#define NEW_RD_DIVOP(instr)                                     \
ir_node *                                                       \
Michael Beck's avatar
Michael Beck committed
142
new_rd_##instr(dbg_info *db, ir_graph *irg, ir_node *block,     \
143
            ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state) \
144
145
146
147
{                                                               \
  ir_node  *res;                                                \
  ir_graph *rem = current_ir_graph;                             \
  current_ir_graph = irg;                                       \
148
  res = new_bd_##instr(db, block, memop, op1, op2, mode, state);\
149
150
151
152
153
154
155
  current_ir_graph = rem;                                       \
  return res;                                                   \
}

/* creates a d constructor for an binop */
#define NEW_D_BINOP(instr)                                                    \
ir_node *                                                                     \
Michael Beck's avatar
Michael Beck committed
156
new_d_##instr(dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode) {      \
157
158
159
160
161
162
  return new_bd_##instr(db, current_ir_graph->current_block, op1, op2, mode); \
}

/* creates a d constructor for an unop */
#define NEW_D_UNOP(instr)                                                     \
ir_node *                                                                     \
Michael Beck's avatar
Michael Beck committed
163
164
new_d_##instr(dbg_info *db, ir_node *op, ir_mode *mode) {                     \
  return new_bd_##instr(db, current_ir_graph->current_block, op, mode);       \
165
166
}

Christian Schäfer's avatar
Christian Schäfer committed
167

Michael Beck's avatar
Michael Beck committed
168
169
/**
 * Constructs a Block with a fixed number of predecessors.
Michael Beck's avatar
Michael Beck committed
170
 * Does not set current_block.  Cannot be used with automatic
Michael Beck's avatar
Michael Beck committed
171
172
 * Phi node construction.
 */
Michael Beck's avatar
BugFix:    
Michael Beck committed
173
static ir_node *
Michael Beck's avatar
Michael Beck committed
174
new_bd_Block(dbg_info *db, int arity, ir_node **in) {
175
176
177
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

Michael Beck's avatar
Michael Beck committed
178
179
180
181
	res = new_ir_node(db, irg, NULL, op_Block, mode_BB, arity, in);

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

Michael Beck's avatar
Michael Beck committed
183
	res->attr.block.is_dead     = 0;
Michael Beck's avatar
Michael Beck committed
184
	res->attr.block.is_mb_head  = 1;
185
	res->attr.block.has_label   = 0;
186
187
188
189
190
	res->attr.block.irg         = irg;
	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;
Michael Beck's avatar
Michael Beck committed
191
	res->attr.block.mb_depth    = 0;
192
	res->attr.block.label       = 0;
193

Michael Beck's avatar
Michael Beck committed
194
195
196
	set_Block_matured(res, 1);
	set_Block_block_visited(res, 0);

Michael Beck's avatar
Michael Beck committed
197
	IRN_VRFY_IRG(res, irg);
198
	return res;
Michael Beck's avatar
Michael Beck committed
199
}  /* new_bd_Block */
Christian Schäfer's avatar
Christian Schäfer committed
200

Michael Beck's avatar
BugFix:    
Michael Beck committed
201
static ir_node *
202
203
204
new_bd_Start(dbg_info *db, ir_node *block) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;
Christian Schäfer's avatar
Christian Schäfer committed
205

206
	res = new_ir_node(db, irg, block, op_Start, mode_T, 0, NULL);
Christian Schäfer's avatar
Christian Schäfer committed
207

208
209
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
210
}  /* new_bd_Start */
Christian Schäfer's avatar
Christian Schäfer committed
211

Michael Beck's avatar
BugFix:    
Michael Beck committed
212
static ir_node *
213
214
215
new_bd_End(dbg_info *db, ir_node *block) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;
Christian Schäfer's avatar
Christian Schäfer committed
216

217
	res = new_ir_node(db, irg, block, op_End, mode_X, -1, NULL);
Christian Schäfer's avatar
Christian Schäfer committed
218

219
220
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
221
}  /* new_bd_End */
Christian Schäfer's avatar
Christian Schäfer committed
222

Michael Beck's avatar
Michael Beck committed
223
224
225
226
/**
 * Creates a Phi node with all predecessors.  Calling this constructor
 * is only allowed if the corresponding block is mature.
 */
Michael Beck's avatar
BugFix:    
Michael Beck committed
227
static ir_node *
228
229
230
231
232
233
234
235
new_bd_Phi(dbg_info *db, ir_node *block, int arity, ir_node **in, ir_mode *mode) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;
	int i;
	int has_unknown = 0;

	/* Don't assert that block matured: the use of this constructor is strongly
	   restricted ... */
236
237
	if (get_Block_matured(block))
		assert(get_irn_arity(block) == arity);
238
239
240

	res = new_ir_node(db, irg, block, op_Phi, mode, arity, in);

241
	res->attr.phi.u.backedge = new_backedge_arr(irg->obst, arity);
242

243
	for (i = arity - 1; i >= 0; --i)
244
		if (is_Unknown(in[i])) {
245
246
247
248
			has_unknown = 1;
			break;
		}

249
	if (!has_unknown) res = optimize_node(res);
250
251
252
253
	IRN_VRFY_IRG(res, irg);

	/* Memory Phis in endless loops must be kept alive.
	   As we can't distinguish these easily we keep all of them alive. */
Michael Beck's avatar
Michael Beck committed
254
	if (is_Phi(res) && mode == mode_M)
255
256
		add_End_keepalive(get_irg_end(irg), res);
	return res;
Michael Beck's avatar
Michael Beck committed
257
}  /* new_bd_Phi */
Christian Schäfer's avatar
Christian Schäfer committed
258

Michael Beck's avatar
BugFix:    
Michael Beck committed
259
static ir_node *
260
new_bd_Const_type(dbg_info *db, ir_mode *mode, tarval *con, ir_type *tp) {
261
262
263
264
265
266
267
268
269
270
271
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	res = new_ir_node(db, irg, get_irg_start_block(irg), op_Const, mode, 0, NULL);
	res->attr.con.tv = con;
	set_Const_type(res, tp);  /* Call method because of complex assertion. */
	res = optimize_node (res);
	assert(get_Const_type(res) == tp);
	IRN_VRFY_IRG(res, irg);

	return res;
Michael Beck's avatar
Michael Beck committed
272
}  /* new_bd_Const_type */
Christian Schäfer's avatar
Christian Schäfer committed
273

Michael Beck's avatar
BugFix:    
Michael Beck committed
274
static ir_node *
275
new_bd_Const(dbg_info *db, ir_mode *mode, tarval *con) {
276
	ir_graph *irg = current_ir_graph;
Michael Beck's avatar
BugFix:    
Michael Beck committed
277

278
	return new_rd_Const_type (db, irg, mode, con, firm_unknown_type);
Michael Beck's avatar
Michael Beck committed
279
}  /* new_bd_Const */
280

Michael Beck's avatar
BugFix:    
Michael Beck committed
281
static ir_node *
282
new_bd_Const_long(dbg_info *db, ir_mode *mode, long value) {
283
	ir_graph *irg = current_ir_graph;
Michael Beck's avatar
BugFix:    
Michael Beck committed
284

285
	return new_rd_Const(db, irg, mode, new_tarval_from_long(value, mode));
Michael Beck's avatar
Michael Beck committed
286
}  /* new_bd_Const_long */
287

Michael Beck's avatar
BugFix:    
Michael Beck committed
288
static ir_node *
289
290
291
292
293
294
295
296
new_bd_Id(dbg_info *db, ir_node *block, ir_node *val, ir_mode *mode) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	res = new_ir_node(db, irg, block, op_Id, mode, 1, &val);
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
297
}  /* new_bd_Id */
Christian Schäfer's avatar
Christian Schäfer committed
298

Michael Beck's avatar
BugFix:    
Michael Beck committed
299
static ir_node *
Michael Beck's avatar
Michael Beck committed
300
new_bd_Proj(dbg_info *db, ir_node *block, ir_node *arg, ir_mode *mode,
301
302
303
        long proj) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;
304

305
306
	res = new_ir_node (db, irg, block, op_Proj, mode, 1, &arg);
	res->attr.proj = proj;
307

308
309
310
	assert(res);
	assert(get_Proj_pred(res));
	assert(get_nodes_block(get_Proj_pred(res)));
311

312
	res = optimize_node(res);
Christian Schäfer's avatar
Christian Schäfer committed
313

314
315
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
316
}  /* new_bd_Proj */
Christian Schäfer's avatar
Christian Schäfer committed
317

Michael Beck's avatar
BugFix:    
Michael Beck committed
318
static ir_node *
Michael Beck's avatar
Michael Beck committed
319
new_bd_defaultProj(dbg_info *db, ir_node *block, ir_node *arg,
320
321
322
323
324
325
326
327
328
           long max_proj) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	assert(arg->op == op_Cond);
	arg->attr.cond.kind = fragmentary;
	arg->attr.cond.default_proj = max_proj;
	res = new_rd_Proj (db, irg, block, arg, mode_X, max_proj);
	return res;
Michael Beck's avatar
Michael Beck committed
329
}  /* new_bd_defaultProj */
330

Michael Beck's avatar
BugFix:    
Michael Beck committed
331
static ir_node *
332
333
334
335
336
337
338
339
340
new_bd_Conv(dbg_info *db, ir_node *block, ir_node *op, ir_mode *mode, int strict_flag) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	res = new_ir_node(db, irg, block, op_Conv, mode, 1, &op);
	res->attr.conv.strict = strict_flag;
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
341
}  /* new_bd_Conv */
Christian Schäfer's avatar
Christian Schäfer committed
342

Michael Beck's avatar
BugFix:    
Michael Beck committed
343
static ir_node *
344
345
346
new_bd_Cast(dbg_info *db, ir_node *block, ir_node *op, ir_type *to_tp) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;
347

348
	assert(is_atomic_type(to_tp));
Götz Lindenmaier's avatar
Götz Lindenmaier committed
349

350
351
352
353
354
	res = new_ir_node(db, irg, block, op_Cast, get_irn_mode(op), 1, &op);
	res->attr.cast.totype = to_tp;
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
355
}  /* new_bd_Cast */
Christian Schäfer's avatar
Christian Schäfer committed
356

Michael Beck's avatar
BugFix:    
Michael Beck committed
357
static ir_node *
358
359
360
361
362
363
364
365
new_bd_Tuple(dbg_info *db, ir_node *block, int arity, ir_node **in) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	res = new_ir_node(db, irg, block, op_Tuple, mode_T, arity, in);
	res = optimize_node (res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
366
}  /* new_bd_Tuple */
Christian Schäfer's avatar
Christian Schäfer committed
367

368
369
370
371
NEW_BD_BINOP(Add)
NEW_BD_BINOP(Sub)
NEW_BD_UNOP(Minus)
NEW_BD_BINOP(Mul)
Michael Beck's avatar
Michael Beck committed
372
NEW_BD_BINOP(Mulh)
373
374
375
376
377
378
379
380
381
382
383
NEW_BD_DIVOP(Quot)
NEW_BD_DIVOP(DivMod)
NEW_BD_DIVOP(Div)
NEW_BD_DIVOP(Mod)
NEW_BD_BINOP(And)
NEW_BD_BINOP(Or)
NEW_BD_BINOP(Eor)
NEW_BD_UNOP(Not)
NEW_BD_BINOP(Shl)
NEW_BD_BINOP(Shr)
NEW_BD_BINOP(Shrs)
384
NEW_BD_BINOP(Rotl)
385
386
387
NEW_BD_UNOP(Abs)
NEW_BD_BINOP(Carry)
NEW_BD_BINOP(Borrow)
Christian Schäfer's avatar
Christian Schäfer committed
388

389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
/** Creates a remainderless Div node. */
static ir_node *new_bd_DivRL(dbg_info *db, ir_node *block,
            ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state)
{
	ir_node  *in[3];
	ir_node  *res;
	ir_graph *irg = current_ir_graph;
	in[0] = memop;
	in[1] = op1;
	in[2] = op2;
	res = new_ir_node(db, irg, block, op_Div, mode_T, 3, in);
	res->attr.divmod.exc.pin_state = state;
	res->attr.divmod.res_mode = mode;
	res->attr.divmod.no_remainder = 1;
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
}

Michael Beck's avatar
BugFix:    
Michael Beck committed
408
static ir_node *
409
410
411
412
413
414
415
416
417
418
new_bd_Cmp(dbg_info *db, ir_node *block, ir_node *op1, ir_node *op2) {
	ir_node  *in[2];
	ir_node  *res;
	ir_graph *irg = current_ir_graph;
	in[0] = op1;
	in[1] = op2;
	res = new_ir_node(db, irg, block, op_Cmp, mode_T, 2, in);
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
419
}  /* new_bd_Cmp */
Christian Schäfer's avatar
Christian Schäfer committed
420

Michael Beck's avatar
BugFix:    
Michael Beck committed
421
static ir_node *
422
423
424
425
new_bd_Jmp(dbg_info *db, ir_node *block) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

426
427
	res = new_ir_node(db, irg, block, op_Jmp, mode_X, 0, NULL);
	res = optimize_node(res);
428
429
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
430
}  /* new_bd_Jmp */
Christian Schäfer's avatar
Christian Schäfer committed
431

Michael Beck's avatar
BugFix:    
Michael Beck committed
432
static ir_node *
433
434
435
new_bd_IJmp(dbg_info *db, ir_node *block, ir_node *tgt) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;
Michael Beck's avatar
Michael Beck committed
436

437
438
	res = new_ir_node(db, irg, block, op_IJmp, mode_X, 1, &tgt);
	res = optimize_node(res);
439
440
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
441
}  /* new_bd_IJmp */
Michael Beck's avatar
Michael Beck committed
442

Michael Beck's avatar
BugFix:    
Michael Beck committed
443
static ir_node *
444
445
446
447
new_bd_Cond(dbg_info *db, ir_node *block, ir_node *c) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

448
	res = new_ir_node(db, irg, block, op_Cond, mode_T, 1, &c);
449
450
451
	res->attr.cond.kind         = dense;
	res->attr.cond.default_proj = 0;
	res->attr.cond.pred         = COND_JMP_PRED_NONE;
452
	res = optimize_node(res);
453
454
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
455
}  /* new_bd_Cond */
Christian Schäfer's avatar
Christian Schäfer committed
456

Michael Beck's avatar
BugFix:    
Michael Beck committed
457
static ir_node *
Michael Beck's avatar
Michael Beck committed
458
new_bd_Call(dbg_info *db, ir_node *block, ir_node *store,
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
        ir_node *callee, int arity, ir_node **in, ir_type *tp) {
	ir_node  **r_in;
	ir_node  *res;
	int      r_arity;
	ir_graph *irg = current_ir_graph;

	r_arity = arity+2;
	NEW_ARR_A(ir_node *, r_in, r_arity);
	r_in[0] = store;
	r_in[1] = callee;
	memcpy(&r_in[2], in, sizeof(ir_node *) * arity);

	res = new_ir_node(db, irg, block, op_Call, mode_T, r_arity, r_in);

	assert((get_unknown_type() == tp) || is_Method_type(tp));
	set_Call_type(res, tp);
	res->attr.call.exc.pin_state = op_pin_state_pinned;
	res->attr.call.callee_arr    = NULL;
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
480
}  /* new_bd_Call */
Christian Schäfer's avatar
Christian Schäfer committed
481

Michael Beck's avatar
BugFix:    
Michael Beck committed
482
static ir_node *
483
new_bd_Return(dbg_info *db, ir_node *block,
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
              ir_node *store, int arity, ir_node **in) {
	ir_node  **r_in;
	ir_node  *res;
	int      r_arity;
	ir_graph *irg = current_ir_graph;

	r_arity = arity+1;
	NEW_ARR_A (ir_node *, r_in, r_arity);
	r_in[0] = store;
	memcpy(&r_in[1], in, sizeof(ir_node *) * arity);
	res = new_ir_node(db, irg, block, op_Return, mode_X, r_arity, r_in);
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
}  /* new_bd_Return */
Christian Schäfer's avatar
Christian Schäfer committed
499

Michael Beck's avatar
BugFix:    
Michael Beck committed
500
static ir_node *
Michael Beck's avatar
Michael Beck committed
501
new_bd_Load(dbg_info *db, ir_node *block,
502
503
504
505
506
507
508
509
510
511
512
        ir_node *store, ir_node *adr, ir_mode *mode) {
	ir_node  *in[2];
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	in[0] = store;
	in[1] = adr;
	res = new_ir_node(db, irg, block, op_Load, mode_T, 2, in);
	res->attr.load.exc.pin_state = op_pin_state_pinned;
	res->attr.load.load_mode     = mode;
	res->attr.load.volatility    = volatility_non_volatile;
Michael Beck's avatar
Michael Beck committed
513
	res->attr.load.aligned       = align_is_aligned;
514
515
516
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
517
}  /* new_bd_Load */
Christian Schäfer's avatar
Christian Schäfer committed
518

Michael Beck's avatar
BugFix:    
Michael Beck committed
519
static ir_node *
Michael Beck's avatar
Michael Beck committed
520
new_bd_Store(dbg_info *db, ir_node *block,
521
522
523
524
525
526
527
528
529
530
531
         ir_node *store, ir_node *adr, ir_node *val) {
	ir_node  *in[3];
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	in[0] = store;
	in[1] = adr;
	in[2] = val;
	res = new_ir_node(db, irg, block, op_Store, mode_T, 3, in);
	res->attr.store.exc.pin_state = op_pin_state_pinned;
	res->attr.store.volatility    = volatility_non_volatile;
Michael Beck's avatar
Michael Beck committed
532
	res->attr.store.aligned       = align_is_aligned;
533
534
535
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
536
}  /* new_bd_Store */
Christian Schäfer's avatar
Christian Schäfer committed
537

Michael Beck's avatar
BugFix:    
Michael Beck committed
538
static ir_node *
Michael Beck's avatar
Michael Beck committed
539
new_bd_Alloc(dbg_info *db, ir_node *block, ir_node *store,
540
        ir_node *size, ir_type *alloc_type, ir_where_alloc where) {
541
542
543
544
545
546
547
548
549
550
551
552
553
	ir_node  *in[2];
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	in[0] = store;
	in[1] = size;
	res = new_ir_node(db, irg, block, op_Alloc, mode_T, 2, in);
	res->attr.alloc.exc.pin_state = op_pin_state_pinned;
	res->attr.alloc.where         = where;
	res->attr.alloc.type          = alloc_type;
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
554
}  /* new_bd_Alloc */
Christian Schäfer's avatar
Christian Schäfer committed
555

Michael Beck's avatar
BugFix:    
Michael Beck committed
556
static ir_node *
Michael Beck's avatar
Michael Beck committed
557
new_bd_Free(dbg_info *db, ir_node *block, ir_node *store,
558
        ir_node *ptr, ir_node *size, ir_type *free_type, ir_where_alloc where) {
559
560
561
562
563
564
565
566
567
568
569
570
571
	ir_node  *in[3];
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	in[0] = store;
	in[1] = ptr;
	in[2] = size;
	res = new_ir_node (db, irg, block, op_Free, mode_M, 3, in);
	res->attr.free.where = where;
	res->attr.free.type  = free_type;
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
572
}  /* new_bd_Free */
Christian Schäfer's avatar
Christian Schäfer committed
573

Michael Beck's avatar
BugFix:    
Michael Beck committed
574
static ir_node *
Michael Beck's avatar
Michael Beck committed
575
new_bd_Sel(dbg_info *db, ir_node *block, ir_node *store, ir_node *objptr,
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
           int arity, ir_node **in, ir_entity *ent) {
	ir_node  **r_in;
	ir_node  *res;
	int      r_arity;
	ir_graph *irg = current_ir_graph;
	ir_mode  *mode = is_Method_type(get_entity_type(ent)) ? mode_P_code : mode_P_data;

	assert(ent != NULL && is_entity(ent) && "entity expected in Sel construction");

	r_arity = arity + 2;
	NEW_ARR_A(ir_node *, r_in, r_arity);  /* uses alloca */
	r_in[0] = store;
	r_in[1] = objptr;
	memcpy(&r_in[2], in, sizeof(ir_node *) * arity);
	/*
	 * Sel's can select functions which should be of mode mode_P_code.
	 */
	res = new_ir_node(db, irg, block, op_Sel, mode, r_arity, r_in);
	res->attr.sel.ent = ent;
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
598
}  /* new_bd_Sel */
Christian Schäfer's avatar
Christian Schäfer committed
599

Michael Beck's avatar
BugFix:    
Michael Beck committed
600
static ir_node *
601
602
new_bd_SymConst_type(dbg_info *db, ir_node *block, ir_mode *mode,
                     symconst_symbol value,symconst_kind symkind, ir_type *tp) {
603
	ir_graph *irg = current_ir_graph;
604
	ir_node  *res = new_ir_node(db, irg, block, op_SymConst, mode, 0, NULL);
Christian Schäfer's avatar
Christian Schäfer committed
605

606
607
608
	res->attr.symc.kind = symkind;
	res->attr.symc.sym  = value;
	res->attr.symc.tp   = tp;
Beyhan's avatar
Beyhan committed
609

610
611
612
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
613
}  /* new_bd_SymConst_type */
Christian Schäfer's avatar
Christian Schäfer committed
614

Michael Beck's avatar
BugFix:    
Michael Beck committed
615
static ir_node *
616
617
618
619
620
621
622
623
new_bd_Sync(dbg_info *db, ir_node *block) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	res = new_ir_node(db, irg, block, op_Sync, mode_M, -1, NULL);
	/* no need to call optimize node here, Sync are always created with no predecessors */
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
624
}  /* new_bd_Sync */
Christian Schäfer's avatar
Christian Schäfer committed
625

Michael Beck's avatar
BugFix:    
Michael Beck committed
626
static ir_node *
627
new_bd_Confirm(dbg_info *db, ir_node *block, ir_node *val, ir_node *bound, pn_Cmp cmp) {
628
629
630
631
632
	ir_node  *in[2], *res;
	ir_graph *irg = current_ir_graph;

	in[0] = val;
	in[1] = bound;
633
	res = new_ir_node(db, irg, block, op_Confirm, get_irn_mode(val), 2, in);
634
	res->attr.confirm.cmp = cmp;
635
	res = optimize_node(res);
636
637
638
	IRN_VRFY_IRG(res, irg);
	return res;
}  /* new_bd_Confirm */
639

Michael Beck's avatar
BugFix:    
Michael Beck committed
640
static ir_node *
641
642
643
new_bd_Unknown(ir_mode *m) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;
644

645
646
647
	res = new_ir_node(NULL, irg, get_irg_start_block(irg), op_Unknown, m, 0, NULL);
	res = optimize_node(res);
	return res;
Michael Beck's avatar
Michael Beck committed
648
}  /* new_bd_Unknown */
649

Michael Beck's avatar
BugFix:    
Michael Beck committed
650
static ir_node *
651
652
653
654
655
656
657
658
659
660
661
662
new_bd_CallBegin(dbg_info *db, ir_node *block, ir_node *call) {
	ir_node  *in[1];
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	in[0] = get_Call_ptr(call);
	res = new_ir_node(db, irg, block, op_CallBegin, mode_T, 1, in);
	/* res->attr.callbegin.irg = irg; */
	res->attr.callbegin.call = call;
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
663
}  /* new_bd_CallBegin */
664

Michael Beck's avatar
BugFix:    
Michael Beck committed
665
static ir_node *
666
667
668
669
670
671
672
673
new_bd_EndReg(dbg_info *db, ir_node *block) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	res = new_ir_node(db, irg, block, op_EndReg, mode_T, -1, NULL);
	set_irg_end_reg(irg, res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
674
}  /* new_bd_EndReg */
675

Michael Beck's avatar
BugFix:    
Michael Beck committed
676
static ir_node *
677
678
679
680
681
682
683
684
new_bd_EndExcept(dbg_info *db, ir_node *block) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	res = new_ir_node(db, irg, block, op_EndExcept, mode_T, -1, NULL);
	set_irg_end_except(irg, res);
	IRN_VRFY_IRG (res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
685
}  /* new_bd_EndExcept */
686

Michael Beck's avatar
BugFix:    
Michael Beck committed
687
static ir_node *
688
689
690
691
692
693
694
695
new_bd_Break(dbg_info *db, ir_node *block) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	res = new_ir_node(db, irg, block, op_Break, mode_X, 0, NULL);
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
696
}  /* new_bd_Break */
697

Michael Beck's avatar
BugFix:    
Michael Beck committed
698
static ir_node *
Michael Beck's avatar
Michael Beck committed
699
new_bd_Filter(dbg_info *db, ir_node *block, ir_node *arg, ir_mode *mode,
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
              long proj) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	res = new_ir_node(db, irg, block, op_Filter, mode, 1, &arg);
	res->attr.filter.proj = proj;
	res->attr.filter.in_cg = NULL;
	res->attr.filter.backedge = NULL;

	assert(res);
	assert(get_Proj_pred(res));
	assert(get_nodes_block(get_Proj_pred(res)));

	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
716
}  /* new_bd_Filter */
717

Michael Beck's avatar
BugFix:    
Michael Beck committed
718
static ir_node *
Michael Beck's avatar
Michael Beck committed
719
new_bd_Mux(dbg_info *db, ir_node *block,
720
721
722
723
           ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode) {
	ir_node  *in[3];
	ir_node  *res;
	ir_graph *irg = current_ir_graph;
724

725
726
727
	in[0] = sel;
	in[1] = ir_false;
	in[2] = ir_true;
728

729
730
	res = new_ir_node(db, irg, block, op_Mux, mode, 3, in);
	assert(res);
731

732
733
734
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
735
}  /* new_bd_Mux */
736

Michael Beck's avatar
Michael Beck committed
737
static ir_node *
Michael Beck's avatar
Michael Beck committed
738
new_bd_CopyB(dbg_info *db, ir_node *block,
739
740
741
742
    ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type) {
	ir_node  *in[3];
	ir_node  *res;
	ir_graph *irg = current_ir_graph;
Michael Beck's avatar
Michael Beck committed
743

744
745
746
	in[0] = store;
	in[1] = dst;
	in[2] = src;
Michael Beck's avatar
Michael Beck committed
747

748
	res = new_ir_node(db, irg, block, op_CopyB, mode_T, 3, in);
749

750
751
752
753
754
	res->attr.copyb.exc.pin_state = op_pin_state_pinned;
	res->attr.copyb.data_type     = data_type;
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
755
}  /* new_bd_CopyB */
Michael Beck's avatar
Michael Beck committed
756

757
static ir_node *
Michael Beck's avatar
Michael Beck committed
758
new_bd_InstOf(dbg_info *db, ir_node *block, ir_node *store,
759
760
761
762
763
764
765
766
767
768
769
770
              ir_node *objptr, ir_type *type) {
	ir_node  *in[2];
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	in[0] = store;
	in[1] = objptr;
	res = new_ir_node(db, irg, block, op_Sel, mode_T, 2, in);
	res->attr.instof.type = type;
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
771
}  /* new_bd_InstOf */
772
773

static ir_node *
774
775
776
777
778
779
780
781
782
783
784
new_bd_Raise(dbg_info *db, ir_node *block, ir_node *store, ir_node *obj) {
	ir_node  *in[2];
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	in[0] = store;
	in[1] = obj;
	res = new_ir_node(db, irg, block, op_Raise, mode_T, 2, in);
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
785
}  /* new_bd_Raise */
786

Michael Beck's avatar
Michael Beck committed
787
static ir_node *
Michael Beck's avatar
Michael Beck committed
788
new_bd_Bound(dbg_info *db, ir_node *block,
789
790
791
792
793
794
795
796
797
798
799
800
801
802
             ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper) {
	ir_node  *in[4];
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	in[0] = store;
	in[1] = idx;
	in[2] = lower;
	in[3] = upper;
	res = new_ir_node(db, irg, block, op_Bound, mode_T, 4, in);
	res->attr.bound.exc.pin_state = op_pin_state_pinned;
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
803
804
805
}  /* new_bd_Bound */

static ir_node *
806
807
808
809
810
811
812
813
new_bd_Pin(dbg_info *db, ir_node *block, ir_node *node) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

	res = new_ir_node(db, irg, block, op_Pin, get_irn_mode(node), 1, &node);
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
814
}  /* new_bd_Pin */
Michael Beck's avatar
Michael Beck committed
815

Michael Beck's avatar
Michael Beck committed
816
static ir_node *
Michael Beck's avatar
Michael Beck committed
817
new_bd_ASM(dbg_info *db, ir_node *block, int arity, ir_node *in[], ir_asm_constraint *inputs,
Michael Beck's avatar
Michael Beck committed
818
           int n_outs, ir_asm_constraint *outputs, int n_clobber, ident *clobber[], ident *asm_text) {
Michael Beck's avatar
Michael Beck committed
819
	ir_node  *res;
Michael Beck's avatar
Michael Beck committed
820
	ir_graph *irg = current_ir_graph;
821
	(void) clobber;
Michael Beck's avatar
Michael Beck committed
822

Michael Beck's avatar
Michael Beck committed
823
	res = new_ir_node(db, irg, block, op_ASM, mode_T, arity, in);
Matthias Braun's avatar
Matthias Braun committed
824
	res->attr.assem.pin_state = op_pin_state_pinned;
Michael Beck's avatar
Michael Beck committed
825
826
	res->attr.assem.inputs    = NEW_ARR_D(ir_asm_constraint, irg->obst, arity);
	res->attr.assem.outputs   = NEW_ARR_D(ir_asm_constraint, irg->obst, n_outs);
Michael Beck's avatar
Michael Beck committed
827
	res->attr.assem.clobber   = NEW_ARR_D(ident *, irg->obst, n_clobber);
Matthias Braun's avatar
Matthias Braun committed
828
	res->attr.assem.asm_text  = asm_text;
Michael Beck's avatar
Michael Beck committed
829

Michael Beck's avatar
Michael Beck committed
830
831
832
	memcpy(res->attr.assem.inputs,  inputs,  sizeof(inputs[0]) * arity);
	memcpy(res->attr.assem.outputs, outputs, sizeof(outputs[0]) * n_outs);
	memcpy(res->attr.assem.clobber, clobber, sizeof(clobber[0]) * n_clobber);
Michael Beck's avatar
Michael Beck committed
833

Michael Beck's avatar
Michael Beck committed
834
835
836
837
838
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
}  /* new_bd_ASM */

Michael Beck's avatar
BugFix:    
Michael Beck committed
839
840
841
842
843
844
845
846
/* --------------------------------------------- */
/* private interfaces, for professional use only */
/* --------------------------------------------- */

/* Constructs a Block with a fixed number of predecessors.
   Does not set current_block.  Can not be used with automatic
   Phi node construction. */
ir_node *
Michael Beck's avatar
Michael Beck committed
847
new_rd_Block(dbg_info *db, ir_graph *irg, int arity, ir_node **in) {
848
849
	ir_graph *rem = current_ir_graph;
	ir_node  *res;
Michael Beck's avatar
BugFix:    
Michael Beck committed
850

851
852
853
	current_ir_graph = irg;
	res = new_bd_Block(db, arity, in);
	current_ir_graph = rem;
Michael Beck's avatar
BugFix:    
Michael Beck committed
854

855
	return res;
Michael Beck's avatar
Michael Beck committed
856
}  /* new_rd_Block */
Michael Beck's avatar
BugFix:    
Michael Beck committed
857
858

ir_node *
859
860
861
new_rd_Start(dbg_info *db, ir_graph *irg, ir_node *block) {
	ir_graph *rem = current_ir_graph;
	ir_node  *res;
Michael Beck's avatar
BugFix:    
Michael Beck committed
862

863
864
865
	current_ir_graph = irg;
	res = new_bd_Start(db, block);
	current_ir_graph = rem;
Michael Beck's avatar
BugFix:    
Michael Beck committed
866

867
	return res;
Michael Beck's avatar
Michael Beck committed
868
}  /* new_rd_Start */
Michael Beck's avatar
BugFix:    
Michael Beck committed
869
870

ir_node *
871
872
873
new_rd_End(dbg_info *db, ir_graph *irg, ir_node *block) {
	ir_node  *res;
	ir_graph *rem = current_ir_graph;
Michael Beck's avatar
BugFix:    
Michael Beck committed
874

875
	current_ir_graph = irg;
876
877
	res = new_bd_End(db, block);
	current_ir_graph = rem;
Michael Beck's avatar
BugFix:    
Michael Beck committed
878

879
	return res;
Michael Beck's avatar
Michael Beck committed
880
}  /* new_rd_End */
Michael Beck's avatar
BugFix:    
Michael Beck committed
881
882
883
884

/* Creates a Phi node with all predecessors.  Calling this constructor
   is only allowed if the corresponding block is mature.  */
ir_node *
885
886
887
new_rd_Phi(dbg_info *db, ir_graph *irg, ir_node *block, int arity, ir_node **in, ir_mode *mode) {
	ir_node  *res;
	ir_graph *rem = current_ir_graph;
Michael Beck's avatar
BugFix:    
Michael Beck committed
888

889
890
891
	current_ir_graph = irg;
	res = new_bd_Phi(db, block,arity, in, mode);
	current_ir_graph = rem;
Michael Beck's avatar
BugFix:    
Michael Beck committed
892

893
	return res;
Michael Beck's avatar
Michael Beck committed
894
}  /* new_rd_Phi */
Michael Beck's avatar
BugFix:    
Michael Beck committed
895
896

ir_node *
897
new_rd_Const_type(dbg_info *db, ir_graph *irg, ir_mode *mode, tarval *con, ir_type *tp) {
898
899
	ir_node  *res;
	ir_graph *rem = current_ir_graph;
Michael Beck's avatar
BugFix:    
Michael Beck committed
900

901
	current_ir_graph = irg;
902
	res = new_bd_Const_type(db, mode, con, tp);
903
	current_ir_graph = rem;
Michael Beck's avatar
BugFix:    
Michael Beck committed
904

905
	return res;
Michael Beck's avatar
Michael Beck committed
906
}  /* new_rd_Const_type */
Michael Beck's avatar
BugFix:    
Michael Beck committed
907
908

ir_node *
909
new_rd_Const(dbg_info *db, ir_graph *irg, ir_mode *mode, tarval *con) {
910
911
	ir_node  *res;
	ir_graph *rem = current_ir_graph;
Michael Beck's avatar
BugFix:    
Michael Beck committed
912

913
	current_ir_graph = irg;
914
	res = new_bd_Const_type(db, mode, con, firm_unknown_type);
915
	current_ir_graph = rem;
Michael Beck's avatar
BugFix:    
Michael Beck committed
916

917
	return res;
Michael Beck's avatar
Michael Beck committed
918
}  /* new_rd_Const */
Michael Beck's avatar
BugFix:    
Michael Beck committed
919
920

ir_node *
921
922
new_rd_Const_long(dbg_info *db, ir_graph *irg, ir_mode *mode, long value) {
	return new_rd_Const(db, irg, mode, new_tarval_from_long(value, mode));
Michael Beck's avatar
Michael Beck committed
923
}  /* new_rd_Const_long */
Michael Beck's avatar
BugFix:    
Michael Beck committed
924
925

ir_node *
926
927
928
new_rd_Id(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *val, ir_mode *mode) {
	ir_node  *res;
	ir_graph *rem = current_ir_graph;
Michael Beck's avatar
BugFix:    
Michael Beck committed
929

930
931
932
	current_ir_graph = irg;
	res = new_bd_Id(db, block, val, mode);
	current_ir_graph = rem;
Michael Beck's avatar
BugFix:    
Michael Beck committed
933

934
	return res;
Michael Beck's avatar
Michael Beck committed
935
}  /* new_rd_Id */
Michael Beck's avatar
BugFix:    
Michael Beck committed
936
937

ir_node *
Michael Beck's avatar
Michael Beck committed
938
new_rd_Proj(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg, ir_mode *mode,
939
940
941
            long proj) {
	ir_node  *res;
	ir_graph *rem = current_ir_graph;
Michael Beck's avatar
BugFix:    
Michael Beck committed
942

943
944
945
	current_ir_graph = irg;
	res = new_bd_Proj(db, block, arg, mode, proj);
	current_ir_graph = rem;
Michael Beck's avatar
BugFix:    
Michael Beck committed
946

947
	return res;
Michael Beck's avatar
Michael Beck committed
948
}  /* new_rd_Proj */
Michael Beck's avatar
BugFix:    
Michael Beck committed
949
950

ir_node *
Michael Beck's avatar
Michael Beck committed
951
new_rd_defaultProj(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
952
953
954
                   long max_proj) {
	ir_node  *res;
	ir_graph *rem = current_ir_graph;
Michael Beck's avatar
BugFix:    
Michael Beck committed
955

956
957
958
	current_ir_graph = irg;
	res = new_bd_defaultProj(db, block, arg, max_proj);
	current_ir_graph = rem;
Michael Beck's avatar
BugFix:    
Michael Beck committed
959

960
	return res;
Michael Beck's avatar
Michael Beck committed
961
}  /* new_rd_defaultProj */
Michael Beck's avatar
BugFix:    
Michael Beck committed
962
963

ir_node *
964
965
966
new_rd_Conv(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *op, ir_mode *mode) {
	ir_node  *res;
	ir_graph *rem = current_ir_graph;
Michael Beck's avatar
BugFix:    
Michael Beck committed
967

968
969
970
	current_ir_graph = irg;
	res = new_bd_Conv(db, block, op, mode, 0);
	current_ir_graph = rem;
Michael Beck's avatar
BugFix:    
Michael Beck committed
971

972
	return res;
Michael Beck's avatar
Michael Beck committed
973
}  /* new_rd_Conv */
Michael Beck's avatar
BugFix:    
Michael Beck committed
974
975

ir_node *
976
977
978
new_rd_Cast(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *op, ir_type *to_tp) {
	ir_node  *res;
	ir_graph *rem = current_ir_graph;
Michael Beck's avatar
BugFix:    
Michael Beck committed
979

980
981
982
	current_ir_graph = irg;
	res = new_bd_Cast(db, block, op, to_tp);
	current_ir_graph = rem;
Michael Beck's avatar
BugFix:    
Michael Beck committed
983

984
	return res;
Michael Beck's avatar
Michael Beck committed
985
}  /* new_rd_Cast */
Michael Beck's avatar
BugFix:    
Michael Beck committed
986
987

ir_node *
988
989
990
new_rd_Tuple(dbg_info *db, ir_graph *irg, ir_node *block, int arity, ir_node **in) {
	ir_node  *res;
	ir_graph *rem = current_ir_graph;
Michael Beck's avatar
BugFix:    
Michael Beck committed
991

992
993
994
	current_ir_graph = irg;
	res = new_bd_Tuple(db, block, arity, in);
	current_ir_graph = rem;
Michael Beck's avatar
BugFix:    
Michael Beck committed