@@ -22,53 +22,54 @@ class OpBuilder;
22
22
namespace spirv {
23
23
class ModuleOp ;
24
24
25
- // / To combine a number of MLIR SPIR-V modules, we move all the module-level ops
25
+ // / The listener function to receive symbol renaming events.
26
+ // /
27
+ // / `originalModule` is the input spirv::ModuleOp that contains the renamed
28
+ // / symbol. `oldSymbol` and `newSymbol` are the original and renamed symbol.
29
+ // / Note that it's the responsibility of the caller to properly retain the
30
+ // / storage underlying the passed StringRefs if the listener callback outlives
31
+ // / this function call.
32
+ using SymbolRenameListener = function_ref<void (
33
+ spirv::ModuleOp originalModule, StringRef oldSymbol, StringRef newSymbol)>;
34
+
35
+ // / Combines a list of SPIR-V `inputModules` into one. Returns the combined
36
+ // / module on success; returns a null module otherwise.
37
+ //
38
+ // / \param inputModules the list of modules to combine. They won't be modified.
39
+ // / \param combinedMdouleBuilder an OpBuilder for building the combined module.
40
+ // / \param symbRenameListener a listener that gets called everytime a symbol in
41
+ // / one of the input modules is renamed.
42
+ // /
43
+ // / To combine multiple SPIR-V modules, we move all the module-level ops
26
44
// / from all the input modules into one big combined module. To that end, the
27
45
// / combination process proceeds in 2 phases:
28
46
// /
29
- // / (1) resolve conflicts between pairs of ops from different modules
30
- // / (2) deduplicate equivalent ops/sub-ops in the merged module.
47
+ // / 1. resolve conflicts between pairs of ops from different modules,
48
+ // / 2. deduplicate equivalent ops/sub-ops in the merged module.
31
49
// /
32
50
// / For the conflict resolution phase, the following rules are employed to
33
51
// / resolve such conflicts:
34
52
// /
35
- // / - If 2 spv.func's have the same symbol name, then rename one of the
53
+ // / - If 2 spv.func's have the same symbol name, then rename one of the
36
54
// / functions.
37
- // / - If an spv.func and another op have the same symbol name, then rename the
55
+ // / - If an spv.func and another op have the same symbol name, then rename the
38
56
// / other symbol.
39
- // / - If none of the 2 conflicting ops are spv.func, then rename either.
57
+ // / - If none of the 2 conflicting ops are spv.func, then rename either.
40
58
// /
41
59
// / For deduplication, the following 3 cases are taken into consideration:
42
60
// /
43
- // / - If 2 spv.GlobalVariable's have either the same descriptor set + binding
61
+ // / - If 2 spv.GlobalVariable's have either the same descriptor set + binding
44
62
// / or the same build_in attribute value, then replace one of them using the
45
63
// / other.
46
- // / - If 2 spv.SpecConstant's have the same spec_id attribute value, then
64
+ // / - If 2 spv.SpecConstant's have the same spec_id attribute value, then
47
65
// / replace one of them using the other.
48
- // / - If 2 spv.func's are identical replace one of them using the other .
66
+ // / - Deduplicating functions are not supported right now .
49
67
// /
50
68
// / In all cases, the references to the updated symbol (whether renamed or
51
69
// / deduplicated) are also updated to reflect the change.
52
- // /
53
- // / \param modules the list of modules to combine. Input modules are not
54
- // / modified.
55
- // / \param combinedMdouleBuilder an OpBuilder to be used for
56
- // building up the combined module.
57
- // / \param symbRenameListener a listener that gets called everytime a symbol in
58
- // / one of the input modules is renamed. The arguments
59
- // / passed to the listener are: the input
60
- // / spirv::ModuleOp that contains the renamed symbol,
61
- // / a StringRef to the old symbol name, and a
62
- // / StringRef to the new symbol name. Note that it is
63
- // / the responsibility of the caller to properly
64
- // / retain the storage underlying the passed
65
- // / StringRefs if the listener callback outlives this
66
- // / function call.
67
- // /
68
- // / \return the combined module.
69
- OwningOpRef<spirv::ModuleOp>
70
- combine (MutableArrayRef<ModuleOp> modules, OpBuilder &combinedModuleBuilder,
71
- function_ref<void (ModuleOp, StringRef, StringRef)> symbRenameListener);
70
+ OwningOpRef<spirv::ModuleOp> combine (ArrayRef<spirv::ModuleOp> inputModules,
71
+ OpBuilder &combinedModuleBuilder,
72
+ SymbolRenameListener symRenameListener);
72
73
} // namespace spirv
73
74
} // namespace mlir
74
75
0 commit comments