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

Sean Silva chisophugis at gmail.com
Fri Aug 29 13:27:56 PDT 2014


On Fri, Aug 29, 2014 at 12:41 PM, Jean-Luc Duprat <jduprat at apple.com> wrote:

> 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.
> +      }
>

Please add a FIXME to this loop for removing the duplication with the one
just above. That is a valuable use case that reduces the problem space for
refactoring the Record.h API's.


>        // 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;
>

Can you provide an explanation for why this is printing differently with
this patch?

-- Sean Silva


>  // 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: }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140829/fe924af5/attachment.html>


More information about the llvm-commits mailing list