diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -1074,7 +1074,9 @@ let convertFromStorage = "$_self.getValue().cast<" # retType # ">()"; } -def TypeAttr : TypeAttrBase<"::mlir::Type", "any type attribute">; +def TypeAttr : TypeAttrBase<"::mlir::Type", "any type attribute"> { + let constBuilderCall = "::mlir::TypeAttr::get($0)"; +} // The mere presence of unit attributes has a meaning. Therefore, unit // attributes are always treated as optional and accessors to them return diff --git a/mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.cpp --- a/mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.cpp @@ -264,9 +264,8 @@ std::string varName = std::string("__workgroup_mem__") + std::to_string(std::distance(varOps.begin(), varOps.end())); - varOp = rewriter.create( - loc, TypeAttr::get(spirvType), varName, - /*initializer = */ nullptr); + varOp = rewriter.create(loc, spirvType, varName, + /*initializer=*/nullptr); } // Get pointer to global variable at the current scope. diff --git a/mlir/lib/Dialect/StandardOps/Transforms/TensorConstantBufferize.cpp b/mlir/lib/Dialect/StandardOps/Transforms/TensorConstantBufferize.cpp --- a/mlir/lib/Dialect/StandardOps/Transforms/TensorConstantBufferize.cpp +++ b/mlir/lib/Dialect/StandardOps/Transforms/TensorConstantBufferize.cpp @@ -61,9 +61,9 @@ auto global = globalBuilder.create( op.getLoc(), (Twine("__constant_") + os.str()).str(), /*sym_visibility=*/globalBuilder.getStringAttr("private"), - /*type=*/ - TypeAttr::get(typeConverter.convertType(type)), /*initial_value=*/ - op.getValue().cast(), /*constant=*/true); + /*type=*/typeConverter.convertType(type), + /*initial_value=*/op.getValue().cast(), + /*constant=*/true); symbolTable.insert(global); // The symbol table inserts at the end of the module, but globals are a bit // nicer if they are at the beginning.