[llvm-commits] [llvm] r90774 - in /llvm/trunk: include/llvm/CompilerDriver/Common.td tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td tools/llvmc/plugins/Base/Base.td.in tools/llvmc/plugins/Clang/Clang.td utils/TableGen/LLVMCConfigurationEmitter.cpp

Mikhail Glushenkov foldr at codedgers.com
Mon Dec 7 10:25:54 PST 2009


Author: foldr
Date: Mon Dec  7 12:25:54 2009
New Revision: 90774

URL: http://llvm.org/viewvc/llvm-project?rev=90774&view=rev
Log:
Deprecate 'unpack_values'.

Use 'forward_values' + 'comma_separated' instead.

Modified:
    llvm/trunk/include/llvm/CompilerDriver/Common.td
    llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td
    llvm/trunk/tools/llvmc/plugins/Base/Base.td.in
    llvm/trunk/tools/llvmc/plugins/Clang/Clang.td
    llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp

Modified: llvm/trunk/include/llvm/CompilerDriver/Common.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/Common.td?rev=90774&r1=90773&r2=90774&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CompilerDriver/Common.td (original)
+++ llvm/trunk/include/llvm/CompilerDriver/Common.td Mon Dec  7 12:25:54 2009
@@ -45,6 +45,7 @@
 def really_hidden;
 def required;
 def zero_or_one;
+def comma_separated;
 
 // The 'case' construct.
 def case;

Modified: llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td?rev=90774&r1=90773&r2=90774&view=diff

==============================================================================
--- llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td (original)
+++ llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td Mon Dec  7 12:25:54 2009
@@ -41,9 +41,9 @@
 //    (help "Optimization level 2. (Default)")),
 // (parameter_option "pre-RA-sched",
 //    (help "Example of an option that is passed to llc")),
