[llvm] b732e6c - Revert "[GlobalISel] NFC: Have LLT::getSizeInBits/Bytes return a TypeSize."
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 25 09:38:32 PDT 2021
Author: Sander de Smalen
Date: 2021-06-25T17:37:16+01:00
New Revision: b732e6c9a8438e5204ac96c8ca76f9b11abf98ff
URL: https://github.com/llvm/llvm-project/commit/b732e6c9a8438e5204ac96c8ca76f9b11abf98ff
DIFF: https://github.com/llvm/llvm-project/commit/b732e6c9a8438e5204ac96c8ca76f9b11abf98ff.diff
LOG: Revert "[GlobalISel] NFC: Have LLT::getSizeInBits/Bytes return a TypeSize."
This patch seems to be causing build errors, reverting it for now.
This reverts commit aeab9d9570ac8cb554aff6e1af24a471fdf5b4e5.
Added:
Modified:
llvm/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h
llvm/include/llvm/Support/LowLevelTypeImpl.h
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerCombiner.cpp
llvm/unittests/CodeGen/LowLevelTypeTest.cpp
llvm/utils/TableGen/GlobalISelEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h b/llvm/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h
index bc9f952146c2d..d9814962d11d8 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h
@@ -595,7 +595,7 @@ bool InstructionSelector::executeMatchTable(
case GIM_CheckPointerToAny: {
int64_t InsnID = MatchTable[CurrentIdx++];
int64_t OpIdx = MatchTable[CurrentIdx++];
- uint64_t SizeInBits = MatchTable[CurrentIdx++];
+ int64_t SizeInBits = MatchTable[CurrentIdx++];
DEBUG_WITH_TYPE(TgtInstructionSelector::getName(),
dbgs() << CurrentIdx << ": GIM_CheckPointerToAny(MIs["
diff --git a/llvm/include/llvm/Support/LowLevelTypeImpl.h b/llvm/include/llvm/Support/LowLevelTypeImpl.h
index 379e37101e9a4..0660bcd8256c8 100644
--- a/llvm/include/llvm/Support/LowLevelTypeImpl.h
+++ b/llvm/include/llvm/Support/LowLevelTypeImpl.h
@@ -67,7 +67,7 @@ class LLT {
assert(!EC.isScalar() && "invalid number of vector elements");
assert(!ScalarTy.isVector() && "invalid vector element type");
return LLT{ScalarTy.isPointer(), /*isVector=*/true, EC,
- ScalarTy.getSizeInBits().getFixedSize(),
+ ScalarTy.getSizeInBits(),
ScalarTy.isPointer() ? ScalarTy.getAddressSpace() : 0};
}
@@ -100,14 +100,12 @@ class LLT {
return EC.isScalar() ? ScalarTy : LLT::vector(EC, ScalarTy);
}
- static LLT scalarOrVector(ElementCount EC, uint64_t ScalarSize) {
- assert(ScalarSize <= std::numeric_limits<unsigned>::max() &&
- "Not enough bits in LLT to represent size");
- return scalarOrVector(EC, LLT::scalar(static_cast<unsigned>(ScalarSize)));
+ static LLT scalarOrVector(ElementCount EC, unsigned ScalarSize) {
+ return scalarOrVector(EC, LLT::scalar(ScalarSize));
}
explicit LLT(bool isPointer, bool isVector, ElementCount EC,
- uint64_t SizeInBits, unsigned AddressSpace) {
+ unsigned SizeInBits, unsigned AddressSpace) {
init(isPointer, isVector, EC, SizeInBits, AddressSpace);
}
explicit LLT() : IsPointer(false), IsVector(false), RawData(0) {}
@@ -150,19 +148,18 @@ class LLT {
}
/// Returns the total size of the type. Must only be called on sized types.
- TypeSize getSizeInBits() const {
+ unsigned getSizeInBits() const {
if (isPointer() || isScalar())
- return TypeSize::Fixed(getScalarSizeInBits());
- auto EC = getElementCount();
- return TypeSize(getScalarSizeInBits() * EC.getKnownMinValue(),
- EC.isScalable());
+ return getScalarSizeInBits();
+ // FIXME: This should return a TypeSize in order to work for scalable
+ // vectors.
+ return getScalarSizeInBits() * getElementCount().getKnownMinValue();
}
/// Returns the total size of the type in bytes, i.e. number of whole bytes
/// needed to represent the size in bits. Must only be called on sized types.
- TypeSize getSizeInBytes() const {
- TypeSize BaseSize = getSizeInBits();
- return {(BaseSize.getKnownMinSize() + 7) / 8, BaseSize.isScalable()};
+ unsigned getSizeInBytes() const {
+ return (getSizeInBits() + 7) / 8;
}
LLT getScalarType() const {
@@ -202,11 +199,11 @@ class LLT {
getElementType());
}
- assert(getScalarSizeInBits() % Factor == 0);
- return scalar(getScalarSizeInBits() / Factor);
+ assert(getSizeInBits() % Factor == 0);
+ return scalar(getSizeInBits() / Factor);
}
- bool isByteSized() const { return getSizeInBits().isKnownMultipleOf(8); }
+ bool isByteSized() const { return (getSizeInBits() & 7) == 0; }
unsigned getScalarSizeInBits() const {
assert(RawData != 0 && "Invalid Type");
@@ -336,10 +333,8 @@ class LLT {
return getMask(FieldInfo) & (RawData >> FieldInfo[1]);
}
- void init(bool IsPointer, bool IsVector, ElementCount EC, uint64_t SizeInBits,
+ void init(bool IsPointer, bool IsVector, ElementCount EC, unsigned SizeInBits,
unsigned AddressSpace) {
- assert(SizeInBits <= std::numeric_limits<unsigned>::max() &&
- "Not enough bits in LLT to represent size");
this->IsPointer = IsPointer;
this->IsVector = IsVector;
if (!IsVector) {
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 42c63849910e4..cbe4568245872 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -1565,7 +1565,7 @@ bool IRTranslator::translateMemFunc(const CallInst &CI,
Register SrcReg = getOrCreateVReg(**AI);
LLT SrcTy = MRI->getType(SrcReg);
if (SrcTy.isPointer())
- MinPtrSize = std::min<unsigned>(SrcTy.getSizeInBits(), MinPtrSize);
+ MinPtrSize = std::min(SrcTy.getSizeInBits(), MinPtrSize);
SrcRegs.push_back(SrcReg);
}
diff --git a/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerCombiner.cpp b/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerCombiner.cpp
index 820694b72fc10..753b380faf44d 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerCombiner.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerCombiner.cpp
@@ -258,8 +258,7 @@ static bool matchBitfieldExtractFromSExtInReg(
m_OneNonDBGUse(m_any_of(m_GAShr(m_Reg(ShiftSrc), m_ICst(ShiftImm)),
m_GLShr(m_Reg(ShiftSrc), m_ICst(ShiftImm))))))
return false;
- if (ShiftImm < 0 ||
- static_cast<uint64_t>(ShiftImm + Width) > Ty.getSizeInBits())
+ if (ShiftImm < 0 || ShiftImm + Width > Ty.getSizeInBits())
return false;
MatchInfo = [=](MachineIRBuilder &B) {
auto Cst1 = B.buildConstant(Ty, ShiftImm);
diff --git a/llvm/unittests/CodeGen/LowLevelTypeTest.cpp b/llvm/unittests/CodeGen/LowLevelTypeTest.cpp
index 9ff75b8f183bb..e27c6e4e955a4 100644
--- a/llvm/unittests/CodeGen/LowLevelTypeTest.cpp
+++ b/llvm/unittests/CodeGen/LowLevelTypeTest.cpp
@@ -81,9 +81,6 @@ TEST(LowLevelTypeTest, Vector) {
EXPECT_EQ(EC, VTy.getElementCount());
if (!EC.isScalable())
EXPECT_EQ(S * EC.getFixedValue(), VTy.getSizeInBits());
- else
- EXPECT_EQ(TypeSize::Scalable(S * EC.getKnownMinValue()),
- VTy.getSizeInBits());
// Test equality operators.
EXPECT_TRUE(VTy == VTy);
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index 693073672fc11..497854ababfe3 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -182,13 +182,7 @@ class LLTCodeGen {
assert((!Ty.isVector() || Ty.isScalable() == Other.Ty.isScalable()) &&
"Unexpected mismatch of scalable property");
- return Ty.isVector()
- ? std::make_tuple(Ty.isScalable(),
- Ty.getSizeInBits().getKnownMinSize()) <
- std::make_tuple(Other.Ty.isScalable(),
- Other.Ty.getSizeInBits().getKnownMinSize())
- : Ty.getSizeInBits().getFixedSize() <
- Other.Ty.getSizeInBits().getFixedSize();
+ return Ty.getSizeInBits() < Other.Ty.getSizeInBits();
}
bool operator==(const LLTCodeGen &B) const { return Ty == B.Ty; }
@@ -3794,8 +3788,7 @@ Optional<unsigned> GlobalISelEmitter::getMemSizeBitsFromPredicate(const TreePred
return None;
// Align so unusual types like i1 don't get rounded down.
- return llvm::alignTo(
- static_cast<unsigned>(MemTyOrNone->get().getSizeInBits()), 8);
+ return llvm::alignTo(MemTyOrNone->get().getSizeInBits(), 8);
}
Expected<InstructionMatcher &> GlobalISelEmitter::addBuiltinPredicates(
More information about the llvm-commits
mailing list