[PATCH] D138341: [TableGen] Fix SubRegIndex size computation for concatenated subregs of unknown size
Bjorn Pettersson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 18 16:19:23 PST 2022
bjope created this revision.
bjope added a reviewer: arsenm.
Herald added subscribers: pengfei, arphaman.
Herald added a project: All.
bjope requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.
When calculating the size of concatenated subregisters, and at least
one of the subregisters involved has an unknown size (-1), then the
concatenated size should be set to -1 as well.
This bug was found for an out-of-tree target.
Looking at lib/Target the only in-tree target that has a subregister
with unknown size is X86:
X86RegisterInfo.td: def sub_mask_0 : SubRegIndex<-1>;
But it looks like sub_mask_0 don't result in any concatenated subreg
index with faulty size if looking at X86SubRegIdxRanges[].
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D138341
Files:
llvm/test/TableGen/ConcatenatedSubregs.td
llvm/utils/TableGen/CodeGenRegisters.cpp
Index: llvm/utils/TableGen/CodeGenRegisters.cpp
===================================================================
--- llvm/utils/TableGen/CodeGenRegisters.cpp
+++ llvm/utils/TableGen/CodeGenRegisters.cpp
@@ -1369,11 +1369,15 @@
unsigned Size = Parts.front()->Size;
unsigned LastOffset = Parts.front()->Offset;
unsigned LastSize = Parts.front()->Size;
+ unsigned UnknownSize = (uint16_t)-1;
for (unsigned i = 1, e = Parts.size(); i != e; ++i) {
Name += '_';
Name += Parts[i]->getName();
- Size += Parts[i]->Size;
- if (Parts[i]->Offset != (LastOffset + LastSize))
+ if (Size == UnknownSize || Parts[i]->Size == UnknownSize)
+ Size = UnknownSize;
+ else
+ Size += Parts[i]->Size;
+ if (LastSize == UnknownSize || Parts[i]->Offset != (LastOffset + LastSize))
isContinuous = false;
LastOffset = Parts[i]->Offset;
LastSize = Parts[i]->Size;
Index: llvm/test/TableGen/ConcatenatedSubregs.td
===================================================================
--- llvm/test/TableGen/ConcatenatedSubregs.td
+++ llvm/test/TableGen/ConcatenatedSubregs.td
@@ -96,12 +96,10 @@
// CHECK-LABEL: SubRegIndex sub2:
// Check inferred indexes:
// CHECK-LABEL: SubRegIndex ssub1_ssub2:
-// FIXME: Size should be unknown (65535).
-// CHECK: Offset, Size: 16, 15
+// CHECK: Offset, Size: 16, 65535
// CHECK-LABEL: SubRegIndex ssub3_ssub4:
// CHECK-LABEL: SubRegIndex ssub0_ssub1_ssub2_ssub3:
-// FIXME: Size should be unknown (65535).
-// CHECK: Offset, Size: 65535, 30
+// CHECK: Offset, Size: 65535, 65535
// CHECK-LABEL: SubRegIndex ssub1_ssub2_ssub3_ssub4:
// Check that all subregs are generated on some examples
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138341.476630.patch
Type: text/x-patch
Size: 1705 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221119/b213c5b7/attachment.bin>
More information about the llvm-commits
mailing list