Skip to content

[mlir][core] NFC update builder create API usage #147311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 5 additions & 5 deletions flang/include/flang/Optimizer/Dialect/FIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -3624,11 +3624,11 @@ def fir_LocalitySpecifierOp : fir_Op<"local", [IsolatedFromAbove]> {
attr-dict
}];

let builders = [
OpBuilder<(ins CArg<"mlir::TypeRange">:$result,
CArg<"mlir::StringAttr">:$sym_name,
CArg<"mlir::TypeAttr">:$type)>
];
// let builders = [
// OpBuilder<(ins CArg<"mlir::TypeRange">:$result,
// CArg<"mlir::StringAttr">:$sym_name,
// CArg<"mlir::TypeAttr">:$type)>
// ];

let extraClassDeclaration = [{
mlir::BlockArgument getInitMoldArg() {
Expand Down
1 change: 1 addition & 0 deletions flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/PatternMatch.h"
Expand Down
1 change: 1 addition & 0 deletions flang/lib/Optimizer/Dialect/FIRCG/CGOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "flang/Optimizer/Dialect/FIRCG/CGOps.h"
#include "flang/Optimizer/Dialect/FIRDialect.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "flang/Optimizer/Dialect/FIROps.h"
#include "flang/Optimizer/Dialect/FIRType.h"

Expand Down
1 change: 1 addition & 0 deletions flang/lib/Optimizer/Dialect/FIROps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/PatternMatch.h"
Expand Down
1 change: 1 addition & 0 deletions flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/OpImplementation.h"
#include "llvm/ADT/APInt.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "Standalone/StandaloneDialect.h"
#include "Standalone/StandaloneOps.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "Standalone/StandaloneTypes.h"

using namespace mlir;
Expand Down
1 change: 1 addition & 0 deletions mlir/examples/standalone/lib/Standalone/StandaloneOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "Standalone/StandaloneOps.h"
#include "Standalone/StandaloneDialect.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"

#define GET_OP_CLASSES
#include "Standalone/StandaloneOps.cpp.inc"
7 changes: 5 additions & 2 deletions mlir/examples/toy/Ch2/mlir/Dialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/OperationSupport.h"
Expand Down Expand Up @@ -144,7 +145,8 @@ void ConstantOp::print(mlir::OpAsmPrinter &printer) {
llvm::LogicalResult ConstantOp::verify() {
// If the return type of the constant is not an unranked tensor, the shape
// must match the shape of the attribute holding the data.
auto resultType = llvm::dyn_cast<mlir::RankedTensorType>(getResult().getType());
auto resultType =
llvm::dyn_cast<mlir::RankedTensorType>(getResult().getType());
if (!resultType)
return success();

Expand Down Expand Up @@ -280,7 +282,8 @@ llvm::LogicalResult ReturnOp::verify() {
auto resultType = results.front();

// Check that the result type of the function matches the operand type.
if (inputType == resultType || llvm::isa<mlir::UnrankedTensorType>(inputType) ||
if (inputType == resultType ||
llvm::isa<mlir::UnrankedTensorType>(inputType) ||
llvm::isa<mlir::UnrankedTensorType>(resultType))
return mlir::success();

Expand Down
7 changes: 5 additions & 2 deletions mlir/examples/toy/Ch3/mlir/Dialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/OperationSupport.h"
Expand Down Expand Up @@ -144,7 +145,8 @@ void ConstantOp::print(mlir::OpAsmPrinter &printer) {
llvm::LogicalResult ConstantOp::verify() {
// If the return type of the constant is not an unranked tensor, the shape
// must match the shape of the attribute holding the data.
auto resultType = llvm::dyn_cast<mlir::RankedTensorType>(getResult().getType());
auto resultType =
llvm::dyn_cast<mlir::RankedTensorType>(getResult().getType());
if (!resultType)
return success();

Expand Down Expand Up @@ -280,7 +282,8 @@ llvm::LogicalResult ReturnOp::verify() {
auto resultType = results.front();

// Check that the result type of the function matches the operand type.
if (inputType == resultType || llvm::isa<mlir::UnrankedTensorType>(inputType) ||
if (inputType == resultType ||
llvm::isa<mlir::UnrankedTensorType>(inputType) ||
llvm::isa<mlir::UnrankedTensorType>(resultType))
return mlir::success();

Expand Down
7 changes: 5 additions & 2 deletions mlir/examples/toy/Ch4/mlir/Dialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/Location.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/OperationSupport.h"
Expand Down Expand Up @@ -206,7 +207,8 @@ void ConstantOp::print(mlir::OpAsmPrinter &printer) {
llvm::LogicalResult ConstantOp::verify() {
// If the return type of the constant is not an unranked tensor, the shape
// must match the shape of the attribute holding the data.
auto resultType = llvm::dyn_cast<mlir::RankedTensorType>(getResult().getType());
auto resultType =
llvm::dyn_cast<mlir::RankedTensorType>(getResult().getType());
if (!resultType)
return success();

Expand Down Expand Up @@ -395,7 +397,8 @@ llvm::LogicalResult ReturnOp::verify() {
auto resultType = results.front();

// Check that the result type of the function matches the operand type.
if (inputType == resultType || llvm::isa<mlir::UnrankedTensorType>(inputType) ||
if (inputType == resultType ||
llvm::isa<mlir::UnrankedTensorType>(inputType) ||
llvm::isa<mlir::UnrankedTensorType>(resultType))
return mlir::success();

Expand Down
7 changes: 5 additions & 2 deletions mlir/examples/toy/Ch5/mlir/Dialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/Location.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/OperationSupport.h"
Expand Down Expand Up @@ -206,7 +207,8 @@ void ConstantOp::print(mlir::OpAsmPrinter &printer) {
llvm::LogicalResult ConstantOp::verify() {
// If the return type of the constant is not an unranked tensor, the shape
// must match the shape of the attribute holding the data.
auto resultType = llvm::dyn_cast<mlir::RankedTensorType>(getResult().getType());
auto resultType =
llvm::dyn_cast<mlir::RankedTensorType>(getResult().getType());
if (!resultType)
return success();

Expand Down Expand Up @@ -395,7 +397,8 @@ llvm::LogicalResult ReturnOp::verify() {
auto resultType = results.front();

// Check that the result type of the function matches the operand type.
if (inputType == resultType || llvm::isa<mlir::UnrankedTensorType>(inputType) ||
if (inputType == resultType ||
llvm::isa<mlir::UnrankedTensorType>(inputType) ||
llvm::isa<mlir::UnrankedTensorType>(resultType))
return mlir::success();

Expand Down
7 changes: 5 additions & 2 deletions mlir/examples/toy/Ch6/mlir/Dialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/Location.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/OperationSupport.h"
Expand Down Expand Up @@ -206,7 +207,8 @@ void ConstantOp::print(mlir::OpAsmPrinter &printer) {
llvm::LogicalResult ConstantOp::verify() {
// If the return type of the constant is not an unranked tensor, the shape
// must match the shape of the attribute holding the data.
auto resultType = llvm::dyn_cast<mlir::RankedTensorType>(getResult().getType());
auto resultType =
llvm::dyn_cast<mlir::RankedTensorType>(getResult().getType());
if (!resultType)
return success();

Expand Down Expand Up @@ -395,7 +397,8 @@ llvm::LogicalResult ReturnOp::verify() {
auto resultType = results.front();

// Check that the result type of the function matches the operand type.
if (inputType == resultType || llvm::isa<mlir::UnrankedTensorType>(inputType) ||
if (inputType == resultType ||
llvm::isa<mlir::UnrankedTensorType>(inputType) ||
llvm::isa<mlir::UnrankedTensorType>(resultType))
return mlir::success();

Expand Down
4 changes: 3 additions & 1 deletion mlir/examples/toy/Ch7/mlir/Dialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/Location.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/OpImplementation.h"
Expand Down Expand Up @@ -429,7 +430,8 @@ llvm::LogicalResult ReturnOp::verify() {
auto resultType = results.front();

// Check that the result type of the function matches the operand type.
if (inputType == resultType || llvm::isa<mlir::UnrankedTensorType>(inputType) ||
if (inputType == resultType ||
llvm::isa<mlir::UnrankedTensorType>(inputType) ||
llvm::isa<mlir::UnrankedTensorType>(resultType))
return mlir::success();

Expand Down
1 change: 1 addition & 0 deletions mlir/examples/transform/Ch2/lib/MyExtension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "mlir/Dialect/Transform/IR/TransformTypes.h"
#include "mlir/Dialect/Transform/Interfaces/TransformInterfaces.h"
#include "mlir/IR/DialectRegistry.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/Operation.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "mlir/Support/LLVM.h"
Expand Down
1 change: 1 addition & 0 deletions mlir/examples/transform/Ch3/lib/MyExtension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "mlir/Dialect/Transform/IR/TransformDialect.h"
#include "mlir/Dialect/Transform/IR/TransformTypes.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/Interfaces/CallInterfaces.h"
#include "llvm/ADT/TypeSwitch.h"

Expand Down
1 change: 1 addition & 0 deletions mlir/examples/transform/Ch4/lib/MyExtension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "MyExtension.h"
#include "mlir/Dialect/Transform/IR/TransformDialect.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "llvm/Support/Debug.h"

#define DEBUG_TYPE_MATCHER "transform-matcher"
Expand Down
21 changes: 21 additions & 0 deletions mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ class AffineDmaStartOp
AffineMap tagMap, ValueRange tagIndices, Value numElements,
Value stride = nullptr, Value elementsPerStride = nullptr);

static AffineDmaStartOp
create(OpBuilder &builder, Location location, Value srcMemRef,
AffineMap srcMap, ValueRange srcIndices, Value destMemRef,
AffineMap dstMap, ValueRange destIndices, Value tagMemRef,
AffineMap tagMap, ValueRange tagIndices, Value numElements,
Value stride = nullptr, Value elementsPerStride = nullptr);

static AffineDmaStartOp create(ImplicitLocOpBuilder &builder, Value srcMemRef,
AffineMap srcMap, ValueRange srcIndices,
Value destMemRef, AffineMap dstMap,
ValueRange destIndices, Value tagMemRef,
AffineMap tagMap, ValueRange tagIndices,
Value numElements, Value stride = nullptr,
Value elementsPerStride = nullptr);

/// Returns the operand index of the source memref.
unsigned getSrcMemRefOperandIndex() { return 0; }

Expand Down Expand Up @@ -319,6 +334,12 @@ class AffineDmaWaitOp

static void build(OpBuilder &builder, OperationState &result, Value tagMemRef,
AffineMap tagMap, ValueRange tagIndices, Value numElements);
static AffineDmaWaitOp create(OpBuilder &builder, Location location,
Value tagMemRef, AffineMap tagMap,
ValueRange tagIndices, Value numElements);
static AffineDmaWaitOp create(ImplicitLocOpBuilder &builder, Value tagMemRef,
AffineMap tagMap, ValueRange tagIndices,
Value numElements);

static StringRef getOperationName() { return "affine.dma_wait"; }

Expand Down
19 changes: 19 additions & 0 deletions mlir/include/mlir/Dialect/Arith/IR/Arith.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,27 @@ class ConstantIntOp : public arith::ConstantOp {
/// Build a constant int op that produces an integer of the specified width.
static void build(OpBuilder &builder, OperationState &result, int64_t value,
unsigned width);
static ConstantIntOp create(OpBuilder &builder, Location location,
int64_t value, unsigned width);
static ConstantIntOp create(ImplicitLocOpBuilder &builder, int64_t value,
unsigned width);

/// Build a constant int op that produces an integer of the specified type,
/// which must be an integer type.
static void build(OpBuilder &builder, OperationState &result, Type type,
int64_t value);
static ConstantIntOp create(OpBuilder &builder, Location location, Type type,
int64_t value);
static ConstantIntOp create(ImplicitLocOpBuilder &builder, Type type,
int64_t value);

/// Build a constant int op that produces an integer from an APInt
static void build(OpBuilder &builder, OperationState &result, Type type,
const APInt &value);
static ConstantIntOp create(OpBuilder &builder, Location location, Type type,
const APInt &value);
static ConstantIntOp create(ImplicitLocOpBuilder &builder, Type type,
const APInt &value);

inline int64_t value() {
return cast<IntegerAttr>(arith::ConstantOp::getValue()).getInt();
Expand All @@ -85,6 +97,10 @@ class ConstantFloatOp : public arith::ConstantOp {
/// Build a constant float op that produces a float of the specified type.
static void build(OpBuilder &builder, OperationState &result, FloatType type,
const APFloat &value);
static ConstantFloatOp create(OpBuilder &builder, Location location,
FloatType type, const APFloat &value);
static ConstantFloatOp create(ImplicitLocOpBuilder &builder, FloatType type,
const APFloat &value);

inline APFloat value() {
return cast<FloatAttr>(arith::ConstantOp::getValue()).getValue();
Expand All @@ -100,6 +116,9 @@ class ConstantIndexOp : public arith::ConstantOp {
static ::mlir::TypeID resolveTypeID() { return TypeID::get<ConstantOp>(); }
/// Build a constant int op that produces an index.
static void build(OpBuilder &builder, OperationState &result, int64_t value);
static ConstantIndexOp create(OpBuilder &builder, Location location,
int64_t value);
static ConstantIndexOp create(ImplicitLocOpBuilder &builder, int64_t value);

inline int64_t value() {
return cast<IntegerAttr>(arith::ConstantOp::getValue()).getInt();
Expand Down
Loading
Loading