// GPU_AllocOp
//===----------------------------------------------------------------------===//
-static LogicalResult verify(AllocOp op) {
- auto memRefType = op.memref().getType().cast<MemRefType>();
+LogicalResult AllocOp::verify() {
+ auto memRefType = memref().getType().cast<MemRefType>();
- if (static_cast<int64_t>(op.dynamicSizes().size()) !=
+ if (static_cast<int64_t>(dynamicSizes().size()) !=
memRefType.getNumDynamicDims())
- return op.emitOpError("dimension operand count does not equal memref "
- "dynamic dimension count");
+ return emitOpError("dimension operand count does not equal memref "
+ "dynamic dimension count");
unsigned numSymbols = 0;
if (!memRefType.getLayout().isIdentity())
numSymbols = memRefType.getLayout().getAffineMap().getNumSymbols();
- if (op.symbolOperands().size() != numSymbols)
- return op.emitOpError("symbol operand count does not equal memref symbol "
- "count");
+ if (symbolOperands().size() != numSymbols) {
+ return emitOpError(
+ "symbol operand count does not equal memref symbol count");
+ }
return success();
}
if (hasStringAttribute(def, "assemblyFormat"))
return;
- bool hasCppFormat = def.getValueAsBit("hasCustomAssemblyFormat");
- if (!hasStringAttribute(def, "parser") && !hasCppFormat)
+ if (!def.getValueAsBit("hasCustomAssemblyFormat"))
return;
SmallVector<MethodParameter> paramList;
paramList.emplace_back("::mlir::OpAsmParser &", "parser");
paramList.emplace_back("::mlir::OperationState &", "result");
- // If this uses the cpp format, only generate a declaration.
- if (hasCppFormat) {
- auto *method = opClass.declareStaticMethod("::mlir::ParseResult", "parse",
- std::move(paramList));
- ERROR_IF_PRUNED(method, "parse", op);
- return;
- }
-
- PrintNote(op.getLoc(),
- "`parser` and `printer` fields are deprecated and will be removed, "
- "please use the `hasCustomAssemblyFormat` field instead");
-
- auto *method = opClass.addStaticMethod("::mlir::ParseResult", "parse",
- std::move(paramList));
+ auto *method = opClass.declareStaticMethod("::mlir::ParseResult", "parse",
+ std::move(paramList));
ERROR_IF_PRUNED(method, "parse", op);
-
- FmtContext fctx;
- fctx.addSubst("cppClass", opClass.getClassName());
- auto parser = def.getValueAsString("parser").ltrim().rtrim(" \t\v\f\r");
- method->body() << " " << tgfmt(parser, &fctx);
}
void OpEmitter::genPrinter() {
if (hasStringAttribute(def, "assemblyFormat"))
return;
- // If this uses the cpp format, only generate a declaration.
- if (def.getValueAsBit("hasCustomAssemblyFormat")) {
- auto *method = opClass.declareMethod(
- "void", "print", MethodParameter("::mlir::OpAsmPrinter &", "p"));
- ERROR_IF_PRUNED(method, "print", op);
+ // Check to see if this op uses a c++ format.
+ if (!def.getValueAsBit("hasCustomAssemblyFormat"))
return;
- }
-
- auto *valueInit = def.getValueInit("printer");
- StringInit *stringInit = dyn_cast<StringInit>(valueInit);
- if (!stringInit)
- return;
-
- auto *method = opClass.addMethod(
+ auto *method = opClass.declareMethod(
"void", "print", MethodParameter("::mlir::OpAsmPrinter &", "p"));
ERROR_IF_PRUNED(method, "print", op);
- FmtContext fctx;
- fctx.addSubst("cppClass", opClass.getClassName());
- auto printer = stringInit->getValue().ltrim().rtrim(" \t\v\f\r");
- method->body() << " " << tgfmt(printer, &fctx);
}
/// Generate verification on native traits requiring attributes.
// This may not act as their expectation because this doesn't call any
// verifiers of native/interface traits. Needs to review those use cases and
// see if we should use the mlir::verify() instead.
- auto *valueInit = def.getValueInit("verifier");
- StringInit *stringInit = dyn_cast<StringInit>(valueInit);
- bool hasCustomVerifyCodeBlock = stringInit && !stringInit->getValue().empty();
-
auto *method = opClass.addMethod("::mlir::LogicalResult", "verifyInvariants");
ERROR_IF_PRUNED(method, "verifyInvariants", op);
auto &body = method->body();
- if (hasCustomVerifyCodeBlock || def.getValueAsBit("hasVerifier")) {
+ if (def.getValueAsBit("hasVerifier")) {
body << " if(::mlir::succeeded(verifyInvariantsImpl()) && "
"::mlir::succeeded(verify()))\n";
body << " return ::mlir::success();\n";
}
void OpEmitter::genCustomVerifier() {
- auto *valueInit = def.getValueInit("verifier");
- StringInit *stringInit = dyn_cast<StringInit>(valueInit);
- bool hasCustomVerifyCodeBlock = stringInit && !stringInit->getValue().empty();
-
if (def.getValueAsBit("hasVerifier")) {
auto *method = opClass.declareMethod("::mlir::LogicalResult", "verify");
ERROR_IF_PRUNED(method, "verify", op);
- } else if (hasCustomVerifyCodeBlock) {
- auto *method = opClass.addMethod("::mlir::LogicalResult", "verify");
- ERROR_IF_PRUNED(method, "verify", op);
- auto &body = method->body();
-
- FmtContext fctx;
- fctx.addSubst("cppClass", opClass.getClassName());
- auto printer = stringInit->getValue().ltrim().rtrim(" \t\v\f\r");
- body << " " << tgfmt(printer, &fctx);
}
if (def.getValueAsBit("hasRegionVerifier")) {