1. Understand various compilation options in gcc
Consider the following code snipets.
Run mobaxterm tool. 2. Access server using ssh. 3. Run scl enable devtoolset-7 bash 4. Run gcc -E pgm1.c -o pgm1.i 5. Understand the option −E in the above command and analyse the same by comparing pgm1.c ﬁle and pgm1.i.
Run gcc -fdump-tree-all-graph pgm1.c -o pgm1 2. Run dot -Tpng pgm1.c.011t.cfg.dot -o pgm1.png 3. Run display pgm1.png and analyse the output by comparing against the C ﬁle pgm1.c.
Run gcc -S -m32 pgm1.c -fverbose-asm -o pgm1-p1.s 2. Run gcc -S -m32 -O2 pgm1.c -fverbose-asm -o pgm1-p2.s 3. Compare the ﬁles pgm1-p1.s and pgm1-p2.s 4. Compare the RTL representation in the ﬁle pgm1.png against the code in pgm1-p1.s/pgm1p2.s
Repeat the same using ﬁles pgm2.c and pgm3.c.
2. Design a mini compiler
Write a program in C which takes another C program as input and checks whether the input ﬁle contains a C statement of the form X = Y + Z; where X, Y and Z are variables. For each statement of the above form, check whether the variables are declared. You could assume each C statement to be present in a separate line and each variable to be declared in a separate line. Further, the only supported data type is “int”