Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=====================================
- //=========PRINT-NODE-FUCNTION=========
- //=====================================
- /*
- void print_stmt(gimple stmt)
- {
- int i;
- switch (gimple_code(stmt)) {
- case GIMPLE_ASM:
- printf("asm code\n");
- break;
- case GIMPLE_CALL: {
- tree callee = gimple_call_fndecl (stmt);
- if (callee != NULL_TREE) {
- if (strcmp(function_name(DECL_STRUCT_FUNCTION(callee)), "(nofn)")) {
- printf("function with name %s and %d arguments %d\n",function_name(DECL_STRUCT_FUNCTION(callee)), gimple_call_num_args (stmt), strcmp(function_name(DECL_STRUCT_FUNCTION(callee)), "(nofn)"));
- for (i=0; i<gimple_call_num_args(stmt); i++) {
- tree arg = gimple_call_arg(stmt, i);
- printf("%d ", i);
- //print_tree_obj(arg);
- }
- }
- }
- } break;
- case GIMPLE_ASSIGN: {
- tree lhs = gimple_assign_lhs(stmt);
- int count = gimple_num_ops(stmt);
- printf("assign with %d arguments\n", count-1);
- switch (count-1) {
- case 1: {
- tree rhs = gimple_assign_rhs1 (stmt);
- enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
- switch (rhs_code) {
- PRINT_CASE( VIEW_CONVERT_EXPR );
- PRINT_CASE( ASSERT_EXPR );
- PRINT_CASE( FIXED_CONVERT_EXPR );
- PRINT_CASE( ADDR_SPACE_CONVERT_EXPR );
- PRINT_CASE( FIX_TRUNC_EXPR );
- PRINT_CASE( FLOAT_EXPR );
- PRINT_CASE( PAREN_EXPR );
- PRINT_CASE( ABS_EXPR );
- PRINT_CASE( NEGATE_EXPR );
- default:
- if (TREE_CODE_CLASS (rhs_code) == tcc_declaration) {
- if (DECL_NAME(rhs)) {
- printf("declaration %s\n", identifier_to_locale (IDENTIFIER_POINTER (DECL_NAME(rhs))));
- } else {
- printf("declaration <unknown name>\n");
- }
- } else if (TREE_CODE_CLASS (rhs_code) == tcc_constant) {
- printf("constant\n");
- print_tree_obj(rhs);
- } else {
- printf("default %d\n", rhs_code);
- }
- }
- } break;
- case 2: {
- } break;
- case 3: {
- } break;
- }
- } break;
- case GIMPLE_RESX: {
- printf("GIMPLE_RESX\n");
- } break;
- case GIMPLE_RETURN: {
- printf("GIMPLE_RETURN\n");
- } break;
- case GIMPLE_SWITCH: {
- printf("GIMPLE_SWITCH\n");
- } break;
- case GIMPLE_TRY: {
- printf("GIMPLE_TRY\n");
- } break;
- case GIMPLE_GOTO: {
- printf("GIMPLE_GOTO\n");
- } break;
- case GIMPLE_COND: {
- printf("GIMPLE_COND\n");
- //tree left = gimple_cond_lhs (gs);
- //tree right = gimple_cond_rhs (gs);
- } break;
- default: {
- printf("default case %d\n", gimple_code(stmt));
- }
- }
- printf("\n");
- }
- */
- static void
- print_nodes()
- {
- printf("===PRINTING NODES===\n");
- basic_block bb;
- //FILE* dump_file = fopen("optlab1.txt", "w");
- FOR_EACH_BB_FN (bb, cfun)
- {
- gimple_stmt_iterator gsi;
- for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) {
- gimple stmt = gsi_stmt (gsi);
- //print_stmt(stmt);
- }
- }
- //fclose(dump_file);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement