static t_myproof_variable *read_operand( tree t, t_myproof_function *function ) { t_myproof_variable *variable = NULL; enum tree_code tc; tc = TREE_CODE( t ); switch ( tc ) { case VAR_DECL: case PARM_DECL: case CONST_DECL: variable = read_data( t, function ); break; case ARRAY_REF: printf("variable pass array_ref\n"); read_operand( TREE_OPERAND(t,0), function ); /* array base */ variable = read_operand( TREE_OPERAND(t,1), function ); /* array index */ /* if ( store == true ) */ /* { */ /* function->nstore++; */ /* } */ /* else */ /* { */ /* function->nload++; */ /* } */ break; case ADDR_EXPR: case INDIRECT_REF: /* pointer & dereferencing */ break; case INTEGER_CST: case REAL_CST: case STRING_CST: /* integer/real/string constant */ break; case SSA_NAME: variable = read_data( SSA_NAME_VAR(t), function ); break; case COND_EXPR: case TARGET_MEM_REF: break; default: fprintf( stderr, "myproof: read_operand(): unhandled \'%s\'\n", tree_code_name[tc] ); gcc_unreachable( ); } return variable; }
static void read_operand( tree t ) { enum tree_code tc; tc = TREE_CODE( t ); /* tree tree_new = TREE_TYPE( t ); */ /* enum tree_code tc_new = TREE_CODE ( t ); */ /* if ( tc_new == REAL_TYPE ) */ /* { */ /* printf("this is a real variable\n"); */ /* } */ /* else if ( tc_new == INTEGER_TYPE ) */ /* { */ /* printf("this is an integer variable\n"); */ /* } */ switch ( tc ) { case VAR_DECL: case PARM_DECL: case CONST_DECL: read_data( t ); break; case ARRAY_REF: read_operand( TREE_OPERAND(t,0) ); /* array base */ read_operand( TREE_OPERAND(t,1) ); /* array index */ break; case ADDR_EXPR: case INDIRECT_REF: /* pointer & dereferencing */ break; case INTEGER_CST: case REAL_CST: case STRING_CST: /* integer/real/string constant */ break; case SSA_NAME: read_data( SSA_NAME_VAR(t) ); break; case COND_EXPR: case TARGET_MEM_REF: break; default: fprintf( stderr, "myproof: read_operand(): unhandled \'%s\'\n", tree_code_name[tc] ); gcc_unreachable( ); } }
void operate(int*num, int*num2, int*num3) // NO printfs allowed here { int *ptr1, *ptr2; if((ptr1 = read_address(1)) && check_address(ptr1, num, num2, num3) && (ptr2 = read_address(2)) && check_address(ptr2, num, num2, num3)) { int operand = read_operand(); // read operand as int char operator = read_operator(); // read operator as char run_operation(ptr1, ptr2, operand, operator); // operate } // endif // done, thank god } // operate();
void operate(int *address1, int *address2, int *address3) { int *ptr1, *ptr2, operand; char operator; ptr1 = read_address(1); // if the user inputs 2 addresses and they are both true call for operand and operator if (check_address(ptr1, address1, address2, address3) && (ptr2 = read_address(2)) && check_address(ptr2, address1, address2, address3)) { operand = read_operand(); operator = read_operator(); run_operation(ptr1, ptr2, operand, operator); } return; }//operate()
static void read_stmt( gimple g, t_myproof_function *function ) { unsigned int i; enum gimple_code gc; gc = gimple_code( g ); switch ( gc ) { case GIMPLE_ASSIGN: { t_myproof_variable *op1 = read_operand( gimple_op(g,1), function ); /* op1 */ if ( op1 ) { op1->visited++; } if ( gimple_num_ops(g) > 2 ) /* op2 */ { t_myproof_variable *op2 = read_operand( gimple_op(g,2), function ); if ( op2 ) { op2->visited++; } } t_myproof_variable *opdef = read_operand( gimple_op(g,0), function ); /* op def */ if ( opdef ) { opdef->modified++; } } break; case GIMPLE_CALL: for ( i = 0; i < gimple_call_num_args(g); ++i ) { read_operand( gimple_call_arg(g,i), function ); } if ( gimple_call_lhs(g) != NULL_TREE ) { read_operand( gimple_call_lhs(g), function ); } break; case GIMPLE_COND: read_operand( gimple_cond_lhs(g), function ); /* op1 */ read_operand( gimple_cond_rhs(g), function ); /* op2 */ break; case GIMPLE_RETURN: if ( gimple_return_retval(g) != NULL_TREE ) { read_operand( gimple_return_retval(g), function ); } break; case GIMPLE_DEBUG: break; default: fprintf( stderr, "myproof: read_stmt(): unhandled \'%s\'\n", gimple_code_name[gc] ); gcc_unreachable ( ); } }
static void read_stmt( gimple g ) { unsigned int i; enum gimple_code gc; gc = gimple_code( g ); /* debug_tree(type1); */ //debug_tree(type1); /* switch ( gc ) */ /* { */ /* case GIMPLE_ASSIGN: */ /* case GIMPLE_CALL: */ /* case GIMPLE_COND: */ /* case GIMPLE_RETURN: */ /* num_all_ops += gimple_num_ops(g); */ /* } */ switch ( gc ) { case GIMPLE_ASSIGN: read_operand( gimple_op(g,1) ); /* op1 */ /* num_all_ops_write++; */ tree type1 = TREE_TYPE( gimple_op( g, 1 ) ); int tc = TREE_CODE( type1 ); if ( tc == REAL_TYPE ) { //debug_tree(type1); /* printf("this is a real variable\n"); */ } /* enum tree_code tr = gimple_assign_rhs_code(g); */ /* printf("Doing %s\n", tree_code_name[tr]); */ if ( gimple_num_ops(g) > 2 ) /* op2 */ { read_operand( gimple_op(g,2) ); } read_operand( gimple_op(g,0) ); /* op def */ break; case GIMPLE_CALL: for ( i = 0; i < gimple_call_num_args(g); ++i ) { read_operand( gimple_call_arg(g,i) ); } if ( gimple_call_lhs(g) != NULL_TREE ) { read_operand( gimple_call_lhs(g) ); } break; case GIMPLE_COND: read_operand( gimple_cond_lhs(g) ); /* op1 */ read_operand( gimple_cond_rhs(g) ); /* op2 */ break; case GIMPLE_RETURN: if ( gimple_return_retval(g) != NULL_TREE ) { read_operand( gimple_return_retval(g) ); } break; case GIMPLE_DEBUG: break; default: fprintf( stderr, "myproof: read_stmt(): unhandled \'%s\'\n", gimple_code_name[gc] ); gcc_unreachable ( ); } }