[llvm] r216757 - Tablegen fixes for new syntax when initializing bits from variables.

Jean-Luc Duprat jduprat at apple.com
Fri Aug 29 12:41:05 PDT 2014


Author: jduprat
Date: Fri Aug 29 14:41:04 2014
New Revision: 216757

URL: http://llvm.org/viewvc/llvm-project?rev=216757&view=rev
Log:
Tablegen fixes for new syntax when initializing bits from variables.
Followup to r215086.


Modified:
    llvm/trunk/lib/TableGen/TGParser.cpp
    llvm/trunk/test/TableGen/BitsInit.td

Modified: llvm/trunk/lib/TableGen/TGParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=216757&r1=216756&r2=216757&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/TGParser.cpp (original)
+++ llvm/trunk/lib/TableGen/TGParser.cpp Fri Aug 29 14:41:04 2014
@@ -1321,6 +1321,15 @@ Init *TGParser::ParseSimpleValue(Record
           NewBits.push_back(BI->getBit((e - i) - 1));
         continue;
       }
+      // bits<n> can also come from variable initializers.
+      if (VarInit *VI = dyn_cast<VarInit>(Vals[i])) {
+        if (BitsRecTy *BitsRec = dyn_cast<BitsRecTy>(VI->getType())) {
+          for (unsigned i = 0, e = BitsRec->getNumBits(); i != e; ++i)
+            NewBits.push_back(VI->getBit((e - i) - 1));
+          continue;
+        }
+        // Fallthrough to try convert this to a bit.
+      }
       // All other values must be convertible to just a single bit.
       Init *Bit = Vals[i]->convertInitializerTo(BitRecTy::get());
       if (!Bit) {

Modified: llvm/trunk/test/TableGen/BitsInit.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/BitsInit.td?rev=216757&r1=216756&r2=216757&view=diff
==============================================================================
--- llvm/trunk/test/TableGen/BitsInit.td (original)
+++ llvm/trunk/test/TableGen/BitsInit.td Fri Aug 29 14:41:04 2014
@@ -16,7 +16,7 @@ def a {
 // CHECK:   bits<2> opc = { 0, 1 };
 // CHECK:   bits<2> opc2 = { 1, 0 };
 // CHECK:   bits<1> opc3 = { 1 };
-// CHECK:   bits<2> a = { ?, ? };
+// CHECK:   bits<2> a;
 // CHECK:   bits<2> b = { 1, 0 };
 // CHECK:   bits<2> c = { 1, 1 };
 // CHECK: }
@@ -51,6 +51,7 @@ def {
 
   bits<16> H;
   let H{15-0} = { { 0b11001100 }, 0b00110011 };
+  bits<16> I = { G1, G2 };
 
   // Make sure we can initialise ints with bits<> values.
   int J = H;
@@ -78,6 +79,7 @@ def {
 // CHECK: bits<8> G2 = { 0, 1, 1, 0, 0, 1, 0, 0 };
 // CHECK: bits<8> G3 = { 0, 1, 1, 0, 0, 1, 0, 0 };
 // CHECK: bits<16> H = { 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1 };
+// CHECK: bits<16> I = { 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0 };
 // CHECK: int J = 52275;
 // CHECK: int K = 1;
 // CHECK: }





More information about the llvm-commits mailing list