[llvm] 294fdd9 - [TableGen] Fix SubRegIndex size computation for concatenated subregs of unknown size
Bjorn Pettersson via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 20 11:52:27 PST 2022
Author: Bjorn Pettersson
Date: 2022-11-20T20:52:13+01:00
New Revision: 294fdd99039e90ff996124c7775ca1efdea15cc2
URL: https://github.com/llvm/llvm-project/commit/294fdd99039e90ff996124c7775ca1efdea15cc2
DIFF: https://github.com/llvm/llvm-project/commit/294fdd99039e90ff996124c7775ca1efdea15cc2.diff
LOG: [TableGen] Fix SubRegIndex size computation for concatenated subregs of unknown size
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[].
Differential Revision: https://reviews.llvm.org/D138341
Added:
Modified:
llvm/test/TableGen/ConcatenatedSubregs.td
llvm/utils/TableGen/CodeGenRegisters.cpp
Removed:
################################################################################
diff --git a/llvm/test/TableGen/ConcatenatedSubregs.td b/llvm/test/TableGen/ConcatenatedSubregs.td
index 87db95949b78c..5b354c94dca52 100644
--- a/llvm/test/TableGen/ConcatenatedSubregs.td
+++ b/llvm/test/TableGen/ConcatenatedSubregs.td
@@ -96,12 +96,10 @@ def TestTarget : Target;
// 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
diff --git a/llvm/utils/TableGen/CodeGenRegisters.cpp b/llvm/utils/TableGen/CodeGenRegisters.cpp
index 999c720e6c303..54541260c9a10 100644
--- a/llvm/utils/TableGen/CodeGenRegisters.cpp
+++ b/llvm/utils/TableGen/CodeGenRegisters.cpp
@@ -1369,11 +1369,15 @@ getConcatSubRegIndex(const SmallVector<CodeGenSubRegIndex *, 8> &Parts) {
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;
More information about the llvm-commits
mailing list