14#include <mlir/IR/DialectImplementation.h>
16#include <llvm/ADT/APInt.h>
19 static mlir::FailureOr<llvm::APInt>
parse(mlir::AsmParser &parser) {
20 auto loc = parser.getCurrentLocation();
22 auto result = parser.parseOptionalInteger(val);
23 if (!result.has_value() || *result) {
24 return parser.emitError(loc,
"expected integer value");
33inline llvm::APInt
toAPInt(int64_t i) {
return llvm::APInt(64, i); }
34inline int64_t
fromAPInt(llvm::APInt i) {
return i.getZExtValue(); }
37inline bool isNullOrEmpty(mlir::DenseArrayAttr a) {
return !a || a.empty(); }
38inline bool isNullOrEmpty(mlir::DictionaryAttr a) {
return !a || a.empty(); }
40inline void appendWithoutType(mlir::raw_ostream &os, mlir::Attribute a) { a.print(os,
true); }
46 mlir::AsmPrinter &printer, mlir::ArrayRef<mlir::Attribute> attrs,
47 const mlir::StringRef &separator
llvm::APInt toAPInt(int64_t i)
void printAttrs(AsmPrinter &printer, ArrayRef< Attribute > attrs, const StringRef &separator)
std::string stringWithoutType(mlir::Attribute a)
bool isNullOrEmpty(mlir::ArrayAttr a)
void appendWithoutType(mlir::raw_ostream &os, mlir::Attribute a)
std::string buildStringViaCallback(Func &&appendFn, Args &&...args)
Generate a string by calling the given appendFn with an llvm::raw_ostream & as the first argument fol...
int64_t fromAPInt(llvm::APInt i)
static mlir::FailureOr< llvm::APInt > parse(mlir::AsmParser &parser)