X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Fllvmc%2Fllvmc.cpp;h=75ea338d5c2304e02f28861ba0a732230f5fabeb;hb=c30088f9612c949b047884deab045e2421690691;hp=9d677d73581c2ea1c603173c2d1d017d2f324b9c;hpb=a3b4e09715f2c65c54e7a875bba01345da8e3914;p=oota-llvm.git diff --git a/tools/llvmc/llvmc.cpp b/tools/llvmc/llvmc.cpp index 9d677d73581..75ea338d5c2 100644 --- a/tools/llvmc/llvmc.cpp +++ b/tools/llvmc/llvmc.cpp @@ -27,7 +27,7 @@ namespace { //===------------------------------------------------------------------------=== //=== PHASE OPTIONS //===------------------------------------------------------------------------=== -cl::opt FinalPhase( +cl::opt FinalPhase(cl::Optional, cl::desc("Choose final phase of compilation:"), cl::init(CompilerDriver::LINKING), cl::values( @@ -46,7 +46,7 @@ cl::opt FinalPhase( //===------------------------------------------------------------------------=== //=== OPTIMIZATION OPTIONS //===------------------------------------------------------------------------=== -cl::opt OptLevel( +cl::opt OptLevel(cl::ZeroOrMore, cl::desc("Choose level of optimization to apply:"), cl::init(CompilerDriver::OPT_FAST_COMPILE), cl::values( @@ -74,6 +74,9 @@ cl::list PreprocessorToolOpts("Tpre", cl::ZeroOrMore, cl::desc("Pass specific options to the pre-processor"), cl::value_desc("option")); +cl::alias PreprocessorToolOptsAlias("Wp,", cl::ZeroOrMore, + cl::desc("Alias for -Tpre"), cl::aliasopt(PreprocessorToolOpts)); + cl::list TranslatorToolOpts("Ttrn", cl::ZeroOrMore, cl::desc("Pass specific options to the assembler"), cl::value_desc("option")); @@ -82,6 +85,9 @@ cl::list AssemblerToolOpts("Tasm", cl::ZeroOrMore, cl::desc("Pass specific options to the assembler"), cl::value_desc("option")); +cl::alias AssemblerToolOptsAlias("Wa,", cl::ZeroOrMore, + cl::desc("Alias for -Tasm"), cl::aliasopt(AssemblerToolOpts)); + cl::list OptimizerToolOpts("Topt", cl::ZeroOrMore, cl::desc("Pass specific options to the optimizer"), cl::value_desc("option")); @@ -90,44 +96,66 @@ cl::list LinkerToolOpts("Tlnk", cl::ZeroOrMore, cl::desc("Pass specific options to the linker"), cl::value_desc("option")); +cl::alias LinkerToolOptsAlias("Wl,", cl::ZeroOrMore, + cl::desc("Alias for -Tlnk"), cl::aliasopt(LinkerToolOpts)); + +cl::list fOpts("f", cl::ZeroOrMore, cl::Prefix, + cl::desc("Pass through -f options to compiler tools"), + cl::value_desc("option")); + +cl::list MOpts("M", cl::ZeroOrMore, cl::Prefix, + cl::desc("Pass through -M options to compiler tools"), + cl::value_desc("option")); + +cl::list WOpts("W", cl::ZeroOrMore, cl::Prefix, + cl::desc("Pass through -W options to compiler tools"), + cl::value_desc("option")); + +cl::list BOpt("B", cl::ZeroOrMore, cl::Prefix, + cl::desc("Specify path to find llvmc sub-tools"), + cl::value_desc("dir")); + //===------------------------------------------------------------------------=== //=== INPUT OPTIONS //===------------------------------------------------------------------------=== cl::list LibPaths("L", cl::Prefix, - cl::desc("Specify a library search path"), cl::value_desc("directory")); - + cl::desc("Specify a library search path"), cl::value_desc("dir")); + cl::list Libraries("l", cl::Prefix, - cl::desc("Specify libraries to link to"), cl::value_desc("library prefix")); + cl::desc("Specify base name of libraries to link to"), cl::value_desc("lib")); cl::list Includes("I", cl::Prefix, cl::desc("Specify location to search for included source"), - cl::value_desc("include directory")); + cl::value_desc("dir")); cl::list Defines("D", cl::Prefix, - cl::desc("Specify a symbol to define for source configuration"), - cl::value_desc("symbol definition")); - + cl::desc("Specify a pre-processor symbol to define"), + cl::value_desc("symbol")); //===------------------------------------------------------------------------=== //=== OUTPUT OPTIONS //===------------------------------------------------------------------------=== cl::opt OutputFilename("o", - cl::desc("Override output filename"), cl::value_desc("filename")); - -cl::opt ForceOutput("f", cl::Optional, cl::init(false), - cl::desc("Force output files to be overridden")); + cl::desc("Override output filename"), cl::value_desc("file")); cl::opt OutputMachine("m", cl::Prefix, cl::desc("Specify a target machine"), cl::value_desc("machine")); - + cl::opt Native("native", cl::init(false), - cl::desc("Generative native object and executables instead of bytecode")); + cl::desc("Generative native code instead of bytecode")); cl::opt DebugOutput("g", cl::init(false), cl::desc("Generate objects that include debug symbols")); +cl::opt StripOutput("strip", cl::init(false), + cl::desc("Strip all symbols from linked output file")); + +cl::opt PrintFileName("print-fname", cl::Optional, + cl::value_desc("file"), + cl::desc("Print the full path for the option's value")); + //===------------------------------------------------------------------------=== //=== INFORMATION OPTIONS //===------------------------------------------------------------------------=== @@ -156,17 +184,13 @@ cl::opt TimeActions("time-actions", cl::Optional, cl::init(false), cl::opt ShowStats("stats", cl::Optional, cl::init(false), cl::desc("Print statistics accumulated during optimization")); -cl::list Warnings("W", cl::Prefix, - cl::desc("Provide warnings for additional classes of errors"), - cl::value_desc("warning category")); - //===------------------------------------------------------------------------=== //=== ADVANCED OPTIONS //===------------------------------------------------------------------------=== static cl::opt ConfigDir("config-dir", cl::Optional, - cl::desc("Specify a configuration directory to override defaults"), - cl::value_desc("directory")); + cl::desc("Specify configuration directory to override defaults"), + cl::value_desc("dir")); static cl::opt EmitRawCode("emit-raw-code", cl::Hidden, cl::Optional, cl::desc("Emit raw, unoptimized code")); @@ -175,13 +199,13 @@ static cl::opt PipeCommands("pipe", cl::Optional, cl::desc("Invoke sub-commands by linking input/output with pipes")); static cl::opt KeepTemps("keep-temps", cl::Optional, - cl::desc("Don't delete the temporary files created during compilation")); + cl::desc("Don't delete temporary files created by llvmc")); //===------------------------------------------------------------------------=== //=== POSITIONAL OPTIONS //===------------------------------------------------------------------------=== -static cl::list Files(cl::Positional, cl::OneOrMore, +static cl::list Files(cl::Positional, cl::ZeroOrMore, cl::desc("[Sources/objects/libraries]")); static cl::list Languages("x", cl::ZeroOrMore, @@ -214,6 +238,17 @@ const std::string GetFileType(const std::string& fname, unsigned pos ) { } // end anonymous namespace +void handleTerminatingOptions(CompilerDriver* CD) { + if (!PrintFileName.empty()) { + sys::Path path = CD->GetPathForLinkageItem(PrintFileName,false); + std::string p = path.toString(); + if (p.empty()) + std::cout << "Can't locate '" << PrintFileName << "'.\n"; + else + std::cout << p << "\n"; + exit(0); + } +} /// @brief The main program for llvmc int main(int argc, char **argv) { @@ -236,8 +271,6 @@ int main(int argc, char **argv) { if (OutputFilename.empty()) if (OptLevel == CompilerDriver::LINKING) OutputFilename = "a.out"; - else - throw std::string("An output file must be specified. Please use the -o option"); // Construct the ConfigDataProvider object LLVMC_ConfigDataProvider Provider; @@ -257,13 +290,13 @@ int main(int argc, char **argv) { if (Verbose) flags |= CompilerDriver::VERBOSE_FLAG; if (Debug) flags |= CompilerDriver::DEBUG_FLAG; if (DryRun) flags |= CompilerDriver::DRY_RUN_FLAG; - if (ForceOutput) flags |= CompilerDriver::FORCE_FLAG; if (Native) flags |= CompilerDriver::EMIT_NATIVE_FLAG; if (EmitRawCode) flags |= CompilerDriver::EMIT_RAW_FLAG; if (KeepTemps) flags |= CompilerDriver::KEEP_TEMPS_FLAG; if (ShowStats) flags |= CompilerDriver::SHOW_STATS_FLAG; if (TimeActions) flags |= CompilerDriver::TIME_ACTIONS_FLAG; if (TimePassesIsEnabled) flags |= CompilerDriver::TIME_PASSES_FLAG; + if (StripOutput) flags |= CompilerDriver::STRIP_OUTPUT_FLAG; CD->setDriverFlags(flags); // Specify requred parameters @@ -273,6 +306,9 @@ int main(int argc, char **argv) { CD->setIncludePaths(Includes); CD->setSymbolDefines(Defines); CD->setLibraryPaths(LibPaths); + CD->setfPassThrough(fOpts); + CD->setMPassThrough(MOpts); + CD->setWPassThrough(WOpts); // Provide additional tool arguments if (!PreprocessorToolOpts.empty()) @@ -286,6 +322,10 @@ int main(int argc, char **argv) { if (!LinkerToolOpts.empty()) CD->setPhaseArgs(CompilerDriver::LINKING, LinkerToolOpts); + // Check for options that cause us to terminate before any significant work + // is done. + handleTerminatingOptions(CD); + // Prepare the list of files to be compiled by the CompilerDriver. CompilerDriver::InputList InpList; std::vector::iterator fileIt = Files.begin(); @@ -328,4 +368,5 @@ int main(int argc, char **argv) { } catch (...) { std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; } + return 1; }