llvm.org GIT mirror llvm / 46f5552
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115742 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 8 years ago
5 changed file(s) with 57 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
17781778
17791779 $(ObjDir)/%.inc.tmp: %.td $(ObjDir)/.dir
17801780 $(Echo) "Building LLVMC compilation graph description with tblgen"
1781 $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
1781 $(Verb) $(TableGen) -gen-llvmc -llvmc-temp-hack -o $(call SYSPATH, $@) $<
17821782
17831783 clean-local::
17841784 -$(Verb) $(RM) -f $(INCFiles)
0 // Check that multiple output languages work.
1 // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t
1 // RUN: tblgen -I %p/../../include -llvmc-temp-hack --gen-llvmc %s -o %t
22 // RUN: FileCheck -input-file %t %s
33 // RUN: %compile_cxx %t
44 // XFAIL: vg_leak
0 // Test for the OptionPreprocessor and related functionality.
1 // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t
1 // RUN: tblgen -I %p/../../include -llvmc-temp-hack --gen-llvmc %s -o %t
22 // RUN: FileCheck -input-file %t %s
33 // RUN: %compile_cxx %t
44 // XFAIL: vg_leak
3232 // CHECK-NEXT: dag d = (X2 Y2)
3333 // CHECK-NEXT: dag e = (Y2 X2)
3434
35
36 //===----------------------------------------------------------------------===//
37 // Complex dag operator (F.TheOp).
38
39 class operator;
40 def somedef1 : operator;
41 def somedef2 : operator;
42
43 class foo {
44 operator TheOp = a;
45 }
46
47 class bar {
48 dag Dag1 = (somedef1 1);
49 dag Dag2 = (a 2);
50 dag Dag3 = (F.TheOp 2);
51 }
52
53 def foo1 : foo;
54 def foo2 : foo;
55
56 def VAL3 : bar;
57
58 // CHECK: def VAL3 { // bar
59 // CHECK-NEXT: dag Dag1 = (somedef1 1);
60 // CHECK-NEXT: dag Dag2 = (somedef1 2);
61 // CHECK-NEXT: dag Dag3 = (somedef1 2);
62 // CHECK-NEXT: }
63
64
65 def VAL4 : bar;
66 // CHECK: def VAL4 {
67 // CHECK-NEXT: dag Dag1 = (somedef1 1);
68 // CHECK-NEXT: dag Dag2 = (somedef2 2);
69 // CHECK-NEXT: dag Dag3 = (somedef2 2);
70 // CHECK-NEXT: }
1616 #include
1717 #include
1818 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/Support/CommandLine.h"
1920 using namespace llvm;
21
22 /// LLVMCHack - This is a temporary hack that changes how "(foo [1, 2, 3])"
23 /// parses.
24 /// FIXME: REMOVE THIS.
25 static cl::opt LLVMCHack("llvmc-temp-hack", cl::ReallyHidden);
2026
2127 //===----------------------------------------------------------------------===//
2228 // Support Code for the Semantic Actions.
12121218 return 0;
12131219 }
12141220
1215 Init *Operator = 0;
1216 if (Lex.getCode() == tgtok::Id)
1217 Operator = ParseIDValue(CurRec);
1218 else
1219 Operator = ParseOperation(CurRec);
1221 Init *Operator;
1222 /// LLVMC Requires an old grammar and I don't know how to update it, placate
1223 /// it in the short term by changing the grammar specifically for llvmc.
1224 /// FIXME: REMOVE THIS.
1225 if (!LLVMCHack)
1226 Operator = ParseValue(CurRec);
1227 else {
1228 if (Lex.getCode() == tgtok::Id)
1229 Operator = ParseIDValue(CurRec);
1230 else
1231 Operator = ParseOperation(CurRec);
1232 }
12201233 if (Operator == 0) return 0;
12211234
12221235 // If the operator name is present, parse it.