- (prefix_list_option "Wa,",
+ (prefix_list_option "Wa,", (comma_separated),
     (help "Pass options to native assembler")),
- (prefix_list_option "Wl,",
+ (prefix_list_option "Wl,", (comma_separated),
     (help "Pass options to native linker"))
 // (prefix_list_option "Wllc,",
 //    (help "Pass options to llc")),
@@ -58,11 +58,11 @@
  (output_suffix "bc"),
  (cmd_line (case
            (switch_on "E"),
-           (case 
+           (case
               (not_empty "o"), !strconcat(cmd, " -E $INFILE -o $OUTFILE"),
               (default), !strconcat(cmd, " -E $INFILE")),
            (default), !strconcat(cmd, " $INFILE -o $OUTFILE"))),
- (actions (case 
+ (actions (case
                 (and (multiple_input_files), (or (switch_on "S"), (switch_on "c"))),
               (error "cannot specify -o with -c or -S with multiple files"),
                 (switch_on "E"), [(stop_compilation), (output_suffix ext_E)],
@@ -138,7 +138,7 @@
  (actions (case
           (switch_on "c"), (stop_compilation),
           (switch_on "g"), (append_cmd "-g"),
-          (not_empty "Wa,"), (unpack_values "Wa,")))
+          (not_empty "Wa,"), (forward_value "Wa,")))
 ]>;
 
 def mplink : Tool<[
@@ -147,13 +147,13 @@
  (output_suffix "cof"),
  (cmd_line "$CALL(GetBinDir)mplink.exe -k $CALL(GetStdLinkerScriptsDir) -l $CALL(GetStdLibsDir) -p 16f1937  intrinsics.lib devices.lib $INFILE -o $OUTFILE"),
  (actions (case
-          (not_empty "Wl,"), (unpack_values "Wl,"),
+          (not_empty "Wl,"), (forward_value "Wl,"),
           (not_empty "L"), (forward_as "L", "-l"),
           (not_empty "K"), (forward_as "K", "-k"),
           (not_empty "m"), (forward "m"),
 //          (not_empty "l"), [(unpack_values "l"),(append_cmd ".lib")])),
-          (not_empty "k"), (unpack_values "k"),
-          (not_empty "l"), (unpack_values "l"))),
+          (not_empty "k"), (forward_value "k"),
+          (not_empty "l"), (forward_value "l"))),
  (join)
 ]>;
 
@@ -175,13 +175,13 @@
 def CompilationGraph : CompilationGraph<[
     Edge<"root", "clang_cc">,
     Edge<"root", "llvm_ld">,
-    OptionalEdge<"root", "llvm_ld_optimizer", (case 
+    OptionalEdge<"root", "llvm_ld_optimizer", (case
                                          (switch_on "S"), (inc_weight),
                                          (switch_on "c"), (inc_weight))>,
     Edge<"root", "gpasm">,
     Edge<"root", "mplink">,
     Edge<"clang_cc", "llvm_ld">,
-    OptionalEdge<"clang_cc", "llvm_ld_optimizer", (case 
+    OptionalEdge<"clang_cc", "llvm_ld_optimizer", (case
                                          (switch_on "S"), (inc_weight),
                                          (switch_on "c"), (inc_weight))>,
     Edge<"llvm_ld", "pic16passes">,

Modified: llvm/trunk/tools/llvmc/plugins/Base/Base.td.in
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Base/Base.td.in?rev=90774&r1=90773&r2=90774&view=diff

==============================================================================
--- llvm/trunk/tools/llvmc/plugins/Base/Base.td.in (original)
+++ llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Mon Dec  7 12:25:54 2009
@@ -71,9 +71,9 @@
     (help "Add a directory to include path")),
  (prefix_list_option "D",
     (help "Define a macro")),
- (prefix_list_option "Wa,",
+ (prefix_list_option "Wa,", (comma_separated),
     (help "Pass options to assembler")),
- (prefix_list_option "Wllc,",
+ (prefix_list_option "Wllc,", (comma_separated),
     (help "Pass options to llc")),
  (prefix_list_option "L",
     (help "Add a directory to link path")),
@@ -81,7 +81,7 @@
     (help "Search a library when linking")),
  (prefix_list_option "Wl,",
     (help "Pass options to linker")),
- (prefix_list_option "Wo,",
+ (prefix_list_option "Wo,", (comma_separated),
     (help "Pass options to opt")),
  (prefix_list_option "m",
      (help "Enable or disable various extensions (-mmmx, -msse, etc.)"),
@@ -159,7 +159,7 @@
 [(in_language "llvm-bitcode"),
  (out_language "llvm-bitcode"),
  (output_suffix "bc"),
- (actions (case (not_empty "Wo,"), (unpack_values "Wo,"),
+ (actions (case (not_empty "Wo,"), (forward_value "Wo,"),
                 (switch_on "O1"), (forward "O1"),
                 (switch_on "O2"), (forward "O2"),
                 (switch_on "O3"), (forward "O3"))),
@@ -181,7 +181,7 @@
  (cmd_line "@LLVMGCCCOMMAND@ -c -x assembler $INFILE -o $OUTFILE"),
  (actions (case
           (switch_on "c"), (stop_compilation),
-          (not_empty "Wa,"), (unpack_values "Wa,")))
+          (not_empty "Wa,"), (forward_value "Wa,")))
 ]>;
 
 def llc : Tool<
@@ -202,7 +202,7 @@
           (not_empty "mtune"), (forward "mcpu"),
           (not_empty "mcpu"), (forward "mcpu"),
           (not_empty "m"), (forward_transformed_value "m", "ConvertToMAttr"),
-          (not_empty "Wllc,"), (unpack_values "Wllc,")))
+          (not_empty "Wllc,"), (forward_value "Wllc,")))
 ]>;
 
 // Base class for linkers

Modified: llvm/trunk/tools/llvmc/plugins/Clang/Clang.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Clang/Clang.td?rev=90774&r1=90773&r2=90774&view=diff

==============================================================================
--- llvm/trunk/tools/llvmc/plugins/Clang/Clang.td (original)
+++ llvm/trunk/tools/llvmc/plugins/Clang/Clang.td Mon Dec  7 12:25:54 2009
@@ -68,7 +68,7 @@
  (out_language "object-code"),
  (output_suffix "o"),
  (cmd_line "as $INFILE -o $OUTFILE"),
- (actions (case (not_empty "Wa,"), (unpack_values "Wa,"),
+ (actions (case (not_empty "Wa,"), (forward_value "Wa,"),
                 (switch_on "c"), (stop_compilation)))
 ]>;
 
@@ -82,7 +82,7 @@
           (switch_on "pthread"), (append_cmd "-lpthread"),
           (not_empty "L"), (forward "L"),
           (not_empty "l"), (forward "l"),
-          (not_empty "Wl,"), (unpack_values "Wl,"))),
+          (not_empty "Wl,"), (forward_value "Wl,"))),
  (join)
 ]>;
 

Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=90774&r1=90773&r2=90774&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Mon Dec  7 12:25:54 2009
@@ -211,7 +211,8 @@
 namespace OptionDescriptionFlags {
   enum OptionDescriptionFlags { Required = 0x1, Hidden = 0x2,
                                 ReallyHidden = 0x4, Extern = 0x8,
-                                OneOrMore = 0x10, ZeroOrOne = 0x20 };
+                                OneOrMore = 0x10, ZeroOrOne = 0x20,
+                                CommaSeparated = 0x40 };
 }
 
 /// OptionDescription - Represents data contained in a single
@@ -247,6 +248,9 @@
 
   bool isMultiVal() const;
 
+  bool isCommaSeparated() const;
+  void setCommaSeparated();
+
   bool isExtern() const;
   void setExtern();
 
@@ -299,6 +303,13 @@
   return MultiVal > 1;
 }
 
+bool OptionDescription::isCommaSeparated() const {
+  return Flags & OptionDescriptionFlags::CommaSeparated;
+}
+void OptionDescription::setCommaSeparated() {
+  Flags |= OptionDescriptionFlags::CommaSeparated;
+}
+
 bool OptionDescription::isExtern() const {
   return Flags & OptionDescriptionFlags::Extern;
 }
@@ -538,6 +549,7 @@
       AddHandler("really_hidden", &CollectOptionProperties::onReallyHidden);
       AddHandler("required", &CollectOptionProperties::onRequired);
       AddHandler("zero_or_one", &CollectOptionProperties::onZeroOrOne);
+      AddHandler("comma_separated", &CollectOptionProperties::onCommaSeparated);
 
       staticMembersInitialized_ = true;
     }
@@ -574,11 +586,18 @@
     optDesc_.setReallyHidden();
   }
 
+  void onCommaSeparated (const DagInit* d) {
+    checkNumberOfArguments(d, 0);
+    if (!optDesc_.isList())
+      throw "'comma_separated' is valid only on list options!";
+    optDesc_.setCommaSeparated();
+  }
+
   void onRequired (const DagInit* d) {
     checkNumberOfArguments(d, 0);
-    if (optDesc_.isOneOrMore())
-      throw std::string("An option can't have both (required) "
-                        "and (one_or_more) properties!");
+    if (optDesc_.isOneOrMore() || optDesc_.isZeroOrOne())
+      throw "Only one of (required), (zero_or_one) or "
+        "(one_or_more) properties is allowed!";
     optDesc_.setRequired();
   }
 
@@ -591,7 +610,7 @@
     correct |= (optDesc_.isSwitch() && (str == "true" || str == "false"));
 
     if (!correct)
-      throw std::string("Incorrect usage of the 'init' option property!");
+      throw "Incorrect usage of the 'init' option property!";
 
     optDesc_.InitVal = i;
   }
