@@ -1408,6 +1408,30 @@ def Xls_InstantiateEprocOp : Xls_Op<"instantiate_eproc", [DeclareOpInterfaceMeth
14081408 }];
14091409}
14101410
1411+ def Xls_InstantiateExternEprocOp : Xls_Op<"instantiate_extern_eproc", []> {
1412+ let summary = "Binds an externally defined eproc";
1413+ let description = [{
1414+ Binds channels to an eproc that is defined externally to this module.
1415+
1416+ This functions similarly to the `xls.instantiate_eproc` op, except that:
1417+ 1) The eproc definition is not available in this module and so it is
1418+ referred to by string, not a symbol.
1419+ 2) Instead of binding global channels to local channels, it binds global
1420+ channels to the boundary channel names of the target eproc.
1421+
1422+ The target eproc is referred to by an opaque string. The interpretation of
1423+ this string is left to the user.
1424+ }];
1425+ let arguments = (ins
1426+ StrAttr:$eproc_name,
1427+ FlatSymbolRefArrayAttr:$global_channels,
1428+ StrArrayAttr:$boundary_channel_names
1429+ );
1430+ let assemblyFormat = [{
1431+ $eproc_name custom<ZippedSymbols>($global_channels, $boundary_channel_names) attr-dict
1432+ }];
1433+ }
1434+
14111435//===----------------------------------------------------------------------===//
14121436// Structured procs
14131437//===----------------------------------------------------------------------===//
@@ -1584,6 +1608,10 @@ def Xls_SprocOp : Xls_Op<"sproc", [
15841608 }
15851609 return index;
15861610 }
1611+
1612+ ::mlir::TypeRange getChannelArgumentTypes() {
1613+ return getChannelArguments().getTypes();
1614+ }
15871615 }];
15881616}
15891617
@@ -1602,6 +1630,45 @@ def Xls_SpawnOp : Xls_Op<"spawn", [
16021630 }];
16031631 let extraClassDeclaration = [{
16041632 SprocOp resolveCallee(::mlir::SymbolTableCollection* symbolTable = nullptr);
1633+ ExternSprocOp resolveExternCallee(::mlir::SymbolTableCollection* symbolTable = nullptr);
1634+ }];
1635+ }
1636+
1637+ def Xls_ExternSprocOp : Xls_Op<"extern_sproc", [
1638+ Symbol,
1639+ CallableOpInterface
1640+ ]> {
1641+ let summary = "extern sproc";
1642+ let description = [{
1643+ Declares an sproc that is external to the current module. The sproc is
1644+ spawnable by sprocs in the current module.
1645+
1646+ The `boundary_channel_names` attribute is used to name each argument or
1647+ result channel. These correspond to the `boundary_channel_names` on the
1648+ target sproc (wherever it is defined). The `channel_types` attribute is used
1649+ to specify the types of the channels.
1650+
1651+ An `spawn` of a `extern_sproc` is lowered to an `instantiate_extern_eproc`
1652+ op.
1653+ }];
1654+ let arguments = (ins
1655+ SymbolNameAttr:$sym_name,
1656+ StrArrayAttr:$boundary_channel_names,
1657+ TypeArrayAttr:$channel_argument_types
1658+ );
1659+ let assemblyFormat = [{
1660+ $sym_name custom<ChannelNamesAndTypes>($boundary_channel_names, $channel_argument_types) attr-dict
1661+ }];
1662+ let extraClassDeclaration = [{
1663+ ::mlir::Region* getCallableRegion() {
1664+ return nullptr;
1665+ }
1666+ ::llvm::ArrayRef<::mlir::Type> getArgumentTypes() {
1667+ return {};
1668+ }
1669+ ::llvm::ArrayRef<::mlir::Type> getResultTypes() {
1670+ return {};
1671+ }
16051672 }];
16061673}
16071674
0 commit comments