[llvm-commits] [llvm] r115742 - in /llvm/trunk: Makefile.rules test/LLVMC/MultipleOutputLanguages.td test/LLVMC/OptionPreprocessor.td test/TableGen/Dag.td utils/TableGen/TGParser.cpp

Chris Lattner sabre at nondot.org
Tue Oct 5 21:55:48 PDT 2010


Author: lattner
Date: Tue Oct  5 23:55:48 2010
New Revision: 115742

URL: http://llvm.org/viewvc/llvm-project?rev=115742&view=rev
Log:
Generalize tblgen's dag parsing logic to handle arbitrary expressions
as the operator of the dag.  Specifically, this allows parsing things
like (F.x 4) in addition to just (a 4).

Unfortunately, this runs afoul of an idiom being used by llvmc.  It
is using dags like (foo [1,2,3]) to represent a list of stuff being
passed into foo.  With this change, this is parsed as a [1,2,3] 
subscript on foo instead of being the first argument to the dag.
Cope with this in the short term by requiring a "-llvmc-temp-hack"
argument to tblgen to get the old parsing behavior.


Modified:
    llvm/trunk/Makefile.rules
    llvm/trunk/test/LLVMC/MultipleOutputLanguages.td
    llvm/trunk/test/LLVMC/OptionPreprocessor.td
    llvm/trunk/test/TableGen/Dag.td
    llvm/trunk/utils/TableGen/TGParser.cpp

Modified: llvm/trunk/Makefile.rules
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=115742&r1=115741&r2=115742&view=diff
==============================================================================
--- llvm/trunk/Makefile.rules (original)
+++ llvm/trunk/Makefile.rules Tue Oct  5 23:55:48 2010
@@ -1779,7 +1779,7 @@
 
 $(ObjDir)/%.inc.tmp: %.td $(ObjDir)/.dir
 	$(Echo) "Building LLVMC compilation graph description with tblgen"
-	$(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
+	$(Verb) $(TableGen) -gen-llvmc -llvmc-temp-hack -o $(call SYSPATH, $@) $<
 
 clean-local::
 	-$(Verb) $(RM) -f $(INCFiles)

Modified: llvm/trunk/test/LLVMC/MultipleOutputLanguages.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/MultipleOutputLanguages.td?rev=115742&r1=115741&r2=115742&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/MultipleOutputLanguages.td (original)
+++ llvm/trunk/test/LLVMC/MultipleOutputLanguages.td Tue Oct  5 23:55:48 2010
@@ -1,5 +1,5 @@
 // Check that multiple output languages work.
-// RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t
+// RUN: tblgen -I %p/../../include -llvmc-temp-hack --gen-llvmc %s -o %t
 // RUN: FileCheck -input-file %t %s
 // RUN: %compile_cxx %t
 // XFAIL: vg_leak

Modified: llvm/trunk/test/LLVMC/OptionPreprocessor.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/OptionPreprocessor.td?rev=115742&r1=115741&r2=115742&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/OptionPreprocessor.td (original)
+++ llvm/trunk/test/LLVMC/OptionPreprocessor.td Tue Oct  5 23:55:48 2010
@@ -1,5 +1,5 @@
 // Test for the OptionPreprocessor and related functionality.
-// RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t
+// RUN: tblgen -I %p/../../include -llvmc-temp-hack --gen-llvmc %s -o %t
 // RUN: FileCheck -input-file %t %s
 // RUN: %compile_cxx %t
 // XFAIL: vg_leak

Modified: llvm/trunk/test/TableGen/Dag.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/Dag.td?rev=115742&r1=115741&r2=115742&view=diff
==============================================================================
--- llvm/trunk/test/TableGen/Dag.td (original)
+++ llvm/trunk/test/TableGen/Dag.td Tue Oct  5 23:55:48 2010
@@ -33,3 +33,39 @@
 // CHECK-NEXT: dag d = (X2 Y2)
 // CHECK-NEXT: dag e = (Y2 X2)
 
+
+//===----------------------------------------------------------------------===//
+// Complex dag operator (F.TheOp).
+
+class operator;
+def somedef1 : operator;
+def somedef2 : operator;
+
+class foo<operator a> {
+ operator TheOp = a;
+}
+
+class bar<foo F, operator a> {
+  dag Dag1 = (somedef1 1);
+  dag Dag2 = (a 2);
+  dag Dag3 = (F.TheOp 2);
+}
+
+def foo1 : foo<somedef1>;
+def foo2 : foo<somedef2>;
+
+def VAL3 : bar<foo1, somedef1>;
+
+// CHECK:     def VAL3 {	// bar
+// CHECK-NEXT:  dag Dag1 = (somedef1 1);
+// CHECK-NEXT:  dag Dag2 = (somedef1 2);
+// CHECK-NEXT:  dag Dag3 = (somedef1 2);
+// CHECK-NEXT: }
+
+
+def VAL4 : bar<foo2, somedef2>;
+// CHECK:      def VAL4 {
+// CHECK-NEXT:  dag Dag1 = (somedef1 1);
+// CHECK-NEXT:  dag Dag2 = (somedef2 2);
+// CHECK-NEXT:  dag Dag3 = (somedef2 2);
+// CHECK-NEXT: }

Modified: llvm/trunk/utils/TableGen/TGParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.cpp?rev=115742&r1=115741&r2=115742&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/TGParser.cpp (original)
+++ llvm/trunk/utils/TableGen/TGParser.cpp Tue Oct  5 23:55:48 2010
@@ -17,8 +17,14 @@
 #include <algorithm>
 #include <sstream>
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/CommandLine.h"
 using namespace llvm;
 
+/// LLVMCHack - This is a temporary hack that changes how "(foo [1, 2, 3])"
+/// parses.
+/// FIXME: REMOVE THIS.
+static cl::opt<bool> LLVMCHack("llvmc-temp-hack", cl::ReallyHidden);
+
 //===----------------------------------------------------------------------===//
 // Support Code for the Semantic Actions.
 //===----------------------------------------------------------------------===//
@@ -1213,11 +1219,18 @@
       return 0;
     }
 
-    Init *Operator = 0;
-    if (Lex.getCode() == tgtok::Id)
-      Operator = ParseIDValue(CurRec);
-    else
-      Operator = ParseOperation(CurRec);
+    Init *Operator;
+    /// LLVMC Requires an old grammar and I don't know how to update it, placate
+    /// it in the short term by changing the grammar specifically for llvmc.
+    /// FIXME: REMOVE THIS.
+    if (!LLVMCHack)
+      Operator = ParseValue(CurRec);
+    else {
+      if (Lex.getCode() == tgtok::Id)
+        Operator = ParseIDValue(CurRec);
+      else
+        Operator = ParseOperation(CurRec);
+    }
     if (Operator == 0) return 0;
 
     // If the operator name is present, parse it.





More information about the llvm-commits mailing list