Skip to content

[mlir] update affine+arith create APIs (1/n) #149656

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

Merged
merged 3 commits into from
Jul 19, 2025
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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