-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ASM: suggest OpResult name for BGV/CKKS/Openfhe
- Loading branch information
1 parent
276bc7c
commit 09754c7
Showing
13 changed files
with
186 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "lib/Utils/OpAsmInterfaceHelper.h" | ||
|
||
#include "lib/Dialect/LWE/IR/LWETypes.h" | ||
#include "lib/Dialect/Openfhe/IR/OpenfheTypes.h" | ||
|
||
namespace mlir { | ||
namespace heir { | ||
|
||
void suggestNameForValue(Value value, ::mlir::OpAsmSetValueNameFn setNameFn) { | ||
auto suggestFunctions = { | ||
lwe::lweSuggestNameForType, | ||
openfhe::openfheSuggestNameForType, | ||
}; | ||
// only the first suggestion is used | ||
// if no suggestion then do nothing | ||
for (auto suggest : suggestFunctions) { | ||
auto suggested = suggest(value.getType()); | ||
if (!suggested.empty()) { | ||
setNameFn(value, suggested); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
void getAsmBlockArgumentNames(Operation* op, Region& region, | ||
::mlir::OpAsmSetValueNameFn setNameFn) { | ||
for (auto& block : region) { | ||
for (auto arg : block.getArguments()) { | ||
suggestNameForValue(arg, setNameFn); | ||
} | ||
} | ||
} | ||
|
||
void getAsmResultNames(Operation* op, ::mlir::OpAsmSetValueNameFn setNameFn) { | ||
for (auto result : op->getResults()) { | ||
suggestNameForValue(result, setNameFn); | ||
} | ||
} | ||
|
||
} // namespace heir | ||
} // namespace mlir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef LIB_UTILS_OPASMINTERFACEHELPER_ | ||
#define LIB_UTILS_OPASMINTERFACEHELPER_ | ||
|
||
#include "mlir/include/mlir/IR/DialectImplementation.h" // from @llvm-project | ||
|
||
namespace mlir { | ||
namespace heir { | ||
|
||
void getAsmResultNames(Operation *op, ::mlir::OpAsmSetValueNameFn setNameFn); | ||
|
||
void getAsmBlockArgumentNames(Operation *op, Region ®ion, | ||
::mlir::OpAsmSetValueNameFn setNameFn); | ||
|
||
} // namespace heir | ||
} // namespace mlir | ||
|
||
#endif // LIB_UTILS_OPASMINTERFACEHELPER_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters