forked from OSchip/llvm-project
Update some of the derived type classes to use getImpl instead of a static_cast.
PiperOrigin-RevId: 240084937
This commit is contained in:
parent
e510de0305
commit
63e8725bc2
|
@ -167,7 +167,7 @@ public:
|
|||
}
|
||||
|
||||
/// Utility for easy access to the storage instance.
|
||||
ImplType *getImpl() { return static_cast<ImplType *>(type); }
|
||||
ImplType *getImpl() const { return static_cast<ImplType *>(type); }
|
||||
};
|
||||
|
||||
using ImplType = TypeStorage;
|
||||
|
|
|
@ -50,9 +50,7 @@ IntegerType IntegerType::getChecked(unsigned width, MLIRContext *context,
|
|||
return Base::getChecked(location, context, StandardTypes::Integer, width);
|
||||
}
|
||||
|
||||
unsigned IntegerType::getWidth() const {
|
||||
return static_cast<ImplType *>(type)->width;
|
||||
}
|
||||
unsigned IntegerType::getWidth() const { return getImpl()->width; }
|
||||
|
||||
/// Float Type.
|
||||
|
||||
|
@ -221,9 +219,7 @@ bool VectorType::verifyConstructionInvariants(llvm::Optional<Location> loc,
|
|||
return false;
|
||||
}
|
||||
|
||||
ArrayRef<int64_t> VectorType::getShape() const {
|
||||
return static_cast<ImplType *>(type)->getShape();
|
||||
}
|
||||
ArrayRef<int64_t> VectorType::getShape() const { return getImpl()->getShape(); }
|
||||
|
||||
/// TensorType
|
||||
|
||||
|
@ -269,11 +265,7 @@ bool RankedTensorType::verifyConstructionInvariants(
|
|||
}
|
||||
|
||||
ArrayRef<int64_t> RankedTensorType::getShape() const {
|
||||
return static_cast<ImplType *>(type)->getShape();
|
||||
}
|
||||
|
||||
ArrayRef<int64_t> MemRefType::getShape() const {
|
||||
return static_cast<ImplType *>(type)->getShape();
|
||||
return getImpl()->getShape();
|
||||
}
|
||||
|
||||
/// UnrankedTensorType
|
||||
|
@ -351,6 +343,10 @@ MemRefType MemRefType::getImpl(ArrayRef<int64_t> shape, Type elementType,
|
|||
cleanedAffineMapComposition, memorySpace);
|
||||
}
|
||||
|
||||
ArrayRef<int64_t> MemRefType::getShape() const {
|
||||
return static_cast<ImplType *>(type)->getShape();
|
||||
}
|
||||
|
||||
Type MemRefType::getElementType() const {
|
||||
return static_cast<ImplType *>(type)->elementType;
|
||||
}
|
||||
|
@ -376,11 +372,7 @@ TupleType TupleType::get(ArrayRef<Type> elementTypes, MLIRContext *context) {
|
|||
}
|
||||
|
||||
/// Return the elements types for this tuple.
|
||||
ArrayRef<Type> TupleType::getTypes() const {
|
||||
return static_cast<ImplType *>(type)->getTypes();
|
||||
}
|
||||
ArrayRef<Type> TupleType::getTypes() const { return getImpl()->getTypes(); }
|
||||
|
||||
/// Return the number of element types.
|
||||
unsigned TupleType::size() const {
|
||||
return static_cast<ImplType *>(type)->size();
|
||||
}
|
||||
unsigned TupleType::size() const { return getImpl()->size(); }
|
||||
|
|
|
@ -41,15 +41,13 @@ FunctionType FunctionType::get(ArrayRef<Type> inputs, ArrayRef<Type> results,
|
|||
}
|
||||
|
||||
ArrayRef<Type> FunctionType::getInputs() const {
|
||||
return static_cast<ImplType *>(type)->getInputs();
|
||||
return getImpl()->getInputs();
|
||||
}
|
||||
|
||||
unsigned FunctionType::getNumResults() const {
|
||||
return static_cast<ImplType *>(type)->numResults;
|
||||
}
|
||||
unsigned FunctionType::getNumResults() const { return getImpl()->numResults; }
|
||||
|
||||
ArrayRef<Type> FunctionType::getResults() const {
|
||||
return static_cast<ImplType *>(type)->getResults();
|
||||
return getImpl()->getResults();
|
||||
}
|
||||
|
||||
/// UnknownType
|
||||
|
@ -66,13 +64,11 @@ UnknownType UnknownType::getChecked(Identifier dialect, StringRef typeData,
|
|||
|
||||
/// Returns the dialect namespace of the unknown type.
|
||||
Identifier UnknownType::getDialectNamespace() const {
|
||||
return static_cast<ImplType *>(type)->dialectNamespace;
|
||||
return getImpl()->dialectNamespace;
|
||||
}
|
||||
|
||||
/// Returns the raw type data of the unknown type.
|
||||
StringRef UnknownType::getTypeData() const {
|
||||
return static_cast<ImplType *>(type)->typeData;
|
||||
}
|
||||
StringRef UnknownType::getTypeData() const { return getImpl()->typeData; }
|
||||
|
||||
/// Verify the construction of an unknown type.
|
||||
bool UnknownType::verifyConstructionInvariants(llvm::Optional<Location> loc,
|
||||
|
|
|
@ -57,7 +57,7 @@ LLVMType LLVMType::get(MLIRContext *context, llvm::Type *llvmType) {
|
|||
}
|
||||
|
||||
llvm::Type *LLVMType::getUnderlyingType() const {
|
||||
return static_cast<ImplType *>(type)->underlyingType;
|
||||
return getImpl()->underlyingType;
|
||||
}
|
||||
|
||||
/*---- LLVM IR Dialect and its registration ----------------------------- */
|
||||
|
|
Loading…
Reference in New Issue