From 5e721a352cab2e86cfda7a69a042a65f92f7b8f9 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 26 Feb 2002 21:36:53 +0000 Subject: [PATCH] * Make all command line arguments static * Change -trace & -tracem options to use a 3 values enum option * Change to use new style interface to passes llvm-svn: 1813 --- tools/llc/llc.cpp | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index d35d5d99674..c4422adfbaf 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -22,14 +22,20 @@ #include using std::string; -cl::String InputFilename ("", "Input filename", cl::NoFlags, "-"); -cl::String OutputFilename("o", "Output filename", cl::NoFlags, ""); -cl::Flag Force ("f", "Overwrite output files"); -cl::Flag DumpAsm ("d", "Print bytecode before native code generation", - cl::Hidden); -cl::Flag TraceBBValues ("trace", - "Trace values at basic block and method exits"); -cl::Flag TraceMethodValues("tracem", "Trace values only at method exits"); +static cl::String InputFilename ("", "Input filename", cl::NoFlags, "-"); +static cl::String OutputFilename("o", "Output filename", cl::NoFlags, ""); +static cl::Flag Force ("f", "Overwrite output files"); +static cl::Flag DumpAsm ("d", "Print bytecode before native code generation", cl::Hidden); + +enum TraceLevel { + TraceOff, TraceMethods, TraceBasicBlocks +}; + +static cl::Enum TraceValues("trace", cl::NoFlags, + "Trace values through methods or basic blocks", + clEnumValN(TraceOff , "off", "Disable trace code"), + clEnumValN(TraceMethods , "method", "Trace each method"), + clEnumValN(TraceBasicBlocks, "basicblock", "Trace each basic block"), 0); // GetFileNameRoot - Helper function to get the basename of a filename... @@ -73,15 +79,19 @@ int main(int argc, char **argv) { PassManager Passes; // Hoist constants out of PHI nodes into predecessor BB's - Passes.add(new HoistPHIConstants()); + Passes.add(createHoistPHIConstantsPass()); - if (TraceBBValues || TraceMethodValues) { // If tracing enabled... + if (TraceValues != TraceOff) { // If tracing enabled... // Insert trace code in all methods in the module - Passes.add(new InsertTraceCode(TraceBBValues, - TraceBBValues ||TraceMethodValues)); + if (TraceValues == TraceBasicBlocks) + Passes.add(createTraceValuesPassForBasicBlocks()); + else if (TraceValues == TraceMethods) + Passes.add(createTraceValuesPassForMethod()); + else + assert(0 && "Bad value for TraceValues!"); // Eliminate duplication in constant pool - Passes.add(new DynamicConstantMerge()); + Passes.add(createDynamicConstantMergePass()); // Then write out the module with tracing code before code generation assert(InputFilename != "-" && @@ -109,7 +119,7 @@ int main(int argc, char **argv) { // Replace malloc and free instructions with library calls. // Do this after tracing until lli implements these lib calls. // For now, it will emulate malloc and free internally. - Passes.add(new LowerAllocations(Target.DataLayout)); + Passes.add(createLowerAllocationsPass(Target.DataLayout)); // If LLVM dumping after transformations is requested, add it to the pipeline if (DumpAsm)