ircons.c 97.8 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
/* Uncomment to use original code instead of generated one */
// #define USE_ORIGINAL

50
51
52
53
54
/* 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
55
#endif /* NDEBUG */
56

Michael Beck's avatar
Michael Beck committed
57
58
/**
 * Language dependent variable initialization callback.
59
 */
60
static uninitialized_local_variable_func_t *default_initialize_local_variable = NULL;
61

62
/* creates a bd constructor for a binop */
63
#define NEW_BD_BINOP(instr)                                     \
64
static ir_node *                                                \
Michael Beck's avatar
Michael Beck committed
65
new_bd_##instr(dbg_info *db, ir_node *block,                    \
66
67
68
69
70
71
72
73
74
75
76
77
78
79
       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 */
80
#define NEW_BD_UNOP(instr)                                      \
81
static ir_node *                                                \
Michael Beck's avatar
Michael Beck committed
82
new_bd_##instr(dbg_info *db, ir_node *block,                    \
83
84
85
86
87
88
89
90
91
92
93
              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 */
94
#define NEW_BD_DIVOP(instr)                                     \
95
static ir_node *                                                \
Michael Beck's avatar
Michael Beck committed
96
new_bd_##instr(dbg_info *db, ir_node *block,                    \
97
            ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state) \
98
99
100
101
102
103
104
105
{                                                               \
  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); \
106
  res->attr.divmod.exc.pin_state = state;                       \
107
  res->attr.divmod.res_mode = mode;                             \
108
  res->attr.divmod.no_remainder = 0;                            \
109
110
111
112
113
114
115
116
  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
117
new_rd_##instr(dbg_info *db, ir_graph *irg, ir_node *block,     \
118
119
120
121
122
123
124
125
126
127
128
129
130
       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
131
new_rd_##instr(dbg_info *db, ir_graph *irg, ir_node *block,     \
132
133
134
135
136
137
138
139
140
141
142
143
144
              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
145
new_rd_##instr(dbg_info *db, ir_graph *irg, ir_node *block,     \
146
            ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state) \
147
148
149
150
{                                                               \
  ir_node  *res;                                                \
  ir_graph *rem = current_ir_graph;                             \
  current_ir_graph = irg;                                       \
151
  res = new_bd_##instr(db, block, memop, op1, op2, mode, state);\
152
153
154
155
156
157
158
  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
159
new_d_##instr(dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode) {      \
160
161
162
163
164
165
  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
166
167
new_d_##instr(dbg_info *db, ir_node *op, ir_mode *mode) {                     \
  return new_bd_##instr(db, current_ir_graph->current_block, op, mode);       \
168
169
}

170
171
172
#ifndef USE_ORIGINAL
#include "gen_ir_cons.c.inl"
#else
Christian Schäfer's avatar
Christian Schäfer committed
173

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

Michael Beck's avatar
Michael Beck committed
184
185
186
187
	res = new_ir_node(db, irg, NULL, op_Block, mode_BB, arity, in);

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

Michael Beck's avatar
Michael Beck committed
189
	res->attr.block.is_dead     = 0;
Michael Beck's avatar
Michael Beck committed
190
	res->attr.block.is_mb_head  = 1;
191
	res->attr.block.has_label   = 0;
192
193
194
195
196
	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
197
	res->attr.block.mb_depth    = 0;
198
	res->attr.block.label       = 0;
199

Michael Beck's avatar
Michael Beck committed
200
201
202
	set_Block_matured(res, 1);
	set_Block_block_visited(res, 0);

Michael Beck's avatar
Michael Beck committed
203
	IRN_VRFY_IRG(res, irg);
204
	return res;
Michael Beck's avatar
Michael Beck committed
205
}  /* new_bd_Block */
Christian Schäfer's avatar
Christian Schäfer committed
206

Michael Beck's avatar
BugFix:    
Michael Beck committed
207
static ir_node *
208
209
210
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
211

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

214
215
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
216
}  /* new_bd_Start */
Christian Schäfer's avatar
Christian Schäfer committed
217

Michael Beck's avatar
BugFix:    
Michael Beck committed
218
static ir_node *
219
220
221
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
222

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

225
226
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
227
}  /* new_bd_End */
228
#endif
Christian Schäfer's avatar
Christian Schäfer committed
229

Michael Beck's avatar
Michael Beck committed
230
231
232
233
/**
 * 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
234
static ir_node *
235
236
237
238
239
240
241
242
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 ... */
243
244
	if (get_Block_matured(block))
		assert(get_irn_arity(block) == arity);
