summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR/Attributes.cpp
diff options
context:
space:
mode:
authorRiver Riddle <riverriddle@google.com>2018-10-30 14:59:22 -0700
committerjpienaar <jpienaar@google.com>2019-03-29 13:45:54 -0700
commit4c465a181db49c436f62da303e8fdd3ed317fee7 (patch)
treefb190912d0714222d6e336e19d5b8ea16342fb6e /mlir/lib/IR/Attributes.cpp
parent75376b8e33c67a42e3dca2c597197e0622b6eaa2 (diff)
downloadbcm5719-llvm-4c465a181db49c436f62da303e8fdd3ed317fee7.tar.gz
bcm5719-llvm-4c465a181db49c436f62da303e8fdd3ed317fee7.zip
Implement value type abstraction for types.
This is done by changing Type to be a POD interface around an underlying pointer storage and adding in-class support for isa/dyn_cast/cast. PiperOrigin-RevId: 219372163
Diffstat (limited to 'mlir/lib/IR/Attributes.cpp')
-rw-r--r--mlir/lib/IR/Attributes.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/mlir/lib/IR/Attributes.cpp b/mlir/lib/IR/Attributes.cpp
index 34312b84a0b..58b5b90d43d 100644
--- a/mlir/lib/IR/Attributes.cpp
+++ b/mlir/lib/IR/Attributes.cpp
@@ -75,9 +75,7 @@ IntegerSet IntegerSetAttr::getValue() const {
TypeAttr::TypeAttr(Attribute::ImplType *ptr) : Attribute(ptr) {}
-Type *TypeAttr::getValue() const {
- return static_cast<ImplType *>(attr)->value;
-}
+Type TypeAttr::getValue() const { return static_cast<ImplType *>(attr)->value; }
FunctionAttr::FunctionAttr(Attribute::ImplType *ptr) : Attribute(ptr) {}
@@ -85,11 +83,11 @@ Function *FunctionAttr::getValue() const {
return static_cast<ImplType *>(attr)->value;
}
-FunctionType *FunctionAttr::getType() const { return getValue()->getType(); }
+FunctionType FunctionAttr::getType() const { return getValue()->getType(); }
ElementsAttr::ElementsAttr(Attribute::ImplType *ptr) : Attribute(ptr) {}
-VectorOrTensorType *ElementsAttr::getType() const {
+VectorOrTensorType ElementsAttr::getType() const {
return static_cast<ImplType *>(attr)->type;
}
@@ -166,8 +164,8 @@ uint64_t DenseIntElementsAttr::readBits(const char *rawData, size_t bitPos,
void DenseIntElementsAttr::getValues(SmallVectorImpl<Attribute> &values) const {
auto bitsWidth = static_cast<ImplType *>(attr)->bitsWidth;
- auto elementNum = getType()->getNumElements();
- auto context = getType()->getContext();
+ auto elementNum = getType().getNumElements();
+ auto context = getType().getContext();
values.reserve(elementNum);
if (bitsWidth == 64) {
ArrayRef<int64_t> vs(
@@ -192,8 +190,8 @@ DenseFPElementsAttr::DenseFPElementsAttr(Attribute::ImplType *ptr)
: DenseElementsAttr(ptr) {}
void DenseFPElementsAttr::getValues(SmallVectorImpl<Attribute> &values) const {
- auto elementNum = getType()->getNumElements();
- auto context = getType()->getContext();
+ auto elementNum = getType().getNumElements();
+ auto context = getType().getContext();
ArrayRef<double> vs({reinterpret_cast<const double *>(getRawData().data()),
getRawData().size() / 8});
values.reserve(elementNum);
OpenPOWER on IntegriCloud