aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/CodeGenRegisters.cpp
diff options
context:
space:
mode:
authorBjorn Pettersson <bjorn.a.pettersson@ericsson.com>2022-11-19 01:16:11 +0100
committerBjorn Pettersson <bjorn.a.pettersson@ericsson.com>2022-11-20 20:52:13 +0100
commit294fdd99039e90ff996124c7775ca1efdea15cc2 (patch)
treeae5120da6a5d208453bd0295e88b37f56f637563 /llvm/utils/TableGen/CodeGenRegisters.cpp
parenta6cb924abcd852cc598d98936aa1c4d7c2e90845 (diff)
downloadllvm-294fdd99039e90ff996124c7775ca1efdea15cc2.zip
llvm-294fdd99039e90ff996124c7775ca1efdea15cc2.tar.gz
llvm-294fdd99039e90ff996124c7775ca1efdea15cc2.tar.bz2
[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
Diffstat (limited to 'llvm/utils/TableGen/CodeGenRegisters.cpp')
-rw-r--r--llvm/utils/TableGen/CodeGenRegisters.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/utils/TableGen/CodeGenRegisters.cpp b/llvm/utils/TableGen/CodeGenRegisters.cpp
index 999c720..5454126 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;