245
246
247

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

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

250
	for (i = arity - 1; i >= 0; --i)
251
		if (is_Unknown(in[i])) {
252
253
254
255
			has_unknown = 1;
			break;
		}

256
	if (!has_unknown) res = optimize_node(res);
257
258
259
260
	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
261
	if (is_Phi(res) && mode == mode_M)
262
263
		add_End_keepalive(get_irg_end(irg), res);
	return res;
Michael Beck's avatar
Michael Beck committed
264
}  /* new_bd_Phi */
Christian Schäfer's avatar
Christian Schäfer committed
265

266
#ifdef USE_ORIGINAL
Michael Beck's avatar
BugFix:    
Michael Beck committed
267
static ir_node *
268
new_bd_Const_type(dbg_info *db, tarval *con, ir_type *tp) {
269
270
271
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

272
	res = new_ir_node(db, irg, get_irg_start_block(irg), op_Const, get_tarval_mode(con), 0, NULL);
273
274
275
276
277
278
279
	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
280
}  /* new_bd_Const_type */
281
#endif
Christian Schäfer's avatar
Christian Schäfer committed
282

Michael Beck's avatar
BugFix:    
Michael Beck committed
283
static ir_node *
284
new_bd_Const(dbg_info *db, tarval *con) {
285
	ir_graph *irg = current_ir_graph;
Michael Beck's avatar
BugFix:    
Michael Beck committed
286

287
	return new_rd_Const_type (db, irg, con, firm_unknown_type);
Michael Beck's avatar
Michael Beck committed
288
}  /* new_bd_Const */
289

Michael Beck's avatar
BugFix:    
Michael Beck committed
290
static ir_node *
291
new_bd_Const_long(dbg_info *db, ir_mode *mode, long value) {
292
	ir_graph *irg = current_ir_graph;
Michael Beck's avatar
BugFix:    
Michael Beck committed
293

294
	return new_rd_Const(db, irg, new_tarval_from_long(value, mode));
Michael Beck's avatar
Michael Beck committed
295
}  /* new_bd_Const_long */
296

297
#ifdef USE_ORIGINAL
Michael Beck's avatar
BugFix:    
Michael Beck committed
298
static ir_node *
299
300
301
302
303
304
305
306
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
307
}  /* new_bd_Id */
Christian Schäfer's avatar
Christian Schäfer committed
308

Michael Beck's avatar
BugFix:    
Michael Beck committed
309
static ir_node *
Michael Beck's avatar
Michael Beck committed
310
new_bd_Proj(dbg_info *db, ir_node *block, ir_node *arg, ir_mode *mode,
311
312
313
        long proj) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;
314

315
316
	res = new_ir_node (db, irg, block, op_Proj, mode, 1, &arg);
	res->attr.proj = proj;
317

318
319
320
	assert(res);
	assert(get_Proj_pred(res));
	assert(get_nodes_block(get_Proj_pred(res)));
321

322
	res = optimize_node(res);
Christian Schäfer's avatar
Christian Schäfer committed
323

324
325
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
326
}  /* new_bd_Proj */
327
#endif
Christian Schäfer's avatar
Christian Schäfer committed
328

Michael Beck's avatar
BugFix:    
Michael Beck committed
329
static ir_node *
Michael Beck's avatar
Michael Beck committed
330
new_bd_defaultProj(dbg_info *db, ir_node *block, ir_node *arg,
331
332
333
334
335
336
337
338
339
           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
340
}  /* new_bd_defaultProj */
341

Michael Beck's avatar
BugFix:    
Michael Beck committed
342
static ir_node *
343
344
345
346
347
348
349
350
351
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
352
}  /* new_bd_Conv */
Christian Schäfer's avatar
Christian Schäfer committed
353

354
#ifdef USE_ORIGINAL
Michael Beck's avatar
BugFix:    
Michael Beck committed
355
static ir_node *
356
357
358
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;
359

360
	assert(is_atomic_type(to_tp));
Götz Lindenmaier's avatar
Götz Lindenmaier committed
361

362
363
364
365
366
	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
367
}  /* new_bd_Cast */
Christian Schäfer's avatar
Christian Schäfer committed
368

Michael Beck's avatar
BugFix:    
Michael Beck committed
369
static ir_node *
370
371
372
373
374
375
376
377
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
378
}  /* new_bd_Tuple */
Christian Schäfer's avatar
Christian Schäfer committed
379

