[mlir][NFC] Use explicit `mlir` namespace in generated code

This makes the generated code independent from actual namespace of its users.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D95520
This commit is contained in:
Vladislav Vinogradov 2021-02-02 18:24:06 +00:00 committed by Mehdi Amini
parent ec6815a72d
commit f1bdf9fa9b
6 changed files with 21 additions and 20 deletions

View File

@ -47,7 +47,7 @@ def OpAsmOpInterface : OpInterface<"OpAsmOpInterface"> {
%first_result, %middle_results:2, %0 = "my.op" ...
```
}],
"void", "getAsmResultNames", (ins "OpAsmSetValueNameFn":$setNameFn)
"void", "getAsmResultNames", (ins "::mlir::OpAsmSetValueNameFn":$setNameFn)
>,
];
}

View File

@ -206,7 +206,7 @@ def SymbolUserOpInterface : OpInterface<"SymbolUserOpInterface"> {
let methods = [
InterfaceMethod<"Verify the symbol uses held by this operation.",
"LogicalResult", "verifySymbolUses",
"::mlir::LogicalResult", "verifySymbolUses",
(ins "::mlir::SymbolTableCollection &":$symbolTable)
>,
];

View File

@ -24,12 +24,12 @@ def CopyOpInterface : OpInterface<"CopyOpInterface"> {
let methods = [
InterfaceMethod<
/*desc=*/"Returns the source value for this copy operation",
/*retTy=*/"Value",
/*retTy=*/"::mlir::Value",
/*methodName=*/"getSource"
>,
InterfaceMethod<
/*desc=*/"Returns the target value for this copy operation",
/*retTy=*/"Value",
/*retTy=*/"::mlir::Value",
/*methodName=*/"getTarget"
>
];

View File

@ -90,14 +90,14 @@ def InferShapedTypeOpInterface : OpInterface<"InferShapedTypeOpInterface"> {
may be returned by this function while returning success. E.g., partial
population of components is not error condition.
}],
/*retTy=*/"LogicalResult",
/*retTy=*/"::mlir::LogicalResult",
/*methodName=*/"inferReturnTypeComponents",
/*args=*/(ins "MLIRContext*":$context,
"Optional<Location>":$location,
"ValueRange":$operands,
"DictionaryAttr":$attributes,
"RegionRange":$regions,
"SmallVectorImpl<ShapedTypeComponents>&":
/*args=*/(ins "::mlir::MLIRContext*":$context,
"::mlir::Optional<::mlir::Location>":$location,
"::mlir::ValueRange":$operands,
"::mlir::DictionaryAttr":$attributes,
"::mlir::RegionRange":$regions,
"::mlir::SmallVectorImpl<::mlir::ShapedTypeComponents>&":
$inferredReturnShapes)
>,
InterfaceMethod<
@ -106,12 +106,12 @@ def InferShapedTypeOpInterface : OpInterface<"InferShapedTypeOpInterface"> {
Insert operations using the given OpBuilder that computes the result
shape.
}],
/*retTy=*/"LogicalResult",
/*retTy=*/"::mlir::LogicalResult",
/*methodName=*/"reifyReturnTypeShapes",
/*args=*/(ins "OpBuilder&":$builder,
"SmallVectorImpl<Value>&":$reifiedReturnShapes),
/*args=*/(ins "::mlir::OpBuilder&":$builder,
"::mlir::SmallVectorImpl<::mlir::Value>&":$reifiedReturnShapes),
/*methodBody=*/[{}],
/*defaultImplementation=*/[{ return failure(); }]
/*defaultImplementation=*/[{ return ::mlir::failure(); }]
>,
];
}

View File

@ -898,8 +898,9 @@ static void generateNamedOperandGetters(const Operator &op, Class &opClass,
if (operand.isOptional()) {
m = opClass.addMethodAndPrune("::mlir::Value", operand.name);
m->body() << " auto operands = getODSOperands(" << i << ");\n"
<< " return operands.empty() ? Value() : *operands.begin();";
m->body()
<< " auto operands = getODSOperands(" << i << ");\n"
<< " return operands.empty() ? ::mlir::Value() : *operands.begin();";
} else if (operand.isVariadic()) {
m = opClass.addMethodAndPrune(rangeType, operand.name);
m->body() << " return getODSOperands(" << i << ");";

View File

@ -260,7 +260,7 @@ void PatternEmitter::emitNativeCodeMatch(DagNode tree, StringRef opName,
raw_indented_ostream::DelimitedScope scope(os);
os << "if(!" << opName << ") return failure();\n";
os << "if(!" << opName << ") return ::mlir::failure();\n";
for (int i = 0, e = tree.getNumArgs(); i != e; ++i) {
std::string argName = formatv("arg{0}_{1}", depth, i);
if (DagNode argTree = tree.getArgAsNestedDag(i)) {
@ -286,7 +286,7 @@ void PatternEmitter::emitNativeCodeMatch(DagNode tree, StringRef opName,
fmt, &fmtCtx.addSubst("_loc", locToUse), opName, capture[0], capture[1],
capture[2], capture[3], capture[4], capture[5], capture[6], capture[7]));
os << "if (failed(" << nativeCodeCall << ")) return failure();\n";
os << "if (failed(" << nativeCodeCall << ")) return ::mlir::failure();\n";
for (int i = 0, e = tree.getNumArgs(); i != e; ++i) {
auto name = tree.getArgName(i);
@ -336,7 +336,7 @@ void PatternEmitter::emitOpMatch(DagNode tree, StringRef opName, int depth) {
// Skip the operand matching at depth 0 as the pattern rewriter already does.
if (depth != 0) {
// Skip if there is no defining operation (e.g., arguments to function).
os << formatv("if (!{0}) return failure();\n", castedName);
os << formatv("if (!{0}) return ::mlir::failure();\n", castedName);
}
if (tree.getNumArgs() != op.getNumArgs()) {
PrintFatalError(loc, formatv("op '{0}' argument number mismatch: {1} in "