Experiments for GCC Mini Workshop ----------------------------------- These experiments work with GCC version 4.0.2 only. You will need to download the source of GCC 4.0.2 from http://gcc.gnu.org. 1) Apply the given patch for adding spim machine descriptions to GCC sources. To do this, change the working directory to . Give the command patch -p1 < Move the spim directory to /gcc/config. Build various levels of spim to see language features being supported at different levels. The details of these levels can be found in the hand outs (also available from http://www.cse.iitb.ac.in/~uday/gcc-workshop). spim can be built by changing working directory to and giving commands: /configure --prefix= --enable-languages=c --target=spim --no-libgcc make make install 2) Build spim compiler with --no-libgcc flag enabled at configure time. Build it without --no-libgcc flag enabled. Observe the output of build processes. What is the difference? Why does it occur? 3) Take the spim machine description (spimB) given to you. Build compiler for it. Try to compile following program: int i,k; int foo(int a) { return a; } * Why does the compilation process fail? * Which instruction should be added in order to compile the above given program successfully? 4) Take the spim machine description (spimA) given to you. Build compiler for it. Try to compile following program: int i,k; int foo(int a) { return (i+k*a); } * Why does the compilation process fail? * Which instruction should be added in order to compile the above given program successfully? * What should happen if that instruction is added to yhr machine description? Can you explain it intuitively (i.e. without bringing in GCC data structures)? * Compare the assembly file generated by this experiment with the one generated by spim4 specification. * What is to be done in order to generate assembly output similar to that generated by spim4 specification? 5) Consider the following program. int i ; int j ; int k ; int main (void) { int t; t = i * j; return t * k; } Draw the pipeline stages as used by the various stages as shown in the handouts to look at the way the various functional units are used across time. Verify the same result with the GCC dumps that you see. You can get the dumps by looking at the output with the -dS and -dR commands.