@@ -599,8 +618,8 @@
   void onOneOrMore (const DagInit* d) {
     checkNumberOfArguments(d, 0);
     if (optDesc_.isRequired() || optDesc_.isZeroOrOne())
-      throw std::string("Only one of (required), (zero_or_one) or "
-                        "(one_or_more) properties is allowed!");
+      throw "Only one of (required), (zero_or_one) or "
+        "(one_or_more) properties is allowed!";
     if (!OptionType::IsList(optDesc_.Type))
       llvm::errs() << "Warning: specifying the 'one_or_more' property "
         "on a non-list option will have no effect.\n";
@@ -610,8 +629,8 @@
   void onZeroOrOne (const DagInit* d) {
     checkNumberOfArguments(d, 0);
     if (optDesc_.isRequired() || optDesc_.isOneOrMore())
-      throw std::string("Only one of (required), (zero_or_one) or "
-                        "(one_or_more) properties is allowed!");
+      throw "Only one of (required), (zero_or_one) or "
+        "(one_or_more) properties is allowed!";
     if (!OptionType::IsList(optDesc_.Type))
       llvm::errs() << "Warning: specifying the 'zero_or_one' property"
         "on a non-list option will have no effect.\n";
@@ -622,11 +641,10 @@
     checkNumberOfArguments(d, 1);
     int val = InitPtrToInt(d->getArg(0));
     if (val < 2)
-      throw std::string("Error in the 'multi_val' property: "
-                        "the value must be greater than 1!");
+      throw "Error in the 'multi_val' property: "
+        "the value must be greater than 1!";
     if (!OptionType::IsList(optDesc_.Type))
-      throw std::string("The multi_val property is valid only "
-                        "on list options!");
+      throw "The multi_val property is valid only on list options!";
     optDesc_.MultiVal = val;
   }
 
@@ -1048,9 +1066,9 @@
     if (ActionName == "forward" || ActionName == "forward_as" ||
         ActionName == "forward_value" ||
         ActionName == "forward_transformed_value" ||
-        ActionName == "unpack_values" || ActionName == "switch_on" ||
-        ActionName == "parameter_equals" || ActionName == "element_in_list" ||
-        ActionName == "not_empty" || ActionName == "empty") {
+        ActionName == "switch_on" || ActionName == "parameter_equals" ||
+        ActionName == "element_in_list" || ActionName == "not_empty" ||
+        ActionName == "empty") {
       checkNumberOfArguments(&Stmt, 1);
       const std::string& Name = InitPtrToString(Stmt.getArg(0));
       OptionNames_.insert(Name);
@@ -1858,30 +1876,8 @@
   void onUnpackValues (const DagInit& Dag,
                        unsigned IndentLevel, raw_ostream& O) const
   {
-    checkNumberOfArguments(&Dag, 1);
-    const std::string& Name = InitPtrToString(Dag.getArg(0));
-    const OptionDescription& D = OptDescs.FindOption(Name);
-
-    if (D.isMultiVal())
-      throw "Can't use unpack_values with multi-valued options!";
-
-    if (D.isList()) {
-      O.indent(IndentLevel)
-        << "for (" << D.GenTypeDeclaration()
-        << "::iterator B = " << D.GenVariableName() << ".begin(),\n";
-      O.indent(IndentLevel)
-        << "E = " << D.GenVariableName() << ".end(); B != E; ++B)\n";
-      O.indent(IndentLevel + Indent1)
-        << "llvm::SplitString(*B, vec, \",\");\n";
-    }
-    else if (D.isParameter()){
-      O.indent(IndentLevel) << "llvm::SplitString("
-                            << D.GenVariableName() << ", vec, \",\");\n";
-    }
-    else {
-      throw "Option '" + D.Name +
-        "': switches can't have the 'unpack_values' property!";
-    }
+    throw "'unpack_values' is deprecated. "
+      "Use 'comma_separated' + 'forward_value' instead!";
   }
 
  public:
@@ -2191,12 +2187,13 @@
         O << ", cl::ZeroOrOne";
     }
 
-    if (val.isReallyHidden()) {
+    if (val.isReallyHidden())
       O << ", cl::ReallyHidden";
-    }
-    else if (val.isHidden()) {
+    else if (val.isHidden())
       O << ", cl::Hidden";
-    }
+
+    if (val.isCommaSeparated())
+      O << ", cl::CommaSeparated";
 
     if (val.MultiVal > 1)
       O << ", cl::multi_val(" << val.MultiVal << ')';
@@ -2650,7 +2647,6 @@
     << "#include \"llvm/CompilerDriver/Plugin.h\"\n"
     << "#include \"llvm/CompilerDriver/Tool.h\"\n\n"
 
-    << "#include \"llvm/ADT/StringExtras.h\"\n"
     << "#include \"llvm/Support/CommandLine.h\"\n"
     << "#include \"llvm/Support/raw_ostream.h\"\n\n"
 





More information about the llvm-commits mailing list