X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;ds=sidebyside;f=Repair%2FRepairCompiler%2FMCC%2FCLI.java;h=b8cce23e2c2b62857c1e25ab22ac50ac2be1c935;hb=e8e7caf9f4a4e0c49fdfe97fc529703ebd8a4d8c;hp=609455ac2bd4484b332908f3313035b0643a2c1a;hpb=ca628f50b6dedc5c650dea4c6862260efba76136;p=repair.git diff --git a/Repair/RepairCompiler/MCC/CLI.java b/Repair/RepairCompiler/MCC/CLI.java index 609455a..b8cce23 100755 --- a/Repair/RepairCompiler/MCC/CLI.java +++ b/Repair/RepairCompiler/MCC/CLI.java @@ -1,7 +1,8 @@ package MCC; -import java.util.Vector; -import java.util.StringTokenizer; +import java.util.*; +import MCC.IR.DebugItem; +import MCC.IR.RepairGenerator; /** * A generic command-line interface for 6.035 compilers. This class @@ -11,47 +12,9 @@ import java.util.StringTokenizer; * files. * * @author le01, 6.035 Staff (6.035-staff@mit.edu) - * @version $Id: CLI.java,v 1.2 2004/04/15 05:41:46 bdemsky Exp $ + * @version $Id: CLI.java,v 1.20 2005/11/09 16:47:42 bdemsky Exp $ */ public class CLI { - /** - * Target value indicating that the compiler should produce its - * default output. - */ - public static final int DEFAULT = 0; - - /** - * Target value indicating that the compiler should scan the input - * and stop. - */ - public static final int SCAN = 1; - - /** - * Target value indicating that the compiler should scan and parse - * its input, and stop. - */ - public static final int PARSE = 2; - - /** - * Target value indicating that the compiler should produce a - * high-level intermediate representation from its input, and stop. - * This is not one of the segment targets for Fall 2000, but you - * may wish to use it for your own purposes. - */ - public static final int INTER = 3; - - /** - * Target value indicating that the compiler should produce a - * low-level intermediate representation from its input, and stop. - */ - public static final int LOWIR = 4; - - /** - * Target value indicating that the compiler should produce - * assembly from its input. - */ - public static final int ASSEMBLY = 5; - /** * Array indicating which optimizations should be performed. If * a particular element is true, it indicates that the optimization @@ -59,13 +22,13 @@ public class CLI { * should be performed. */ public boolean opts[]; - + /** * Vector of String containing the command-line arguments which could * not otherwise be parsed. */ public Vector extras; - + /** * Vector of String containing the optimizations which could not be * parsed. It is okay to complain about anything in this list, even @@ -77,49 +40,19 @@ public class CLI { * Name of the file to put the output in. */ public String outfile; - + /** * Name of the file to get input from. This is null if the user didn't * provide a file name. */ public String infile; - /** - * The target stage. This should be one of the integer constants - * defined elsewhere in this package. - */ - public int target; - /** * The debug flag. This is true if -debug was passed on * the command line, requesting debugging output. */ public boolean debug; - /** - * Native MIPS architecture is specified by "-native". The default - * is SPIM. - */ - public boolean fNative; - - /** - * Runs IRVis on final node tree. - */ - public boolean fVis; - public String visClass; - public String visMethod; - - /** - * Dumps the before and after Node structure to two files that can be diffed. - */ - public boolean fDiff; - public String diffFile; - - /** - * Maximum optimization iterations. - */ - public int numIterations = 5; - /** * Verbose output */ @@ -134,16 +67,9 @@ public class CLI { public CLI() { outfile = null; infile = null; - target = DEFAULT; extras = new Vector(); extraopts = new Vector(); - fNative = false; - fVis = false; verbose = 0; - visClass = ""; - visMethod = ""; - fDiff = false; - diffFile = ""; } /** @@ -173,23 +99,66 @@ public class CLI { opts = new boolean[optnames.length]; + if (args.length==0) { + System.out.println("-debugcompiler -- print out debug messages"); + System.out.println("-depth depthnum constraintnum -- generate dependency graph from constraintnum with depth of depthnum"); + System.out.println("-depthconj depthnum constraintnum conjunctionnum -- generate dependency graph from constraintnum with depth of depthnum"); + System.out.println("-instrument -- generate instrumentation code"); + System.out.println("-aggressivesearch -- search for one repair per constraint"); + System.out.println("-prunequantifiernodes -- prune nodes that satisfy constraint by decreasing scope"); + System.out.println("-cplusplus -- properly set up c++ classes"); + System.out.println("-time -- generate timing code"); + System.out.println("-omitcomp -- omit compensation updates"); + System.out.println("-mergenodes -- omit nodes for simpler role dependence graphs"); + System.out.println("-debuggraph -- add edge labels and support to debug graph"); + System.out.println("-rejectlengthchanges -- reject all updates which change the length of an array"); + System.out.println("-printrepairs -- print log of repair actions"); + System.out.println("-exactallocation -- application calls malloc for each struct and"); + System.out.println(" allocates exactly the right amount of space."); + System.out.println("-name -- set name"); + System.exit(-1); + } + for (int i = 0; i < args.length; i++) { - if (args[i].equals("-debug")) { + if (args[i].equals("-debugcompiler")) { context = 0; debug = true; - } else if (args[i].equals("-native")) { - context = 0; - fNative = true; } else if (args[i].equals("-checkonly")) { Compiler.REPAIR=false; - } else if (args[i].equals("-vis")) { - context = 4; - fVis = true; - } else if (args[i].equals("-diff")) { - context = 5; - fDiff = true; - } else if (args[i].equals("-i")) { - context = 6; + } else if (args[i].equals("-exactallocation")) { + Compiler.EXACTALLOCATION=true; + } else if (args[i].equals("-omitcomp")) { + Compiler.OMITCOMP=true; + } else if (args[i].equals("-debuggraph")) { + Compiler.DEBUGGRAPH=true; + } else if (args[i].equals("-mergenodes")) { + Compiler.MERGENODES=true; + } else if (args[i].equals("-printrepairs")) { + Compiler.PRINTREPAIRS=true; + } else if (args[i].equals("-depth")) { + Compiler.debuggraphs.add(new DebugItem(Integer.parseInt(args[i+1]),Integer.parseInt(args[i+2]))); + i+=2; + } else if (args[i].equals("-depthconj")) { + Compiler.debuggraphs.add(new DebugItem(Integer.parseInt(args[i+1]),Integer.parseInt(args[i+2]),Integer.parseInt(args[i+3]))); + i+=3; + } else if (args[i].equals("-rejectlengthchanges")) { + Compiler.REJECTLENGTH=true; + } else if (args[i].equals("-debug")) { + Compiler.GENERATEDEBUGHOOKS=true; + } else if (args[i].equals("-time")) { + Compiler.TIME=true; + } else if (args[i].equals("-instrument")) { + Compiler.GENERATEINSTRUMENT=true; + } else if (args[i].equals("-aggressivesearch")) { + Compiler.AGGRESSIVESEARCH=true; + } else if (args[i].equals("-prunequantifiernodes")) { + Compiler.PRUNEQUANTIFIERS=true; + } else if (args[i].equals("-cplusplus")) { + Compiler.ALLOCATECPLUSPLUS=true; + } else if (args[i].equals("-name")) { + i++; + RepairGenerator.name=args[i]; + RepairGenerator.postfix=args[i]; } else if (args[i].equals("-verbose") || args[i].equals("-v")) { context = 0; verbose++; @@ -197,8 +166,6 @@ public class CLI { context = 1; else if (args[i].equals("-o")) context = 2; - else if (args[i].equals("-target")) - context = 3; else if (context == 1) { boolean hit = false; for (int j = 0; j < optnames.length; j++) { @@ -214,41 +181,9 @@ public class CLI { } if (!hit) extraopts.addElement(args[i]); - } - else if (context == 2) { + } else if (context == 2) { outfile = args[i]; context = 0; - } - else if (context == 3) { - // Process case insensitive. - String argSansCase = args[i].toLowerCase(); - // accept "scan" and "scanner" due to handout mistake - if (argSansCase.equals("scan") || - argSansCase.equals("scanner")) - target = SCAN; - else if (argSansCase.equals("parse")) - target = PARSE; - else if (argSansCase.equals("inter")) - target = INTER; - else if (argSansCase.equals("lowir")) - target = LOWIR; - else if (argSansCase.equals("assembly") || - argSansCase.equals("codegen")) - target = ASSEMBLY; - else - target = DEFAULT; // Anything else is just default - context = 0; - } else if (context == 4) { // -vis - StringTokenizer st = new StringTokenizer(args[i], "."); - visClass = st.nextToken(); - visMethod = st.nextToken(); - context = 0; - } else if (context == 5) { // -diff - diffFile = args[i]; // argument following is filename - context = 0; - } else if (context == 6) { // -i - numIterations = Integer.parseInt(args[i]); - context = 0; } else { boolean hit = false; for (int j = 0; j < optnames.length; j++) { @@ -267,7 +202,7 @@ public class CLI { int i = 0; while (infile == null && i < extras.size()) { String fn = (String) extras.elementAt(i); - + if (fn.charAt(0) != '-') { infile = fn; @@ -275,40 +210,5 @@ public class CLI { } i++; } - - // create outfile name - switch (target) { - case SCAN: - ext = ".scan"; - break; - case PARSE: - ext = ".parse"; - break; - case INTER: - ext = ".ir"; - break; - case LOWIR: - ext = ".lowir"; - break; - case ASSEMBLY: - ext = ".s"; - break; - case DEFAULT: - default: - ext = ".out"; - break; - } - - if (outfile == null && infile != null) { - int dot = infile.lastIndexOf('.'); - int slash = infile.lastIndexOf('/'); - // Last dot comes after last slash means that the file - // has an extention. Note that the base case where dot - // or slash are -1 also work. - if (dot <= slash) - outfile = infile + ext; - else - outfile = infile.substring(0, dot) + ext; - } } }