def main(): if len(argv) >= 2 and argv[1] == '-h': print_usage() elif len(argv) >= 3 and argv[1] == '-x': if not path.exists(argv[2]): raise IOError('Invalid file name.') scanner = ILOCScanner() operations, src_regs = scanner.scan_file(argv[2]) allocator = RegisterAllocator(operations, src_regs) allocator.rename_regs() allocator.print_vrs() elif len(argv) >= 3 and argv[1].isdigit(): if not path.exists(argv[2]): raise IOError('Invalid file name.') scanner = ILOCScanner() operations, src_regs = scanner.scan_file(argv[2]) allocator = RegisterAllocator(operations, src_regs) allocator.rename_regs() allocator.alloc_regs(int(argv[1])) allocator.print_prs() else: raise ValueError('Illegal arguments.')
from ILOCScanner import ILOCScanner from RegisterAllocator import RegisterAllocator scanner = ILOCScanner() operations, src_regs = scanner.scan_file("report/report5.i") # print(operations.size) allocator = RegisterAllocator(operations, src_regs) allocator.rename_regs() # allocator.print_vrs() allocator.alloc_regs(5) allocator.print_prs()