Difference: ProjectHome (13 vs. 14)

Revision 142008-01-28 - ChenDing

Line: 1 to 1
 
META TOPICPARENT name="CS255Spring08"

Project for CSC 255/455, Spring 2008

Introduction

Changed:
<
<
In the project, we add our own passes in Gcc at gimple level. Because Gcc is a real compiler, it looks a little more difficult than previous semesters. You have to know the basic framework of Gcc and how to manipulate gimple tree to do the analyses and transformations. The following resources will help you through the problems. Remember to read the useful tips carefully, especially for them about how to build the working environment. Wish you have a happy journey with Gcc.
>
>
In the project, you will add your own optimization passes in the most recent Gnu C compiler, Gcc 4.2.2. Because Gcc is a real compiler, it is more difficult to use than the teaching compiler used in previous semesters. You have to know the basic framework of Gcc and how to manipulate the intermediate form, the gimple tree, for program analysis and transformation. This page includes many suggestions that will help you in the process. Please read the entire page and the page on source browsing and debugging before you start. Wish you a happy journey with Gcc.
 
Changed:
<
<

Browsing Gcc code and debugging

Gcc Resources

Useful tips

>
>

Installation, compilation, and turn-in

 
  • Check out code and install: see Gcc-4.2.2-cs255 notes on installation
  • Use qsub -I at node64 to get a node to accelerate the make and install: see ClusterJobs
  • To prevent the problem of hardware incompatibility, you'd better build your compiler and use it and run the compiled executables on the same kind of machines.
Line: 29 to 18
 
Changed:
<
<

Part 1: Trivial

In this part, we count and output the number of executed statements of a run of a program. So you need to maintain a global counter which is initialized to 0 and increased before each real gimple statement (i.e. not label statement) and reported when the program exits. Following are the three parts of the instrumented code which are already defined as three functions in cs255-lib.c:
  • Initialization: added at the entry of main function
  • Increasing: added before each statements
  • Report: added at all possible exits of the program
>
>

Browsing Gcc code and debugging

Other Gcc resources

 
Changed:
<
<
This part is very easy. Its purpose is to make you get familiar with Gcc and concentrate on real stuffs of the class after it. What you need to do is to put the code in cs255.c which part is tagged with Do It Yourself. The code for counting the number of basic blocks and statements statically is already in the file. And the code for counting the number of basic blocks dynamically is there too. Read the existing code is the best way to write your own code. Remember to add #include "cs255-lib.h" in your own testing cases.
>
>

Part 1: Trivial

In this part, you will add a pass that will insert code into a program to count and output the number of executed statements when the program executes. You need to first add a call at the beginning of the main function, which has a global counter initialized to 0; then add a call before each gimple statement, which increments the counter; and finally add a call at the exit, which reports the run-time instruction counts. The three functions are provided in cs255-lib.c:
  • Initialization: you'll need to add it at the entry of the main function
  • Increment: to be added before each real gimple statements (all except for labels)
  • Report: to be added at all possible exits of the program
  • Remember to add #include "cs255-lib.h" in your own testing programs.
 
Added:
>
>
This part should take at most tens of lines of code and no more than a day (including half an hour compiling the compiler for the first time). The purpose is to get you familiar with Gcc and the basic Gcc functions that you'll need for adding your optimization passes. In particular for this project, you will write the code in cs255.c at places tagged with string Do It Yourself. The code for counting the number of basic blocks and statements statically is already in the file. The code for getting the dynamic count of the basic blocks is also given.
 
Added:
>
>
Reading the relevant, existing code is the best way to help you writing your new code in an existing system. The next best way is to ask your instructor, TA, and your classmates to find out how to get Gcc to do something. You are encouraged to discuss the project and work out the algorithms on paper or a white or black board with others. The only limitation is that you should not copy other people's code---every line in your submitted code file must be yours.
 

Deleted:
<
<
-- XiaomingGu - 16 Jan 2008
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding URCS? Send feedback