[PATCH] D105423: Add support for Opaque as a LowLevelType
Paulo Matos via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 8 03:50:23 PDT 2021
pmatos updated this revision to Diff 357185.
pmatos added a comment.
Remove extraneous code
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105423/new/
https://reviews.llvm.org/D105423
Files:
llvm/include/llvm/Support/LowLevelTypeImpl.h
llvm/lib/CodeGen/MachineOperand.cpp
llvm/lib/Support/LowLevelType.cpp
Index: llvm/lib/Support/LowLevelType.cpp
===================================================================
--- llvm/lib/Support/LowLevelType.cpp
+++ llvm/lib/Support/LowLevelType.cpp
@@ -23,9 +23,12 @@
} else if (VT.isValid()) {
// Aggregates are no different from real scalars as far as GlobalISel is
// concerned.
- assert(VT.getSizeInBits().isNonZero() && "invalid zero-sized type");
- init(/*IsPointer=*/false, /*IsVector=*/false, ElementCount::getFixed(0),
- VT.getSizeInBits(), /*AddressSpace=*/0);
+ if (VT.getSizeInBits().isNonZero())
+ init(/*IsPointer=*/false, /*IsVector=*/false, ElementCount::getFixed(0),
+ VT.getSizeInBits(), /*AddressSpace=*/0);
+ else
+ init(/*IsPointer=*/false, /*IsVector=*/false, ElementCount::getFixed(0),
+ VT.getSizeInBits(), /*AddressSpace=*/0);
} else {
IsPointer = false;
IsVector = false;
@@ -39,6 +42,8 @@
OS << getElementCount() << " x " << getElementType() << ">";
} else if (isPointer())
OS << "p" << getAddressSpace();
+ else if (isOpaque())
+ OS << "<opaque>";
else if (isValid()) {
assert(isScalar() && "unexpected type");
OS << "s" << getScalarSizeInBits();
Index: llvm/lib/CodeGen/MachineOperand.cpp
===================================================================
--- llvm/lib/CodeGen/MachineOperand.cpp
+++ llvm/lib/CodeGen/MachineOperand.cpp
@@ -1048,9 +1048,12 @@
const MDNode *Ranges, SyncScope::ID SSID,
AtomicOrdering Ordering,
AtomicOrdering FailureOrdering)
- : MachineMemOperand(ptrinfo, f,
- s == ~UINT64_C(0) ? LLT() : LLT::scalar(8 * s), a,
- AAInfo, Ranges, SSID, Ordering, FailureOrdering) {}
+ : MachineMemOperand(
+ ptrinfo, f,
+ s == ~UINT64_C(0)
+ ? LLT()
+ : (s == UINT64_C(0) ? LLT::opaque() : LLT::scalar(8 * s)),
+ a, AAInfo, Ranges, SSID, Ordering, FailureOrdering) {}
/// Profile - Gather unique data for the object.
///
Index: llvm/include/llvm/Support/LowLevelTypeImpl.h
===================================================================
--- llvm/include/llvm/Support/LowLevelTypeImpl.h
+++ llvm/include/llvm/Support/LowLevelTypeImpl.h
@@ -47,6 +47,13 @@
/*AddressSpace=*/0};
}
+ /// Get a low-level opaque type, defined as a scalar of zero size
+ static LLT opaque() {
+ return LLT{/*isPointer=*/false, /*isVector=*/false,
+ ElementCount::getFixed(0), 0,
+ /*AddressSpace=*/0};
+ }
+
/// Get a low-level pointer in the given address space.
static LLT pointer(unsigned AddressSpace, unsigned SizeInBits) {
assert(SizeInBits > 0 && "invalid pointer size");
@@ -116,12 +123,18 @@
bool isValid() const { return RawData != 0; }
- bool isScalar() const { return isValid() && !IsPointer && !IsVector; }
+ bool isScalar() const {
+ return isValid() && !IsPointer && !IsVector && getScalarSizeInBits() != 0;
+ }
bool isPointer() const { return isValid() && IsPointer && !IsVector; }
bool isVector() const { return isValid() && IsVector; }
+ bool isOpaque() const {
+ return isValid() && !IsPointer && !IsVector && getScalarSizeInBits() == 0;
+ }
+
/// Returns the number of elements in a vector LLT. Must only be called on
/// vector types.
uint16_t getNumElements() const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105423.357185.patch
Type: text/x-patch
Size: 3486 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210708/5da5e1d8/attachment.bin>
More information about the llvm-commits
mailing list