Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=====================================
- //=========PRINT-NODE-FUCNTION=========
- //=====================================
- 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);
- switch (gimple_code (stmt)) {
- case GIMPLE_ASSIGN:
- fprintf (dump_file, "\n======ASSIGN======\n");
- print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
- break;
- case GIMPLE_CALL:
- fprintf (dump_file, "\n=======CALL=======\n");
- print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
- break;
- case GIMPLE_COND:
- fprintf (dump_file, "\n=======COND=======\n");
- print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
- break;
- case GIMPLE_RETURN:
- fprintf (dump_file, "\n======RETURN======\n");
- print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
- break;
- default:
- break;
- }
- if (gimple_has_mem_ops(stmt)) {
- fprintf (dump_file, "statement has memory operands\n");
- fprintf(dump_file, "statement's number of operands: %d\n", gimple_num_ops(stmt));
- }
- if (gimple_has_volatile_ops(stmt)) {
- fprintf (dump_file, "statement has volatile operands\n");
- }
- if (0 != gimple_num_ops(stmt)) {
- int k;
- for (k = 0; k < gimple_num_ops(stmt); k++) {
- fprintf(dump_file, "operand %d:", k);
- tree tmp_tree = gimple_op(stmt, k);
- print_generic_stmt(dump_file, tmp_tree, TDF_SLIM);
- }
- }
- }
- }
- fclose(dump_file);
- }
- #include <stdio.h>
- #include <time.h>
- #include <stdlib.h>
- int func(int x) {
- return x * 1337;
- }
- int func2(int a, int b) {
- int d = a + b;
- return d;
- }
- int main (void)
- {
- srand(time(NULL));
- int cond = (rand() % 5) -2;
- int b, c, a;
- a = 322;
- c = 1337;
- if (cond > 0) {
- a += func2(a, b);
- } else {
- a -= func2(a, b);
- }
- printf("Hello, World!\n");
- printf("c=%d, a=%d\n", c, a);
- return 0;
- }
- =======CALL=======
- _4 = time (0B);
- statement has memory operands
- statement's number of operands: 4
- operand 0:_4
- operand 1:time;
- operand 2:
- operand 3:0B
- ======ASSIGN======
- _5 = (unsigned int) _4;
- statement has memory operands
- statement's number of operands: 2
- operand 0:_5
- operand 1:_4
- =======CALL=======
- srand (_5);
- statement has memory operands
- statement's number of operands: 4
- operand 0:
- operand 1:srand;
- operand 2:
- operand 3:_5
- =======CALL=======
- _8 = rand ();
- statement has memory operands
- statement's number of operands: 3
- operand 0:_8
- operand 1:rand;
- operand 2:
- ======ASSIGN======
- _9 = _8 % 5;
- statement has memory operands
- statement's number of operands: 3
- operand 0:_9
- operand 1:_8
- operand 2:5
- =======COND=======
- if (_9 > 2)
- operand 0:_9
- operand 1:2
- operand 2:
- operand 3:
- ======ASSIGN======
- a_11 = b_10(D) + 644;
- statement has memory operands
- statement's number of operands: 3
- operand 0:a_11
- operand 1:b_10(D)
- operand 2:644
- ======ASSIGN======
- a_12 = -b_10(D);
- statement has memory operands
- statement's number of operands: 2
- operand 0:a_12
- operand 1:b_10(D)
- =======CALL=======
- __builtin_puts (&"Hello, World!"[0]);
- statement has memory operands
- statement's number of operands: 4
- operand 0:
- operand 1:__builtin_puts;
- operand 2:
- operand 3:&"Hello, World!"[0];
- =======CALL=======
- printf ("c=%d, a=%d\n", 1337, a_1);
- statement has memory operands
- statement's number of operands: 6
- operand 0:
- operand 1:printf;
- operand 2:
- operand 3:"c=%d, a=%d\n";
- operand 4:1337
- operand 5:a_1
- ======RETURN======
- return 0;
- statement has memory operands
- statement's number of operands: 1
- operand 0:0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement