24 auto valueAttr = dyn_cast<IntegerAttr>(attr);
26 emitError() <<
"expected IntegerAttr for key `value`";
29 storage = valueAttr.getValue().getSExtValue();
36 template <
typename DenseArrayTy,
typename T>
40 StringRef denseArrayTyStr) {
41 auto valueAttr = dyn_cast<DenseArrayTy>(attr);
43 emitError() <<
"expected " << denseArrayTyStr <<
" for key `value`";
46 if (valueAttr.size() !=
static_cast<int64_t
>(storage.size())) {
47 emitError() <<
"size mismatch in attribute conversion: " << valueAttr.size()
48 <<
" vs " << storage.size();
51 llvm::copy(valueAttr.asArrayRef(), storage.begin());
57 return convertDenseArrayFromAttr<DenseI64ArrayAttr>(storage, attr,
emitError,
63 return convertDenseArrayFromAttr<DenseI32ArrayAttr>(storage, attr,
emitError,
static void copy(Location loc, Value dst, Value src, Value size, OpBuilder &builder)
Copies the given number of bytes from src to dst pointers.
LogicalResult convertDenseArrayFromAttr(MutableArrayRef< T > storage, Attribute attr, function_ref< InFlightDiagnostic()> emitError, StringRef denseArrayTyStr)
Attributes are known-constant values of operations.
This class represents a diagnostic that is inflight and set to be reported.
MLIRContext is the top-level object for a collection of MLIR operations.
static DenseArrayAttrImpl get(MLIRContext *context, ArrayRef< T > content)
Builder from ArrayRef<T>.
Include the generated interface declarations.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
Attribute convertToAttribute(MLIRContext *ctx, int64_t storage)
Convert the provided int64_t to an IntegerAttr attribute.
LogicalResult convertFromAttribute(int64_t &storage, Attribute attr, function_ref< InFlightDiagnostic()> emitError)
Convert an IntegerAttr attribute to an int64_t, or return an error if the attribute isn't an IntegerA...
This class represents an efficient way to signal success or failure.