Welcome to the course homepage. Your instructor is Uday Khedker and TA is Sameera Deshpande. Please see the proposal document of this course to get an idea of the nature of the course.
Announcements
(14 Nov 2008). I am planning to float several R&D projects
(CS 691) on GCC in the next semester. I have listed some topics below.
Your suggestions about possible topics are most welcome.
(2 Nov 2008). Here is a report describing incremental construction of machine descriptions.
See the file optabs.h
in gcc
subdirectory
to find a list of the pattern names known to GCC.
(17 Oct 2008). On second thoughts, I have decided to divide assignment 5 into two parts.
no-libgcc
option by cc1
option. The deadline for this assignment is Sat 15 Nov.(17 Oct 2008). I will evaluate your 4th assignment on Wed 22 Oct.
(17 Oct 2008). As described in the lecture on Wed 15 Oct, your 5th assignment is to extend the spim machine descriptions for level 4 in the following manner.
(29 Sep 2008). Your 3rd assignment was to traverse the call
graph and print details of function calls and usage of global
variables. Your 4th assignment is to traverse the RTL level CFG and
print a more understandable RTL code by using "=" for set operations,
converting prefix expressions into infix, and using familiar symbols
for operations. All organizationsl details of the data structures,
comments, and auxilliary information must be skipped. For example,
consider the following RTL code dumped in file.c.13.cfg
for
an assignment statement
c = a
+ b.
Basic
block 1 prev -1, next -2, loop_depth 0, count 0, freq 0.
Predecessors: ENTRY
(fallthru)
Successors: EXIT
[100.0%] (fallthru)
(note 2 0 4 NOTE_INSN_DELETED)
(note 4 2 7 0
NOTE_INSN_FUNCTION_BEG)
;; Start of basic block 1,
registers live: (nil)
(note 7 4 9 1 [bb 1]
NOTE_INSN_BASIC_BLOCK)
(insn 9 7 10 1 (set (reg:SI 61 [
c ])
(mem/c/i:SI (plus:SI (reg/f:SI 20 frame)
(const_int -4 [0xfffffffc])) [0 c+0 S4 A32])) 34 {*movsi_1} (nil)
(nil))
(insn 10 9 11 1 (parallel [
(set (reg:SI 60)
(plus:SI (mem/c/i:SI (plus:SI (reg/f:SI 20 frame)
(const_int -8 [0xfffffff8])) [0 b+0 S4 A32])
(reg:SI 61 [ c ])))
(clobber (reg:CC 17 flags))
]) 148 {*addsi_1} (nil)
(nil))
(insn 11 10 12 1 (set (mem/c/i:SI
(plus:SI (reg/f:SI 20 frame)
(const_int -12 [0xfffffff4])) [0 a+0 S4 A32])
(reg:SI 60)) 34 {*movsi_1} (nil)
(expr_list:REG_EQUAL (plus:SI (mem/c/i:SI (plus:SI (reg/f:SI 20 frame)
(const_int -8 [0xfffffff8])) [0 b+0 S4 A32])
(mem/c/i:SI (plus:SI (reg/f:SI 20 frame)
(const_int -4 [0xfffffffc])) [0 c+0 S4 A32]))
(nil)))
(note
12 11 16 1 NOTE_INSN_FUNCTION_END)
(insn 16 12 17 1 (clobber
(reg/i:SI 0 ax)) -1 (nil)
(nil))
(insn 17 16 21 1 (clobber (reg:SI
58 [ <result> ])) -1 (nil)
(nil))
(insn 21 17 0 1 (use (reg/i:SI 0
ax)) -1 (nil)
(nil))
;; End of basic block 1,
registers live:
(nil)
;;
Start of basic block 1, PRED Blocks: ENTRY (fallthru), SUCC Blocks:
EXIT (fallthru)
;; SI Registers: r60, r20, r61,
r0, r58
;; Address Registers: r20
r61 = *(r20 - 4)
r60 = *(r60 - 8) + r61 || clobber
r17
*(r20 - 12) = r60
clobber r0
clobber r58
use r0
;; End of basic block 1
gccint.pdf
for details. The
submission deadline for this assignment is 12:00 noon on Sunday 12 Oct.
2008.(29 Aug 2008). Here are some tips that might help you in assignment 2.
tcc_statement
and tcc_expression
in files tree.def
and tree.h
. Find out the relevant
statements, expressions, and assignment statements.NULL
pointer. When this occurs
while building gcc, it means that a change made by you has caused
the resulting compiler in accesing illegal memory when it is used to
compile the GCC source. Disabling the added code and rebuilding the
compiler can help you to debug your code. This has to be done
repeatedly by progressively enabling chunks of disabled code. $SOURCE/gcc/common.opt,
$BUILD/gcc/options.h
, and $BUILD/gcc/options.c
. These
options may not be available if you compile cc1 independently as in the
previous case. This is because the options are processed by the driver.
Still you need not do the complete build after every small change. I
have found the following approach very effective in speeding up the
process: I do the complete build for the first time and then for
subsequent builds, I give make
cc1
command $BUILD/gcc/.
Unlike
first assignment, this does not require adding cc1 option in the top
level make file. After this, the
make install
command
in the top level directory copies the newly built cc1
to the libexec directory thereby making the new
cc1
available to the gcc
driver.
(22 Aug 2008). Details of assingment 2. You have to add a pass
that will traverse gimple cfg in GCC 4.3.1
Generate the following statistics for each function processed: Number of global variables, number of local variables, number of scalar variables, number of aggregate variables (i.e. structures, arrays, pointers, unions etc.) number of assignment statements, number of function calls, number of unconditional branches, number of conditional branches, number of conditions, number and values of numeric constants, number of four arithmetic operations (+,-,*,/), number of copy statements.
You have to submit a patch of your implementation by Wed 3
Sept. 13:00 hours.
Additional work in any project will get additional credit.
(22 Aug 2008). Slides
on
machine independent phases of GCC.
(15 Aug 2008). Use the option "--enable-languages=c
" option
for your assignment to build cc1
.
(14 Aug 2008). Some of you have shown interest in knowing how I have implemented the configuration system required in your earlier assignment. I have updated the simple compiler implementation html pages that point to the required files. Observe the additional configuration that I have set up.
(14 Aug 2008). In yesterday's lecture, we compiled the programs empty.c
,
and add-global.c
using the command "gcc
-fdump-tree-all -da -S
" and examined the following dump
files: AST (.c.t00.tu
),
Gimple (.c.t03.gimple
and .c.t21.cfg
),
RTL (.c.00.expand
, .c.13.cfg
, .c.58.shorten
), and Assembly (.s
). Repeat the experiment for
add-global-return.c
,
add-global-assign.c
,
add-local.c
, add-local-return.c
,
and add-local-assign.c
.
Subsequent steps in understanding compilation are to consider the
following features: more complex expressions, arrays and structures,
loops, and function calls with and without parameters.
(14 Aug 2008). Assignment 1. Modify the configuration and build
process of GCC 4.3.1 such that after the configure
command, it is
possible to give a command "make
cc1
" from the top level build directory to build only cc1
. This assignment is due on
Friday 22 Aug.
(14 Aug 2008). An
interesting (but old) discussion about configuration and build tools.
(2 Aug 2008). For your assignment, you may want to read this seminar report on configuration and build tools.
(1 Aug 2008). In your first assignment, you have to build a configuration system that builds ceCC by checking the following:
lex
, yacc
, or iburg
are not available,
the configuration must abort with a suitable error message. spim
is not available,
the configuration should just give a warning but the compiler must be
built. gv
is not available, the
configuration should check for kghostview
and replace
the use of gv
in the code by kghostview
and the compiler should be built. dot
is not available,
the configuration should avoid compiling the code that uses dot
. The file ce-show-tree.c
should
also be excluded from compilation but rest of the compiler must be
built. (1 Aug 2008). Slides that were used in today's lecture have been uploaded.
(1 Aug 2008). Simple compiler which we will study in today's lecture.
(30 July 2008). Many of you have asked me several questions outside of the class. These questions indicate that many of you have not seen a compiler source code and some of you have not used make before. Hence I have decided to change the schedule a bit. Instead of the lab exercise on Friday, we will have a lecture and I will explain to you the source of a topy compiler. Our first lab experiment will involve enhancing this toy compiler and building a configuration system for it. Hence we meet in SIC 305/304 on Friday, 1st August rather than in NSL.
(30 July 2008). Slides
of today's
lectures. I have updated the slides to remove the confusion about
building a cross compiler. Also, the statement about --prefix
is correct.
(29 July 2008). Most of the GCC sources are available locally on IITB ftp server.
You may need the sources of
GCC 4.0.2 and
GCC 4.3.0 only in the course. Please avoid downloading them from
external sources. Please make sure that you have adequate space in your
account before you download these sources The .tar.bz2 file for GCC
4.0.2 is 30.3 MB which inflates to 378 MB on
untarring. The corresponding sizes for GCC 4.3.0 are 56.6 MB
and 511 MB. The build directories take more space than the
extracted source directories.
I will to talk to the system administrators to find out if they would
prefer this work to be done on specific machines only. Until then
please avoid compiling the GCC source on commonly used servers.
(27 July 2008). Slides
of first two
lectures and the demo
examples will
be put up some time tonight.
(27 July 2008). Our documentation on GCC can be found on the GCC Resource Center website.