2 //**************************************************************************/
7 // Options for the llc compiler.
10 // 7/15/01 - Vikram Adve - Created
12 //**************************************************************************/
14 //************************** System Include Files **************************/
20 //*************************** User Include Files ***************************/
22 #include "llvm/Support/ProgramOptions.h"
23 #include "llvm/Support/ProgramOption.h"
24 #include "LLCOptions.h"
27 //---------------------------------------------------------------------------
29 //---------------------------------------------------------------------------
32 LLCOptions::LLCOptions (int _argc,
35 : ProgramOptions(_argc, _argv, _envp)
38 ParseArgs(argc, argv, envp);
43 LLCOptions::~LLCOptions()
46 //--------------------------------------------------------------------
47 // Initialize all our compiler options
48 //--------------------------------------------------------------------
51 LLCOptions::InitializeOptions()
53 Register(new FlagOption(HELP_OPT,
54 "print usage message",
55 false /*initValue*/));
57 Register(new FlagOption(DEBUG_OPT,
58 "turn on default debugging options",
59 false /*initValue*/));
61 Register(new FlagOption(DEBUG_OPT,
62 "turn off all diagnostic messages",
63 false /*initValue*/));
65 Register(new StringOption(OUTFILENAME_OPT,
69 Register(new IntegerValuedOption(DEBUG_INSTR_SELECT_OPT,
70 "control amount of debugging information for instruction selection",
76 LLCOptions::ParseExtraArgs()
78 if (argsConsumed != argc-1)
81 // input file name should be the last argument
82 inputFileName = argv[argc-1];
84 // output file name may be specified with -o option;
85 // otherwise create it from the input file name by replace ".ll" with ".o"
86 const string &outfilenameOpt = StringOptionValue(OUTFILENAME_OPT);
87 if (outfilenameOpt.length())
88 {// "-o" option was used
89 outputFileName = outfilenameOpt;
93 outputFileName = inputFileName;
94 unsigned int suffixPos = outputFileName.rfind(".bc");
96 if (suffixPos >= outputFileName.length())
97 suffixPos = outputFileName.rfind(".ll");
99 if (suffixPos >= outputFileName.length())
101 cerr << "Unrecognized suffix in file name " << inputFileName << endl;
105 outputFileName.replace(suffixPos, 3, ".o");
109 //--------------------------------------------------------------------
110 // Functions that must be overridden in subclass of ProgramOptions
111 //--------------------------------------------------------------------
114 LLCOptions::CheckParse()
118 LLCOptions::PrintUsage(ostream& stream) const
120 stream << "\nUSAGE:\n\t" << ProgramName() << " [options] "
121 << "llvm-file" << endl << endl;
122 PrintOptions(stream);