[PATCH] [lld] add InputGraph to process Command line arguments

Michael Spencer bigcheesegs at gmail.com
Fri Jul 26 12:27:18 PDT 2013


  I agree that this is overkill.


================
Comment at: include/lld/Driver/InputGraph.h:33-76
@@ +32,46 @@
+
+/// \brief Each flavor of lld creates a OptionInfo object that defines the set
+/// of options that the flavor handles. It also associates the command line
+/// with the Option Type thats associated with it.
+class OptionInfo {
+public:
+  /// \brief The various types of options that are supported
+  /// Positional option indicates that processing the next argument depends
+  /// on the current positional argument. The positional argument would decide
+  /// the way the following argument is processed by lld
+  /// Control options indicate how the next set of options would be processed
+  /// by lld. This would control how the arguments would be processed by the
+  /// linker
+  enum class OptType : uint8_t {
+    Opt_Unknown,       // The option is Unknown
+    Opt_LLVMOption,    // The Option is handled by LLVM
+    Opt_Positional,    // Positional Option
+    Opt_SimpleControl, // A simple control flag
+    Opt_ControlEnter,  // Start the control option
+    Opt_ControlExit,   // Exit the control option
+    Opt_Global,        // Global Option
+    Opt_Input          // Input File
+  };
+
+  OptionInfo() {}
+
+  /// \brief Determine the option type for a particular Input argument
+  virtual OptType getInputOptionType(llvm::opt::Arg &arg) = 0;
+
+  /// \brief Create an input element corresponding to the Input option
+  virtual std::unique_ptr<InputElement> getInputElement(llvm::opt::Arg &arg,
+                                                        OptType optionType) = 0;
+
+  /// \brief process Global option
+  virtual bool processGlobalOption(llvm::opt::Arg &arg, OptType optionType) = 0;
+
+  /// \brief process LLVM Options
+  virtual bool processLLVMOption(llvm::opt::Arg &arg, OptType optionType) = 0;
+
+  /// \brief process Unknown Option
+  virtual bool processUnknownOption(llvm::opt::Arg &arg,
+                                    OptType optionType) = 0;
+
+  virtual ~OptionInfo() {}
+};
+
----------------
This should not be part of InputGraph.

================
Comment at: include/lld/Driver/InputGraph.h:83-84
@@ +82,4 @@
+/// to do when it processes the option. Each InputElement that is part of the
+/// Graph has also an Ordinal value associated with it. The ordinal value is
+/// needed for components to figure out the relative position of the arguments
+/// that appeared in the Command Line. One such example is adding the list of
----------------
The InputGraph should replace the ordinal, as ordinals change as the graph is processed if new files get added.

================
Comment at: include/lld/Driver/InputGraph.h:89
@@ +88,3 @@
+/// weight of the file, for statistical purposes. The InputGraph also would
+/// contain a set of General options that are processed by the linker, which
+/// control the output
----------------
The only options handled by the InputGraph should be those that effect the graph.

================
Comment at: include/lld/Driver/InputGraph.h:101-109
@@ +100,11 @@
+
+  /// \brief Read inputs that were passed
+  virtual bool processArgs(const llvm::opt::InputArgList &inputArgList);
+
+  /// \brief Process Argument, Process argument determines what
+  /// the current argument type is and creates either a ControlNode
+  /// or an InputFileNode. If the argument is a positional option
+  /// it appends the positional option to the InputElement, which
+  /// is either a a control node or an InputFileNode.
+  virtual bool processArg(llvm::opt::Arg &arg);
+
----------------
The InputGraph should know nothing of llvm::opt. Some other code should build an InputGraph using the command line.

================
Comment at: include/lld/Driver/InputGraph.h:165
@@ +164,3 @@
+  int64_t _ordinal;
+  int64_t _weight;
+};
----------------
I don't get the purpose of this.


http://llvm-reviews.chandlerc.com/D1217



More information about the llvm-commits mailing list