*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+# include "config.h"
+#endif
+
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
#endif
# include "irgraph_t.h"
# include "iropt_t.h"
# include "irgmod.h"
# include "array.h"
-/* memset belongs to string.h */
-# include "string.h"
# include "irbackedge_t.h"
# include "irflag_t.h"
*/
static default_initialize_local_variable_func_t *default_initialize_local_variable = NULL;
-/*** ******************************************** */
-/** privat interfaces, for professional use only */
+/* -------------------------------------------- */
+/* privat 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
/* res->attr.block.exc = exc_normal; */
/* res->attr.block.handler_entry = 0; */
- res->attr.block.irg = irg;
- res->attr.block.backedge = new_backedge_arr(irg->obst, arity);
- res->attr.block.in_cg = NULL;
+ res->attr.block.dead = 0;
+ 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;
IRN_VRFY_IRG(res, irg);
INLINE ir_node *
new_rd_Const (dbg_info* db, ir_graph *irg, ir_node *block, ir_mode *mode, tarval *con)
{
- type *tp = unknown_type;
+ type *tp = firm_unknown_type;
/* removing this somehow causes errors in jack. */
return new_rd_Const_type (db, irg, block, mode, con, tp);
}
{
ir_node *res;
+ assert(is_atomic_type(to_tp));
+
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);
INLINE ir_node *
new_rd_SymConst_type (dbg_info* db, ir_graph *irg, ir_node *block, symconst_symbol value,
- symconst_kind symkind, type *tp)
-{
+ symconst_kind symkind, type *tp) {
ir_node *res;
ir_mode *mode;
mode = mode_P_mach;
else
mode = mode_Iu;
+
res = new_ir_node(db, irg, block, op_SymConst, mode, 0, NULL);
res->attr.i.num = symkind;
new_rd_SymConst (dbg_info* db, ir_graph *irg, ir_node *block, symconst_symbol value,
symconst_kind symkind)
{
- ir_node *res = new_rd_SymConst_type(db, irg, block, value, symkind, unknown_type);
+ ir_node *res = new_rd_SymConst_type(db, irg, block, value, symkind, firm_unknown_type);
return res;
}
res = optimize_node(res);
IRN_VRFY_IRG(res, irg);
return res;
+}
+INLINE ir_node *
+new_rd_NoMem (ir_graph *irg) {
+ return irg->no_mem;
}
-ir_node *
-new_rd_FuncCall (dbg_info* db, ir_graph *irg, ir_node *block,
- ir_node *callee, int arity, ir_node **in, type *tp)
+INLINE ir_node *
+new_rd_Mux (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode)
{
- ir_node **r_in;
+ ir_node *in[3];
ir_node *res;
- int r_arity;
- r_arity = arity+1;
- NEW_ARR_A(ir_node *, r_in, r_arity);
- r_in[0] = callee;
- memcpy(&r_in[1], in, sizeof (ir_node *) * arity);
+ in[0] = sel;
+ in[1] = ir_false;
+ in[2] = ir_true;
- res = new_ir_node(db, irg, block, op_FuncCall, mode_T, r_arity, r_in);
+ res = new_ir_node(db, irg, block, op_Mux, mode, 3, in);
+ assert(res);
- assert(is_method_type(tp));
- set_FuncCall_type(res, tp);
- res->attr.call.callee_arr = NULL;
res = optimize_node(res);
IRN_VRFY_IRG(res, irg);
return res;
ir_mode *mode, long proj) {
return new_rd_Filter(NULL, irg, block, arg, mode, proj);
}
-INLINE ir_node *new_r_FuncCall (ir_graph *irg, ir_node *block,
- ir_node *callee, int arity, ir_node **in,
- type *tp) {
- return new_rd_FuncCall(NULL, irg, block, callee, arity, in, tp);
+INLINE ir_node *new_r_NoMem (ir_graph *irg) {
+ return new_rd_NoMem(irg);
+}
+INLINE ir_node *new_r_Mux (ir_graph *irg, ir_node *block,
+ ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode) {
+ return new_rd_Mux(NULL, irg, block, sel, ir_false, ir_true, mode);
}
}
ir_node *
-new_d_FuncCall (dbg_info* db, ir_node *callee, int arity, ir_node **in,
- type *tp)
+(new_d_NoMem)(void)
{
- ir_node *res;
- res = new_rd_FuncCall (db, current_ir_graph, current_ir_graph->current_block,
- callee, arity, in, tp);
+ return __new_d_NoMem();
+}
- return res;
+ir_node *
+new_d_Mux (dbg_info *db, ir_node *sel, ir_node *ir_false,
+ ir_node *ir_true, ir_mode *mode) {
+ return new_rd_Mux (db, current_ir_graph, current_ir_graph->current_block,
+ sel, ir_false, ir_true, mode);
}
/* ********************************************************************* */
/* creates a new dynamic in-array as length of in is -1 */
res = new_ir_node (db, current_ir_graph, NULL, op_Block, mode_BB, -1, NULL);
current_ir_graph->current_block = res;
- res->attr.block.matured = 0;
+ res->attr.block.matured = 0;
+ res->attr.block.dead = 0;
/* res->attr.block.exc = exc_normal; */
/* res->attr.block.handler_entry = 0; */
- res->attr.block.irg = current_ir_graph;
- res->attr.block.backedge = NULL;
- res->attr.block.in_cg = NULL;
+ res->attr.block.irg = current_ir_graph;
+ res->attr.block.backedge = NULL;
+ res->attr.block.in_cg = NULL;
res->attr.block.cg_backedge = NULL;
set_Block_block_visited(res, 0);
ir_node *new_Const (ir_mode *mode, tarval *con) {
return new_d_Const(NULL, mode, con);
}
+
+ir_node *new_Const_type(tarval *con, type *tp) {
+ return new_d_Const_type(NULL, get_type_mode(tp), con, tp);
+}
+
ir_node *new_SymConst (symconst_symbol value, symconst_kind kind) {
return new_d_SymConst(NULL, value, kind);
}
ir_node *new_Filter (ir_node *arg, ir_mode *mode, long proj) {
return new_d_Filter(NULL, arg, mode, proj);
}
-ir_node *new_FuncCall (ir_node *callee, int arity, ir_node **in, type *tp) {
- return new_d_FuncCall(NULL, callee, arity, in, tp);
+ir_node *new_NoMem (void) {
+ return new_d_NoMem();
+}
+ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode) {
+ return new_d_Mux(NULL, sel, ir_false, ir_true, mode);
}