380
NEW_BD_BINOP(Add)
381
#endif
382
383
384
NEW_BD_BINOP(Sub)
NEW_BD_UNOP(Minus)
NEW_BD_BINOP(Mul)
Michael Beck's avatar
Michael Beck committed
385
NEW_BD_BINOP(Mulh)
386
387
NEW_BD_DIVOP(Quot)
NEW_BD_DIVOP(DivMod)
388
#ifdef USE_ORIGINAL
389
NEW_BD_DIVOP(Div)
390
#endif
391
392
393
394
395
396
397
398
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)
399
NEW_BD_BINOP(Rotl)
400
401
402
NEW_BD_UNOP(Abs)
NEW_BD_BINOP(Carry)
NEW_BD_BINOP(Borrow)
Christian Schäfer's avatar
Christian Schäfer committed
403

404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
/** 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;
}

423
#ifdef USE_ORIGINAL
Michael Beck's avatar
BugFix:    
Michael Beck committed
424
static ir_node *
425
426
427
428
429
430
431
432
433
434
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
435
}  /* new_bd_Cmp */
Christian Schäfer's avatar
Christian Schäfer committed
436

Michael Beck's avatar
BugFix:    
Michael Beck committed
437
static ir_node *
438
439
440
441
new_bd_Jmp(dbg_info *db, ir_node *block) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

442
443
	res = new_ir_node(db, irg, block, op_Jmp, mode_X, 0, NULL);
	res = optimize_node(res);
444
445
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
446
}  /* new_bd_Jmp */
Christian Schäfer's avatar
Christian Schäfer committed
447

Michael Beck's avatar
BugFix:    
Michael Beck committed
448
static ir_node *
449
450
451
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
452

453
454
	res = new_ir_node(db, irg, block, op_IJmp, mode_X, 1, &tgt);
	res = optimize_node(res);
455
456
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
457
}  /* new_bd_IJmp */
Michael Beck's avatar
Michael Beck committed
458

Michael Beck's avatar
BugFix:    
Michael Beck committed
459
static ir_node *
460
461
462
463
new_bd_Cond(dbg_info *db, ir_node *block, ir_node *c) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;

464
	res = new_ir_node(db, irg, block, op_Cond, mode_T, 1, &c);
465
466
467
	res->attr.cond.kind         = dense;
	res->attr.cond.default_proj = 0;
	res->attr.cond.pred         = COND_JMP_PRED_NONE;
468
	res = optimize_node(res);
469
470
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
471
}  /* new_bd_Cond */
472
#endif
Christian Schäfer's avatar
Christian Schäfer committed
473

Michael Beck's avatar
BugFix:    
Michael Beck committed
474
static ir_node *
Michael Beck's avatar
Michael Beck committed
475
new_bd_Call(dbg_info *db, ir_node *block, ir_node *store,
476
477
478
479
480
481
        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;

482
	r_arity = arity + 2;
483
484
485
486
487
488
489
490
491
492
493
494
495
496
	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
497
}  /* new_bd_Call */
Christian Schäfer's avatar
Christian Schäfer committed
498

499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
static ir_node *
new_bd_Builtin(dbg_info *db, ir_node *block, ir_node *store,
               ir_builtin_kind kind, 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 + 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_Builtin, mode_T, r_arity, r_in);

	assert((get_unknown_type() == tp) || is_Method_type(tp));
	res->attr.builtin.exc.pin_state = op_pin_state_pinned;
	res->attr.builtin.kind          = kind;
	res->attr.builtin.builtin_tp    = tp;
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
}  /* new_bd_Buildin */

Michael Beck's avatar
BugFix:    
Michael Beck committed
523
static ir_node *
524
new_bd_Return(dbg_info *db, ir_node *block,
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
              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
540

Michael Beck's avatar
BugFix:    
Michael Beck committed
541
static ir_node *
Michael Beck's avatar
Michael Beck committed
542
new_bd_Load(dbg_info *db, ir_node *block,
543
        ir_node *store, ir_node *adr, ir_mode *mode, ir_cons_flags flags) {
544
545
546
547
548
549
550
	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);
551
	res->attr.load.exc.pin_state = flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned;
552
	res->attr.load.load_mode     = mode;
553
554
	res->attr.load.volatility    = flags & cons_volatile ? volatility_is_volatile : volatility_non_volatile;
	res->attr.load.aligned       = flags & cons_unaligned ? align_non_aligned : align_is_aligned;
555
556
557
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
558
}  /* new_bd_Load */
Christian Schäfer's avatar
Christian Schäfer committed
559

