#include "mlir/IR/BuiltinAttributes.h"
#include "AttributeDetail.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/BuiltinDialect.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/DialectResourceBlobManager.h"
#include "mlir/IR/IntegerSet.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/SymbolTable.h"
#include "mlir/IR/Types.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/Sequence.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Endian.h"
#include <optional>
#define DEBUG_TYPE …
usingnamespacemlir;
usingnamespacemlir::detail;
#define GET_ATTRDEF_CLASSES
#include "mlir/IR/BuiltinAttributes.cpp.inc"
void BuiltinDialect::registerAttributes() { … }
template <bool inPlace>
static bool dictionaryAttrSort(ArrayRef<NamedAttribute> value,
SmallVectorImpl<NamedAttribute> &storage) { … }
static std::optional<NamedAttribute>
findDuplicateElement(ArrayRef<NamedAttribute> value) { … }
bool DictionaryAttr::sort(ArrayRef<NamedAttribute> value,
SmallVectorImpl<NamedAttribute> &storage) { … }
bool DictionaryAttr::sortInPlace(SmallVectorImpl<NamedAttribute> &array) { … }
std::optional<NamedAttribute>
DictionaryAttr::findDuplicate(SmallVectorImpl<NamedAttribute> &array,
bool isSorted) { … }
DictionaryAttr DictionaryAttr::get(MLIRContext *context,
ArrayRef<NamedAttribute> value) { … }
DictionaryAttr DictionaryAttr::getWithSorted(MLIRContext *context,
ArrayRef<NamedAttribute> value) { … }
Attribute DictionaryAttr::get(StringRef name) const { … }
Attribute DictionaryAttr::get(StringAttr name) const { … }
std::optional<NamedAttribute> DictionaryAttr::getNamed(StringRef name) const { … }
std::optional<NamedAttribute> DictionaryAttr::getNamed(StringAttr name) const { … }
bool DictionaryAttr::contains(StringRef name) const { … }
bool DictionaryAttr::contains(StringAttr name) const { … }
DictionaryAttr::iterator DictionaryAttr::begin() const { … }
DictionaryAttr::iterator DictionaryAttr::end() const { … }
size_t DictionaryAttr::size() const { … }
DictionaryAttr DictionaryAttr::getEmptyUnchecked(MLIRContext *context) { … }
void StridedLayoutAttr::print(llvm::raw_ostream &os) const { … }
bool StridedLayoutAttr::hasStaticLayout() const { … }
AffineMap StridedLayoutAttr::getAffineMap() const { … }
LogicalResult
StridedLayoutAttr::verify(function_ref<InFlightDiagnostic()> emitError,
int64_t offset, ArrayRef<int64_t> strides) { … }
LogicalResult StridedLayoutAttr::verifyLayout(
ArrayRef<int64_t> shape,
function_ref<InFlightDiagnostic()> emitError) const { … }
StringAttr StringAttr::getEmptyStringAttrUnchecked(MLIRContext *context) { … }
StringAttr StringAttr::get(MLIRContext *context, const Twine &twine) { … }
StringAttr StringAttr::get(const Twine &twine, Type type) { … }
StringRef StringAttr::getValue() const { … }
Type StringAttr::getType() const { … }
Dialect *StringAttr::getReferencedDialect() const { … }
double FloatAttr::getValueAsDouble() const { … }
double FloatAttr::getValueAsDouble(APFloat value) { … }
LogicalResult FloatAttr::verify(function_ref<InFlightDiagnostic()> emitError,
Type type, APFloat value) { … }
SymbolRefAttr SymbolRefAttr::get(MLIRContext *ctx, StringRef value,
ArrayRef<FlatSymbolRefAttr> nestedRefs) { … }
FlatSymbolRefAttr SymbolRefAttr::get(MLIRContext *ctx, StringRef value) { … }
FlatSymbolRefAttr SymbolRefAttr::get(StringAttr value) { … }
FlatSymbolRefAttr SymbolRefAttr::get(Operation *symbol) { … }
StringAttr SymbolRefAttr::getLeafReference() const { … }
int64_t IntegerAttr::getInt() const { … }
int64_t IntegerAttr::getSInt() const { … }
uint64_t IntegerAttr::getUInt() const { … }
APSInt IntegerAttr::getAPSInt() const { … }
LogicalResult IntegerAttr::verify(function_ref<InFlightDiagnostic()> emitError,
Type type, APInt value) { … }
BoolAttr IntegerAttr::getBoolAttrUnchecked(IntegerType type, bool value) { … }
bool BoolAttr::getValue() const { … }
bool BoolAttr::classof(Attribute attr) { … }
LogicalResult OpaqueAttr::verify(function_ref<InFlightDiagnostic()> emitError,
StringAttr dialect, StringRef attrData,
Type type) { … }
const char DenseIntOrFPElementsAttrStorage::kSplatTrue = …;
const char DenseIntOrFPElementsAttrStorage::kSplatFalse = …;
static size_t getDenseElementStorageWidth(size_t origWidth) { … }
static size_t getDenseElementStorageWidth(Type elementType) { … }
static void setBit(char *rawData, size_t bitPos, bool value) { … }
static bool getBit(const char *rawData, size_t bitPos) { … }
static void copyAPIntToArrayForBEmachine(APInt value, size_t numBytes,
char *result) { … }
static void copyArrayToAPIntForBEmachine(const char *inArray, size_t numBytes,
APInt &result) { … }
static void writeBits(char *rawData, size_t bitPos, APInt value) { … }
static APInt readBits(const char *rawData, size_t bitPos, size_t bitWidth) { … }
template <typename Values>
static bool hasSameElementsOrSplat(ShapedType type, const Values &values) { … }
DenseElementsAttr::AttributeElementIterator::AttributeElementIterator(
DenseElementsAttr attr, size_t index)
: … { … }
Attribute DenseElementsAttr::AttributeElementIterator::operator*() const { … }
DenseElementsAttr::BoolElementIterator::BoolElementIterator(
DenseElementsAttr attr, size_t dataIndex)
: … { … }
bool DenseElementsAttr::BoolElementIterator::operator*() const { … }
DenseElementsAttr::IntElementIterator::IntElementIterator(
DenseElementsAttr attr, size_t dataIndex)
: … { … }
APInt DenseElementsAttr::IntElementIterator::operator*() const { … }
DenseElementsAttr::ComplexIntElementIterator::ComplexIntElementIterator(
DenseElementsAttr attr, size_t dataIndex)
: … { … }
std::complex<APInt>
DenseElementsAttr::ComplexIntElementIterator::operator*() const { … }
LogicalResult
DenseArrayAttr::verify(function_ref<InFlightDiagnostic()> emitError,
Type elementType, int64_t size, ArrayRef<char> rawData) { … }
namespace {
template <size_t width,
IntegerType::SignednessSemantics signedness = IntegerType::Signless>
struct DenseArrayAttrIntUtil { … };
template <typename T>
struct DenseArrayAttrUtil;
template <>
struct DenseArrayAttrUtil<bool> : public DenseArrayAttrIntUtil<1> { … };
template <>
struct DenseArrayAttrUtil<int8_t> : public DenseArrayAttrIntUtil<8> { … };
template <>
struct DenseArrayAttrUtil<int16_t> : public DenseArrayAttrIntUtil<16> { … };
template <>
struct DenseArrayAttrUtil<int32_t> : public DenseArrayAttrIntUtil<32> { … };
template <>
struct DenseArrayAttrUtil<int64_t> : public DenseArrayAttrIntUtil<64> { … };
template <>
struct DenseArrayAttrUtil<float> { … };
template <>
struct DenseArrayAttrUtil<double> { … };
}
template <typename T>
void DenseArrayAttrImpl<T>::print(AsmPrinter &printer) const { … }
template <typename T>
void DenseArrayAttrImpl<T>::printWithoutBraces(raw_ostream &os) const { … }
template <typename T>
void DenseArrayAttrImpl<T>::print(raw_ostream &os) const { … }
template <typename T>
Attribute DenseArrayAttrImpl<T>::parseWithoutBraces(AsmParser &parser,
Type odsType) { … }
template <typename T>
Attribute DenseArrayAttrImpl<T>::parse(AsmParser &parser, Type odsType) { … }
operator ArrayRef<type-parameter-0-0>()
template <typename T>
DenseArrayAttrImpl<T> DenseArrayAttrImpl<T>::get(MLIRContext *context,
ArrayRef<T> content) { … }
template <typename T>
bool DenseArrayAttrImpl<T>::classof(Attribute attr) { … }
namespace mlir {
namespace detail {
template class DenseArrayAttrImpl<bool>;
template class DenseArrayAttrImpl<int8_t>;
template class DenseArrayAttrImpl<int16_t>;
template class DenseArrayAttrImpl<int32_t>;
template class DenseArrayAttrImpl<int64_t>;
template class DenseArrayAttrImpl<float>;
template class DenseArrayAttrImpl<double>;
}
}
bool DenseElementsAttr::classof(Attribute attr) { … }
DenseElementsAttr DenseElementsAttr::get(ShapedType type,
ArrayRef<Attribute> values) { … }
DenseElementsAttr DenseElementsAttr::get(ShapedType type,
ArrayRef<bool> values) { … }
DenseElementsAttr DenseElementsAttr::get(ShapedType type,
ArrayRef<StringRef> values) { … }
DenseElementsAttr DenseElementsAttr::get(ShapedType type,
ArrayRef<APInt> values) { … }
DenseElementsAttr DenseElementsAttr::get(ShapedType type,
ArrayRef<std::complex<APInt>> values) { … }
DenseElementsAttr DenseElementsAttr::get(ShapedType type,
ArrayRef<APFloat> values) { … }
DenseElementsAttr
DenseElementsAttr::get(ShapedType type,
ArrayRef<std::complex<APFloat>> values) { … }
DenseElementsAttr
DenseElementsAttr::getFromRawBuffer(ShapedType type, ArrayRef<char> rawBuffer) { … }
bool DenseElementsAttr::isValidRawBuffer(ShapedType type,
ArrayRef<char> rawBuffer,
bool &detectedSplat) { … }
static bool isValidIntOrFloat(Type type, int64_t dataEltSize, bool isInt,
bool isSigned) { … }
DenseElementsAttr DenseElementsAttr::getRawComplex(ShapedType type,
ArrayRef<char> data,
int64_t dataEltSize,
bool isInt, bool isSigned) { … }
DenseElementsAttr DenseElementsAttr::getRawIntOrFloat(ShapedType type,
ArrayRef<char> data,
int64_t dataEltSize,
bool isInt,
bool isSigned) { … }
bool DenseElementsAttr::isValidIntOrFloat(int64_t dataEltSize, bool isInt,
bool isSigned) const { … }
bool DenseElementsAttr::isValidComplex(int64_t dataEltSize, bool isInt,
bool isSigned) const { … }
bool DenseElementsAttr::isSplat() const { … }
static bool isComplexOfIntType(Type type) { … }
auto DenseElementsAttr::tryGetComplexIntValues() const
-> FailureOr<iterator_range_impl<ComplexIntElementIterator>> { … }
auto DenseElementsAttr::tryGetFloatValues() const
-> FailureOr<iterator_range_impl<FloatElementIterator>> { … }
auto DenseElementsAttr::tryGetComplexFloatValues() const
-> FailureOr<iterator_range_impl<ComplexFloatElementIterator>> { … }
ArrayRef<char> DenseElementsAttr::getRawData() const { … }
ArrayRef<StringRef> DenseElementsAttr::getRawStringData() const { … }
DenseElementsAttr DenseElementsAttr::reshape(ShapedType newType) { … }
DenseElementsAttr DenseElementsAttr::resizeSplat(ShapedType newType) { … }
DenseElementsAttr DenseElementsAttr::bitcast(Type newElType) { … }
DenseElementsAttr
DenseElementsAttr::mapValues(Type newElementType,
function_ref<APInt(const APInt &)> mapping) const { … }
DenseElementsAttr DenseElementsAttr::mapValues(
Type newElementType, function_ref<APInt(const APFloat &)> mapping) const { … }
ShapedType DenseElementsAttr::getType() const { … }
Type DenseElementsAttr::getElementType() const { … }
int64_t DenseElementsAttr::getNumElements() const { … }
template <typename APRangeT>
static void writeAPIntsToBuffer(size_t storageWidth, std::vector<char> &data,
APRangeT &&values) { … }
DenseElementsAttr DenseIntOrFPElementsAttr::getRaw(ShapedType type,
size_t storageWidth,
ArrayRef<APFloat> values) { … }
DenseElementsAttr DenseIntOrFPElementsAttr::getRaw(ShapedType type,
size_t storageWidth,
ArrayRef<APInt> values) { … }
DenseElementsAttr DenseIntOrFPElementsAttr::getRaw(ShapedType type,
ArrayRef<char> data) { … }
DenseElementsAttr DenseIntOrFPElementsAttr::getRawComplex(ShapedType type,
ArrayRef<char> data,
int64_t dataEltSize,
bool isInt,
bool isSigned) { … }
DenseElementsAttr
DenseIntOrFPElementsAttr::getRawIntOrFloat(ShapedType type, ArrayRef<char> data,
int64_t dataEltSize, bool isInt,
bool isSigned) { … }
void DenseIntOrFPElementsAttr::convertEndianOfCharForBEmachine(
const char *inRawData, char *outRawData, size_t elementBitWidth,
size_t numElements) { … }
void DenseIntOrFPElementsAttr::convertEndianOfArrayRefForBEmachine(
ArrayRef<char> inRawData, MutableArrayRef<char> outRawData,
ShapedType type) { … }
template <typename Fn, typename Attr>
static ShapedType mappingHelper(Fn mapping, Attr &attr, ShapedType inType,
Type newElementType,
llvm::SmallVectorImpl<char> &data) { … }
DenseElementsAttr DenseFPElementsAttr::mapValues(
Type newElementType, function_ref<APInt(const APFloat &)> mapping) const { … }
bool DenseFPElementsAttr::classof(Attribute attr) { … }
DenseElementsAttr DenseIntElementsAttr::mapValues(
Type newElementType, function_ref<APInt(const APInt &)> mapping) const { … }
bool DenseIntElementsAttr::classof(Attribute attr) { … }
DenseResourceElementsAttr
DenseResourceElementsAttr::get(ShapedType type,
DenseResourceElementsHandle handle) { … }
DenseResourceElementsAttr DenseResourceElementsAttr::get(ShapedType type,
StringRef blobName,
AsmResourceBlob blob) { … }
namespace {
template <typename T>
struct DenseResourceAttrUtil;
template <size_t width, bool isSigned>
struct DenseResourceElementsAttrIntUtil { … };
template <>
struct DenseResourceAttrUtil<bool> { … };
template <>
struct DenseResourceAttrUtil<int8_t>
: public DenseResourceElementsAttrIntUtil<8, true> { … };
template <>
struct DenseResourceAttrUtil<uint8_t>
: public DenseResourceElementsAttrIntUtil<8, false> { … };
template <>
struct DenseResourceAttrUtil<int16_t>
: public DenseResourceElementsAttrIntUtil<16, true> { … };
template <>
struct DenseResourceAttrUtil<uint16_t>
: public DenseResourceElementsAttrIntUtil<16, false> { … };
template <>
struct DenseResourceAttrUtil<int32_t>
: public DenseResourceElementsAttrIntUtil<32, true> { … };
template <>
struct DenseResourceAttrUtil<uint32_t>
: public DenseResourceElementsAttrIntUtil<32, false> { … };
template <>
struct DenseResourceAttrUtil<int64_t>
: public DenseResourceElementsAttrIntUtil<64, true> { … };
template <>
struct DenseResourceAttrUtil<uint64_t>
: public DenseResourceElementsAttrIntUtil<64, false> { … };
template <>
struct DenseResourceAttrUtil<float> { … };
template <>
struct DenseResourceAttrUtil<double> { … };
}
template <typename T>
DenseResourceElementsAttrBase<T>
DenseResourceElementsAttrBase<T>::get(ShapedType type, StringRef blobName,
AsmResourceBlob blob) { … }
template <typename T>
std::optional<ArrayRef<T>>
DenseResourceElementsAttrBase<T>::tryGetAsArrayRef() const { … }
template <typename T>
bool DenseResourceElementsAttrBase<T>::classof(Attribute attr) { … }
namespace mlir {
namespace detail {
template class DenseResourceElementsAttrBase<bool>;
template class DenseResourceElementsAttrBase<int8_t>;
template class DenseResourceElementsAttrBase<int16_t>;
template class DenseResourceElementsAttrBase<int32_t>;
template class DenseResourceElementsAttrBase<int64_t>;
template class DenseResourceElementsAttrBase<uint8_t>;
template class DenseResourceElementsAttrBase<uint16_t>;
template class DenseResourceElementsAttrBase<uint32_t>;
template class DenseResourceElementsAttrBase<uint64_t>;
template class DenseResourceElementsAttrBase<float>;
template class DenseResourceElementsAttrBase<double>;
}
}
APFloat SparseElementsAttr::getZeroAPFloat() const { … }
APInt SparseElementsAttr::getZeroAPInt() const { … }
Attribute SparseElementsAttr::getZeroAttr() const { … }
std::vector<ptrdiff_t> SparseElementsAttr::getFlattenedSparseIndices() const { … }
LogicalResult
SparseElementsAttr::verify(function_ref<InFlightDiagnostic()> emitError,
ShapedType type, DenseIntElementsAttr sparseIndices,
DenseElementsAttr values) { … }
DistinctAttr DistinctAttr::create(Attribute referencedAttr) { … }
Attribute DistinctAttr::getReferencedAttr() const { … }
AffineMap mlir::makeStridedLinearLayoutMap(ArrayRef<int64_t> strides,
int64_t offset,
MLIRContext *context) { … }