Skip to content

Commit 1a708bd

Browse files
committed
Revert "[mlir] share argument attributes interface between calls and callables (llvm#123176)"
This reverts commit 327d627.
1 parent c06d0ff commit 1a708bd

File tree

32 files changed

+256
-452
lines changed

32 files changed

+256
-452
lines changed

flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,7 @@ def cuf_KernelLaunchOp : cuf_Op<"kernel_launch", [CallOpInterface,
207207
I32:$block_z,
208208
Optional<I32>:$bytes,
209209
Optional<I32>:$stream,
210-
Variadic<AnyType>:$args,
211-
OptionalAttr<DictArrayAttr>:$arg_attrs,
212-
OptionalAttr<DictArrayAttr>:$res_attrs
210+
Variadic<AnyType>:$args
213211
);
214212

215213
let assemblyFormat = [{

flang/include/flang/Optimizer/Dialect/FIROps.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,8 +2432,6 @@ def fir_CallOp : fir_Op<"call",
24322432
let arguments = (ins
24332433
OptionalAttr<SymbolRefAttr>:$callee,
24342434
Variadic<AnyType>:$args,
2435-
OptionalAttr<DictArrayAttr>:$arg_attrs,
2436-
OptionalAttr<DictArrayAttr>:$res_attrs,
24372435
OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs,
24382436
DefaultValuedAttr<Arith_FastMathAttr,
24392437
"::mlir::arith::FastMathFlags::none">:$fastmath
@@ -2520,8 +2518,6 @@ def fir_DispatchOp : fir_Op<"dispatch", []> {
25202518
fir_ClassType:$object,
25212519
Variadic<AnyType>:$args,
25222520
OptionalAttr<I32Attr>:$pass_arg_pos,
2523-
OptionalAttr<DictArrayAttr>:$arg_attrs,
2524-
OptionalAttr<DictArrayAttr>:$res_attrs,
25252521
OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs
25262522
);
25272523

flang/lib/Lower/ConvertCall.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,7 @@ Fortran::lower::genCallOpAndResult(
594594

595595
builder.create<cuf::KernelLaunchOp>(
596596
loc, funcType.getResults(), funcSymbolAttr, grid_x, grid_y, grid_z,
597-
block_x, block_y, block_z, bytes, stream, operands,
598-
/*arg_attrs=*/nullptr, /*res_attrs=*/nullptr);
597+
block_x, block_y, block_z, bytes, stream, operands);
599598
callNumResults = 0;
600599
} else if (caller.requireDispatchCall()) {
601600
// Procedure call requiring a dynamic dispatch. Call is created with
@@ -622,8 +621,7 @@ Fortran::lower::genCallOpAndResult(
622621
dispatch = builder.create<fir::DispatchOp>(
623622
loc, funcType.getResults(), builder.getStringAttr(procName),
624623
caller.getInputs()[*passArg], operands,
625-
builder.getI32IntegerAttr(*passArg), /*arg_attrs=*/nullptr,
626-
/*res_attrs=*/nullptr, procAttrs);
624+
builder.getI32IntegerAttr(*passArg), procAttrs);
627625
} else {
628626
// NOPASS
629627
const Fortran::evaluate::Component *component =
@@ -638,17 +636,15 @@ Fortran::lower::genCallOpAndResult(
638636
passObject = builder.create<fir::LoadOp>(loc, passObject);
639637
dispatch = builder.create<fir::DispatchOp>(
640638
loc, funcType.getResults(), builder.getStringAttr(procName),
641-
passObject, operands, nullptr, /*arg_attrs=*/nullptr,
642-
/*res_attrs=*/nullptr, procAttrs);
639+
passObject, operands, nullptr, procAttrs);
643640
}
644641
callNumResults = dispatch.getNumResults();
645642
if (callNumResults != 0)
646643
callResult = dispatch.getResult(0);
647644
} else {
648645
// Standard procedure call with fir.call.
649646
auto call = builder.create<fir::CallOp>(
650-
loc, funcType.getResults(), funcSymbolAttr, operands,
651-
/*arg_attrs=*/nullptr, /*res_attrs=*/nullptr, procAttrs);
647+
loc, funcType.getResults(), funcSymbolAttr, operands, procAttrs);
652648

653649
callNumResults = call.getNumResults();
654650
if (callNumResults != 0)

flang/lib/Optimizer/CodeGen/TargetRewrite.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,6 @@ class TargetRewrite : public fir::impl::TargetRewritePassBase<TargetRewrite> {
518518
newOpers.insert(newOpers.end(), trailingOpers.begin(), trailingOpers.end());
519519

520520
llvm::SmallVector<mlir::Value, 1> newCallResults;
521-
// TODO propagate/update call argument and result attributes.
522521
if constexpr (std::is_same_v<std::decay_t<A>, mlir::gpu::LaunchFuncOp>) {
523522
auto newCall = rewriter->create<A>(
524523
loc, callOp.getKernel(), callOp.getGridSizeOperandValues(),
@@ -558,7 +557,6 @@ class TargetRewrite : public fir::impl::TargetRewritePassBase<TargetRewrite> {
558557
loc, newResTys, rewriter->getStringAttr(callOp.getMethod()),
559558
callOp.getOperands()[0], newOpers,
560559
rewriter->getI32IntegerAttr(*callOp.getPassArgPos() + passArgShift),
561-
/*arg_attrs=*/nullptr, /*res_attrs=*/nullptr,
562560
callOp.getProcedureAttrsAttr());
563561
if (wrap)
564562
newCallResults.push_back((*wrap)(dispatchOp.getOperation()));

flang/lib/Optimizer/Transforms/AbstractResult.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ class CallConversion : public mlir::OpRewritePattern<Op> {
147147
newResultTypes.emplace_back(getVoidPtrType(result.getContext()));
148148

149149
Op newOp;
150-
// TODO: propagate argument and result attributes (need to be shifted).
151150
// fir::CallOp specific handling.
152151
if constexpr (std::is_same_v<Op, fir::CallOp>) {
153152
if (op.getCallee()) {
@@ -190,11 +189,9 @@ class CallConversion : public mlir::OpRewritePattern<Op> {
190189
if (op.getPassArgPos())
191190
passArgPos =
192191
rewriter.getI32IntegerAttr(*op.getPassArgPos() + passArgShift);
193-
// TODO: propagate argument and result attributes (need to be shifted).
194192
newOp = rewriter.create<fir::DispatchOp>(
195193
loc, newResultTypes, rewriter.getStringAttr(op.getMethod()),
196194
op.getOperands()[0], newOperands, passArgPos,
197-
/*arg_attrs=*/nullptr, /*res_attrs=*/nullptr,
198195
op.getProcedureAttrsAttr());
199196
}
200197

flang/lib/Optimizer/Transforms/PolymorphicOpConversion.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,8 @@ struct DispatchOpConv : public OpConversionPattern<fir::DispatchOp> {
205205
// Make the call.
206206
llvm::SmallVector<mlir::Value> args{funcPtr};
207207
args.append(dispatch.getArgs().begin(), dispatch.getArgs().end());
208-
rewriter.replaceOpWithNewOp<fir::CallOp>(
209-
dispatch, resTypes, nullptr, args, dispatch.getArgAttrsAttr(),
210-
dispatch.getResAttrsAttr(), dispatch.getProcedureAttrsAttr());
208+
rewriter.replaceOpWithNewOp<fir::CallOp>(dispatch, resTypes, nullptr, args,
209+
dispatch.getProcedureAttrsAttr());
211210
return mlir::success();
212211
}
213212

mlir/docs/Interfaces.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -753,15 +753,10 @@ interface section goes as follows:
753753
- (`C++ class` -- `ODS class`(if applicable))
754754

755755
##### CallInterfaces
756+
756757
* `CallOpInterface` - Used to represent operations like 'call'
757758
- `CallInterfaceCallable getCallableForCallee()`
758759
- `void setCalleeFromCallable(CallInterfaceCallable)`
759-
- `ArrayAttr getArgAttrsAttr()`
760-
- `ArrayAttr getResAttrsAttr()`
761-
- `void setArgAttrsAttr(ArrayAttr)`
762-
- `void setResAttrsAttr(ArrayAttr)`
763-
- `Attribute removeArgAttrsAttr()`
764-
- `Attribute removeResAttrsAttr()`
765760
* `CallableOpInterface` - Used to represent the target callee of call.
766761
- `Region * getCallableRegion()`
767762
- `ArrayRef<Type> getArgumentTypes()`

mlir/examples/toy/Ch4/include/toy/Ops.td

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,7 @@ def GenericCallOp : Toy_Op<"generic_call",
215215

216216
// The generic call operation takes a symbol reference attribute as the
217217
// callee, and inputs for the call.
218-
let arguments = (ins
219-
FlatSymbolRefAttr:$callee,
220-
Variadic<F64Tensor>:$inputs,
221-
OptionalAttr<DictArrayAttr>:$arg_attrs,
222-
OptionalAttr<DictArrayAttr>:$res_attrs
223-
);
218+
let arguments = (ins FlatSymbolRefAttr:$callee, Variadic<F64Tensor>:$inputs);
224219

225220
// The generic call operation returns a single value of TensorType.
226221
let results = (outs F64Tensor);

mlir/examples/toy/Ch5/include/toy/Ops.td

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,7 @@ def GenericCallOp : Toy_Op<"generic_call",
214214

215215
// The generic call operation takes a symbol reference attribute as the
216216
// callee, and inputs for the call.
217-
let arguments = (ins
218-
FlatSymbolRefAttr:$callee,
219-
Variadic<F64Tensor>:$inputs,
220-
OptionalAttr<DictArrayAttr>:$arg_attrs,
221-
OptionalAttr<DictArrayAttr>:$res_attrs
222-
);
217+
let arguments = (ins FlatSymbolRefAttr:$callee, Variadic<F64Tensor>:$inputs);
223218

224219
// The generic call operation returns a single value of TensorType.
225220
let results = (outs F64Tensor);

mlir/examples/toy/Ch6/include/toy/Ops.td

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,7 @@ def GenericCallOp : Toy_Op<"generic_call",
214214

215215
// The generic call operation takes a symbol reference attribute as the
216216
// callee, and inputs for the call.
217-
let arguments = (ins
218-
FlatSymbolRefAttr:$callee,
219-
Variadic<F64Tensor>:$inputs,
220-
OptionalAttr<DictArrayAttr>:$arg_attrs,
221-
OptionalAttr<DictArrayAttr>:$res_attrs
222-
);
217+
let arguments = (ins FlatSymbolRefAttr:$callee, Variadic<F64Tensor>:$inputs);
223218

224219
// The generic call operation returns a single value of TensorType.
225220
let results = (outs F64Tensor);

mlir/examples/toy/Ch7/include/toy/Ops.td

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,7 @@ def GenericCallOp : Toy_Op<"generic_call",
237237

238238
// The generic call operation takes a symbol reference attribute as the
239239
// callee, and inputs for the call.
240-
let arguments = (ins
241-
FlatSymbolRefAttr:$callee,
242-
Variadic<Toy_Type>:$inputs,
243-
OptionalAttr<DictArrayAttr>:$arg_attrs,
244-
OptionalAttr<DictArrayAttr>:$res_attrs
245-
);
240+
let arguments = (ins FlatSymbolRefAttr:$callee, Variadic<Toy_Type>:$inputs);
246241

247242
// The generic call operation returns a single value of TensorType or
248243
// StructType.
@@ -255,8 +250,7 @@ def GenericCallOp : Toy_Op<"generic_call",
255250

256251
// Add custom build methods for the generic call operation.
257252
let builders = [
258-
OpBuilder<(ins "Type":$result_type, "StringRef":$callee,
259-
"ArrayRef<Value>":$arguments)>
253+
OpBuilder<(ins "StringRef":$callee, "ArrayRef<Value>":$arguments)>
260254
];
261255
}
262256

mlir/examples/toy/Ch7/mlir/Dialect.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,9 @@ void FuncOp::print(mlir::OpAsmPrinter &p) {
350350
//===----------------------------------------------------------------------===//
351351

352352
void GenericCallOp::build(mlir::OpBuilder &builder, mlir::OperationState &state,
353-
mlir::Type resultType, StringRef callee,
354-
ArrayRef<mlir::Value> arguments) {
355-
state.addTypes(resultType);
353+
StringRef callee, ArrayRef<mlir::Value> arguments) {
354+
// Generic call always returns an unranked Tensor initially.
355+
state.addTypes(UnrankedTensorType::get(builder.getF64Type()));
356356
state.addOperands(arguments);
357357
state.addAttribute("callee",
358358
mlir::SymbolRefAttr::get(builder.getContext(), callee));

mlir/examples/toy/Ch7/mlir/MLIRGen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,8 @@ class MLIRGenImpl {
535535
}
536536
mlir::toy::FuncOp calledFunc = calledFuncIt->second;
537537
return builder.create<GenericCallOp>(
538-
location, calledFunc.getFunctionType().getResult(0), callee, operands);
538+
location, calledFunc.getFunctionType().getResult(0),
539+
mlir::SymbolRefAttr::get(builder.getContext(), callee), operands);
539540
}
540541

541542
/// Emit a print expression. It emits specific operations for two builtins:

mlir/include/mlir/Dialect/Async/IR/AsyncOps.td

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,7 @@ def Async_CallOp : Async_Op<"call",
208208
```
209209
}];
210210

211-
let arguments = (ins
212-
FlatSymbolRefAttr:$callee,
213-
Variadic<AnyType>:$operands,
214-
OptionalAttr<DictArrayAttr>:$arg_attrs,
215-
OptionalAttr<DictArrayAttr>:$res_attrs
216-
);
217-
211+
let arguments = (ins FlatSymbolRefAttr:$callee, Variadic<AnyType>:$operands);
218212
let results = (outs Variadic<Async_AnyValueOrTokenType>);
219213

220214
let builders = [

mlir/include/mlir/Dialect/EmitC/IR/EmitC.td

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -551,13 +551,7 @@ def EmitC_CallOp : EmitC_Op<"call",
551551
%2 = emitc.call @my_add(%0, %1) : (f32, f32) -> f32
552552
```
553553
}];
554-
let arguments = (ins
555-
FlatSymbolRefAttr:$callee,
556-
Variadic<EmitCType>:$operands,
557-
OptionalAttr<DictArrayAttr>:$arg_attrs,
558-
OptionalAttr<DictArrayAttr>:$res_attrs
559-
);
560-
554+
let arguments = (ins FlatSymbolRefAttr:$callee, Variadic<EmitCType>:$operands);
561555
let results = (outs Variadic<EmitCType>);
562556

563557
let builders = [

mlir/include/mlir/Dialect/Func/IR/FuncOps.td

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,8 @@ def CallOp : Func_Op<"call",
4949
```
5050
}];
5151

52-
let arguments = (ins
53-
FlatSymbolRefAttr:$callee,
54-
Variadic<AnyType>:$operands,
55-
OptionalAttr<DictArrayAttr>:$arg_attrs,
56-
OptionalAttr<DictArrayAttr>:$res_attrs,
57-
UnitAttr:$no_inline
58-
);
59-
52+
let arguments = (ins FlatSymbolRefAttr:$callee, Variadic<AnyType>:$operands,
53+
UnitAttr:$no_inline);
6054
let results = (outs Variadic<AnyType>);
6155

6256
let builders = [
@@ -79,18 +73,6 @@ def CallOp : Func_Op<"call",
7973
CArg<"ValueRange", "{}">:$operands), [{
8074
build($_builder, $_state, StringAttr::get($_builder.getContext(), callee),
8175
results, operands);
82-
}]>,
83-
OpBuilder<(ins "TypeRange":$results, "FlatSymbolRefAttr":$callee,
84-
CArg<"ValueRange", "{}">:$operands), [{
85-
build($_builder, $_state, callee, results, operands);
86-
}]>,
87-
OpBuilder<(ins "TypeRange":$results, "StringAttr":$callee,
88-
CArg<"ValueRange", "{}">:$operands), [{
89-
build($_builder, $_state, callee, results, operands);
90-
}]>,
91-
OpBuilder<(ins "TypeRange":$results, "StringRef":$callee,
92-
CArg<"ValueRange", "{}">:$operands), [{
93-
build($_builder, $_state, callee, results, operands);
9476
}]>];
9577

9678
let extraClassDeclaration = [{
@@ -154,13 +136,8 @@ def CallIndirectOp : Func_Op<"call_indirect", [
154136
```
155137
}];
156138

157-
let arguments = (ins
158-
FunctionType:$callee,
159-
Variadic<AnyType>:$callee_operands,
160-
OptionalAttr<DictArrayAttr>:$arg_attrs,
161-
OptionalAttr<DictArrayAttr>:$res_attrs
162-
);
163-
139+
let arguments = (ins FunctionType:$callee,
140+
Variadic<AnyType>:$callee_operands);
164141
let results = (outs Variadic<AnyType>:$results);
165142

166143
let builders = [

mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,6 @@ def LLVM_InvokeOp : LLVM_Op<"invoke", [
633633
OptionalAttr<TypeAttrOf<LLVM_FunctionType>>:$var_callee_type,
634634
OptionalAttr<FlatSymbolRefAttr>:$callee,
635635
Variadic<LLVM_Type>:$callee_operands,
636-
OptionalAttr<DictArrayAttr>:$arg_attrs,
637-
OptionalAttr<DictArrayAttr>:$res_attrs,
638636
Variadic<LLVM_Type>:$normalDestOperands,
639637
Variadic<LLVM_Type>:$unwindDestOperands,
640638
OptionalAttr<DenseI32ArrayAttr>:$branch_weights,
@@ -757,9 +755,7 @@ def LLVM_CallOp : LLVM_MemAccessOpBase<"call",
757755
VariadicOfVariadic<LLVM_Type,
758756
"op_bundle_sizes">:$op_bundle_operands,
759757
DenseI32ArrayAttr:$op_bundle_sizes,
760-
OptionalAttr<ArrayAttr>:$op_bundle_tags,
761-
OptionalAttr<DictArrayAttr>:$arg_attrs,
762-
OptionalAttr<DictArrayAttr>:$res_attrs);
758+
OptionalAttr<ArrayAttr>:$op_bundle_tags);
763759
// Append the aliasing related attributes defined in LLVM_MemAccessOpBase.
764760
let arguments = !con(args, aliasAttrs);
765761
let results = (outs Optional<LLVM_Type>:$result);

mlir/include/mlir/Dialect/SPIRV/IR/SPIRVControlFlowOps.td

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,24 +214,13 @@ def SPIRV_FunctionCallOp : SPIRV_Op<"FunctionCall", [
214214

215215
let arguments = (ins
216216
FlatSymbolRefAttr:$callee,
217-
Variadic<SPIRV_Type>:$arguments,
218-
OptionalAttr<DictArrayAttr>:$arg_attrs,
219-
OptionalAttr<DictArrayAttr>:$res_attrs
217+
Variadic<SPIRV_Type>:$arguments
220218
);
221219

222220
let results = (outs
223221
Optional<SPIRV_Type>:$return_value
224222
);
225223

226-
let builders = [
227-
OpBuilder<(ins "Type":$returnType, "FlatSymbolRefAttr":$callee,
228-
"ValueRange":$arguments),
229-
[{
230-
build($_builder, $_state, returnType, callee, arguments,
231-
/*arg_attrs=*/nullptr, /*res_attrs=*/nullptr);
232-
}]>
233-
];
234-
235224
let autogenSerialization = 0;
236225

237226
let assemblyFormat = [{

mlir/include/mlir/Dialect/Transform/IR/TransformOps.td

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -886,9 +886,7 @@ def IncludeOp : TransformDialectOp<"include",
886886

887887
let arguments = (ins SymbolRefAttr:$target,
888888
FailurePropagationMode:$failure_propagation_mode,
889-
Variadic<Transform_AnyHandleOrParamType>:$operands,
890-
OptionalAttr<DictArrayAttr>:$arg_attrs,
891-
OptionalAttr<DictArrayAttr>:$res_attrs);
889+
Variadic<Transform_AnyHandleOrParamType>:$operands);
892890
let results = (outs Variadic<Transform_AnyHandleOrParamType>:$results);
893891

894892
let assemblyFormat =

0 commit comments

Comments
 (0)