Michael Beck's avatar
BugFix:    
Michael Beck committed
560
static ir_node *
Michael Beck's avatar
Michael Beck committed
561
new_bd_Store(dbg_info *db, ir_node *block,
562
         ir_node *store, ir_node *adr, ir_node *val, ir_cons_flags flags) {
563
564
565
566
567
568
569
570
	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);
571
572
573
574
	res->attr.store.exc.pin_state = flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned;
	res->attr.store.volatility    = flags & cons_volatile ? volatility_is_volatile : volatility_non_volatile;
	res->attr.store.aligned       = flags & cons_unaligned ? align_non_aligned : align_is_aligned;

575
576
577
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
578
}  /* new_bd_Store */
Christian Schäfer's avatar
Christian Schäfer committed
579

Michael Beck's avatar
BugFix:    
Michael Beck committed
580
static ir_node *
Michael Beck's avatar
Michael Beck committed
581
new_bd_Alloc(dbg_info *db, ir_node *block, ir_node *store,
582
        ir_node *size, ir_type *alloc_type, ir_where_alloc where) {
583
584
585
586
587
588
589
590
591
592
593
594
595
	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
596
}  /* new_bd_Alloc */
Christian Schäfer's avatar
Christian Schäfer committed
597

Michael Beck's avatar
BugFix:    
Michael Beck committed
598
static ir_node *
Michael Beck's avatar
Michael Beck committed
599
new_bd_Free(dbg_info *db, ir_node *block, ir_node *store,
600
        ir_node *ptr, ir_node *size, ir_type *free_type, ir_where_alloc where) {
601
602
603
604
605
606
607
608
609
610
611
612
613
	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
614
}  /* new_bd_Free */
Christian Schäfer's avatar
Christian Schäfer committed
615

Michael Beck's avatar
BugFix:    
Michael Beck committed
616
static ir_node *
Michael Beck's avatar
Michael Beck committed
617
new_bd_Sel(dbg_info *db, ir_node *block, ir_node *store, ir_node *objptr,
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
           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
640
}  /* new_bd_Sel */
Christian Schäfer's avatar
Christian Schäfer committed
641

Michael Beck's avatar
BugFix:    
Michael Beck committed
642
static ir_node *
643
644
new_bd_SymConst_type(dbg_info *db, ir_node *block, ir_mode *mode,
                     symconst_symbol value,symconst_kind symkind, ir_type *tp) {
645
	ir_graph *irg = current_ir_graph;
646
	ir_node  *res = new_ir_node(db, irg, block, op_SymConst, mode, 0, NULL);
Christian Schäfer's avatar
Christian Schäfer committed
647

648
649
650
	res->attr.symc.kind = symkind;
	res->attr.symc.sym  = value;
	res->attr.symc.tp   = tp;
Beyhan's avatar
Beyhan committed
651

652
653
654
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
655
}  /* new_bd_SymConst_type */
Christian Schäfer's avatar
Christian Schäfer committed
656

Michael Beck's avatar
BugFix:    
Michael Beck committed
657
static ir_node *
658
659
660
661
662
663
664
665
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
666
}  /* new_bd_Sync */
Christian Schäfer's avatar
Christian Schäfer committed
667

Michael Beck's avatar
BugFix:    
Michael Beck committed
668
static ir_node *
669
new_bd_Confirm(dbg_info *db, ir_node *block, ir_node *val, ir_node *bound, pn_Cmp cmp) {
670
671
672
673
674
	ir_node  *in[2], *res;
	ir_graph *irg = current_ir_graph;

	in[0] = val;
	in[1] = bound;
675
	res = new_ir_node(db, irg, block, op_Confirm, get_irn_mode(val), 2, in);
676
	res->attr.confirm.cmp = cmp;
677
	res = optimize_node(res);
678
679
680
	IRN_VRFY_IRG(res, irg);
	return res;
}  /* new_bd_Confirm */
681

Michael Beck's avatar
BugFix:    
Michael Beck committed
682
static ir_node *
683
684
685
new_bd_Unknown(ir_mode *m) {
	ir_node  *res;
	ir_graph *irg = current_ir_graph;
686

687
688
689
	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
690
}  /* new_bd_Unknown */
691

