summaryrefslogtreecommitdiff
path: root/compiler/loco/src/IR/CanonicalDialect.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/loco/src/IR/CanonicalDialect.cpp')
-rw-r--r--compiler/loco/src/IR/CanonicalDialect.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/compiler/loco/src/IR/CanonicalDialect.cpp b/compiler/loco/src/IR/CanonicalDialect.cpp
index b46269d5f..f89ea447b 100644
--- a/compiler/loco/src/IR/CanonicalDialect.cpp
+++ b/compiler/loco/src/IR/CanonicalDialect.cpp
@@ -15,10 +15,46 @@
*/
#include "loco/IR/CanonicalDialect.h"
+#include "loco/IR/Graph.h"
+#include "loco/IR/Nodes.h"
+
+#include <stdex/Memory.h>
+
+#include <cassert>
+
+namespace
+{
+
+struct GraphOutputIndexQueryServiceImpl final : public loco::GraphOutputIndexQueryService
+{
+ bool associated(const loco::Node *node) const final
+ {
+ if (auto push = dynamic_cast<const loco::Push *>(node))
+ {
+ return push->indexed();
+ }
+ return false;
+ }
+
+ loco::GraphOutputIndex index(const loco::Node *node) const final
+ {
+ assert(associated(node));
+ auto push = dynamic_cast<const loco::Push *>(node);
+ assert(push != nullptr);
+ return push->index();
+ }
+};
+
+} // namespace
namespace loco
{
+CanonicalDialect::CanonicalDialect()
+{
+ service<GraphOutputIndexQueryService>(stdex::make_unique<GraphOutputIndexQueryServiceImpl>());
+}
+
Dialect *CanonicalDialect::get(void)
{
static CanonicalDialect d;