1 salcianu 1.1 // MIPSOptimizations.java, created Sat Apr 12 15:39:22 2003 by salcianu
 2 salcianu 1.1 // Copyright (C) 2003 Alexandru Salcianu <salcianu@MIT.EDU>
 3 salcianu 1.1 // Licensed under the terms of the GNU GPL; see COPYING for details.
 4 salcianu 1.1 package harpoon.Main;
 5 salcianu 1.1 
 6 salcianu 1.1 import harpoon.Analysis.Quads.CallGraphImpl;
 7 salcianu 1.1 
 8 salcianu 1.1 import harpoon.Backend.Backend;
 9 salcianu 1.1 
10 salcianu 1.1 /**
11 salcianu 1.1  * <code>MIPSOptimizations</code>
12 salcianu 1.1  * 
13 salcianu 1.1  * @author  Alexandru Salcianu <salcianu@MIT.EDU>
14 salcianu 1.1  * @version $Id: MIPSOptimizations.java,v 1.1 2003/04/17 00:19:29 salcianu Exp $
15 salcianu 1.1  */
16 salcianu 1.1 public abstract class MIPSOptimizations {
17 salcianu 1.1     
18 salcianu 1.1     private static boolean enabled() {
19 salcianu 1.1         return 
20 salcianu 1.1             (SAMain.BACKEND == Backend.MIPSDA) ||
21 salcianu 1.1             (SAMain.BACKEND == Backend.MIPSYP);
22 salcianu 1.1     }
23 salcianu 1.1         
24 salcianu 1.1     public static class QuadPass extends CompilerStageEZ {
25 salcianu 1.1         public QuadPass() { super("mips-optimizations.quad-pass"); }
26 salcianu 1.1         public boolean enabled() { return MIPSOptimizations.enabled(); }
27 salcianu 1.1 
28 salcianu 1.1         public void real_action() {
29 salcianu 1.1             hcf = new harpoon.Analysis.Quads.ArrayUnroller(hcf).codeFactory();
30 salcianu 1.1             /*
31 salcianu 1.1               hcf = new harpoon.Analysis.Quads.DispatchTreeTransformation
32 salcianu 1.1               (hcf, classHierarchy).codeFactory();
33 salcianu 1.1             */
34 salcianu 1.1             hcf = harpoon.IR.Quads.QuadSSA.codeFactory(hcf);
35 salcianu 1.1             hcf = new harpoon.ClassFile.CachingCodeFactory(hcf);
36 salcianu 1.1             hcf = new harpoon.Analysis.Quads.SmallMethodInliner
37 salcianu 1.1                 (hcf, classHierarchy);
38 salcianu 1.1             hcf = harpoon.IR.Quads.QuadSSI.codeFactory(hcf);
39 salcianu 1.1             hcf = new harpoon.ClassFile.CachingCodeFactory(hcf);
40 salcianu 1.1             hcf = new harpoon.Analysis.Quads.MemoryOptimization
41 salcianu 1.1                 (hcf, classHierarchy, new CallGraphImpl(classHierarchy, hcf))
42 salcianu 1.1                 .codeFactory();
43 salcianu 1.1             hcf = new harpoon.ClassFile.CachingCodeFactory(hcf);
44 salcianu 1.1         }
45 salcianu 1.1     };
46 salcianu 1.1     
47 salcianu 1.1 
48 salcianu 1.1     public static class TreePass extends CompilerStageEZ {
49 salcianu 1.1         public TreePass() { super("mips-optimizations.tree-pass"); }
50 salcianu 1.1         public boolean enabled() { return MIPSOptimizations.enabled(); }
51 salcianu 1.1 
52 salcianu 1.1         public void real_action() {
53 salcianu 1.1             // unknown if this is strictly needed
54 salcianu 1.1             hcf = new harpoon.ClassFile.CachingCodeFactory(hcf);
55 salcianu 1.1             hcf = harpoon.Analysis.Tree.MemHoisting.codeFactory(hcf);
56 salcianu 1.1             hcf = new harpoon.Analysis.Tree.DominatingMemoryAccess
57 salcianu 1.1                 (hcf, frame, classHierarchy).codeFactory();
58 salcianu 1.1         }
59 salcianu 1.1     };
60 salcianu 1.1 }