Michael Beck's avatar
BugFix:    
Michael Beck committed
692
static ir_node *
693
694
695
696
697
698
699
700
701
702
703
704
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
705
}  /* new_bd_CallBegin */
706

Michael Beck's avatar
BugFix:    
Michael Beck committed
707
static ir_node *
708
709
710
711
712
713
714
715
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
716
}  /* new_bd_EndReg */
717

Michael Beck's avatar
BugFix:    
Michael Beck committed
718
static ir_node *
719
720
721
722
723
724
725
726
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
727
}  /* new_bd_EndExcept */
728

Michael Beck's avatar
BugFix:    
Michael Beck committed
729
static ir_node *
730
731
732
733
734
735
736
737
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
738
}  /* new_bd_Break */
739

Michael Beck's avatar
BugFix:    
Michael Beck committed
740
static ir_node *
Michael Beck's avatar
Michael Beck committed
741
new_bd_Filter(dbg_info *db, ir_node *block, ir_node *arg, ir_mode *mode,
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
              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
758
}  /* new_bd_Filter */
759

Michael Beck's avatar
BugFix:    
Michael Beck committed
760
static ir_node *
Michael Beck's avatar
Michael Beck committed
761
new_bd_Mux(dbg_info *db, ir_node *block,
762
763
764
765
           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;
766

767
768
769
	in[0] = sel;
	in[1] = ir_false;
	in[2] = ir_true;
770

771
772
	res = new_ir_node(db, irg, block, op_Mux, mode, 3, in);
	assert(res);
773

774
775
776
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
Michael Beck's avatar
Michael Beck committed
777
}  /* new_bd_Mux */
778

Michael Beck's avatar
Michael Beck committed
779
static ir_node *
Michael Beck's avatar
Michael Beck committed
780
new_bd_CopyB(dbg_info *db, ir_node *block,
781
782
783
784
    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
785

786
787
788
	in[0] = store;
	in[1] = dst;
	in[2] = src;
Michael Beck's avatar
Michael Beck committed
789

790
	res = new_ir_node(db, irg, block, op_CopyB, mode_T, 3, in);
791

792
793
794
795
796
	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
797
}  /* new_bd_CopyB */
Michael Beck's avatar
Michael Beck committed
798

799
static ir_node *
Michael Beck's avatar
Michael Beck committed
800
new_bd_InstOf(dbg_info *db, ir_node *block, ir_node *store,
801
802
803
804
805
806
807
808
809
810
811
812
              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
813
}  /* new_bd_InstOf */
814
815

static ir_node *
816
817
818
819
820
821
822
823
824
825
826
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
827
}  /* new_bd_Raise */
828

Michael Beck's avatar
Michael Beck committed
829
static ir_node *
Michael Beck's avatar
Michael Beck committed
830
new_bd_Bound(dbg_info *db, ir_node *block,
831
832
833
834
835
836
837
838
839
840
841
842
843
844
             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
845
846
847
}  /* new_bd_Bound */

static ir_node *
848
849
850
851
852
853
854
855
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
856
}  /* new_bd_Pin */
Michael Beck's avatar
Michael Beck committed
857

Michael Beck's avatar
Michael Beck committed
858
static ir_node *
Michael Beck's avatar
Michael Beck committed
859
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
860
           int n_outs, ir_asm_constraint *outputs, int n_clobber, ident *clobber[], ident *asm_text) {
Michael Beck's avatar
Michael Beck committed
861
	ir_node  *res;
Michael Beck's avatar
Michael Beck committed
862
863
	ir_graph *irg = current_ir_graph;

Michael Beck's avatar
Michael Beck committed
864
	res = new_ir_node(db, irg, block, op_ASM, mode_T, arity, in);
Matthias Braun's avatar
Matthias Braun committed
865
	res->attr.assem.pin_state = op_pin_state_pinned;
Michael Beck's avatar
Michael Beck committed
866
867
	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
868
	res->attr.assem.clobber   = NEW_ARR_D(ident *, irg->obst, n_clobber);
Matthias Braun's avatar
Matthias Braun committed
869
	res->attr.assem.asm_text  = asm_text;
Michael Beck's avatar
Michael Beck committed
870

Michael Beck's avatar
Michael Beck committed
871
872
873
	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
874

Michael Beck's avatar
Michael Beck committed
875
876
877
878
879
	res = optimize_node(res);
	IRN_VRFY_IRG(res, irg);
	return res;
}  /* new_bd_ASM */

