CSC451 Project 6 Register Allocation
Goal Implement register allocation based on graph coloring. Download the Project Tests
Download and unzip the tests W for this project under $j/j–.
Run the following command inside the $j/j– directory to compile the j– compiler with your changes:
Copyright By PowCoder代写 加微信 powcoder
To compile a j– program P.java for the MIPS target, using register allocation based on “graph coloring”, run the following command:
Use the -r
Problem 1. (Register Allocation) Modify the file $j/j–/src/jminusminus/NGraphRegisterAllocator.java to implement register alloca- tion algorithm based on graph coloring.
Directions:
• Build liveness intervals.
• Use the liveness intervals to build an interference graph G.
• Apply “degree < r” heuristic to determine if G is r-colorable, where r is the number of physical registers available. • If G is r-colorable, allocate physical registers to the virtual registers — there’s no need to generate spill instructions. • If G is not r-colorable, allocate physical registers to the virtual registers, generating spill instructions as needed.
à ~/workspace/j--
à ~/workspace/j--
$ bash ./bin/j-- -s graph P.java
à ~/workspace/j--
$ spim -f P.s
à ~/workspace/j--
$ $j/j--/bin/j-- -s graph -r 3 project6/Factorial.java $ spim -f Factorial.s
SPIM Version 8.0 of January 8, 2010
Copyright 1990-2010, . Larus.
All Rights Reserved.
See the file README for a full copyright notice. Loaded: /usr/lib/spim/exceptions.s
Before you submit your files, make sure:
• Your code is adequately commented and follows good programming principles.
• You use the template file report.txt for your report. • Your report meets the prescribed guidelines.
Files to submit:
1. NGraphRegisterAllocator.java 2. report.txt