Project for CSC 255/455, Ruby Track (using URCC), Spring 2009


Finally, we are glad to announce that our URCC code is ready for Project Part 2. As Chen said in the class, you have a week for this assignment from our release, which means the deadline for Part 2 is Feb.18. You can argue for more time by sending both Instructor and TA an email.
URCC is an experimental C compiler written in Ruby. It takes a C file as input, calls GCC to generate a gimple raw format file, parse the gimple file into rawEntries, construct from rawEntries to Ast intermediate language, transform back into C file format, and then call GCC to compile the new C file into executable. Optimizations can be done on the Ast intermediate representation level.

Check out, Installation and Run

  • Check out the code from file:///p/compiler/repos/urcc by using subversion. Undergrads can get a copy from /home/hoover/u1/cs255/urcc.tar.bz2, which is from version 26. Our URCC is still under development, more bug fixings and improvements are expected in the future. We will send out notices when we have major updates. Then svn update can always get the latest version, and also we will update the corresponding copy in cs255 account.
  • Our top directory has a How_To_Install file to provide instructions for installation. Basically, in order to use urcc from anywhere, just as how you use gcc, you need to add the bin directory into your environment variable PATH, and add the ast directory into your RUBYLIB. For instance, you have the top directory, urcc, under your home directory, and you are using C Shell. Then you need to add the following lines into your .cshrc file
       setenv PATH "$PATH":"$HOME/urcc/bin"
       setenv RUBYLIB "$HOME/urcc/ast"
  • If you are working on undergrad network, you need to change ast/driver.rb file to specify your own GCC 4.2.2 directory (what you built in Project Part 1), since the default GCC 4.1.2 does not well. Somehow, the default GCC on grad network works fine. Search ast/driver.rb for gcc and replace them (of course not the one in the comment) with the position of your own GCC. For those who have a different system, we suggest to use the GCC you built in last assignment.
  • To Run URCC, just type urcc following with your file name, e.g. urcc ab.c. By default, it will generate a ab.c.*.gimple file, the c file generated by urcc ab_urcc.c, and the binary file ab.

Where to Start

  • Take some time to read the documentation for Ast.
  • Your optimizations need to be called after we generate the Ast IR for the whole program. Invoke your optimizations in driver.rb after prog = raw2ast.Construct_Ast(parser.funcList), and before we generate the C file.


  • Most time, I explicitly insert p or print to print the values I care (Bin Bao). If you have better idea or reference to any Ruby debugger, please let me know.
  • If you find any bug in our code, please shoot us with email attaching your test case. If you can also provide a fixing, that will be great.
  • Known Problems
    • Insert Ast::Const nodes with the same numeric value will cause problem. Thus we have slightly changed the loop.c for Project Part 2. We will provide a solution soon.
    • If the end of the string is "\n", sometimes we will lose it during the transformation. This might cause problem for scanf. E.g. run ab we generated from ab.c will require any extra input after providing two numbers. Under fixing.
    • Array supporting will come soon.


Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2009-02-12 - BinBao
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding URCS? Send feedback