Compilers (CS362 2002F)

Exploring Compilation

Summary: Today, you will explore various issues in compilation. While you have used a compiler before (or I hope you have), I expect you haven't thought much about various options and details.

Disclaimer: You come to this lab with widely varying backgrounds. Some of you have programmed in C, some of you haven't; some of you have written (or read) some assembly language, some of you haven't; some of you are Unix experts, some of you aren't. Don't worry if you can't finish the lab (or if you finish it in five minutes).

Collaboration: Feel free to work on this lab in pairs or trios.

Turning It In: Save your answers in a plain text file and submit it using the ECA.

Grading: I expect that you will gain more from doing this lab than from me grading this lab. I will simply scan through your answers to see if you had any particularly valuable insights.

Questions:

1. GCC's Stages

Read information on the GNU Compiler Collection (gcc) and determine which of its intermediate program representations are available to you. You might use man or info to learn more about gcc.

Summarize the intermediate representations available to you.

2. A Sample C Program

Here's a sample C program. Generate the intermediate representations and scan through those that you can read.

What, if anything, did you learn about the intermediate representations?

3. C vs. Pascal

Here are a Pascal program and a C program that print the phrase Hello World. Have gcc generate assembly code for the two programs.

Note that you may have to use the Pascal compiler (pc) on erdos.

How do the results differ? How are they similar?

4. GCC's Intermediate Representations, Revisited

Look on the Web for internal documentation on GCC. Explore which, if any, internal program representations are available to those building new GCC compilers.

Describe, in as much detail as you deem appropriate, the intermediate representations available and their purpose.

GCC Source

If you think it might be useful, you can find a copy of the GCC source code at /home/rebelsky/Web/Courses/Examples/gcc-3.2.tar.gz. You can find a list of files in that archive with

% zcat gztarfile | tar tvf - | less

You can extract a particular file with

% zcat gztarfile | tar xvf - file 

 

History

Monday, 2 September 2002

  • Designed.

Tuesday, 3 September 2002

  • Created.

 

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Tue Dec 10 08:53:24 2002.
The source to the document was last modified on Tue Sep 3 08:50:45 2002.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS362/2002F/Labs/lab.01.html.

You may wish to validate this document's HTML ; Valid CSS! ; Check with Bobby

Glimmer Labs: The Grinnell Laboratory for Interactive Multimedia Experimentation & Research
glimmer@grinnell.edu