MLIR
20.0.0git
|
#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>
#include "mlir/IR/BuiltinAttributes.cpp.inc"
Go to the source code of this file.
Namespaces | |
mlir | |
Include the generated interface declarations. | |
mlir::detail | |
AttrTypeReplacer. | |
Macros | |
#define | DEBUG_TYPE "builtinattributes" |
#define | GET_ATTRDEF_CLASSES |
Tablegen Attribute Definitions. More... | |
#define | GET_ATTRDEF_LIST |
Functions | |
template<bool inPlace> | |
static bool | dictionaryAttrSort (ArrayRef< NamedAttribute > value, SmallVectorImpl< NamedAttribute > &storage) |
Helper function that does either an in place sort or sorts from source array into destination. More... | |
static std::optional< NamedAttribute > | findDuplicateElement (ArrayRef< NamedAttribute > value) |
Returns an entry with a duplicate name from the given sorted array of named attributes. More... | |
static size_t | getDenseElementStorageWidth (size_t origWidth) |
Get the bitwidth of a dense element type within the buffer. More... | |
static size_t | getDenseElementStorageWidth (Type elementType) |
static void | setBit (char *rawData, size_t bitPos, bool value) |
Set a bit to a specific value. More... | |
static bool | getBit (const char *rawData, size_t bitPos) |
Return the value of the specified bit. More... | |
static void | copyAPIntToArrayForBEmachine (APInt value, size_t numBytes, char *result) |
Copy actual numBytes data from value (APInt) to char array(result ) for BE format. More... | |
static void | copyArrayToAPIntForBEmachine (const char *inArray, size_t numBytes, APInt &result) |
Copy numBytes data from inArray (char array) to result (APINT) for BE format. More... | |
static void | writeBits (char *rawData, size_t bitPos, APInt value) |
Writes value to the bit position bitPos in array rawData . More... | |
static APInt | readBits (const char *rawData, size_t bitPos, size_t bitWidth) |
Reads the next bitWidth bits from the bit position bitPos in array rawData . More... | |
template<typename Values > | |
static bool | hasSameElementsOrSplat (ShapedType type, const Values &values) |
Returns true if 'values' corresponds to a splat, i.e. More... | |
static bool | isValidIntOrFloat (Type type, int64_t dataEltSize, bool isInt, bool isSigned) |
Check the information for a C++ data type, check if this type is valid for the current attribute. More... | |
static bool | isComplexOfIntType (Type type) |
Return if the given complex type has an integer element type. More... | |
template<typename APRangeT > | |
static void | writeAPIntsToBuffer (size_t storageWidth, std::vector< char > &data, APRangeT &&values) |
Utility method to write a range of APInt values to a buffer. More... | |
template<typename Fn , typename Attr > | |
static ShapedType | mappingHelper (Fn mapping, Attr &attr, ShapedType inType, Type newElementType, llvm::SmallVectorImpl< char > &data) |
#define DEBUG_TYPE "builtinattributes" |
Definition at line 27 of file BuiltinAttributes.cpp.
#define GET_ATTRDEF_CLASSES |
Tablegen Attribute Definitions.
Definition at line 36 of file BuiltinAttributes.cpp.
#define GET_ATTRDEF_LIST |
|
static |
Copy actual numBytes
data from value
(APInt) to char array(result
) for BE format.
Definition at line 475 of file BuiltinAttributes.cpp.
Referenced by writeBits().
|
static |
Copy numBytes
data from inArray
(char array) to result
(APINT) for BE format.
Definition at line 504 of file BuiltinAttributes.cpp.
Referenced by readBits().
|
static |
Helper function that does either an in place sort or sorts from source array into destination.
If inPlace then storage is both the source and the destination, else value is the source and storage destination. Returns whether source was sorted.
Definition at line 60 of file BuiltinAttributes.cpp.
|
static |
Returns an entry with a duplicate name from the given sorted array of named attributes.
Returns std::nullopt if all elements have unique names.
Definition at line 102 of file BuiltinAttributes.cpp.
|
static |
Return the value of the specified bit.
Definition at line 469 of file BuiltinAttributes.cpp.
Referenced by mlir::DenseElementsAttr::BoolElementIterator::operator*(), and readBits().
|
static |
Get the bitwidth of a dense element type within the buffer.
DenseElementsAttr requires bitwidths greater than 1 to be aligned by 8.
Definition at line 453 of file BuiltinAttributes.cpp.
Referenced by mlir::DenseElementsAttr::get(), getDenseElementStorageWidth(), mlir::DenseElementsAttr::isValidRawBuffer(), mappingHelper(), mlir::DenseElementsAttr::IntElementIterator::operator*(), and mlir::DenseElementsAttr::ComplexIntElementIterator::operator*().
|
static |
Definition at line 456 of file BuiltinAttributes.cpp.
References mlir::detail::getDenseElementBitWidth(), and getDenseElementStorageWidth().
|
static |
Returns true if 'values' corresponds to a splat, i.e.
one element, or has the same element count as 'type'.
Definition at line 592 of file BuiltinAttributes.cpp.
Referenced by mlir::DenseElementsAttr::get().
|
static |
Return if the given complex type has an integer element type.
Definition at line 1183 of file BuiltinAttributes.cpp.
References mlir::DenseElementsAttr::getElementType().
Referenced by mlir::DenseElementsAttr::tryGetComplexIntValues().
|
static |
Check the information for a C++ data type, check if this type is valid for the current attribute.
This method is used to verify specific type invariants that the templatized 'getValues' method cannot.
Definition at line 1105 of file BuiltinAttributes.cpp.
References mlir::detail::getDenseElementBitWidth(), and mlir::Type::isIndex().
Referenced by mlir::DenseElementsAttr::isValidComplex(), and mlir::DenseElementsAttr::isValidIntOrFloat().
|
static |
Definition at line 1456 of file BuiltinAttributes.cpp.
References mlir::detail::divideCeil(), mlir::detail::getDenseElementBitWidth(), getDenseElementStorageWidth(), and writeBits().
Referenced by mlir::DenseFPElementsAttr::mapValues(), and mlir::DenseIntElementsAttr::mapValues().
|
static |
Reads the next bitWidth
bits from the bit position bitPos
in array rawData
.
Definition at line 564 of file BuiltinAttributes.cpp.
References copyArrayToAPIntForBEmachine(), mlir::detail::divideCeil(), and getBit().
Referenced by mlir::DenseElementsAttr::IntElementIterator::operator*(), and mlir::DenseElementsAttr::ComplexIntElementIterator::operator*().
|
static |
Set a bit to a specific value.
Definition at line 461 of file BuiltinAttributes.cpp.
Referenced by mlir::DenseElementsAttr::get(), and writeBits().
|
static |
Utility method to write a range of APInt values to a buffer.
Definition at line 1305 of file BuiltinAttributes.cpp.
References mlir::detail::divideCeil(), and writeBits().
|
static |
Writes value to the bit position bitPos
in array rawData
.
Definition at line 538 of file BuiltinAttributes.cpp.
References copyAPIntToArrayForBEmachine(), mlir::detail::divideCeil(), and setBit().
Referenced by mlir::DenseElementsAttr::get(), mappingHelper(), and writeAPIntsToBuffer().