[Mlir-commits] [mlir] f1bdf9f - [mlir][NFC] Use explicit `mlir` namespace in generated code
Mehdi Amini
llvmlistbot at llvm.org
Tue Feb 2 10:24:55 PST 2021
Author: Vladislav Vinogradov
Date: 2021-02-02T18:24:43Z
New Revision: f1bdf9fa9bc5edc616842b6cb9028b7d207e012c
URL: https://github.com/llvm/llvm-project/commit/f1bdf9fa9bc5edc616842b6cb9028b7d207e012c
DIFF: https://github.com/llvm/llvm-project/commit/f1bdf9fa9bc5edc616842b6cb9028b7d207e012c.diff
LOG: [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
Added:
Modified:
mlir/include/mlir/IR/OpAsmInterface.td
mlir/include/mlir/IR/SymbolInterfaces.td
mlir/include/mlir/Interfaces/CopyOpInterface.td
mlir/include/mlir/Interfaces/InferTypeOpInterface.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
mlir/tools/mlir-tblgen/RewriterGen.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/OpAsmInterface.td b/mlir/include/mlir/IR/OpAsmInterface.td
index ec50288348c4..f009ed997bf8 100644
--- a/mlir/include/mlir/IR/OpAsmInterface.td
+++ b/mlir/include/mlir/IR/OpAsmInterface.td
@@ -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)
>,
];
}
diff --git a/mlir/include/mlir/IR/SymbolInterfaces.td b/mlir/include/mlir/IR/SymbolInterfaces.td
index f5158f238985..c5f252e45a20 100644
--- a/mlir/include/mlir/IR/SymbolInterfaces.td
+++ b/mlir/include/mlir/IR/SymbolInterfaces.td
@@ -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)
>,
];
diff --git a/mlir/include/mlir/Interfaces/CopyOpInterface.td b/mlir/include/mlir/Interfaces/CopyOpInterface.td
index a503abc185d9..f6c5a6f8bb81 100644
--- a/mlir/include/mlir/Interfaces/CopyOpInterface.td
+++ b/mlir/include/mlir/Interfaces/CopyOpInterface.td
@@ -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"
>
];
diff --git a/mlir/include/mlir/Interfaces/InferTypeOpInterface.td b/mlir/include/mlir/Interfaces/InferTypeOpInterface.td
index 9de087b1b4ca..ca044f019366 100644
--- a/mlir/include/mlir/Interfaces/InferTypeOpInterface.td
+++ b/mlir/include/mlir/Interfaces/InferTypeOpInterface.td
@@ -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(); }]
>,
];
}
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 69c6b022054e..2f0b3379d152 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -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 << ");";
diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp
index 1a6651700004..1b28bf880a44 100644
--- a/mlir/tools/mlir-tblgen/RewriterGen.cpp
+++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp
@@ -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 "
More information about the Mlir-commits
mailing list