Michael Beck's avatar
BugFix:    
Michael Beck committed
880
881
882
883
/* --------------------------------------------- */
/* private interfaces, for professional use only */
/* --------------------------------------------- */

884
#ifdef USE_ORIGINAL
Michael Beck's avatar
BugFix:    
Michael Beck committed
885
886
887
888
/* 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
889
new_rd_Block(dbg_info *db, ir_graph *irg, int arity, ir_node **in) {
890
891
	ir_graph *rem = current_ir_graph;
	ir_node  *res;
Michael Beck's avatar
BugFix:    
Michael Beck committed
892

893
894
895
	current_ir_graph = irg;
	res = new_bd_Block(db, arity, in);
	current_ir_graph = rem;
Michael Beck's avatar
BugFix:    
Michael Beck committed
896

897
	return res;
Michael Beck's avatar
Michael Beck committed
898
}  /* new_rd_Block */
Michael Beck's avatar
BugFix:    
Michael Beck committed
899
900

ir_node *
901
902
903
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
904

905
906
907
	current_ir_graph = irg;
	res = new_bd_Start(db, block);
	current_ir_graph = rem;
Michael Beck's avatar
BugFix:    
Michael Beck committed
908

909
	return res;
Michael Beck's avatar
Michael Beck committed
910
}  /* new_rd_Start */
Michael Beck's avatar
BugFix:    
Michael Beck committed
911
912

ir_node *
913
914
915
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
916

917
	current_ir_graph = irg;
918
919
	res = new_bd_End(db, block);
	current_ir_graph = rem;
Michael Beck's avatar
BugFix:    
Michael Beck committed
920

921
	return res;
Michael Beck's avatar
Michael Beck committed
922
}  /* new_rd_End */
923
#endif
Michael Beck's avatar
BugFix:    
Michael Beck committed
924
925
926
927

/* Creates a Phi node with all predecessors.  Calling this constructor
   is only allowed if the corresponding block is mature.  */
ir_node *
928
929
930
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
931

932
933
934
	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
935

936
	return res;
Michael Beck's avatar
Michael Beck committed
937
}  /* new_rd_Phi */
Michael Beck's avatar
BugFix:    
Michael Beck committed
938

939
#ifdef USE_ORIGINAL
Michael Beck's avatar
BugFix:    
Michael Beck committed
940
ir_node *
941
new_rd_Const_type(dbg_info *db, ir_graph *irg, tarval *con, ir_type *tp) {
942
943
	ir_node  *res;
	ir_graph *rem = current_ir_graph;
Michael Beck's avatar
BugFix:    
Michael Beck committed
944

945
	current_ir_graph = irg;
946
	res = new_bd_Const_type(db, con, tp);
947
	current_ir_graph = rem;
Michael Beck's avatar
BugFix:    
Michael Beck committed
948

949
	return res;
Michael Beck's avatar
Michael Beck committed
950
}  /* new_rd_Const_type */
951
#endif
Michael Beck's avatar
BugFix:    
Michael Beck committed
952
953

ir_node *
954
new_rd_Const(dbg_info *db, ir_graph *irg, tarval *con) {
955
	ir_node  *res;
956
#ifdef USE_ORIGINAL
957
	ir_graph *rem = current_ir_graph;
Michael Beck's avatar
BugFix:    
Michael Beck committed
958

959
	current_ir_graph = irg;
960
	res = new_bd_Const_type(db, con, firm_unknown_type);
961
	current_ir_graph = rem;
962
963
964
#else
	res = new_rd_Const_type(db, irg, con, firm_unknown_type);
#endif
Michael Beck's avatar
BugFix:    
Michael Beck committed
965

966
	return res;
Michael Beck's avatar
Michael Beck committed
967
}  /* new_rd_Const */
Michael Beck's avatar
BugFix:    
Michael Beck committed
968
969

ir_node *
970
new_rd_Const_long(dbg_info *db, ir_graph *irg, ir_mode *mode, long value) {
971
	return new_rd_Const(db, irg, new_tarval_from_long(value, mode));
Michael Beck's avatar
Michael Beck committed
972
}  /* new_rd_Const_long */
Michael Beck's avatar
BugFix:    
Michael Beck committed
973

974
#ifdef USE_ORIGINAL
Michael Beck's avatar
BugFix:    
Michael Beck committed
975
ir_node *
976
977
978
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
979

980
981
982
	current_ir_graph = irg;
	res = new_bd_Id(db, block, val, mode);
	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_Id */
Michael Beck's avatar
BugFix:    
Michael Beck committed