@@ -1798,13 +1798,8 @@ class CIR_CallOpBase<string mnemonic, list<Trait> extra_traits = []>
17981798 DeclareOpInterfaceMethods<SymbolUserOpInterface>])> {
17991799 let extraClassDeclaration = [{
18001800 /// Get the argument operands to the called function.
1801- mlir::OperandRange getArgOperands() {
1802- return getArgs();
1803- }
1804-
1805- mlir::MutableOperandRange getArgOperandsMutable() {
1806- return getArgsMutable();
1807- }
1801+ mlir::OperandRange getArgOperands();
1802+ mlir::MutableOperandRange getArgOperandsMutable();
18081803
18091804 /// Return the callee of this operation
18101805 mlir::CallInterfaceCallable getCallableForCallee() {
@@ -1826,6 +1821,9 @@ class CIR_CallOpBase<string mnemonic, list<Trait> extra_traits = []>
18261821 ::mlir::Attribute removeArgAttrsAttr() { return {}; }
18271822 ::mlir::Attribute removeResAttrsAttr() { return {}; }
18281823
1824+ bool isIndirect() { return !getCallee(); }
1825+ mlir::Value getIndirectCall();
1826+
18291827 void setArg(unsigned index, mlir::Value value) {
18301828 setOperand(index, value);
18311829 }
@@ -1839,16 +1837,24 @@ class CIR_CallOpBase<string mnemonic, list<Trait> extra_traits = []>
18391837 // the upstreaming process moves on. The verifiers is also missing for now,
18401838 // will add in the future.
18411839
1842- dag commonArgs = (ins FlatSymbolRefAttr:$callee,
1843- Variadic<CIR_AnyType>:$args);
1840+ dag commonArgs = (ins OptionalAttr< FlatSymbolRefAttr> :$callee,
1841+ Variadic<CIR_AnyType>:$args);
18441842}
18451843
18461844def CallOp : CIR_CallOpBase<"call", [NoRegionArguments]> {
18471845 let summary = "call a function";
18481846 let description = [{
1849- The `cir.call` operation represents a direct call to a function that is
1850- within the same symbol scope as the call. The callee is encoded as a symbol
1851- reference attribute named `callee`.
1847+ The `cir.call` operation represents a function call. It could represent
1848+ either a direct call or an indirect call.
1849+
1850+ If the operation represents a direct call, the callee should be defined
1851+ within the same symbol scope as the call. The `callee` attribute contains a
1852+ symbol reference to the callee function. All operands of this operation are
1853+ arguments to the callee function.
1854+
1855+ If the operation represents an indirect call, the `callee` attribute is
1856+ empty. The first operand of this operation must be a pointer to the callee
1857+ function. All the rest operands are arguments to the callee function.
18521858
18531859 Example:
18541860
@@ -1861,13 +1867,23 @@ def CallOp : CIR_CallOpBase<"call", [NoRegionArguments]> {
18611867 let arguments = commonArgs;
18621868
18631869 let builders = [OpBuilder<(ins "mlir::SymbolRefAttr":$callee,
1864- "mlir::Type":$resType,
1865- "mlir::ValueRange":$operands), [{
1870+ "mlir::Type":$resType,
1871+ "mlir::ValueRange":$operands),
1872+ [{
18661873 $_state.addOperands(operands);
18671874 $_state.addAttribute("callee", callee);
18681875 if (resType && !isa<VoidType>(resType))
18691876 $_state.addTypes(resType);
1870- }]>];
1877+ }]>,
1878+ OpBuilder<(ins "mlir::Value":$callee, "mlir::Type":$resType,
1879+ "mlir::ValueRange":$operands),
1880+ [{
1881+ $_state.addOperands(callee);
1882+ $_state.addOperands(operands);
1883+ if (resType && !isa<VoidType>(resType))
1884+ $_state.addTypes(resType);
1885+ }]>,
1886+ ];
18711887}
18721888
18731889//===----------------------------------------------------------------------===//
0 commit comments