[PATCH] D74220: [TableGen] Fix spurious type error in bit assignment.
Simon Tatham via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 7 07:15:18 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5c6b1a6dfdb4: [TableGen] Fix spurious type error in bit assignment. (authored by simon_tatham).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74220/new/
https://reviews.llvm.org/D74220
Files:
llvm/lib/TableGen/TGParser.cpp
llvm/test/TableGen/BitsInit.td
Index: llvm/test/TableGen/BitsInit.td
===================================================================
--- llvm/test/TableGen/BitsInit.td
+++ llvm/test/TableGen/BitsInit.td
@@ -56,6 +56,10 @@
// Make sure we can initialise ints with bits<> values.
int J = H;
int K = { 0, 1 };
+
+ bits<2> L;
+ let L{0} = 1;
+ let L{1} = !eq(L{0}, 0);
}
// CHECK: def {{.*}} {
@@ -82,4 +86,5 @@
// 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: bits<2> L = { 0, 1 };
// CHECK: }
Index: llvm/lib/TableGen/TGParser.cpp
===================================================================
--- llvm/lib/TableGen/TGParser.cpp
+++ llvm/lib/TableGen/TGParser.cpp
@@ -2640,6 +2640,11 @@
return TokError("Value '" + FieldName->getValue() + "' unknown!");
RecTy *Type = Field->getType();
+ if (!BitList.empty() && isa<BitsRecTy>(Type)) {
+ // When assigning to a subset of a 'bits' object, expect the RHS to have
+ // the type of that subset instead of the type of the whole object.
+ Type = BitsRecTy::get(BitList.size());
+ }
Init *Val = ParseValue(CurRec, Type);
if (!Val) return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74220.243165.patch
Type: text/x-patch
Size: 1195 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200207/2dcdca7f/attachment.bin>
More information about the llvm-commits
mailing list