void fold_stmt_if(stmt *s) { fold_check_expr(s->expr, FOLD_CHK_BOOL, s->f_str()); fold_stmt(s->lhs); if(s->rhs) fold_stmt(s->rhs); }
void fold_stmt_if(stmt *s) { symtable *test_symtab = fold_stmt_test_init_expr(s, "if"); fold_expr(s->expr, test_symtab); fold_need_expr(s->expr, s->f_str(), 1); OPT_CHECK(s->expr, "constant expression in if"); fold_stmt(s->lhs); if(s->rhs) fold_stmt(s->rhs); }
void fold_stmt_label(stmt *s) { label *l = symtab_label_find_or_new( s->symtab, s->bits.lbl.spel, &s->where); /* update its where */ memcpy_safe(&l->where, &s->where); /* update its scope */ l->scope = s->symtab; /* update code the label uses */ l->next_stmt = s; if(l->complete){ warn_at_print_error(&s->where, "duplicate label '%s'", s->bits.lbl.spel); fold_had_error = 1; }else{ l->complete = 1; } s->bits.lbl.label = l; l->unused = s->bits.lbl.unused; fold_stmt(s->lhs); /* compound */ }
void fold_stmt_for(stmt *s) { if(s->flow->for_while){ fold_check_expr( s->flow->for_while, FOLD_CHK_NO_ST_UN | FOLD_CHK_BOOL, "for-test"); } fold_stmt(s->lhs); }
void backprop::complete_change (gimple *stmt) { gimple_stmt_iterator gsi = gsi_for_stmt (stmt); if (fold_stmt (&gsi)) { if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, " which folds to: "); print_gimple_stmt (dump_file, gsi_stmt (gsi), 0, TDF_SLIM); } } update_stmt (gsi_stmt (gsi)); }
void fold_stmt_for(stmt *s) { s->lbl_break = asm_label_flow("for_start"); s->lbl_continue = asm_label_flow("for_contiune"); if(s->flow->for_init_decls){ expr *init_exp = fold_for_if_init_decls(s); UCC_ASSERT(!s->flow->for_init, "for init in c99 for-decl mode"); s->flow->for_init = init_exp; } #define FOLD_IF(x) if(x) fold_expr(x, s->flow->for_init_symtab) FOLD_IF(s->flow->for_init); FOLD_IF(s->flow->for_while); FOLD_IF(s->flow->for_inc); #undef FOLD_IF if(s->flow->for_while){ fold_need_expr(s->flow->for_while, "for-while", 1); OPT_CHECK(s->flow->for_while, "constant expression in for"); } fold_stmt(s->lhs); /* * need an extra generation for for_init, * since it's generated unlike other loops (symtab_new() in parse.c) */ gen_code_decls(s->flow->for_init_symtab); #ifdef SYMTAB_DEBUG fprintf(stderr, "for-code st:\n"); PRINT_STAB(s->lhs, 1); fprintf(stderr, "for-init st:\n"); print_stab(s->flow->for_init_symtab, 0, NULL); fprintf(stderr, "for enclosing scope st:\n"); PRINT_STAB(s, 0); #endif }
void fold_expr_stmt(expr *e, symtable *stab) { stmt *last_stmt; int last; (void)stab; last = dynarray_count(e->code->bits.code.stmts); if(last){ last_stmt = e->code->bits.code.stmts[last - 1]; last_stmt->freestanding = 1; /* allow the final to be freestanding */ last_stmt->expr_no_pop = 1; } fold_stmt(e->code); /* symtab should've been set by parse */ if(last && stmt_kind(last_stmt, expr)){ expr *last_expr = last_stmt->expr; e->tree_type = last_expr->tree_type; if(fold_check_expr(e, FOLD_CHK_ALLOW_VOID, "({ ... }) statement")) { return; } switch(expr_is_lval(last_expr)){ case LVALUE_NO: break; case LVALUE_STRUCT: case LVALUE_USER_ASSIGNABLE: e->f_islval = expr_is_lval_struct; } }else{ e->tree_type = type_nav_btype(cc1_type_nav, type_void); } e->freestanding = 1; /* ({ ... }) on its own is freestanding */ }
void fold_stmt_label(stmt *s) { fold_stmt_goto(s); fold_stmt(s->lhs); /* compound */ }