10.07.2015 Views

MIPS - AG Softwaretechnik

MIPS - AG Softwaretechnik

MIPS - AG Softwaretechnik

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

append wrapper procedures to your code during pretty-printing that will helpyou with this. They are:– _print: prints the content of register a0. Modifies a0,v0.– _halloc: allocates the number of bytes in a0 and leaves a pointer to thenewly allocated memory in v0. Modifies a0.– _error: prints “ERROR” and aborts.• The Spim website contains a statically-linked Spim 9.0.5 binary for Linux, whichthe KangaToMips tests use to compare the output of Kanga programs in theinterpreter with the output of your <strong>MIPS</strong> programs in Spim. Unfortunately,there is no headless Spim for Windows, so the test tool chain works on Linuxonly.Register Allocation by Graph coloringThis last part of the project consists of two parts, combining the theoretical and practicalaspects of register allocation.Liveness Analysis (5 Points = 5%)• Specify an (intra-procedural) liveness analysis for Spiglet.– In Spiglet, each procedure basically consists of a list of possibly labeledstatements. Each statement is uniquely identified by its position in the list.For a procedure S 0 . . . S n , we definepos(S 0 . . . S n ) = {0, . . . , n}to be the set of all possible positions within a procedure. We define as theentry point of the procedureand further as the exit pointinitial(S 0 . . . S n ) = 0final(S 0 . . . S n ) = nThe flow equations are now a mapping of labeled statement (with position)to a set of two positions denoting an edge in the flow graph.Example:flow([l : NOOP] i ) = {(i, i + 1)} ∀i ∈ {0, . . . , n − 1}Specify in a similar way the flow equations for all statement types in Spiglet.– For each statement, specify the use and def sets of temporaries. You maywant to define auxiliary definitions for expressions etc.The formal specification should be submitted as a PDF. An example for sucha specification can be found in Nielson et al., Principles of Program Analysis,Springer 2005, Chapter 2.1 and 2.1.4. (There, use sets are called gen sets, anddefs sets are called kill sets. Further, the labels they use do not correspond tolabels in SPiglet, but to the position of a statement in the statement list of aprocedure. )• Implement the construction of the flow graph and the liveness analysis for Spiglet.Test your liveness analysis thoroughly; debugging bad liveness information byobserving misbehaving Kanga programs is not fun.


Register allocation (10 Points = 10%)• Implement the register allocation algorithm using graph coloring for SPiglet and acorresponding transformation of SPiglet to Kanga. Remember that each methodcall requires some prologue and epilogue for caller and callee. Remember that forKanga, you need to take care of arguments, caller-save and callee-save registers,and the return value. (The interpreter handles the stack pointer).For these parts, you can and should reuse parts of your solution from Sheet 5.• To simplify things, you may assume that the interference graph of the temporariesis always colorable, i.e. spilling and coalescing is not needed. (Beware, youwill still need to spill arguments when a procedure call requires more than 4arguments!)• Write a description of your implementation.Bonus Task: Spilling and coalescing (up to 10 Points)• Change your register allocation algorithm such that it can also spill if necessary.• Improve it further by coalescing source and destination nodes of move instructions.• To get points for this task, you are required to have already implemented thesimplified register allocation correctly!Submission• Deadline: 22. July 2013, 23:59 (extended!).• Late submissions will not be accepted.• Submit your solution via your group’s Mercurial repository.• The description may be either German or English. Clear and understandablestyle is required.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!