[Mlir-commits] [mlir] f2beca9 - [mlir][tblgen] Consistently use `$_ctxt` instead of `$_ctx`
Markus Böck
llvmlistbot at llvm.org
Tue Jul 5 11:14:39 PDT 2022
Author: Markus Böck
Date: 2022-07-05T20:06:52+02:00
New Revision: f2beca908d4ec409e4201ee08b1d4a7d9fcb1ab7
URL: https://github.com/llvm/llvm-project/commit/f2beca908d4ec409e4201ee08b1d4a7d9fcb1ab7
DIFF: https://github.com/llvm/llvm-project/commit/f2beca908d4ec409e4201ee08b1d4a7d9fcb1ab7.diff
LOG: [mlir][tblgen] Consistently use `$_ctxt` instead of `$_ctx`
With the exceptions of AttrOrTypeParameter and DerivedAttr, all of MLIR consistently uses $_ctxt as the substitute variable for the MLIRContext in TableGen C++ code.
Usually this does not matter unless one where to reuse some code in multiple fields but it is still needlessly inconsistent and prone to error.
This patch fixes that by consistently using _$ctxt everywhere.
Differential Revision: https://reviews.llvm.org/D129153
Added:
Modified:
mlir/docs/AttributesAndTypes.md
mlir/include/mlir/IR/AttrTypeBase.td
mlir/include/mlir/IR/OpBase.td
mlir/test/lib/Dialect/Test/TestTypeDefs.td
mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
Removed:
################################################################################
diff --git a/mlir/docs/AttributesAndTypes.md b/mlir/docs/AttributesAndTypes.md
index bfe9e6c476604..36c134ee9435b 100644
--- a/mlir/docs/AttributesAndTypes.md
+++ b/mlir/docs/AttributesAndTypes.md
@@ -673,10 +673,10 @@ Which will look like:
```
For optional `Attribute` or `Type` parameters, the current MLIR context is
-available through `$_ctx`. E.g.
+available through `$_ctxt`. E.g.
```tablegen
-DefaultValuedParameter<"IntegerType", "IntegerType::get($_ctx, 32)">
+DefaultValuedParameter<"IntegerType", "IntegerType::get($_ctxt, 32)">
```
##### Assembly Format Directives
diff --git a/mlir/include/mlir/IR/AttrTypeBase.td b/mlir/include/mlir/IR/AttrTypeBase.td
index 88d35e12ef547..be8fed544ae1b 100644
--- a/mlir/include/mlir/IR/AttrTypeBase.td
+++ b/mlir/include/mlir/IR/AttrTypeBase.td
@@ -319,7 +319,7 @@ class AttrOrTypeParameter<string type, string desc, string accessorType = ""> {
// will be set to the default value. Parameters equal to their default values
// are elided when printing. Equality is checked using the `comparator` field,
// which by default is the C++ equality operator. The current MLIR context is
- // made available through `$_ctx`, e.g., for constructing default values for
+ // made available through `$_ctxt`, e.g., for constructing default values for
// attributes and types.
string defaultValue = ?;
}
diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td
index 807216abd9813..89c7122b5ba78 100644
--- a/mlir/include/mlir/IR/OpBase.td
+++ b/mlir/include/mlir/IR/OpBase.td
@@ -1513,7 +1513,7 @@ class DerivedAttr<code ret, code b, code convert = ""> :
// Special placeholders can be used to refer to entities during conversion:
//
// * `$_builder` will be replaced by a mlir::Builder instance.
- // * `$_ctx` will be replaced by the MLIRContext* instance.
+ // * `$_ctxt` will be replaced by the MLIRContext* instance.
// * `$_self` will be replaced with the derived attribute (value produces
// `returnType`).
let convertFromStorage = convert;
diff --git a/mlir/test/lib/Dialect/Test/TestTypeDefs.td b/mlir/test/lib/Dialect/Test/TestTypeDefs.td
index fd50dd3e0e90b..6e5834832e1c8 100644
--- a/mlir/test/lib/Dialect/Test/TestTypeDefs.td
+++ b/mlir/test/lib/Dialect/Test/TestTypeDefs.td
@@ -312,7 +312,7 @@ def TestTypeAPFloat : Test_Type<"TestTypeAPFloat"> {
def TestTypeDefaultValuedType : Test_Type<"TestTypeDefaultValuedType"> {
let parameters = (ins
DefaultValuedParameter<"mlir::IntegerType",
- "mlir::IntegerType::get($_ctx, 32)">:$type
+ "mlir::IntegerType::get($_ctxt, 32)">:$type
);
let mnemonic = "default_valued_type";
let assemblyFormat = "`<` (`(` $type^ `)`)? `>`";
diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
index a8a63f187d0b4..19ab7f3eb72ce 100644
--- a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
+++ b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
@@ -249,7 +249,7 @@ class DefFormat {
void DefFormat::genParser(MethodBody &os) {
FmtContext ctx;
ctx.addSubst("_parser", "odsParser");
- ctx.addSubst("_ctx", "odsParser.getContext()");
+ ctx.addSubst("_ctxt", "odsParser.getContext()");
ctx.withBuilder("odsBuilder");
if (isa<AttrDef>(def))
ctx.addSubst("_type", "odsType");
@@ -672,7 +672,7 @@ void DefFormat::genOptionalGroupParser(OptionalElement *el, FmtContext &ctx,
void DefFormat::genPrinter(MethodBody &os) {
FmtContext ctx;
ctx.addSubst("_printer", "odsPrinter");
- ctx.addSubst("_ctx", "getContext()");
+ ctx.addSubst("_ctxt", "getContext()");
ctx.withBuilder("odsBuilder");
os.indent();
os << "::mlir::Builder odsBuilder(getContext());\n";
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index a3626b5d3f791..dd3487bb2b0cd 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -1071,7 +1071,7 @@ void OpEmitter::genAttrGetters() {
body << " {" << name << "AttrName(),\n"
<< tgfmt(tmpl, &fctx.withSelf(name + "()")
.withBuilder("odsBuilder")
- .addSubst("_ctx", "ctx"))
+ .addSubst("_ctxt", "ctx"))
<< "}";
},
",\n");
More information about the Mlir-commits
mailing list